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
c1ef0d45
Commit
c1ef0d45
authored
11 months ago
by
BARTHES Nicolas
Browse files
Options
Downloads
Patches
Plain Diff
supervised UMAP working with metadata
parent
8ad6a010
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Class_Mod/UMAP_.py
+6
-5
6 additions, 5 deletions
Class_Mod/UMAP_.py
pages/1-samples_selection.py
+8
-2
8 additions, 2 deletions
pages/1-samples_selection.py
with
14 additions
and
7 deletions
Class_Mod/UMAP_.py
+
6
−
5
View file @
c1ef0d45
# UMAP function for the Sample Selection module
# UMAP function for the Sample Selection module
from
Packages
import
*
from
Packages
import
*
from
Class_Mod.DATA_HANDLING
import
*
from
Class_Mod.DATA_HANDLING
import
*
class
Umap
:
class
Umap
:
...
@@ -10,13 +10,14 @@ class Umap:
...
@@ -10,13 +10,14 @@ class Umap:
def
__init__
(
self
,
data_import
,
numerical_data
,
cat_data
):
def
__init__
(
self
,
data_import
,
numerical_data
,
cat_data
):
self
.
x
=
data_import
self
.
x
=
data_import
self
.
numerical_data
=
numerical_data
self
.
numerical_data
=
numerical_data
if
len
(
cat_data
)
>
0
:
if
cat_data
is
None
:
self
.
categorical_data_encoded
=
cat_data
elif
len
(
cat_data
)
>
0
:
self
.
categorical_data
=
cat_data
self
.
categorical_data
=
cat_data
self
.
le
=
LabelEncoder
()
self
.
le
=
LabelEncoder
()
self
.
categorical_data_encoded
=
self
.
le
.
fit_transform
(
self
.
categorical_data
)
self
.
categorical_data_encoded
=
self
.
le
.
fit_transform
(
self
.
categorical_data
)
else
:
else
:
self
.
categorical_data
=
Fals
e
self
.
categorical_data
_encoded
=
Non
e
self
.
model
=
UMAP
(
n_neighbors
=
20
,
n_components
=
3
,
min_dist
=
0.0
,
random_state
=
42
,)
self
.
model
=
UMAP
(
n_neighbors
=
20
,
n_components
=
3
,
min_dist
=
0.0
,
random_state
=
42
,)
self
.
model
.
fit
(
self
.
numerical_data
,
y
=
self
.
categorical_data_encoded
)
self
.
model
.
fit
(
self
.
numerical_data
,
y
=
self
.
categorical_data_encoded
)
...
...
This diff is collapsed.
Click to expand it.
pages/1-samples_selection.py
+
8
−
2
View file @
c1ef0d45
...
@@ -88,7 +88,13 @@ if not spectra.empty:
...
@@ -88,7 +88,13 @@ if not spectra.empty:
if
dim_red_method
==
dim_red_methods
[
1
]:
if
dim_red_method
==
dim_red_methods
[
1
]:
dr_model
=
LinearPCA
(
xc
,
Ncomp
=
5
)
dr_model
=
LinearPCA
(
xc
,
Ncomp
=
5
)
elif
dim_red_method
==
dim_red_methods
[
2
]:
elif
dim_red_method
==
dim_red_methods
[
2
]:
dr_model
=
Umap
(
data_import
=
imp
,
numerical_data
=
MinMaxScale
(
spectra
),
cat_data
=
meta_data
)
if
not
meta_data
.
empty
:
filter
=
meta_data
.
columns
[
1
:]
col
=
pc
.
selectbox
(
'
Supervised UMAP by:
'
,
options
=
filter
,
key
=
108
)
supervised
=
meta_data
[
col
]
else
:
supervised
=
None
dr_model
=
Umap
(
data_import
=
imp
,
numerical_data
=
MinMaxScale
(
spectra
),
cat_data
=
supervised
)
if
dr_model
:
if
dr_model
:
axis1
=
pc
.
selectbox
(
"
x-axis
"
,
options
=
dr_model
.
scores_
.
columns
,
index
=
0
)
axis1
=
pc
.
selectbox
(
"
x-axis
"
,
options
=
dr_model
.
scores_
.
columns
,
index
=
0
)
...
@@ -109,7 +115,7 @@ if not t.empty:
...
@@ -109,7 +115,7 @@ if not t.empty:
data
,
labels
=
cl_model
.
fit_optimal
(
nclusters
=
ncluster
)
data
,
labels
=
cl_model
.
fit_optimal
(
nclusters
=
ncluster
)
elif
clus_method
==
cluster_methods
[
2
]:
elif
clus_method
==
cluster_methods
[
2
]:
optimized_hdbscan
=
Hdbscan
(
model
.
scores_raw_
)
optimized_hdbscan
=
Hdbscan
(
dr_
model
.
scores_raw_
)
labels
,
hdbscan_score
=
optimized_hdbscan
.
HDBSCAN_scores_
labels
,
hdbscan_score
=
optimized_hdbscan
.
HDBSCAN_scores_
##### Plots
##### Plots
...
...
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