def __remodel__(self, model_type, regr, __X_train, __Y_train):
"""
Function to retrain certain models based on optimal alphas and/or ratios
"""
if model_type == "ridge":
alpha = regr.alpha_
regr = linear_model.RidgeCV(alphas = self.__realpha__(alpha), cv = 10)
elif model_type == "lasso":
alpha = regr.alpha_
regr = linear_model.LassoCV(alphas = self.__realpha__(alpha), max_iter = 5000, cv = 10)
elif model_type == "elasticnet":
alpha = regr.alpha_
ratio = regr.l1_ratio_
regr = linear_model.ElasticNetCV(l1_ratio = self.__reratio__(ratio), alphas = self.__elasticnet_init["alpha"], max_iter = 1000, cv = 3)
regr.fit(__X_train, __Y_train)
return regr
评论列表
文章目录