diff --git a/README.md b/README.md index 16f76ca..90a9bd6 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,16 @@ Our Goal is to democratize Machine Learning and make it accessible to everyone. - "lcv": "LassoCV Classifier" - "llic": "LassoLarsIC Classifier" - "llcv": "LassoLarsCV Classifier" + - "ransac": "RANSACClassifiers", + - "ompcv": "OrthogonalMatchingPursuitCV Classifier", + - "omp": "OrthogonalMatchingPursuit Classifier", + - "iso": "IsotonicRegression Classifier", + - "rad": "RadiusNeighbors Classifier", + - "quantile": "QuantileRegression Classifier", + - "theil": "TheilSenRegressor Classifier", + - "lars": "Lars Classifeir", + - "lcv": "LarsCV Classifier", + - "tweedie": "TweedieClassifiers", - "all": "All Classifiers" 2) Regression @@ -84,6 +94,16 @@ Our Goal is to democratize Machine Learning and make it accessible to everyone. - "lcv": "LassoCV Regressor" - "llic": "LassoLarsIC Regressor" - "llcv": "LassoLarsCV Regressor" + - "ransac": "RANSACRegressor", + - "ompcv": "OrthogonalMatchingPursuitCV", + - "gpr": "GaussianProcessRegressor", + - "omp": "OrthogonalMatchingPursuit", + - "llars": "LassoLars", + - "iso": "IsotonicRegression", + - "fm": "Factorisation Machine Regressors", + - "rnr": "Radius Neighbors Regressor Regressors", + - "qr": "Quantile Regression Regressors", + - "theil": "TheilSenRegressor Regressors", - "all": "All Regressors" ### Usage Example diff --git a/anai/supervised/__init__.py b/anai/supervised/__init__.py index 273d300..35ba70a 100644 --- a/anai/supervised/__init__.py +++ b/anai/supervised/__init__.py @@ -102,6 +102,16 @@ def __init__( "lcv": "LassoCV Classifier",\n "llic": "LassoLarsIC Classifier",\n "llcv": "LassoLarsCV Classifier",\n + "ransac": "RANSACClassifiers",\n + "ompcv": "OrthogonalMatchingPursuitCV Classifier",\n + "omp": "OrthogonalMatchingPursuit Classifier",\n + "iso": "IsotonicRegression Classifier",\n + "rad": "RadiusNeighbors Classifier",\n + "quantile": "QuantileRegression Classifier",\n + "theil": "TheilSenRegressor Classifier",\n + "lars": "Lars Classifeir",\n + "lcv": "LarsCV Classifier",\n + "tweedie": "TweedieClassifiers",\n "all": "All Classifiers",\n params : dict contains parameters for model @@ -853,6 +863,16 @@ def __init__( "lcv": "LassoCV Regressor",\n "llic": "LassoLarsIC Regressor",\n "llcv": "LassoLarsCV Regressor",\n + "ransac": "RANSACRegressor",\n + "ompcv": "OrthogonalMatchingPursuitCV",\n + "gpr": "GaussianProcessRegressor",\n + "omp": "OrthogonalMatchingPursuit",\n + "llars": "LassoLars",\n + "iso": "IsotonicRegression",\n + "fm": "Factorisation Machine Regressors",\n + "rnr": "Radius Neighbors Regressor Regressors",\n + "qr": "Quantile Regression Regressors",\n + "theil": "TheilSenRegressor Regressors",\n "all": "All Regressors",\n params : dict contains parameters for model diff --git a/anai/utils/configs.py b/anai/utils/configs.py index 56feb29..035391e 100644 --- a/anai/utils/configs.py +++ b/anai/utils/configs.py @@ -35,6 +35,16 @@ "lcv": "LassoCV Classifier", "llic": "LassoLarsIC Classifier", "llcv": "LassoLarsCV Classifier", + "ransac": "RANSACClassifiers", + "ompcv": "OrthogonalMatchingPursuitCV Classifier", + "omp": "OrthogonalMatchingPursuit Classifier", + "iso": "IsotonicRegression Classifier", + "rad": "RadiusNeighbors Classifier", + "quantile": "QuantileRegression Classifier", + "theil": "TheilSenRegressor Classifier", + "lars": "Lars Classifeir", + "lcv": "LarsCV Classifier", + "tweedie": "TweedieClassifiers", } regressors = { @@ -55,14 +65,24 @@ "xgb": "XGBoost Regressor", "cat": "Catboost Regressor", "ann": "Multi-Layer Perceptron Regressor", - # "poisson": "Poisson Regressor", + "poisson": "Poisson Regressor", "huber": "Huber Regressor", "gamma": "Gamma Regressor", "ridge": "Ridge CV Regressor", "encv": "ElasticNetCV Regressor", "lcv": "LassoCV Regressor", - # "llic": "LassoLarsIC Regressor", - # "llcv": "LassoLarsCV Regressor", + "llic": "LassoLarsIC Regressor", + "llcv": "LassoLarsCV Regressor", + "ransac": "RANSACRegressor", + "ompcv": "OrthogonalMatchingPursuitCV", + "gpr": "GaussianProcessRegressor", + "omp": "OrthogonalMatchingPursuit", + "llars": "LassoLars", + "iso": "IsotonicRegression", + "fm": "Factorisation Machine Regressors", + "rnr": "Radius Neighbors Regressor Regressors", + "qr": "Quantile Regression Regressors", + "theil": "TheilSenRegressor Regressors", } classifiers_ver = { @@ -91,6 +111,16 @@ "lcv": "LassoCV Classifier", "llic": "LassoLarsIC Classifier", "llcv": "LassoLarsCV Classifier", + "ransac": "RANSACClassifiers", + "ompcv": "OrthogonalMatchingPursuitCV Classifier", + "omp": "OrthogonalMatchingPursuit Classifier", + "iso": "IsotonicRegression Classifier", + "rad": "RadiusNeighbors Classifier", + "quantile": "QuantileRegression Classifier", + "theil": "TheilSenRegressor Classifier", + "lars": "Lars Classifeir", + "lcv": "LarsCV Classifier", + "tweedie": "TweedieClassifiers", "all": "All Classifiers", } @@ -120,6 +150,16 @@ "lcv": "LassoCV Regressor", "llic": "LassoLarsIC Regressor", "llcv": "LassoLarsCV Regressor", + "ransac": "RANSACRegressor", + "ompcv": "OrthogonalMatchingPursuitCV", + "gpr": "GaussianProcessRegressor", + "omp": "OrthogonalMatchingPursuit", + "llars": "LassoLars", + "iso": "IsotonicRegression", + "fm": "Factorisation Machine Regressors", + "rnr": "Radius Neighbors Regressor Regressors", + "qr": "Quantile Regression Regressors", + "theil": "TheilSenRegressor Regressors", "all": "All Regressors", } diff --git a/anai/utils/custom_models/wrapped_classifiers.py b/anai/utils/custom_models/wrapped_classifiers.py index 5d6ce60..6fbd758 100644 --- a/anai/utils/custom_models/wrapped_classifiers.py +++ b/anai/utils/custom_models/wrapped_classifiers.py @@ -1,28 +1,79 @@ from anai.utils.wrappers.classification_shell import ClassificationWrapper -from sklearn.linear_model import (PoissonRegressor, GammaRegressor, LassoLarsIC, - LassoLarsCV) +from sklearn.linear_model import (GammaRegressor, LassoLarsCV, LassoLarsIC, + OrthogonalMatchingPursuit, + OrthogonalMatchingPursuitCV, + PoissonRegressor, QuantileRegressor, + RANSACRegressor, TheilSenRegressor, + TweedieRegressor) class PoissonClassifier(ClassificationWrapper): - def __init__(self,num_classes=2, **params): + def __init__(self, num_classes=2, **params): self.model = PoissonRegressor(**params) self.num_classes = num_classes - 1 class GammaClassifier(ClassificationWrapper): - def __init__(self,num_classes=2, **params): + def __init__(self, num_classes=2, **params): self.model = GammaRegressor(**params) self.num_classes = num_classes - 1 class LassoLarsICClassifier(ClassificationWrapper): - def __init__(self,num_classes=2, **params): + def __init__(self, num_classes=2, **params): self.model = LassoLarsIC(**params) self.num_classes = num_classes - 1 class LassoLarsCVClassifier(ClassificationWrapper): - def __init__(self,num_classes=2, **params): + def __init__(self, num_classes=2, **params): self.model = LassoLarsCV(**params) self.num_classes = num_classes - 1 + +class TweedieClassifier(ClassificationWrapper): + def __init__(self, num_classes=2, **params): + self.model = TweedieRegressor(**params) + self.num_classes = num_classes - 1 + + +# class GeneralizedLinearClassifier(ClassificationWrapper): +# def __init__(self,num_classes=2, **params): +# self.model = GeneralizedLinearRegressor(**params) +# self.num_classes = num_classes - 1 + + +class RANSACClassifier(ClassificationWrapper): + def __init__(self, num_classes=2, **params): + self.model = RANSACRegressor(**params) + self.num_classes = num_classes - 1 + + +class OrthogonalMatchingPursuitCVClassifier(ClassificationWrapper): + def __init__(self, num_classes=2, **params): + self.model = OrthogonalMatchingPursuitCV(**params) + self.num_classes = num_classes - 1 + + +class OrthogonalMatchingPursuitClassifier(ClassificationWrapper): + def __init__(self, num_classes=2, **params): + self.model = OrthogonalMatchingPursuit(**params) + self.num_classes = num_classes - 1 + + +# class AFMClassifier(ClassificationWrapper): +# def __init__(self,num_classes=2, **params): +# self.model = ComponentwiseGradientBoostingSurvivalAnalysis(**params) +# self.num_classes = num_classes - 1 + + +class QuantileClassifier(ClassificationWrapper): + def __init__(self, num_classes=2, **params): + self.model = QuantileRegressor(**params) + self.num_classes = num_classes - 1 + + +class TheilSenClassifier(ClassificationWrapper): + def __init__(self, num_classes=2, **params): + self.model = TheilSenRegressor(**params) + self.num_classes = num_classes - 1 diff --git a/anai/utils/predictors.py b/anai/utils/predictors.py index 46b14dc..bade64e 100644 --- a/anai/utils/predictors.py +++ b/anai/utils/predictors.py @@ -8,25 +8,36 @@ from catboost import CatBoostClassifier, CatBoostRegressor from colorama import Fore from lightgbm import LGBMClassifier, LGBMRegressor +from sklearn.calibration import CalibratedClassifierCV from sklearn.ensemble import (AdaBoostClassifier, AdaBoostRegressor, BaggingClassifier, BaggingRegressor, ExtraTreesClassifier, ExtraTreesRegressor, GradientBoostingClassifier, GradientBoostingRegressor, RandomForestClassifier, RandomForestRegressor) +from sklearn.gaussian_process import GaussianProcessRegressor +from sklearn.isotonic import IsotonicRegression from sklearn.kernel_ridge import KernelRidge from sklearn.linear_model import (BayesianRidge, ElasticNet, ElasticNetCV, - GammaRegressor, HuberRegressor, LassoCV, - LassoLarsCV, LassoLarsIC, LinearRegression, + GammaRegressor, HuberRegressor, Lars, LarsCV, + Lasso, LassoCV, LassoLars, LassoLarsCV, + LassoLarsIC, LinearRegression, LogisticRegression, LogisticRegressionCV, + OrthogonalMatchingPursuit, + OrthogonalMatchingPursuitCV, PassiveAggressiveClassifier, Perceptron, - PoissonRegressor, Ridge, RidgeClassifier, - SGDClassifier, SGDRegressor) + PoissonRegressor, QuantileRegressor, + RANSACRegressor, Ridge, RidgeClassifier, + SGDClassifier, SGDRegressor, + TheilSenRegressor) from sklearn.naive_bayes import GaussianNB -from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor +from sklearn.neighbors import (KNeighborsClassifier, KNeighborsRegressor, + RadiusNeighborsClassifier, + RadiusNeighborsRegressor) from sklearn.neural_network import MLPClassifier, MLPRegressor from sklearn.svm import SVC, SVR from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor +from tensorfm.sklearn import FactorizationMachineRegressor from xgboost import XGBClassifier, XGBRegressor @@ -246,6 +257,60 @@ def classification_predictor( classifier = LassoLarsCVClassifier(**params) objective_to_be_tuned = objective.llcv_classifier_objective params.pop("normalize") + elif predictor == "tweedie": + if mode == 'single': + print(Fore.YELLOW + + "Training Tweedie Classifier on Training Set [*]\n") + classifier = TweedieClassifier(**params) + objective_to_be_tuned = None + elif predictor == "ransac": + if mode == 'single': + print(Fore.YELLOW + + "Training RANSAC Classifier on Training Set [*]\n") + classifier = RANSACClassifier(**params) + objective_to_be_tuned = None + elif predictor == "ompcv": + if mode == 'single': + print(Fore.YELLOW + + "Training OrthogonalMatchingPursuitCV Classifier on Training Set [*]\n") + params['normalize'] = False + classifier = OrthogonalMatchingPursuitCVClassifier(**params) + objective_to_be_tuned = None + params.pop("normalize") + elif predictor == "omp": + if mode == 'single': + print(Fore.YELLOW + + "Training OrthogonalMatchingPursuit Classifier on Training Set [*]\n") + params['normalize'] = False + classifier = OrthogonalMatchingPursuitClassifier(**params) + objective_to_be_tuned = None + params.pop("normalize") + elif predictor == "iso": + if mode == 'single': + print(Fore.YELLOW + + "Training Isotonic Classifier on Training Set [*]\n") + params['method'] = 'isotonic' + classifier = CalibratedClassifierCV(**params) + objective_to_be_tuned = None + params.pop("method") + elif predictor == "rad": + if mode == 'single': + print(Fore.YELLOW + + "Training Radius Neighbors Classifier on Training Set [*]\n") + classifier = RadiusNeighborsClassifier(**params) + objective_to_be_tuned = None + elif predictor == "quantile": + if mode == 'single': + print(Fore.YELLOW + + "Training Quantile Classifier on Training Set [*]\n") + classifier = QuantileClassifier(**params) + objective_to_be_tuned = None + elif predictor == "theil": + if mode == 'single': + print(Fore.YELLOW + + "Training TheilSen Classifier on Training Set [*]\n") + classifier = TheilSenClassifier(**params) + objective_to_be_tuned = None return (classifier, objective_to_be_tuned) except Exception as error: print(traceback.format_exc()) @@ -482,6 +547,89 @@ def regression_predictor( objective_to_be_tuned = objective.llcv_regressor_objective params.pop("verbose") params.pop("n_jobs") + elif predictor == "ransac": + if mode == "single": + print(Fore.YELLOW + + "Training RANSAC Regressor on Training Set [*]\n") + regressor = RANSACRegressor(**params) + objective_to_be_tuned = objective.ransac_regressor_objective + elif predictor == "ompcv": + if mode == "single": + print(Fore.YELLOW + + "Training OrthogonalMatchingPursuitCV on Training Set [*]\n") + params["verbose"] = verbose + params["n_jobs"] = -1 + params['normalize'] = False + regressor = OrthogonalMatchingPursuitCV(**params) + objective_to_be_tuned = objective.ompcv_regressor_objective + params.pop("verbose") + params.pop("n_jobs") + params.pop("normalize") + elif predictor == "gpr": + if mode == "single": + print(Fore.YELLOW + + "Training Gaussian Process Regressor on Training Set [*]\n") + regressor = GaussianProcessRegressor(**params) + objective_to_be_tuned = objective.gpr_regressor_objective + elif predictor == "omp": + if mode == "single": + print(Fore.YELLOW + + "Training OrthogonalMatchingPursuit on Training Set [*]\n") + params['normalize'] = False + regressor = OrthogonalMatchingPursuit(**params) + objective_to_be_tuned = objective.omp_regressor_objective + params.pop("normalize") + elif predictor == "llars": + if mode == "single": + print(Fore.YELLOW + + "Training LassoLars on Training Set [*]\n") + params["verbose"] = verbose + params['normalize'] = False + regressor = LassoLars(**params) + objective_to_be_tuned = objective.llars_regressor_objective + params.pop("verbose") + params.pop("normalize") + elif predictor == "iso": + if mode == "single": + print(Fore.YELLOW + + "Training Isotonic regression on Training Set [*]\n") + regressor = IsotonicRegression(**params) + objective_to_be_tuned = None + elif predictor == "fm": + if mode == "single": + print(Fore.YELLOW + + "Training Factorization Machine regression on Training Set [*]\n") + params["random_state"] = random_state + regressor = FactorizationMachineRegressor(**params) + objective_to_be_tuned = None + params.pop("random_state") + elif predictor == "rnr": + if mode == "single": + print(Fore.YELLOW + + "Training Radius Neighbors Regressor on Training Set [*]\n") + params["n_jobs"] = -1 + regressor = RadiusNeighborsRegressor(**params) + objective_to_be_tuned = None + params.pop("n_jobs") + elif predictor == "qr": + if mode == "single": + print(Fore.YELLOW + + "Training Quantile Regressor on Training Set [*]\n") + regressor = QuantileRegressor(**params) + objective_to_be_tuned = None + elif predictor == "theil": + if mode == "single": + print(Fore.YELLOW + + "Training Theil-Sen Regressor on Training Set [*]\n") + params["verbose"] = verbose + params["n_jobs"] = -1 + params["random_state"] = random_state + regressor = TheilSenRegressor(**params) + objective_to_be_tuned = None + params.pop("verbose") + params.pop("n_jobs") + params.pop("random_state") + return (regressor, objective_to_be_tuned) except Exception as error: print(traceback.format_exc()) diff --git a/docs/Features.md b/docs/Features.md index b46780e..316337d 100644 --- a/docs/Features.md +++ b/docs/Features.md @@ -268,6 +268,16 @@ As you can see, SHAP explainer failed to explain the model. So it switched to Su - "lcv": "LassoCV Regressor" - "llic": "LassoLarsIC Regressor" - "llcv": "LassoLarsCV Regressor" + - "ransac": "RANSACRegressor", + - "ompcv": "OrthogonalMatchingPursuitCV", + - "gpr": "GaussianProcessRegressor", + - "omp": "OrthogonalMatchingPursuit", + - "llars": "LassoLars", + - "iso": "IsotonicRegression", + - "fm": "Factorisation Machine Regressors", + - "rnr": "Radius Neighbors Regressor Regressors", + - "qr": "Quantile Regression Regressors", + - "theil": "TheilSenRegressor Regressors", - "all": "All Regressors" ### Classification @@ -299,6 +309,16 @@ As you can see, SHAP explainer failed to explain the model. So it switched to Su - "lcv": "LassoCV Classifier" - "llic": "LassoLarsIC Classifier" - "llcv": "LassoLarsCV Classifier" + - "ransac": "RANSACClassifiers", + - "ompcv": "OrthogonalMatchingPursuitCV Classifier", + - "omp": "OrthogonalMatchingPursuit Classifier", + - "iso": "IsotonicRegression Classifier", + - "rad": "RadiusNeighbors Classifier", + - "quantile": "QuantileRegression Classifier", + - "theil": "TheilSenRegressor Classifier", + - "lars": "Lars Classifeir", + - "lcv": "LarsCV Classifier", + - "tweedie": "TweedieClassifiers", - "all": "All Classifiers" ### Model Explanation diff --git a/setup.py b/setup.py index 96308b8..f39355e 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ ], include=["anai.*", "anai"], ), - version="0.1.3", + version="0.1.4", license="Apache License 2.0", description="Automated ML", url="https://github.com/Revca-ANAI/ANAI",