Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MANOCCA
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
Container 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Statistical-Genetics
MANOCCA
Commits
db8236da
Commit
db8236da
authored
3 years ago
by
Christophe BOETTO
Browse files
Options
Downloads
Patches
Plain Diff
Added simulation and explainer
parent
67c8c71f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/manocca_package/manocca.py
+9
-6
9 additions, 6 deletions
src/manocca_package/manocca.py
src/manocca_package/tools/explainer.py
+11
-0
11 additions, 0 deletions
src/manocca_package/tools/explainer.py
src/manocca_package/tools/simulation.py
+52
-0
52 additions, 0 deletions
src/manocca_package/tools/simulation.py
with
72 additions
and
6 deletions
src/manocca_package/manocca.py
+
9
−
6
View file @
db8236da
...
@@ -46,7 +46,7 @@ class MANOCCA:
...
@@ -46,7 +46,7 @@ class MANOCCA:
self
.
prodV_red
=
prodV_red
self
.
prodV_red
=
prodV_red
else
:
# If not we preprocess the data and compute prodV and prodV_red
else
:
# If not we preprocess the data and compute prodV and prodV_red
self
.
prodV
=
self
.
get_prodV_para_wrap
(
self
.
output
,
n_jobs
=
self
.
n_jobs
)
self
.
prodV
=
self
.
get_prodV_para_wrap
(
scale
(
self
.
output
)
,
n_jobs
=
self
.
n_jobs
)
self
.
prodV
=
scale
(
self
.
prodV
)
self
.
prodV
=
scale
(
self
.
prodV
)
self
.
prodV_red
,
self
.
pca
=
self
.
get_prodV_red
(
self
.
prodV
,
self
.
n_comp
,
return_pca
=
True
)
# prodV_red is scaled within the get_prodV_red function
self
.
prodV_red
,
self
.
pca
=
self
.
get_prodV_red
(
self
.
prodV
,
self
.
n_comp
,
return_pca
=
True
)
# prodV_red is scaled within the get_prodV_red function
...
@@ -80,19 +80,22 @@ class MANOCCA:
...
@@ -80,19 +80,22 @@ class MANOCCA:
return
scale
(
tmp
)
return
scale
(
tmp
)
def
test
(
self
,
n_comp
=
None
):
def
test
(
self
,
var
=
None
,
n_comp
=
None
,
min_comp
=
0
):
if
n_comp
is
None
:
if
n_comp
is
None
:
n_comp
=
self
.
prodV_red
.
shape
[
1
]
n_comp
=
self
.
prodV_red
.
shape
[
1
]
n_preds
=
self
.
predictors
.
shape
[
1
]
if
var
is
None
:
var
=
self
.
predictors
n_preds
=
var
.
shape
[
1
]
p
=
np
.
empty
(
n_preds
)
p
=
np
.
empty
(
n_preds
)
for
i_pred
in
range
(
n_preds
):
for
i_pred
in
range
(
n_preds
):
nan_mask
=
np
.
isnan
(
self
.
predictors
[:,
i_pred
])
nan_mask
=
np
.
isnan
(
var
[:,
i_pred
])
if
self
.
covariates
is
not
None
:
if
self
.
covariates
is
not
None
:
print
(
"
With covariates
"
)
print
(
"
With covariates
"
)
p
[
i_pred
]
=
custom_manova
(
self
.
prodV_red
[
~
nan_mask
,:
n_comp
],
scale
(
self
.
predictors
[
~
nan_mask
,
i_pred
].
reshape
(
-
1
,
1
)),
scale
(
self
.
covariates
[
~
nan_mask
,:]))
p
[
i_pred
]
=
custom_manova
(
self
.
prodV_red
[
~
nan_mask
,
min_comp
:
n_comp
],
scale
(
var
[
~
nan_mask
,
i_pred
].
reshape
(
-
1
,
1
)),
scale
(
self
.
covariates
[
~
nan_mask
,:]))
else
:
else
:
print
(
"
Without covariates
"
)
print
(
"
Without covariates
"
)
p
[
i_pred
]
=
custom_manova
(
self
.
prodV_red
[
~
nan_mask
,:
n_comp
],
scale
(
self
.
predictors
[
~
nan_mask
,
i_pred
].
reshape
(
-
1
,
1
)))
p
[
i_pred
]
=
custom_manova
(
self
.
prodV_red
[
~
nan_mask
,
min_comp
:
n_comp
],
scale
(
var
[
~
nan_mask
,
i_pred
].
reshape
(
-
1
,
1
)))
self
.
p
=
p
self
.
p
=
p
...
...
This diff is collapsed.
Click to expand it.
src/manocca_package/tools/explainer.py
0 → 100644
+
11
−
0
View file @
db8236da
from
manocca
import
MANOCCA
from
manova
import
MANOVA
class
Explainer
:
def
__init__
(
self
,
model
):
self
.
model
=
model
def
pc_
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/manocca_package/tools/simulation.py
0 → 100644
+
52
−
0
View file @
db8236da
from
manocca
import
MANOCCA
from
manova
import
MANOVA
import
tools.preprocessing_tools
as
pt
class
Simu
:
def
__init__
(
self
,
methods
,
output
,
predictors
,
covariates
=
None
,
cols_output
=
None
,
cols_predictors
=
None
,
cols_covariates
=
None
,
L_preproc
=
[],
prodV_red
=
None
,
n_comp
=
None
,
n_jobs
=
1
):
self
.
methods
=
methods
### Initializing
self
.
output
=
output
self
.
cols_output
=
cols_output
self
.
output
,
self
.
cols_output
=
pt
.
_extract_cols
(
self
.
output
,
self
.
cols_output
)
self
.
predictors
=
predictors
self
.
cols_predictors
=
cols_predictors
self
.
predictors
,
self
.
cols_predictors
=
pt
.
_extract_cols
(
self
.
predictors
,
self
.
cols_predictors
)
self
.
covariates
=
covariates
self
.
cols_covariates
=
cols_covariates
if
covariates
is
not
None
:
self
.
covariates
,
self
.
cols_covariates
=
pt
.
_extract_cols
(
self
.
covariates
,
self
.
cols_covariates
)
self
.
prodV_red
=
prodV_red
self
.
n_comp
=
n_comp
self
.
n_jobs
=
n_jobs
if
len
(
L_preproc
)
>
0
:
self
.
output
=
pt
.
pipeline
(
self
.
output
,
L_pipe
=
L_preproc
)
self
.
L_models
=
[]
self
.
_get_model
()
### To fill later ###
self
.
p
=
np
.
empty
((
self
.
predictors
.
shape
[
0
],
0
))
def
_get_model
(
self
):
for
m
in
self
.
methods
:
if
m
==
'
MANOCCA
'
:
self
.
L_models
+=
[
MANOCCA
(
self
.
output
,
self
.
predictors
,
self
.
covariates
,
self
.
cols_output
,
self
.
cols_predictors
,
self
.
cols_covariates
,
self
.
prodV_red
,
self
.
n_comp
,
self
.
n_jobs
)]
elif
m
==
'
MANOVA
'
:
self
.
L_models
+=
[
MANOVA
(
self
.
output
,
self
.
predictors
,
self
.
covariates
,
self
.
cols_output
,
self
.
cols_predictors
,
self
.
cols_covariates
)]
def
run_simu
(
self
,
n_comp
):
for
m
in
self
.
L_models
:
m
.
test
()
self
.
p
=
np
.
hstack
([
self
.
p
,
m
.
p
])
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