diff --git a/auto_ml/predictor.py b/auto_ml/predictor.py index 74c1f66..f60873e 100644 --- a/auto_ml/predictor.py +++ b/auto_ml/predictor.py @@ -189,7 +189,7 @@ def _construct_pipeline(self, model_name='LogisticRegression', trained_pipeline= final_model = utils_models.get_model_from_name(model_name, training_params=params) pipeline_list.append(('final_model', utils_model_training.FinalModelATC(model=final_model, type_of_estimator=self.type_of_estimator, ml_for_analytics=self.ml_for_analytics, name=self.name, _scorer=self._scorer, feature_learning=feature_learning, uncertainty_model=self.need_to_train_uncertainty_model, training_prediction_intervals=training_prediction_intervals, column_descriptions=self.column_descriptions, training_features=training_features, keep_cat_features=keep_cat_features, is_hp_search=is_hp_search, X_test=self.X_test, y_test=self.y_test))) - constructed_pipeline = utils.ExtendedPipeline(pipeline_list, keep_cat_features=keep_cat_features) + constructed_pipeline = utils.ExtendedPipeline(pipeline_list, keep_cat_features=keep_cat_features, name=self.name) return constructed_pipeline diff --git a/auto_ml/utils.py b/auto_ml/utils.py index b9a55b3..752137d 100644 --- a/auto_ml/utils.py +++ b/auto_ml/utils.py @@ -2,6 +2,7 @@ import datetime import numbers import os +import pkg_resources import numpy as np import pandas as pd @@ -13,6 +14,8 @@ from sklearn.utils.metaestimators import if_delegate_has_method from sklearn.utils import column_or_1d +from _version import __version__ as auto_ml_version + def is_linear_model(model_names): linear_models = set(['RANSACRegressor', 'LinearRegression', 'Ridge', 'Lasso', 'ElasticNet', 'LassoLars', 'OrthogonalMatchingPursuit', 'BayesianRidge', 'ARDRegression', 'SGDRegressor', 'PassiveAggressiveRegressor', 'LogisticRegression', 'RidgeClassifier', 'SGDClassifier', 'Perceptron', 'PassiveAggressiveClassifier']) @@ -225,15 +228,6 @@ def __init__(self): super(self.__class__, self).__init__() def transform(self, y): - """Transform labels to normalized encoding. - Parameters - ---------- - y : array-like of shape [n_samples] - Target values. - Returns - ------- - y : array-like of shape [n_samples] - """ y = column_or_1d(y, warn=True) classes = np.unique(y) @@ -242,11 +236,31 @@ def transform(self, y): self.classes_ = np.hstack((self.classes_, diff)) return np.searchsorted(self.classes_, y)[0] + +def get_versions(): + + libraries_to_check = ['dill', 'h5py', 'keras', 'lightgbm', 'numpy', 'pandas', 'pathos', 'python', 'scikit-learn', 'scipy', 'sklearn-deap2', 'tabulate', 'tensorflow', 'xgboost'] + + versions = { + 'auto_ml': auto_ml_version + } + + for lib in libraries_to_check: + try: + versions[lib] = pkg_resources.get_distribution(lib).version + except: + pass + + return versions + + class ExtendedPipeline(Pipeline): - def __init__(self, steps, keep_cat_features=False): + def __init__(self, steps, keep_cat_features=False, name=None): super(self.__class__, self).__init__(steps) self.keep_cat_features = keep_cat_features + self.__versions__ = get_versions() + self.name = name @if_delegate_has_method(delegate='_final_estimator')