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
28813755
Commit
28813755
authored
3 months ago
by
DIANE
Browse files
Options
Downloads
Patches
Plain Diff
model creation
parent
c35aebcb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pages/2-model_creation.py
+6
-6
6 additions, 6 deletions
src/pages/2-model_creation.py
with
6 additions
and
6 deletions
src/pages/2-model_creation.py
+
6
−
6
View file @
28813755
...
@@ -257,6 +257,9 @@ if not x_block.empty and not y.empty:
...
@@ -257,6 +257,9 @@ if not x_block.empty and not y.empty:
from
utils.miscellaneous
import
data_split
from
utils.miscellaneous
import
data_split
X_train
,
X_test
,
y_train
,
y_test
,
train_index
,
test_index
=
data_split
(
X_train
,
X_test
,
y_train
,
y_test
,
train_index
,
test_index
=
data_split
(
x
=
x_block
,
y
=
y
)
x
=
x_block
,
y
=
y
)
import
functools
train_pos
=
functools
.
reduce
(
lambda
acc
,
x
:
acc
+
[
list
(
x_block
.
index
).
index
(
x
)],
list
(
train_index
),
[])
test_pos
=
functools
.
reduce
(
lambda
acc
,
x
:
acc
+
[
list
(
x_block
.
index
).
index
(
x
)],
list
(
test_index
),
[])
with
c3
:
with
c3
:
st
.
write
(
'
Loaded data summary
'
)
st
.
write
(
'
Loaded data summary
'
)
...
@@ -471,9 +474,6 @@ if not x_block.empty and not y.empty:
...
@@ -471,9 +474,6 @@ if not x_block.empty and not y.empty:
Model
=
None
Model
=
None
st
.
info
(
st
.
info
(
'
Info: Choose a modelling algorithm from the dropdown list!
'
)
'
Info: Choose a modelling algorithm from the dropdown list!
'
)
import
pickle
with
open
(
'
star.pkl
'
,
"
wb
"
)
as
f
:
pickle
.
dump
(
Model
,
f
)
return
Model
return
Model
c7
,
c8
=
st
.
columns
([
2
,
2
])
c7
,
c8
=
st
.
columns
([
2
,
2
])
...
@@ -739,12 +739,12 @@ if model:
...
@@ -739,12 +739,12 @@ if model:
imp_fig
.
savefig
(
res_path
/
"
figures/vipscores.png
"
)
imp_fig
.
savefig
(
res_path
/
"
figures/vipscores.png
"
)
# pickle the results
# pickle the results
pklfile
=
{
'
data
'
:
{
'
raw-spectra
'
:
x_block
,
'
target
'
:
y
,
'
training_data_idx
'
:
train_
index
,
'
testing_data_idx
'
:
test_
index
},
pklfile
=
{
'
data
'
:
{
'
raw-spectra
'
:
x_block
,
'
target
'
:
y
,
'
training_data_idx
'
:
train_
pos
,
'
testing_data_idx
'
:
test_
pos
},
'
spec-preprocessing
'
:
{
"
normalization
"
:
modelling
.
best_hyperparams_
[
'
normalization
'
],
'
SavGol(polyorder,window_length,deriv)
'
:
[
modelling
.
best_hyperparams_
[
"
polyorder
"
],
'
spec-preprocessing
'
:
{
"
normalization
"
:
modelling
.
best_hyperparams_
[
'
normalization
'
],
'
SavGol(polyorder,window_length,deriv)
'
:
[
modelling
.
best_hyperparams_
[
"
polyorder
"
],
modelling
.
best_hyperparams_
[
modelling
.
best_hyperparams_
[
'
window_length
'
],
'
window_length
'
],
modelling
.
best_hyperparams_
[
'
deriv
'
]]},
modelling
.
best_hyperparams_
[
'
deriv
'
]]},
"
model_type
"
:
model_type
,
'
model_
'
:
modelling
.
model_
,
'
predictors_
'
:
predictors
if
model_type
==
'
TPE-iPLS
'
else
list
(
x_block
.
columns
)
}
"
model_type
"
:
model_type
,
'
model_
'
:
modelling
.
model_
,
'
predictors_
'
:
list
(
x_block
.
columns
),
'
selected-wls
'
:
predictors
if
model_type
==
'
TPE-iPLS
'
else
None
}
with
open
(
res_path
/
'
file_system.pkl
'
,
"
wb
"
)
as
pkl
:
with
open
(
res_path
/
'
file_system.pkl
'
,
"
wb
"
)
as
pkl
:
dump
(
pklfile
,
pkl
)
dump
(
pklfile
,
pkl
)
...
@@ -776,7 +776,7 @@ if model:
...
@@ -776,7 +776,7 @@ if model:
# def preparing_results_for_downloading(change):
# def preparing_results_for_downloading(change):
# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
pklfile
=
{
'
model_
'
:
modelling
.
model_
,
"
model_type
"
:
model_type
,
'
data
'
:
{
'
raw-spectra
'
:
x_block
,
'
target
'
:
y
,
'
training_data_idx
'
:
train_
index
,
'
testing_data_idx
'
:
test_
index
},
pklfile
=
{
'
model_
'
:
modelling
.
model_
,
"
model_type
"
:
model_type
,
'
data
'
:
{
'
raw-spectra
'
:
x_block
,
'
target
'
:
y
,
'
training_data_idx
'
:
train_
pos
,
'
testing_data_idx
'
:
test_
pos
},
'
spec-preprocessing
'
:
{
"
normalization
"
:
modelling
.
best_hyperparams_
[
'
normalization
'
],
'
SavGol(polyorder,window_length,deriv)
'
:
[
modelling
.
best_hyperparams_
[
"
polyorder
"
],
'
spec-preprocessing
'
:
{
"
normalization
"
:
modelling
.
best_hyperparams_
[
'
normalization
'
],
'
SavGol(polyorder,window_length,deriv)
'
:
[
modelling
.
best_hyperparams_
[
"
polyorder
"
],
modelling
.
best_hyperparams_
[
modelling
.
best_hyperparams_
[
'
window_length
'
],
'
window_length
'
],
...
...
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