Skip to content
Snippets Groups Projects
Commit e7d02da1 authored by BARTHES Nicolas's avatar BARTHES Nicolas
Browse files

Delete pinard_test.py

parent 88d79c83
No related branches found
No related tags found
No related merge requests found
print(X_train.shape, y_train.shape, X_test.shape, y_test.shape)
# ## Learning
# In[111]:
# In[112]:
preprocessing
# In[113]:
# Declare complete pipeline
pipeline = Pipeline([
('scaler', MinMaxScaler()), # scaling the data
('preprocessing', FeatureUnion(preprocessing)), # preprocessing
# Pipeline([('sg1',pp.SavitzkyGolay()),('sg2',pp.SavitzkyGolay())]),
# ('sg1',pp.SavitzkyGolay()),('sg2',pp.SavitzkyGolay()),
# preprocessing - nested pipeline to perform the Savitzky-Golay method twice for 2nd order preprocessing
('PLS', PLSRegression()) # regressor
])
# In[114]:
pipeline
# In[115]:
# Estimator including y values scaling
estimator = TransformedTargetRegressor(regressor = pipeline, transformer = MinMaxScaler())
# In[116]:
estimator
# In[117]:
# Training
estimator.fit(X_train, y_train)
# In[110]:
estimator.score(X_test,y_test)
# In[ ]:
# Predictions
Y_preds = estimator.predict(X_test) # make predictions on test data and assign to Y_preds variable
print("", r2_score(y_test, Y_preds))
# ## Résultats de prédiction
# In[ ]:
print("MAE", mean_absolute_error(y_test, Y_preds))
print("MSE", mean_squared_error(y_test, Y_preds))
print("MAPE", mean_absolute_percentage_error(y_test, Y_preds))
print("", r2_score(y_test, Y_preds))
# print(estimator.get_params())
# ## Cross Validation
# In[ ]:
print("CV_scores", cross_val_score(estimator, x, y, cv=3))
print("-- CV predict --")
Y_preds = cross_val_predict(estimator, x, y, cv=3)
print("MAE", mean_absolute_error(y, Y_preds))
print("MSE", mean_squared_error(y, Y_preds))
print("MAPE", mean_absolute_percentage_error(y, Y_preds))
print("", r2_score(y, Y_preds))
print("-- Cross Validate --")
cv_results = cross_validate(estimator, x, y, cv=3, return_train_score=True, n_jobs=3)
for key in cv_results.keys():
print(key, cv_results[key])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment