@@ -140,4 +140,32 @@ def create_multiclass_prediction_df(model, class_names: List[str], X_test: Union
140140 if only_wrong :
141141 model_predictions_df = model_predictions_df [model_predictions_df ['Top Prediction' ] != model_predictions_df ['Label' ]]
142142 # return the dataframe
143- return model_predictions_df
143+ return model_predictions_df
144+
145+ def quickregression (name ):
146+ from sklearn .metrics import mean_absolute_error , mean_squared_error , mean_absolute_percentage_error
147+ """
148+ Function to save time when doing Machine Learning models.
149+ It only asks the name of the model to train and returns the scoring.
150+
151+ Parameters
152+ ----------
153+ name = Name of the ML model.
154+ Input Example = LinearRegression
155+
156+ Returns
157+ ----------
158+ MAE, MAPE, MSE, RMSE and R2 Scores.
159+ """
160+
161+ # Fit of the model in the previously split X_train, y_train
162+ model = name ()
163+ model .fit (X_train , y_train )
164+ # Predict of the model with X_test
165+ modpred = model .predict (X_test )
166+ # Scores of the model with y_test and the predict values.
167+ print ("MAE test:" , mean_absolute_error (y_test , modpred ))
168+ print ("MAPE test:" , mean_absolute_percentage_error (y_test , modpred ))
169+ print ("MSE test:" , mean_squared_error (y_test , modpred ))
170+ print ("RMSE test:" , np .sqrt (mean_squared_error (y_test , modpred )))
171+ return (model .score (X_train , y_train ))
0 commit comments