-
Notifications
You must be signed in to change notification settings - Fork 25
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
Feature/transf date #29
Merged
Merged
Conversation
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
Signed-off-by: Gillesa <arm.gilles@gmail.com>
Signed-off-by: Gillesa <arm.gilles@gmail.com>
Great ! Maybe your transformation is not in method _analyze_consistency, but before, to be more clearer on a transformation of datasets. |
Signed-off-by: Gillesa <arm.gilles@gmail.com>
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
from eurybia.data.data_loader import data_loading
from eurybia import SmartDrift
house_df, house_dict = data_loading('house_prices')
house_df_learning = house_df.loc[house_df['YrSold'] == 2006]
house_df_2007 = house_df.loc[house_df['YrSold'] == 2007]
y_df_learning=house_df_learning['SalePrice'].to_frame()
X_df_learning=house_df_learning[house_df_learning.columns.difference(['SalePrice','YrSold'])]
y_df_2007=house_df_2007['SalePrice'].to_frame()
X_df_2007=house_df_2007[house_df_2007.columns.difference(['SalePrice','YrSold'])]
# Create random columns dates
X_df_learning['random_col_date'] = np.random.choice(pd.date_range(start='01/01/2000', end='31/12/2006'), size=len(X_df_learning))
X_df_learning['other_random_col_date'] = np.random.choice(pd.date_range(start='01/01/2000', end='31/12/2006'), size=len(X_df_learning))
X_df_2007['random_col_date'] = np.random.choice(pd.date_range(start='01/01/2007', end='31/12/2007'), size=len(X_df_2007))
X_df_2007['other_random_col_date'] = np.random.choice(pd.date_range(start='01/01/2007', end='31/12/2007'), size=len(X_df_2007))
# Just a Random models
regressor = RandomForestRegressor(n_estimators=2).fit(X_df_learning[['1stFlrSF', '2ndFlrSF']],
y_df_learning
)
# Should be ok & informed user of transformation
SD = SmartDrift(df_current=X_df_2007,
df_baseline=X_df_learning,
dataset_names={"df_current": "2007 dataset", "df_baseline": "Learning dataset"}
)
SD.compile()
# Column random_col_date will be dropped and transformed in df_current by : random_col_date_year, random_col_date_month, random_col_date_day
# Column other_random_col_date will be dropped and transformed in df_current by : other_random_col_date_year, other_random_col_date_month, other_random_col_date_day
# Column random_col_date will be dropped and transformed in df_baseline by : random_col_date_year, random_col_date_month, random_col_date_day
# Column other_random_col_date will be dropped and transformed in df_baseline by : other_random_col_date_year, other_random_col_date_month, other_random_col_date_day
# Should raise error
SD = SmartDrift(df_current=X_df_2007,
df_baseline=X_df_learning,
deployed_model=regressor,
dataset_names={"df_current": "2007 dataset", "df_baseline": "Learning dataset"}
)
SD.compile()
# TypeError: df_current have datetime column. You should drop it |
Great, Thanks for you contribution ! |
ThomasBouche
approved these changes
Sep 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Allow
datetime
column in EurybiaReference Issues/PRs : #28