Association Rules is a well know tool when analyzing transactional data in the context of transactions and e-commerce sales. However, the applications go further, even to analyze the gene expression as shown by Carmona-Saez et al 1.
While in the context of a shopping experience we would use association rules to understand which sets of items are bought together and use this information for advertising or to optimize the store layout. We can use it to understand which specific variables have an impact on the delay on arrival and impact on the On Time Performance (OTP) metrics of flights. Most airlines consider a delay of more than 15 minutes a disruption of the service, and therefore a flight that arrives or departs within 15 minutes of the scheduled time is considered to be on time. The goal is to have 80% of flights or more on time, meaning airlines aim for an On Time Performance (OTP) >= 80% 2.
Using this information could be relevant for airlines to adjust what’s within their control (like routing or schedules) to prevent delays, ensure passenger satisfaction and reduce costs related to compensations.3 4
There are several factors that can affect the delay 5, such as:
The dataset chosen for this purpose is “Airline On-Time Performance Data” from the Bureau of Transportation Statistics from USA which is reported monthly since January 2018. Among the relevant variables we find:
From this dataset with 100000 rows, we can observe that only 21.67% of flights are delayed.
From the On Time Performance dataset, I will analyse the distribution of frequencies of the categorical variables. It is observed that occurrences of arrival delays (ArrDel15) are substantially lower than on-time arrivals, from the previous data, we can observe that the OTP for the industry in USA is 78.33%. Departure delays (DepDel15) also follow this trend but to a lesser extent, with 21.34% of delays. Examining the Operating Airlines (IATA_Code_Operating_Airline), there is a visible diversity among carriers, with none dominating flight operations, therefore we can assume that any rules associated to the operating airline are not affected by its prevalence in the dataset. Distance group categories indicate a higher concentration of flights within shorter ranges, which indicates most flights are within the USA. Looking at the time of the day, the ‘morning’ is the most common time for flight operations, progressively decreasing through ‘afternoon’ and ‘night’ hours. This distribution could be useful when understanding whether the number of flights at a given time of the day have an influence on the delay, or perhaps reduced visibility could be a factor.
## `summarise()` has grouped output by 'Category'. You can override using the
## `.groups` argument.
The use case of frequent itemsets applied to on time performance data differs from the most common ones in association rules, because there are excluding items, such as ArrDel15=Yes and ArrDel15=No (a flight can’t be both on time and delayed), nor depart from two airports at the same time.
Nonetheless, we can still infer which items are most common in this setting such as DepDel15=No and ArrDel15=No which is not surprising. Most flights seem to depart during the morning hours, which could lead to some congestion at the airport.
item_freq <- round(itemFrequency(trans1), 3)
top_20 <- base::sort(item_freq, decreasing=T)[0:20]
top_20_df <- data.frame(Item = names(top_20), Frequency = top_20)
# Plotting with ggplot2
ggplot(top_20_df, aes(x = reorder(Item, -Frequency), y = Frequency)) +
geom_bar(stat = "identity", fill = "blue") +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = "Item", y = "Frequency", title = "Top 20 Items by Frequency")
For the association rules approach, I will use the Apriori algorithm, using a minimum support of 0.05 and a minimum confidence of 0.8 for exploratory purposes and determine some general rules.
Support shows how frequent an item appears in the set, considering the nature of the dataset, I chose a lower value of support to include rules from less frequent variables (such as operating airline or distance groups).
Using the previously defined minimum values for the apriori algorithm, we can analyze the first set of rules.
The rules with the highest lift are:
{periodOfDay=afternoon,DepDel15=Yes} => {ArrDel15=Yes}{DepDel15=Yes} => {ArrDel15=Yes}{periodOfDay=morning,DepDel15=Yes} => {ArrDel15=Yes}Which indicate that a delay in the departure will indeed involve a delay on arrival, especially for flights in the afternoon. It is important to note that some of these rules are redundant, especially when considering ArrDel15 and DepDel15. I will address this in the next steps.
rules.trans1 <- apriori(trans1, parameter=list(supp=apriori_supp, conf=apriori_conf))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.8 0.1 1 none FALSE TRUE 5 0.05 1
## maxlen target ext
## 10 rules TRUE
##
## Algorithmic control:
## filter tree heap memopt load sort verbose
## 0.1 TRUE TRUE FALSE TRUE 2 TRUE
##
## Absolute minimum support count: 5000
##
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[763 item(s), 100000 transaction(s)] done [0.10s].
## sorting and recoding items ... [28 item(s)] done [0.01s].
## creating transaction tree ... done [0.04s].
## checking subsets of size 1 2 3 4 done [0.00s].
## writing ... [150 rule(s)] done [0.00s].
## creating S4 object ... done [0.01s].
#rules.trans1 <- apriori(trans1, parameter=list(supp=apriori_supp, conf=apriori_conf))
rules.by.lift <- sort(rules.trans1, by="lift", decreasing=TRUE) # sorting by lift
rules_by_lift <- as(rules.by.lift[1:50], "data.frame")
datatable(rules_by_lift,
options = list(
pageLength = 10,
autoWidth = TRUE,
scrollX = TRUE
),
class = "display nowrap compact",
#extensions = 'Responsive'
)
To determine the rules that will help us determine the items
associated to a delay on arrival (ArrDel15=Yes), we need to set this
parameter as a right hand side rhs=ArrDel15=Yes. Because
this rule is more specific, we need to lower the support to explore more
rules, using a minimum support of 0.01 and a minimum confidence of
0.8.
Among the rules with the highest confidence, we find the following:
Where OO=SkyWest Airlines and B6=JetBlue. These rules reflect that when these airlines have a delay on departure, with a confidence > 0.8 and a lift > 3.8 we can determine that the flight will be delayed on arrival as well. The same is true for shorter flights where the distnace is between 0 and 250 miles.
rules.delay <- apriori(data=trans1, parameter=list(supp = apriori_supp, conf = apriori_conf, minlen=1),
appearance=list(default="lhs", rhs="ArrDel15=Yes"), control=list(verbose=F))
rules.delay.byconf <- sort(rules.delay, by="confidence", decreasing=TRUE)
rules_by_conf <- as(rules.delay.byconf, "data.frame")
datatable(rules_by_conf,
options = list(
pageLength = 10,
autoWidth = TRUE,
scrollX = TRUE
),
class = "display nowrap compact",
#extensions = 'Responsive'
)
A rule is considered redundant if there is a more general one with comparable or superior confidence, implying that the nuances of the rule offer no additional value over the superset. Detecting redudant rules enables us to focus on the most significant rules.
In the table below, we can see a list of redundant rules, characterized by similar levels of confidence. These rules show that some conditions such as periodOfDay and DayOfWeek may not be so relevant, considering the confidence doesn’t have a large increase in comparison to more general rules.
redundant_rules <- as(rules.delay[is.redundant(rules.delay)==TRUE], "data.frame")
datatable(redundant_rules,
options = list(
pageLength = 10,
autoWidth = TRUE,
scrollX = TRUE,
dom = 't'
),
class = "display nowrap compact"
)
“The implementation for association rules uses Fisher’s exact test with correction for multiple comparisons to test the null hypothesis that the LHS and the RHS of the rule are independent. Significant rules have a p-value less then the specified significance level alpha (the null hypothesis of independence is rejected). See Hahsler and Hornik (2007) for details.” 6
The analysis of significant association rules from flight data reveals a clear link between departure delays and the arrival delays, with a notable confidence exceeding 80%. This pattern persists across various airlines, particularly with JetBlue (B6) and SkyWest Airlines (OO), where the lift for these rules is among the highest. The airline-specific rules regarding delays suggest a need for improvement in the operational procedures.
Operations during the night seem to have an effect on delays as well, if we look at the rule involving delays on departure during the night, we see that this rule has a high lift and confidence as well.
significant_rules <- as(rules.delay[is.significant(rules.delay)==TRUE], "data.frame")
datatable(significant_rules,
options = list(
pageLength = 10,
autoWidth = TRUE,
scrollX = TRUE
),
class = "display nowrap compact",
#extensions = 'Responsive'
)
The dendrogram below represents the clusters of variables based on their similarity using the dissimilarity index (jaccard). Here, we can see that departure delay of more than 15 minutes and arrival delay of more than 15 minutes are closely related, as seen previously. There seems to be a connection as well with airlines and their distance groups. SkyWest Airlines (OO) and Southwest Airlines (WN) and seem to be closely connected to 0-250 and 250-500 groupings respectively. As seen in previous rules, distance may have an impact on wether a delayed flight on departure is able to arrive on time.
trans.sel<-trans1[,itemFrequency(trans1)>0.05]
d.jac.i<-dissimilarity(trans.sel, which="items") # Jaccard
plot(hclust(d.jac.i, method="ward.D2"), main="Dendrogram for items")
plot(sort(rules.delay, by='lift'), method="graph", control=list(type="items", max=15, verbose=FALSE), main="Graph for 15 rules")
plot(rules.delay, method="paracoord", control=list(reorder=TRUE))
The scatter plot above shows the influence of certain carriers (such as AA, OO and B6) on flight delays, particularly during the afternoon and night periods. The parallel coordinates plot provides a multi-dimensional analysis of the same rules, showing the interplay between the time of flight and the probability of delays. Notably, many rules seem to be connected to departures in the afternoon and the departure delay. Both plots demonstrate the complex nature of flight delays, shaped by airline-specific operations, temporal factors, and flight distances.
In the research of factors contributing to airline delays using association rules, several visual analytics methods have been employed, as well as verifying the redundant rules. The most common factor in these rules is the delay on departure greater than 15 minutes, which seems to be an important factor in the delay on arrival. However, there are other factors that affect the delay, such as time of the day (night time operations), airline specific factors (related to the operations), and the travelled distance. It was shown that delays in shorter distances are more prone to generate a delay on arrival than in longer distances. Future analysis could include weather factors into the association rules analysis and the number of flights operating during the same time block, to explore whether congestion at the origin airport plays a factor in the departure delays.
Carmona-Saez, P., Chagoyen, M., Rodriguez, A. et al. Integrated analysis of gene expression by association rules discovery. BMC Bioinformatics 7, 54 (2006). https://doi.org/10.1186/1471-2105-7-54↩︎
Factors Affecting the International Flight Delays and Their Impact on Airline Operation and Management and Passenger Compensations Fees in Air Transport Industry: Case Study of a Selected Airlines in Europe↩︎
Airline Disruption Management: A Review of Models and Solution Methods↩︎
Bureau of Transportation Statistics: (Airline On-Time Performance and Causes of Flight Delays)↩︎