-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling time documentation page #512
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
37803f8
Updated docs
CharlesBradshaw 8a10dfa
manually linted
CharlesBradshaw 03e35af
updated docs
CharlesBradshaw ae363f8
clarified cutoff_times
CharlesBradshaw f03a45a
updated handling_time
CharlesBradshaw 3be6493
Merge branch 'master' into cutoff_time_docs
CharlesBradshaw da547be
first pass
kmax12 429af34
Merge branch 'master' into cutoff_time_docs
kmax12 cb79dd2
update test_load_flight
kmax12 5dcf921
update
kmax12 c88f72b
update ref
kmax12 e1b6e7e
edits
kmax12 c61ddaf
update intro
kmax12 9151dcd
Merge branch 'master' into cutoff_time_docs
kmax12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
312 changes: 156 additions & 156 deletions
312
docs/source/automated_feature_engineering/handling_time.rst
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,22 +90,22 @@ def load_flight(month_filter=None, | |
|
||
def make_es(data): | ||
es = ft.EntitySet('Flight Data') | ||
labely_columns = ['arr_delay', 'dep_delay', 'carrier_delay', 'weather_delay', | ||
'national_airspace_delay', 'security_delay', | ||
'late_aircraft_delay', 'cancelled', 'diverted', | ||
'taxi_in', 'taxi_out', 'air_time', 'dep_time'] | ||
arr_time_columns = ['arr_delay', 'dep_delay', 'carrier_delay', 'weather_delay', | ||
'national_airspace_delay', 'security_delay', | ||
'late_aircraft_delay', 'canceled', 'diverted', | ||
'taxi_in', 'taxi_out', 'air_time', 'dep_time'] | ||
|
||
variable_types = {'flight_num': vtypes.Categorical, | ||
'distance_group': vtypes.Ordinal, | ||
'cancelled': vtypes.Boolean, | ||
'canceled': vtypes.Boolean, | ||
'diverted': vtypes.Boolean} | ||
|
||
es.entity_from_dataframe('trip_logs', | ||
data, | ||
index='trip_log_id', | ||
make_index=True, | ||
time_index='time_index', | ||
secondary_time_index={'arr_time': labely_columns}, | ||
time_index='date_scheduled', | ||
secondary_time_index={'arr_time': arr_time_columns}, | ||
variable_types=variable_types) | ||
|
||
es.normalize_entity('trip_logs', 'flights', 'flight_id', | ||
|
@@ -134,7 +134,8 @@ def _clean_data(data): | |
'crs_elapsed_time': 'scheduled_elapsed_time', | ||
'nas_delay': 'national_airspace_delay', | ||
'origin_city_name': 'origin_city', | ||
'dest_city_name': 'dest_city'}) | ||
'dest_city_name': 'dest_city', | ||
'cancelled': 'canceled'}) | ||
|
||
# Combine strings like 0130 (1:30 AM) with dates (2017-01-01) | ||
clean_data['scheduled_dep_time'] = clean_data['scheduled_dep_time'].apply(lambda x: str(x)) + clean_data['flight_date'].astype('str') | ||
|
@@ -148,7 +149,7 @@ def _clean_data(data): | |
clean_data = _reconstruct_times(clean_data) | ||
|
||
# Create a time index 6 months before scheduled_dep | ||
clean_data.loc[:, 'time_index'] = clean_data['scheduled_dep_time'] - \ | ||
clean_data.loc[:, 'date_scheduled'] = clean_data['scheduled_dep_time'].dt.date - \ | ||
pd.Timedelta('120d') | ||
|
||
# A null entry for a delay means no delay | ||
|
@@ -163,13 +164,34 @@ def _clean_data(data): | |
clean_data.loc[:, 'flight_id'] = clean_data['carrier'] + '-' + \ | ||
clean_data['flight_num'].apply(lambda x: str(x)) + ':' + clean_data['origin'] + '->' + clean_data['dest'] | ||
|
||
column_order = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated column order to improve print out in the docs |
||
'flight_id', | ||
'flight_num', | ||
'date_scheduled', | ||
'scheduled_dep_time', | ||
'scheduled_arr_time', | ||
'carrier', | ||
'origin', 'origin_city', 'origin_state', | ||
'dest', 'dest_city', 'dest_state', | ||
'distance_group', | ||
'dep_time', | ||
'arr_time', | ||
'dep_delay', 'taxi_out', 'taxi_in', 'arr_delay', | ||
'diverted', 'scheduled_elapsed_time', 'air_time', 'distance', | ||
'carrier_delay', 'weather_delay', | ||
'national_airspace_delay', 'security_delay', 'late_aircraft_delay', | ||
'canceled' | ||
] | ||
|
||
clean_data = clean_data[column_order] | ||
|
||
return clean_data | ||
|
||
|
||
def _fill_labels(clean_data): | ||
labely_columns = ['arr_delay', 'dep_delay', 'carrier_delay', 'weather_delay', | ||
'national_airspace_delay', 'security_delay', | ||
'late_aircraft_delay', 'cancelled', 'diverted', | ||
'late_aircraft_delay', 'canceled', 'diverted', | ||
'taxi_in', 'taxi_out', 'air_time'] | ||
for col in labely_columns: | ||
clean_data.loc[:, col] = clean_data[col].fillna(0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to something more meaningful