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
45a4a313
Commit
45a4a313
authored
3 months ago
by
DIANE
Browse files
Options
Downloads
Patches
Plain Diff
prediction with manual range selection
parent
53510d15
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/3-prediction.py
+10
-10
10 additions, 10 deletions
src/pages/3-prediction.py
with
10 additions
and
10 deletions
src/pages/3-prediction.py
+
10
−
10
View file @
45a4a313
...
@@ -137,8 +137,9 @@ with c1:
...
@@ -137,8 +137,9 @@ with c1:
x_block
.
columns
=
x_block
.
columns
.
astype
(
str
)
x_block
.
columns
=
x_block
.
columns
.
astype
(
str
)
yname
=
system_data
[
'
data
'
][
'
target
'
].
name
yname
=
system_data
[
'
data
'
][
'
target
'
].
name
st
.
info
(
"
Loaded model to predict
"
+
yname
)
st
.
info
(
"
Loaded model to predict
"
+
yname
)
if
ObjectHash
(
current
=
None
,
add
=
list
(
system_data
[
'
predictors_
'
]))
==
ObjectHash
(
current
=
None
,
add
=
list
(
x_block
.
columns
)):
shared_elements
=
set
(
system_data
[
'
predictors_
'
]).
intersection
(
x_block
.
columns
)
pred_data
=
x_block
if
len
(
shared_elements
)
==
len
(
system_data
[
'
predictors_
'
]):
pred_data
=
x_block
.
loc
[:,
system_data
[
'
predictors_
'
]]
else
:
else
:
st
.
error
(
st
.
error
(
'
The names of the features (columns) in the training set and the prediction set are not identical. Thus, prediction cannot be performed.
'
)
'
The names of the features (columns) in the training set and the prediction set are not identical. Thus, prediction cannot be performed.
'
)
...
@@ -237,13 +238,11 @@ if not preprocessed.empty:
...
@@ -237,13 +238,11 @@ if not preprocessed.empty:
st
.
session_state
[
'
predict
'
]
=
True
st
.
session_state
[
'
predict
'
]
=
True
if
not
preprocessed
.
empty
and
st
.
session_state
[
'
predict
'
]:
if
not
preprocessed
.
empty
and
st
.
session_state
[
'
predict
'
]:
c4
,
c5
=
st
.
columns
([
2
,
1
])
model
=
system_data
[
'
model_
'
]
with
c5
:
if
system_data
[
'
model_type
'
]
in
[
'
PLS
'
,
'
TPE-iPLS
'
]:
model
=
system_data
[
'
model_
'
]
nvar
=
system_data
[
'
model_
'
].
n_features_in_
if
system_data
[
'
model_type
'
]
in
[
'
PLS
'
,
'
TPE-iPLS
'
]:
elif
system_data
[
'
model_type
'
]
==
'
LW-PLS
'
:
nvar
=
system_data
[
'
model_
'
].
n_features_in_
nvar
=
system_data
[
'
data
'
][
'
raw-spectra
'
].
shape
[
1
]
elif
system_data
[
'
model_type
'
]
==
'
LW-PLS
'
:
nvar
=
system_data
[
'
data
'
][
'
raw-spectra
'
].
shape
[
1
]
if
system_data
[
'
selected-wls
'
]
is
None
:
if
system_data
[
'
selected-wls
'
]
is
None
:
preprocesseddf
=
preprocessed
preprocesseddf
=
preprocessed
...
@@ -317,11 +316,12 @@ if not preprocessed.empty:
...
@@ -317,11 +316,12 @@ if not preprocessed.empty:
################################### results display ###################################
################################### results display ###################################
if
not
result
.
empty
:
if
not
result
.
empty
:
c4
,
c5
=
st
.
columns
([
2
,
1
])
hist
=
pred_hist
(
pred
=
result
)
hist
=
pred_hist
(
pred
=
result
)
with
c4
:
with
c4
:
st
.
write
(
'
Predicted values distribution
'
)
st
.
write
(
'
Predicted values distribution
'
)
st
.
pyplot
(
hist
)
st
.
pyplot
(
hist
)
st
.
write
(
'
P
redicted values
table
'
)
st
.
write
(
'
Table of p
redicted values
'
)
resultT
=
result
.
reset_index
()
resultT
=
result
.
reset_index
()
st
.
dataframe
(
resultT
.
T
)
st
.
dataframe
(
resultT
.
T
)
with
c5
:
with
c5
:
...
...
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