-
Notifications
You must be signed in to change notification settings - Fork 86
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
Changed target name/series ID divider and added ability to return series ID column with predictions #4357
Merged
Merged
Changed target name/series ID divider and added ability to return series ID column with predictions #4357
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
69be047
Try extra debug
machineFL 08694b0
Updated release notes
christopherbunn 5721615
Join with separator symbol
christopherbunn fa437a1
Added infer to the end
christopherbunn 95e6681
updated test to infer type
christopherbunn 36185ae
Add series ID indexing test
christopherbunn 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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
TimeSeriesRegressionPipeline, | ||
) | ||
from evalml.problem_types import ProblemTypes | ||
from evalml.utils import infer_feature_types | ||
|
||
|
||
class MultiseriesRegressionPipeline(TimeSeriesRegressionPipeline): | ||
|
@@ -91,6 +92,7 @@ | |
y_train, | ||
objective=None, | ||
calculating_residuals=False, | ||
include_series_id=False, | ||
): | ||
"""Predict on future data where the target is known, e.g. cross validation. | ||
|
||
|
@@ -102,6 +104,7 @@ | |
objective (ObjectiveBase, str, None): Objective used to threshold predicted probabilities, optional. | ||
calculating_residuals (bool): Whether we're calling predict_in_sample to calculate the residuals. This means | ||
the X and y arguments are not future data, but actually the train data. | ||
include_series_id (bool): If true, include the series ID value in the prediction results | ||
|
||
Returns: | ||
pd.Series: Estimated labels. | ||
|
@@ -125,6 +128,31 @@ | |
self.time_index, | ||
self.input_target_name, | ||
) | ||
# Order series columns to be same as expected input feature names | ||
input_features = list(self.input_feature_names.values())[0] | ||
X_unstacked = X_unstacked[ | ||
[feature for feature in input_features if feature in X_unstacked.columns] | ||
] | ||
X_train_unstacked = X_train_unstacked[ | ||
[ | ||
feature | ||
for feature in input_features | ||
if feature in X_train_unstacked.columns | ||
] | ||
] | ||
y_overlapping_features = [ | ||
feature | ||
for feature in y_train_unstacked.columns | ||
if feature in y_unstacked.columns | ||
] | ||
y_unstacked = y_unstacked[y_overlapping_features] | ||
y_train_unstacked = y_train_unstacked[y_overlapping_features] | ||
|
||
X_train_unstacked = infer_feature_types(X_train_unstacked) | ||
y_train_unstacked = infer_feature_types(y_train_unstacked) | ||
X_unstacked = infer_feature_types(X_unstacked) | ||
y_unstacked = infer_feature_types(y_unstacked) | ||
|
||
unstacked_predictions = super().predict_in_sample( | ||
X_unstacked, | ||
y_unstacked, | ||
|
@@ -133,7 +161,14 @@ | |
objective, | ||
calculating_residuals, | ||
) | ||
stacked_predictions = stack_data(unstacked_predictions) | ||
if include_series_id: | ||
stacked_predictions = stack_data( | ||
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. We're missing testing on this branch? |
||
unstacked_predictions, | ||
include_series_id=True, | ||
series_id_name=self.series_id, | ||
) | ||
else: | ||
stacked_predictions = stack_data(unstacked_predictions) | ||
christopherbunn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Index will start at the unstacked index, so we need to reset it to the original index | ||
stacked_predictions.index = X.index | ||
|
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
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
Oops, something went wrong.
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.
This is a really long chunk of text, where a lot of it's repeated. A few questions:
X_unstacked
andX_train_unstacked
ever going to have different columns? It seems odd that we get those separately from each other, so differently from howy
is handled hereThere 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.
Will push an additional test case. Actually our current test case forpredict_in_sample()
errors out if it isn't in the right order. I could add something explicitly if you think it would be helpful?X_train
even if they're not specified in the currentX
. We can generally expect they
andy_train
values to be consistent since the column names come from the same series ID values.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.
When you say the current test case errors out if it isn't in the right order, does that mean you changed it around manually to verify it fails in that case? I'm thinking we'd benefit from an explicit test case that fails if this code isn't in place, no modification required. It'll help stop us from removing or breaking this bit in the future
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.
Added
test_multiseries_pipeline_predict_in_sample_series_out_of_order()
which evaluates this case.