This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Fix bug in Pipeline.transform() #294
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
282190f
Remove unnecessary code from Pipeline.transform that was causing a bug
najeeb-kazmi b74c64d
Update release-next.md
najeeb-kazmi 321e911
Merge branch 'master' into 271
najeeb-kazmi 41d47da
Remove y argument from transform() method
najeeb-kazmi b5eb5c3
Merge branch '271' of https://github.com/najeeb-kazmi/NimbusML into 271
najeeb-kazmi 1f93791
Update release-next.md
najeeb-kazmi ef43417
Fix test
najeeb-kazmi f3cd450
Merge branch 'master' into 271
najeeb-kazmi 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2254,7 +2254,6 @@ def test( | |
| def transform( | ||
| self, | ||
| X, | ||
| y=None, | ||
| verbose=0, | ||
| as_binary_data_stream=False, | ||
| **params): | ||
|
|
@@ -2275,18 +2274,7 @@ def transform( | |
| "Model is not fitted. Train or load a model before test(" | ||
| ").") | ||
|
|
||
| if y is not None: | ||
| if len(self.steps) > 0: | ||
| last_node = self.last_node | ||
| if last_node.type == 'transform': | ||
| raise ValueError( | ||
| "Pipeline needs a trainer as last step for test()") | ||
|
|
||
| X, y_temp, columns_renamed, feature_columns, label_column, \ | ||
| schema, weights, weight_column = self._preprocess_X_y(X, y) | ||
|
|
||
| if not isinstance(y, (str, tuple)): | ||
| y = y_temp | ||
| X, _, _, _, _, schema, _, _ = self._preprocess_X_y(X) | ||
|
Member
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.
Do you need to call this at all? #Resolved |
||
|
|
||
| all_nodes = [] | ||
|
|
||
|
|
||
26 changes: 26 additions & 0 deletions
26
src/python/nimbusml/tests/pipeline/test_pipeline_transform_method.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import unittest | ||
|
|
||
| import pandas | ||
| from nimbusml import Pipeline, FileDataStream | ||
| from nimbusml.datasets import get_dataset | ||
| from nimbusml.feature_extraction.text import NGramFeaturizer | ||
|
|
||
| path = get_dataset("wiki_detox_train").as_filepath() | ||
| data = FileDataStream.read_csv(path, sep='\t') | ||
| df = data.to_df().head() | ||
| X = df['SentimentText'] | ||
|
|
||
| class TestPipelineTransformMethod(unittest.TestCase): | ||
|
|
||
| def test_transform_only_pipeline_transform_method(self): | ||
| p = Pipeline([NGramFeaturizer(char_feature_extractor=None) << 'SentimentText']) | ||
| p.fit(X) | ||
| xf = p.transform(X) | ||
| assert 'SentimentText.==rude==' in xf.columns | ||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
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.
Uh oh!
There was an error while loading. Please reload this page.
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 y could be a tuple? How y_temp is used now? #Resolved
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.
y_temp is not used at all in this method.
In reply to: 330999871 [](ancestors = 330999871)