mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-27 18:57:55 +00:00
1cd0119589
* fix(FeatureExtractor): apply log to transform some series to normality * feat(DataLoader): add ability of not returning returns when they're not needed (exogenous data), applied log to certain features * feat(FeatureExtractors): added standard scaling for exogenous data * feat(FeatureSelection): scale data with the passed in scaler before doing feature-selection * fix(Config): sweep config * feat(Models): output probability, store it * feat(Core): added caching to select_features() and load_data() * fix(Dependencies): added diskcache * fix(Training): error when creating results DF * feat(Models): added xgboost, fixed tests * refactor(Cache): moved hashing to a separate function, created wrapper functions to separate business logic and caching * fix(Tests): new syntax * fix(Model): XGboost can't handle -1 class, so we'll use the deprecated label_encoder fornow * fix(Model): XGBoost config * feat(Cache): add run_clear_cache script * fix(Pipeline) accidentally re-instatiating all_predictions for each asset
50 lines
2.6 KiB
Python
50 lines
2.6 KiB
Python
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
|
|
from xgboost import XGBClassifier
|
|
|
|
|
|
model_map = {
|
|
"regression_models": dict(
|
|
LR = SKLearnModel(LinearRegression(n_jobs=-1)),
|
|
Lasso = SKLearnModel(Lasso(alpha=100, random_state=1)),
|
|
Ridge = SKLearnModel(Ridge(alpha=0.1)),
|
|
BayesianRidge = SKLearnModel(BayesianRidge()),
|
|
KNN = SKLearnModel(KNeighborsRegressor(n_neighbors=25)),
|
|
AB = SKLearnModel(AdaBoostRegressor(random_state=1)),
|
|
MLP = SKLearnModel(MLPRegressor(hidden_layer_sizes=(100,20), max_iter=1000)),
|
|
RF = SKLearnModel(RandomForestRegressor(n_jobs=-1, max_depth=20, random_state=1)),
|
|
SVR = SKLearnModel(SVR(kernel='rbf', C=1e3, gamma=0.1)),
|
|
StaticNaive = StaticNaiveModel(),
|
|
),
|
|
"classification_models": dict(
|
|
LR= SKLearnModel(LogisticRegression(C=10, random_state=1, max_iter=1000, n_jobs=-1)),
|
|
LDA= SKLearnModel(LinearDiscriminantAnalysis()),
|
|
KNN= SKLearnModel(KNeighborsClassifier()),
|
|
CART= SKLearnModel(DecisionTreeClassifier(max_depth=15, random_state=1)),
|
|
NB= SKLearnModel(GaussianNB()),
|
|
AB= SKLearnModel(AdaBoostClassifier(n_estimators=15)),
|
|
RF= SKLearnModel(RandomForestClassifier(n_jobs=-1, max_depth=20, random_state=1)),
|
|
XGB= SKLearnModel(XGBClassifier(n_jobs=-1, max_depth = 20, random_state=1, use_label_encoder=True, objective='multi:softprob', eval_metric='mlogloss')),
|
|
StaticMom= StaticMomentumModel(allow_short=True),
|
|
Ensemble_Average = StaticAverageModel(),
|
|
),
|
|
}
|
|
|
|
model_names_classification = list(model_map["classification_models"].keys())
|
|
model_names_regression = list(model_map["regression_models"].keys())
|
|
|
|
default_feature_selector_regression = model_map['regression_models']['RF']
|
|
default_feature_selector_classification = model_map['classification_models']['RF']
|
|
|