mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-27 18:57:55 +00:00
Feature: Added sweep functionality (#65)
* feat: Parametricized model selection works now. * feat: Fixed errors. Sweep generates and you can run it, but it gives an error for model.only_columns attribute. * feat: Factored the wandb management, default config managment and the model_dictionary out of the run_pipeline to a seperate file. * fix: Took out prints and fixed the mismatch of ensemble models when classifing. * fix(Models): added StaticMomentum model to the dictionary, hopefully fixed sklearn-ex RandomForestRegressor problem * fix(Dependencies): pin scikit-learn-ex's version, moved map_model_name_to_function to `models` * feat(Sweep): added `run_sweep.py` shortcut * feat(Pipeline): skip training a meta model if array is empty Co-authored-by: Mark Aron Szulyovszky <mark.szulyovszky@gmail.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
from sklearn.linear_model import LinearRegression, Lasso, BayesianRidge, LogisticRegression, Ridge
|
||||
from sklearn.tree import DecisionTreeClassifier
|
||||
from sklearnex.neighbors import KNeighborsRegressor, KNeighborsClassifier
|
||||
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
|
||||
from sklearnex.svm import SVR
|
||||
from sklearn.naive_bayes import GaussianNB
|
||||
from sklearn.neural_network import MLPRegressor, MLPClassifier
|
||||
from sklearn.ensemble import AdaBoostRegressor, RandomForestRegressor, ExtraTreesRegressor, AdaBoostClassifier, GradientBoostingClassifier, ExtraTreesClassifier
|
||||
from sklearnex.ensemble import RandomForestClassifier
|
||||
from models.base import SKLearnModel
|
||||
from models.momentum import StaticMomentumModel
|
||||
from models.average import StaticAverageModel
|
||||
from models.naive import StaticNaiveModel
|
||||
|
||||
|
||||
model_map = {
|
||||
"regression_models": dict(
|
||||
Lasso = SKLearnModel(Lasso(alpha=0.1, max_iter=1000)),
|
||||
Ridge = SKLearnModel(Ridge(alpha=0.1)),
|
||||
BayesianRidge = SKLearnModel(BayesianRidge()),
|
||||
KNN = SKLearnModel(KNeighborsRegressor(n_neighbors=25)),
|
||||
AB = SKLearnModel(AdaBoostRegressor(random_state=1)),
|
||||
LR = SKLearnModel(LinearRegression(n_jobs=-1)),
|
||||
MLP = SKLearnModel(MLPRegressor(hidden_layer_sizes=(100,20), max_iter=1000)),
|
||||
RF = SKLearnModel(RandomForestRegressor(n_jobs=-1)),
|
||||
SVR = SKLearnModel(SVR(kernel='rbf', C=1e3, gamma=0.1)),
|
||||
StaticNaive = StaticNaiveModel(),
|
||||
),
|
||||
"classification_models": dict(
|
||||
LR= SKLearnModel(LogisticRegression(n_jobs=-1)),
|
||||
LDA= SKLearnModel(LinearDiscriminantAnalysis()),
|
||||
KNN= SKLearnModel(KNeighborsClassifier()),
|
||||
CART= SKLearnModel(DecisionTreeClassifier()),
|
||||
NB= SKLearnModel(GaussianNB()),
|
||||
AB= SKLearnModel(AdaBoostClassifier()),
|
||||
RF= SKLearnModel(RandomForestClassifier(n_jobs=-1)),
|
||||
StaticMom= StaticMomentumModel(allow_short=True),
|
||||
),
|
||||
"classification_ensemble_models": dict(
|
||||
Ensemble_CART = SKLearnModel(DecisionTreeClassifier()),
|
||||
Ensemble_Average = StaticAverageModel(),
|
||||
),
|
||||
"regression_ensemble_models": dict(
|
||||
Ensemble_Ridge = SKLearnModel(Ridge(alpha=0.1)),
|
||||
Ensemble_Average = StaticAverageModel(),
|
||||
)
|
||||
}
|
||||
|
||||
model_names_classification = model_map["classification_models"].keys()
|
||||
model_names_regression = model_map["regression_models"].keys()
|
||||
|
||||
|
||||
def map_model_name_to_function(model_config:dict, method:str) -> dict:
|
||||
for level in ['level_1_models', 'level_2_models']:
|
||||
model_category = method + '_models' if level=='level_1_models' else method + '_ensemble_models'
|
||||
model_config[level] = [(model_name, model_map[model_category][model_name]) for model_name in model_config[level]]
|
||||
|
||||
return model_config
|
||||
Reference in New Issue
Block a user