Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NIRS_Workflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CEFE
PACE
NIRS_Workflow
Commits
e7d02da1
Commit
e7d02da1
authored
1 year ago
by
BARTHES Nicolas
Browse files
Options
Downloads
Patches
Plain Diff
Delete pinard_test.py
parent
88d79c83
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pinard_test.py
+0
-101
0 additions, 101 deletions
pinard_test.py
with
0 additions
and
101 deletions
pinard_test.py
deleted
100644 → 0
+
0
−
101
View file @
88d79c83
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
(
"
R²
"
,
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
(
"
R²
"
,
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
(
"
R²
"
,
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
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment