-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ww-tech/train-test-split-updates
Train test split updates
- Loading branch information
Showing
3 changed files
with
34 additions
and
26 deletions.
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
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 |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
Carl Anderson ([email protected]) | ||
""" | ||
from primrose.base.transformer import AbstractTransformer | ||
import logging | ||
import pandas as pd | ||
|
||
from primrose.base.transformer import AbstractTransformer | ||
|
||
class SklearnPreprocessingTransformer(AbstractTransformer): | ||
|
||
def __init__(self, preprocessor, columns): | ||
|
@@ -60,7 +62,11 @@ def transform(self, data): | |
|
||
else: | ||
scaled_features = self.preprocessor.transform(data.values) | ||
scaled_features_df = pd.DataFrame(scaled_features, index=data.index, columns=data.columns) | ||
try: | ||
scaled_features_df = pd.DataFrame(scaled_features, index=data.index, columns=data.columns) | ||
except ValueError: | ||
logging.info(f'{self.preprocessor.__class__.__name__} instance changed the number of columns. Returning raw values') | ||
return pd.DataFrame(scaled_features) | ||
return scaled_features_df | ||
|
||
return self.preprocessor.transform(data) | ||
|