File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 11import pandas as pd
2- import pickle
2+ import joblib
33from sklearn .model_selection import GridSearchCV , train_test_split
44from sklearn .datasets import load_diabetes
55from aplr import APLRRegressor
3535print ("Done training" )
3636
3737#Saving model
38- pickle .dump (best_model ,open ( "best_model.zip" , "wb" ) )
38+ joblib .dump (best_model ,"best_model.gz" )
3939
4040#Cross validation results when doing grid search
4141cv_results = pd .DataFrame (grid_search_cv .cv_results_ ).sort_values (by = "rank_test_score" )
4444validation_error_per_boosting_step = best_model .get_validation_error_steps ()
4545
4646#Terms in the best model
47- terms = pd .DataFrame ({"Predictor " :best_model .get_term_names (),"Coefficient " :best_model .get_term_coefficients ()})
47+ terms = pd .DataFrame ({"term " :best_model .get_term_names (),"coefficient " :best_model .get_term_coefficients ()})
4848
49- #Coefficients for intercept and the first predictor per boosting step
49+ #Coefficients for intercept and the first term per boosting step
5050intercept_coefficient_per_boosting_step = best_model .get_intercept_steps ()
51- first_predictor_coefficient_per_boosting_step = best_model .get_term_coefficient_steps (term_index = 0 )
51+ first_term_coefficient_per_boosting_step = best_model .get_term_coefficient_steps (term_index = 0 )
5252
5353#Estimated feature importance was estimated on the validation set when the best model was trained
5454estimated_feature_importance = pd .DataFrame ({"predictor" :predictors ,"importance" :best_model .get_feature_importance ()})
Original file line number Diff line number Diff line change 11import pandas as pd
22import numpy as np
3- import pickle
3+ import joblib
44from sklearn .model_selection import ParameterGrid , train_test_split
55from sklearn .datasets import load_diabetes
66from aplr import APLRRegressor
4545print ("Done training" )
4646
4747#Saving model
48- pickle .dump (best_model ,open ( "best_model.zip" , "wb" ) )
48+ joblib .dump (best_model ,"best_model.gz" )
4949
5050#Validation results when doing grid search
5151validation_results = validation_results .sort_values (by = "validation_error" )
5454validation_error_per_boosting_step = best_model .get_validation_error_steps ()
5555
5656#Terms in the best model
57- terms = pd .DataFrame ({"Predictor " :best_model .get_term_names (),"Coefficient " :best_model .get_term_coefficients ()})
57+ terms = pd .DataFrame ({"term " :best_model .get_term_names (),"coefficient " :best_model .get_term_coefficients ()})
5858
59- #Coefficients for intercept and the first predictor per boosting step
59+ #Coefficients for intercept and the first term per boosting step
6060intercept_coefficient_per_boosting_step = best_model .get_intercept_steps ()
61- first_predictor_coefficient_per_boosting_step = best_model .get_term_coefficient_steps (term_index = 0 )
61+ first_term_coefficient_per_boosting_step = best_model .get_term_coefficient_steps (term_index = 0 )
6262
6363#Estimated feature importance was estimated on the validation set when the best model was trained
6464estimated_feature_importance = pd .DataFrame ({"predictor" :predictors ,"importance" :best_model .get_feature_importance ()})
You can’t perform that action at this time.
0 commit comments