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
084f7d2d
Commit
084f7d2d
authored
11 months ago
by
DIANE
Browse files
Options
Downloads
Patches
Plain Diff
Miscellaneous update
parent
4154ce32
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
Class_Mod/Miscellaneous.py
+21
-15
21 additions, 15 deletions
Class_Mod/Miscellaneous.py
with
21 additions
and
15 deletions
Class_Mod/Miscellaneous.py
+
21
−
15
View file @
084f7d2d
...
@@ -7,21 +7,6 @@ def local_css(file_name):
...
@@ -7,21 +7,6 @@ def local_css(file_name):
st
.
markdown
(
f
"
<style>
{
f
.
read
()
}
</style>
"
,
unsafe_allow_html
=
True
)
st
.
markdown
(
f
"
<style>
{
f
.
read
()
}
</style>
"
,
unsafe_allow_html
=
True
)
local_css
(
"
style/style.css
"
)
local_css
(
"
style/style.css
"
)
# Cross-Validation of the model
def
CV_model
(
estimator
,
x
,
y
,
cv
):
st
.
write
(
'
Cross-Validation of this model
'
)
st
.
write
(
"
CV_scores
"
,
cross_val_score
(
estimator
,
x
,
y
,
cv
=
cv
))
st
.
write
(
"
-- CV predict --
"
)
Y_preds
=
cross_val_predict
(
estimator
,
x
,
y
,
cv
=
3
)
st
.
write
(
"
MAE
"
,
mean_absolute_error
(
y
,
Y_preds
))
st
.
write
(
"
MSE
"
,
mean_squared_error
(
y
,
Y_preds
))
st
.
write
(
"
MAPE
"
,
mean_absolute_percentage_error
(
y
,
Y_preds
))
st
.
write
(
"
R²
"
,
r2_score
(
y
,
Y_preds
))
st
.
write
(
"
-- Cross Validate --
"
)
cv_results
=
cross_validate
(
estimator
,
x
,
y
,
cv
=
cv
,
return_train_score
=
True
,
n_jobs
=
3
)
for
key
in
cv_results
.
keys
():
st
.
write
(
key
,
cv_results
[
key
])
# predict module
# predict module
def
prediction
(
NIRS_csv
,
qsep
,
qhdr
,
model
):
def
prediction
(
NIRS_csv
,
qsep
,
qhdr
,
model
):
# hdr var correspond to column header True or False in the CSV
# hdr var correspond to column header True or False in the CSV
...
@@ -33,3 +18,24 @@ def prediction(NIRS_csv, qsep, qhdr, model):
...
@@ -33,3 +18,24 @@ def prediction(NIRS_csv, qsep, qhdr, model):
Y_preds
=
model
.
predict
(
X_test
)
Y_preds
=
model
.
predict
(
X_test
)
# Y_preds = X_test
# Y_preds = X_test
return
Y_preds
return
Y_preds
def
reg_plot
(
meas
,
pred
):
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
12
,
4
))
sns
.
regplot
(
x
=
meas
[
0
]
,
y
=
pred
[
0
],
color
=
'
blue
'
,
label
=
'
Calib
'
)
sns
.
regplot
(
x
=
meas
[
1
],
y
=
pred
[
1
],
color
=
'
red
'
,
label
=
'
CV
'
)
sns
.
regplot
(
x
=
meas
[
2
],
y
=
pred
[
2
],
color
=
'
green
'
,
label
=
'
Test
'
)
plt
.
plot
([
np
.
min
(
meas
[
0
])
+
0.1
,
np
.
max
([
meas
[
0
]])
+
0.1
],
[
np
.
min
(
meas
[
0
])
+
0.1
,
np
.
max
([
meas
[
0
]])
+
0.1
],
color
=
'
black
'
)
ax
.
set_ylabel
(
'
Predicted values
'
)
ax
.
set_xlabel
(
'
Measured values
'
)
plt
.
legend
()
plt
.
margins
(
0
)
def
resid_plot
(
meas
,
pred
):
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
12
,
4
))
sns
.
residplot
(
x
=
meas
[
0
],
y
=
pred
[
0
],
color
=
'
blue
'
,
label
=
'
Calib
'
)
sns
.
residplot
(
x
=
meas
[
1
],
y
=
pred
[
1
],
color
=
'
red
'
,
label
=
'
CV
'
)
sns
.
residplot
(
x
=
meas
[
2
],
y
=
pred
[
2
],
color
=
'
green
'
,
label
=
'
Test
'
)
ax
.
set_ylabel
(
'
Residuals
'
)
ax
.
set_xlabel
(
'
Predicted values
'
)
plt
.
legend
()
\ No newline at end of file
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