From 960c5f0a96bc869364ced58bd0b793c48ec25560 Mon Sep 17 00:00:00 2001 From: Panyi Dong Date: Fri, 8 Apr 2022 21:23:23 -0500 Subject: [PATCH] better legacy archive, prepare for later changes --- My_AutoML/_balancing/_legacy.py | 65 ++++++++++++++++++ My_AutoML/_encoding/_legacy.py | 43 ++++++++++++ My_AutoML/_feature_selection/_legacy.py | 74 ++++++++++++++++++++ My_AutoML/_imputation/_legacy.py | 54 +++++++++++++++ My_AutoML/_model/_legacy.py | 90 +++++++++++++++++++++++++ My_AutoML/_model_selection/_legacy.py | 14 ++-- My_AutoML/_scaling/_legacy.py | 61 +++++++++++++++++ 7 files changed, 394 insertions(+), 7 deletions(-) create mode 100644 My_AutoML/_balancing/_legacy.py create mode 100644 My_AutoML/_encoding/_legacy.py create mode 100644 My_AutoML/_feature_selection/_legacy.py create mode 100644 My_AutoML/_imputation/_legacy.py create mode 100644 My_AutoML/_model/_legacy.py create mode 100644 My_AutoML/_scaling/_legacy.py diff --git a/My_AutoML/_balancing/_legacy.py b/My_AutoML/_balancing/_legacy.py new file mode 100644 index 0000000..908f288 --- /dev/null +++ b/My_AutoML/_balancing/_legacy.py @@ -0,0 +1,65 @@ +""" +File: _legacy.py +Author: Panyi Dong +GitHub: https://github.com/PanyiDong/ +Mathematics Department, University of Illinois at Urbana-Champaign (UIUC) + +Project: My_AutoML +Latest Version: 0.2.0 +Relative Path: /My_AutoML/_balancing/_legacy.py +File Created: Friday, 8th April 2022 9:19:36 pm +Author: Panyi Dong (panyid2@illinois.edu) + +----- +Last Modified: Friday, 8th April 2022 9:19:56 pm +Modified By: Panyi Dong (panyid2@illinois.edu) + +----- +MIT License + +Copyright (c) 2022 - 2022, Panyi Dong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from ._over_sampling import SimpleRandomOverSampling, Smote +from ._under_sampling import ( + SimpleRandomUnderSampling, + TomekLink, + EditedNearestNeighbor, + CondensedNearestNeighbor, + OneSidedSelection, + CNN_TomekLink, +) +from ._mixed_sampling import Smote_TomekLink, Smote_ENN +from My_AutoML._base import no_processing + +balancings = { + "no_processing": no_processing, + "SimpleRandomOverSampling": SimpleRandomOverSampling, + "SimpleRandomUnderSampling": SimpleRandomUnderSampling, + "TomekLink": TomekLink, + "EditedNearestNeighbor": EditedNearestNeighbor, + "CondensedNearestNeighbor": CondensedNearestNeighbor, + "OneSidedSelection": OneSidedSelection, + "CNN_TomekLink": CNN_TomekLink, + "Smote": Smote, + "Smote_TomekLink": Smote_TomekLink, + "Smote_ENN": Smote_ENN, +} diff --git a/My_AutoML/_encoding/_legacy.py b/My_AutoML/_encoding/_legacy.py new file mode 100644 index 0000000..d1ab5d1 --- /dev/null +++ b/My_AutoML/_encoding/_legacy.py @@ -0,0 +1,43 @@ +""" +File: _legacy.py +Author: Panyi Dong +GitHub: https://github.com/PanyiDong/ +Mathematics Department, University of Illinois at Urbana-Champaign (UIUC) + +Project: My_AutoML +Latest Version: 0.2.0 +Relative Path: /My_AutoML/_encoding/_legacy.py +File Created: Friday, 8th April 2022 9:20:03 pm +Author: Panyi Dong (panyid2@illinois.edu) + +----- +Last Modified: Friday, 8th April 2022 9:20:14 pm +Modified By: Panyi Dong (panyid2@illinois.edu) + +----- +MIT License + +Copyright (c) 2022 - 2022, Panyi Dong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from ._encoding import DataEncoding + +encoders = {"DataEncoding": DataEncoding} diff --git a/My_AutoML/_feature_selection/_legacy.py b/My_AutoML/_feature_selection/_legacy.py new file mode 100644 index 0000000..b05668e --- /dev/null +++ b/My_AutoML/_feature_selection/_legacy.py @@ -0,0 +1,74 @@ +""" +File: _legacy.py +Author: Panyi Dong +GitHub: https://github.com/PanyiDong/ +Mathematics Department, University of Illinois at Urbana-Champaign (UIUC) + +Project: My_AutoML +Latest Version: 0.2.0 +Relative Path: /My_AutoML/_feature_selection/_legacy.py +File Created: Friday, 8th April 2022 9:20:27 pm +Author: Panyi Dong (panyid2@illinois.edu) + +----- +Last Modified: Friday, 8th April 2022 9:20:55 pm +Modified By: Panyi Dong (panyid2@illinois.edu) + +----- +MIT License + +Copyright (c) 2022 - 2022, Panyi Dong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from ._base import RBFSampler +from ._advance import FeatureFilter, ASFFS, GeneticAlgorithm +from My_AutoML._base import no_processing + +import autosklearn +import autosklearn.pipeline.components.feature_preprocessing + +feature_selections = { + "no_processing": no_processing, + # "LDASelection": LDASelection, + # "PCA_FeatureSelection": PCA_FeatureSelection, + "RBFSampler": RBFSampler, + "FeatureFilter": FeatureFilter, + "ASFFS": ASFFS, + "GeneticAlgorithm": GeneticAlgorithm, + # 'densifier' : autosklearn.pipeline.components.feature_preprocessing.densifier.Densifier, # from autosklearn + "extra_trees_preproc_for_classification": autosklearn.pipeline.components.feature_preprocessing.extra_trees_preproc_for_classification.ExtraTreesPreprocessorClassification, + "extra_trees_preproc_for_regression": autosklearn.pipeline.components.feature_preprocessing.extra_trees_preproc_for_regression.ExtraTreesPreprocessorRegression, + # "fast_ica": autosklearn.pipeline.components.feature_preprocessing.fast_ica.FastICA, + # "feature_agglomeration": autosklearn.pipeline.components.feature_preprocessing.feature_agglomeration.FeatureAgglomeration, + # "kernel_pca": autosklearn.pipeline.components.feature_preprocessing.kernel_pca.KernelPCA, + # "kitchen_sinks": autosklearn.pipeline.components.feature_preprocessing.kitchen_sinks.RandomKitchenSinks, + "liblinear_svc_preprocessor": autosklearn.pipeline.components.feature_preprocessing.liblinear_svc_preprocessor.LibLinear_Preprocessor, + # "nystroem_sampler": autosklearn.pipeline.components.feature_preprocessing.nystroem_sampler.Nystroem, + # "pca": autosklearn.pipeline.components.feature_preprocessing.pca.PCA, + "polynomial": autosklearn.pipeline.components.feature_preprocessing.polynomial.PolynomialFeatures, + # "random_trees_embedding": autosklearn.pipeline.components.feature_preprocessing.random_trees_embedding.RandomTreesEmbedding, + # 'select_percentile' : autosklearn.pipeline.components.feature_preprocessing.select_percentile.SelectPercentileBase, + "select_percentile_classification": autosklearn.pipeline.components.feature_preprocessing.select_percentile_classification.SelectPercentileClassification, + "select_percentile_regression": autosklearn.pipeline.components.feature_preprocessing.select_percentile_regression.SelectPercentileRegression, + "select_rates_classification": autosklearn.pipeline.components.feature_preprocessing.select_rates_classification.SelectClassificationRates, + "select_rates_regression": autosklearn.pipeline.components.feature_preprocessing.select_rates_regression.SelectRegressionRates, + "truncatedSVD": autosklearn.pipeline.components.feature_preprocessing.truncatedSVD.TruncatedSVD, +} diff --git a/My_AutoML/_imputation/_legacy.py b/My_AutoML/_imputation/_legacy.py new file mode 100644 index 0000000..a41f69e --- /dev/null +++ b/My_AutoML/_imputation/_legacy.py @@ -0,0 +1,54 @@ +""" +File: _legacy.py +Author: Panyi Dong +GitHub: https://github.com/PanyiDong/ +Mathematics Department, University of Illinois at Urbana-Champaign (UIUC) + +Project: My_AutoML +Latest Version: 0.2.0 +Relative Path: /My_AutoML/_imputation/_legacy.py +File Created: Friday, 8th April 2022 9:21:08 pm +Author: Panyi Dong (panyid2@illinois.edu) + +----- +Last Modified: Friday, 8th April 2022 9:21:33 pm +Modified By: Panyi Dong (panyid2@illinois.edu) + +----- +MIT License + +Copyright (c) 2022 - 2022, Panyi Dong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from ._base import SimpleImputer, DummyImputer, JointImputer +from ._multiple import ExpectationMaximization, KNNImputer, MissForestImputer, MICE +from ._nn import GAIN + +imputers = { + "SimpleImputer": SimpleImputer, + # 'DummyImputer' : DummyImputer, + "JointImputer": JointImputer, + "ExpectationMaximization": ExpectationMaximization, + "KNNImputer": KNNImputer, + "MissForestImputer": MissForestImputer, + "MICE": MICE, + "GAIN": GAIN, +} diff --git a/My_AutoML/_model/_legacy.py b/My_AutoML/_model/_legacy.py new file mode 100644 index 0000000..b391b5f --- /dev/null +++ b/My_AutoML/_model/_legacy.py @@ -0,0 +1,90 @@ +""" +File: _legacy.py +Author: Panyi Dong +GitHub: https://github.com/PanyiDong/ +Mathematics Department, University of Illinois at Urbana-Champaign (UIUC) + +Project: My_AutoML +Latest Version: 0.2.0 +Relative Path: /My_AutoML/_model/_legacy.py +File Created: Friday, 8th April 2022 9:18:08 pm +Author: Panyi Dong (panyid2@illinois.edu) + +----- +Last Modified: Friday, 8th April 2022 9:18:53 pm +Modified By: Panyi Dong (panyid2@illinois.edu) + +----- +MIT License + +Copyright (c) 2022 - 2022, Panyi Dong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +import autosklearn.pipeline.components.classification +import autosklearn.pipeline.components.regression + +#################################################################################################### +# classifiers + +classifiers = { + # classification models from autosklearn + "AdaboostClassifier": autosklearn.pipeline.components.classification.adaboost.AdaboostClassifier, + "BernoulliNB": autosklearn.pipeline.components.classification.bernoulli_nb.BernoulliNB, + "DecisionTree": autosklearn.pipeline.components.classification.decision_tree.DecisionTree, + "ExtraTreesClassifier": autosklearn.pipeline.components.classification.extra_trees.ExtraTreesClassifier, + "GaussianNB": autosklearn.pipeline.components.classification.gaussian_nb.GaussianNB, + "GradientBoostingClassifier": autosklearn.pipeline.components.classification.gradient_boosting.GradientBoostingClassifier, + "KNearestNeighborsClassifier": autosklearn.pipeline.components.classification.k_nearest_neighbors.KNearestNeighborsClassifier, + "LDA": autosklearn.pipeline.components.classification.lda.LDA, + "LibLinear_SVC": autosklearn.pipeline.components.classification.liblinear_svc.LibLinear_SVC, + "LibSVM_SVC": autosklearn.pipeline.components.classification.libsvm_svc.LibSVM_SVC, + "MLPClassifier": autosklearn.pipeline.components.classification.mlp.MLPClassifier, + "MultinomialNB": autosklearn.pipeline.components.classification.multinomial_nb.MultinomialNB, + "PassiveAggressive": autosklearn.pipeline.components.classification.passive_aggressive.PassiveAggressive, + "QDA": autosklearn.pipeline.components.classification.qda.QDA, + "RandomForest": autosklearn.pipeline.components.classification.random_forest.RandomForest, + "SGD": autosklearn.pipeline.components.classification.sgd.SGD, +} + +# regressors +regressors = { + # regression models from autosklearn + "AdaboostRegressor": autosklearn.pipeline.components.regression.adaboost.AdaboostRegressor, + "ARDRegression": autosklearn.pipeline.components.regression.ard_regression.ARDRegression, + "DecisionTree": autosklearn.pipeline.components.regression.decision_tree.DecisionTree, + "ExtraTreesRegressor": autosklearn.pipeline.components.regression.extra_trees.ExtraTreesRegressor, + "GaussianProcess": autosklearn.pipeline.components.regression.gaussian_process.GaussianProcess, + "GradientBoosting": autosklearn.pipeline.components.regression.gradient_boosting.GradientBoosting, + "KNearestNeighborsRegressor": autosklearn.pipeline.components.regression.k_nearest_neighbors.KNearestNeighborsRegressor, + "LibLinear_SVR": autosklearn.pipeline.components.regression.liblinear_svr.LibLinear_SVR, + "LibSVM_SVR": autosklearn.pipeline.components.regression.libsvm_svr.LibSVM_SVR, + "MLPRegressor": autosklearn.pipeline.components.regression.mlp.MLPRegressor, + "RandomForest": autosklearn.pipeline.components.regression.random_forest.RandomForest, + "SGD": autosklearn.pipeline.components.regression.sgd.SGD, +} + + +""" +LibSVM_SVR, MLP and SGD have problems of requiring inverse_transform +of StandardScaler while having 1D array +https://github.com/automl/auto-sklearn/issues/1297 +problem solved +""" diff --git a/My_AutoML/_model_selection/_legacy.py b/My_AutoML/_model_selection/_legacy.py index 0417210..6148be0 100644 --- a/My_AutoML/_model_selection/_legacy.py +++ b/My_AutoML/_model_selection/_legacy.py @@ -10,7 +10,7 @@ Author: Panyi Dong (panyid2@illinois.edu) ----- -Last Modified: Thursday, 7th April 2022 4:02:23 pm +Last Modified: Friday, 8th April 2022 9:22:44 pm Modified By: Panyi Dong (panyid2@illinois.edu) ----- @@ -60,12 +60,12 @@ from sklearn.utils._testing import ignore_warnings from sklearn.exceptions import ConvergenceWarning -from My_AutoML._encoding import encoders -from My_AutoML._imputation import imputers -from My_AutoML._balancing import balancings -from My_AutoML._scaling import scalings -from My_AutoML._feature_selection import feature_selections -from My_AutoML._model import ( +from My_AutoML._encoding._legacy import encoders +from My_AutoML._imputation._legacy import imputers +from My_AutoML._balancing._legacy import balancings +from My_AutoML._scaling._legacy import scalings +from My_AutoML._feature_selection._legacy import feature_selections +from My_AutoML._model._legacy import ( classifiers, regressors, ) diff --git a/My_AutoML/_scaling/_legacy.py b/My_AutoML/_scaling/_legacy.py new file mode 100644 index 0000000..e13c554 --- /dev/null +++ b/My_AutoML/_scaling/_legacy.py @@ -0,0 +1,61 @@ +""" +File: _legacy.py +Author: Panyi Dong +GitHub: https://github.com/PanyiDong/ +Mathematics Department, University of Illinois at Urbana-Champaign (UIUC) + +Project: My_AutoML +Latest Version: 0.2.0 +Relative Path: /My_AutoML/_scaling/_legacy.py +File Created: Friday, 8th April 2022 9:21:57 pm +Author: Panyi Dong (panyid2@illinois.edu) + +----- +Last Modified: Friday, 8th April 2022 9:22:14 pm +Modified By: Panyi Dong (panyid2@illinois.edu) + +----- +MIT License + +Copyright (c) 2022 - 2022, Panyi Dong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from ._scaling import ( + MinMaxScale, + Standardize, + Normalize, + RobustScale, + PowerTransformer, + QuantileTransformer, + Winsorization, +) +from My_AutoML._base import no_processing + +scalings = { + "no_processing": no_processing, + "MinMaxScale": MinMaxScale, + "Standardize": Standardize, + "Normalize": Normalize, + "RobustScale": RobustScale, + "PowerTransformer": PowerTransformer, + "QuantileTransformer": QuantileTransformer, + "Winsorization": Winsorization, +}