Last active
April 9, 2020 05:30
-
-
Save Wapiti08/727dfbc18bd2a4a1f84e0446d8c373be to your computer and use it in GitHub Desktop.
ml_pipeline
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
from sklearn.linear_model import Lasso | |
from sklearn.pipeline import Pipeline | |
from sklearn.preprocessing import MinMaxScaler | |
from regression_model.processing import preprocessors | |
from regression_model.processing import features | |
from regression_model.config import config | |
import logging | |
_logger = logging.getLogger(__name__) | |
price_pipe = Pipeline( | |
[ | |
('categorical_inputer', | |
pp.CategoricalImputer(variables=config.CATEGORICAL_VARS_WITH_NA)), | |
('numerical_inputer', | |
pp.NumericalImputer(variables=config.NUMERICAL_VARS_WITH_NA)), | |
('temporal_variable', | |
pp.TemporalVariableEstimator( | |
variables=config.TEMPORAL_VARS, | |
reference_variable=config.DROP_FEATURES)), | |
('rare_label_encoder', | |
pp.RareLabelCategoricalEncoder( | |
tol=0.01, | |
variables=config.CATEGORICAL_VARS | |
)), | |
('categorical_encoder', | |
pp.CategoricalEncoder(variables=config.CATEGORICAL_VARS)), | |
('log_transformer', | |
# you can build your own pipeline | |
features.LogTransformer(variables=config.NUMERICALS_LOG_VARS)), | |
('drop_features', | |
pp.DropUncessaryFeatures(variables_to_drop=config.DROP_FEATURES)), | |
('scaler', MinMaxScaler()), | |
('Linear_model', Lasso(alpha=0.005, random_state=0)) | |
] | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment