Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MPBA
INF
Commits
0e47745e
Commit
0e47745e
authored
Mar 26, 2020
by
Marco Chierici
Browse files
General improvements
parent
3827b663
Changes
1
Show whitespace changes
Inline
Side-by-side
list_distances.py
View file @
0e47745e
...
@@ -3,12 +3,17 @@ import pandas as pd
...
@@ -3,12 +3,17 @@ import pandas as pd
import
numpy
as
np
import
numpy
as
np
from
mlpy
import
canberra_stability
from
mlpy
import
canberra_stability
from
itertools
import
combinations
from
itertools
import
combinations
from
pathlib
import
Path
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--resultsdir'
,
type
=
str
,
help
=
'Results folder'
)
parser
.
add_argument
(
'--resultsdir'
,
type
=
str
,
help
=
'Results folder'
)
parser
.
add_argument
(
'--dataset'
,
type
=
str
,
help
=
'Dataset name'
)
parser
.
add_argument
(
'--dataset'
,
type
=
str
,
help
=
'Dataset name'
)
parser
.
add_argument
(
'--model'
,
type
=
str
,
default
=
'randomForest'
,
help
=
'Model (default: %default)'
)
parser
.
add_argument
(
'--target'
,
type
=
str
,
help
=
'Clinical endpoint'
)
parser
.
add_argument
(
'--target'
,
type
=
str
,
help
=
'Clinical endpoint'
)
parser
.
add_argument
(
'--model'
,
type
=
str
,
default
=
'randomForest'
,
help
=
'Model (default: %(default)s)'
)
parser
.
add_argument
(
'--nf_min'
,
type
=
int
,
default
=
10
,
help
=
'Min #feat (default: %(default)s)'
)
parser
.
add_argument
(
'--nf_max'
,
type
=
int
,
default
=
50
,
help
=
'Max #feat (default: %(default)s)'
)
parser
.
add_argument
(
'--nf_step'
,
type
=
int
,
default
=
10
,
help
=
'Increase by these many feat (default: %(default)s)'
)
parser
.
add_argument
(
'--nf_rsnf'
,
type
=
int
,
nargs
=
'+'
,
help
=
'One or more #feat for rSNF'
)
parser
.
add_argument
(
'--layers'
,
type
=
str
,
nargs
=
'+'
,
help
=
''
)
parser
.
add_argument
(
'--layers'
,
type
=
str
,
nargs
=
'+'
,
help
=
''
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -16,10 +21,22 @@ RESULTSDIR = args.resultsdir # top-level results directory
...
@@ -16,10 +21,22 @@ RESULTSDIR = args.resultsdir # top-level results directory
DATASET
=
args
.
dataset
# 'tcga_breast'
DATASET
=
args
.
dataset
# 'tcga_breast'
TARGET
=
args
.
target
# 'ER'
TARGET
=
args
.
target
# 'ER'
MODEL
=
args
.
model
MODEL
=
args
.
model
NF_MIN
=
args
.
nf_min
NF_MAX
=
args
.
nf_max
NF_STEP
=
args
.
nf_step
NF_RSNF
=
args
.
nf_rsnf
LAYERS
=
args
.
layers
LAYERS
=
args
.
layers
N_LAYERS
=
len
(
LAYERS
)
N_LAYERS
=
len
(
LAYERS
)
MODE
=
'rSNF'
MODE
=
'rSNF'
assert
(
Path
(
RESULTSDIR
,
DATASET
).
expanduser
().
exists
()
),
f
"
{
RESULTSDIR
}
/
{
DATASET
}
not found"
assert
(
Path
(
RESULTSDIR
,
f
"
{
DATASET
}
_SNFdap"
).
expanduser
().
exists
()
),
f
"
{
RESULTSDIR
}
/
{
DATASET
}
_SNFdap not found"
for
k
in
range
(
2
,
N_LAYERS
+
1
):
for
k
in
range
(
2
,
N_LAYERS
+
1
):
for
comb
in
combinations
(
LAYERS
,
k
):
for
comb
in
combinations
(
LAYERS
,
k
):
layers_concat
=
'_'
.
join
(
comb
)
layers_concat
=
'_'
.
join
(
comb
)
...
@@ -30,7 +47,13 @@ for k in range(2, N_LAYERS+1):
...
@@ -30,7 +47,13 @@ for k in range(2, N_LAYERS+1):
# prepare ranks for canberra_stability
# prepare ranks for canberra_stability
ranks
=
pd
.
concat
([
np
.
argsort
(
bordas
[
0
][
'FEATURE_ID'
]),
ranks
=
pd
.
concat
([
np
.
argsort
(
bordas
[
0
][
'FEATURE_ID'
]),
np
.
argsort
(
bordas
[
1
][
'FEATURE_ID'
])],
axis
=
1
).
transpose
().
values
np
.
argsort
(
bordas
[
1
][
'FEATURE_ID'
])],
axis
=
1
).
transpose
().
values
for
nf
in
np
.
arange
(
10
,
60
,
10
):
for
nf
in
np
.
arange
(
NF_MIN
,
NF_MAX
+
NF_STEP
,
NF_STEP
):
cs
=
canberra_stability
(
ranks
,
nf
)
print
(
f
'
{
MODE
}
-
{
layers_concat
}
- stability(
{
nf
}
) =
{
cs
:.
3
f
}
'
)
# additional steps for NF_RSNF
print
()
for
nf
in
NF_RSNF
:
cs
=
canberra_stability
(
ranks
,
nf
)
cs
=
canberra_stability
(
ranks
,
nf
)
print
(
f
'
{
MODE
}
-
{
layers_concat
}
- stability(
{
nf
}
) =
{
cs
:.
3
f
}
'
)
print
(
f
'
{
MODE
}
-
{
layers_concat
}
- stability(
{
nf
}
) =
{
cs
:.
3
f
}
'
)
print
()
print
()
print
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment