Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linkprediction_depo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jacques Fize
linkprediction_depo
Commits
9ee35151
Commit
9ee35151
authored
4 years ago
by
Fize Jacques
Browse files
Options
Downloads
Patches
Plain Diff
debug
parent
d5036dab
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eval_mixed_model.py
+8
-6
8 additions, 6 deletions
eval_mixed_model.py
with
8 additions
and
6 deletions
eval_mixed_model.py
+
8
−
6
View file @
9ee35151
...
@@ -49,7 +49,7 @@ NB_COM = args.nb_com
...
@@ -49,7 +49,7 @@ NB_COM = args.nb_com
NB_ITERATION
=
args
.
nb_iterations
NB_ITERATION
=
args
.
nb_iterations
VERBOSE
=
args
.
verbose
VERBOSE
=
args
.
verbose
FEATURES
=
set
(
args
.
features
.
split
(
"
,
"
))
FEATURES
=
set
(
args
.
features
.
split
(
"
,
"
))
TIMEOUT
=
60
dist
=
lambda
a
,
b
:
np
.
linalg
.
norm
(
a
-
b
)
**
2
dist
=
lambda
a
,
b
:
np
.
linalg
.
norm
(
a
-
b
)
**
2
hash_func
=
lambda
x
:
"
_
"
.
join
(
sorted
([
str
(
x
[
0
]),
str
(
x
[
1
])]))
hash_func
=
lambda
x
:
"
_
"
.
join
(
sorted
([
str
(
x
[
0
]),
str
(
x
[
1
])]))
...
@@ -58,9 +58,12 @@ def get_aucs(G):
...
@@ -58,9 +58,12 @@ def get_aucs(G):
traintest_split
=
LPEvalSplit
()
traintest_split
=
LPEvalSplit
()
traintest_split
.
compute_splits
(
H
,
split_alg
=
"
spanning_tree
"
,
train_frac
=
0.90
,
fe_ratio
=
1
)
traintest_split
.
compute_splits
(
H
,
split_alg
=
"
spanning_tree
"
,
train_frac
=
0.90
,
fe_ratio
=
1
)
nee
=
LPEvaluator
(
traintest_split
)
nee
=
LPEvaluator
(
traintest_split
)
auc_spatial
,
auc_sbm
=
0
,
0
auc_spatial
=
nee
.
evaluate_baseline
(
method
=
"
spatial_link_prediction
"
).
test_scores
.
auroc
()
try
:
auc_sbm
=
nee
.
evaluate_baseline
(
method
=
"
stochastic_block_model
"
).
test_scores
.
auroc
()
auc_spatial
=
nee
.
evaluate_baseline
(
method
=
"
spatial_link_prediction
"
,
timeout
=
TIMEOUT
).
test_scores
.
auroc
()
auc_sbm
=
nee
.
evaluate_baseline
(
method
=
"
stochastic_block_model
"
,
timeout
=
TIMEOUT
).
test_scores
.
auroc
()
except
:
print
(
"
Could not compuyte AUC !
"
)
return
auc_sbm
,
auc_spatial
return
auc_sbm
,
auc_spatial
dist
=
lambda
a
,
b
:
np
.
linalg
.
norm
(
a
-
b
)
dist
=
lambda
a
,
b
:
np
.
linalg
.
norm
(
a
-
b
)
...
@@ -82,7 +85,6 @@ block_assign = nx.get_node_attributes(G,"block")
...
@@ -82,7 +85,6 @@ block_assign = nx.get_node_attributes(G,"block")
H
=
G
.
copy
()
H
=
G
.
copy
()
float_epsilon
=
np
.
finfo
(
float
).
eps
float_epsilon
=
np
.
finfo
(
float
).
eps
df_data
[
"
p_0
"
]
=
df_data
.
apply
(
lambda
x
:
1
if
G
.
has_edge
(
x
.
u
,
x
.
v
)
else
0
,
axis
=
1
)
df_data
[
"
p_0
"
]
=
df_data
.
apply
(
lambda
x
:
1
if
G
.
has_edge
(
x
.
u
,
x
.
v
)
else
0
,
axis
=
1
)
print
(
df_data
)
for
i
in
range
(
1
,
NB_ITERATION
+
1
):
for
i
in
range
(
1
,
NB_ITERATION
+
1
):
old_probs
=
dict
(
df_data
[
"
hash_ p_{0}
"
.
format
(
i
-
1
).
split
()].
values
)
old_probs
=
dict
(
df_data
[
"
hash_ p_{0}
"
.
format
(
i
-
1
).
split
()].
values
)
auc_sbm
,
auc_spatial
=
get_aucs
(
H
)
auc_sbm
,
auc_spatial
=
get_aucs
(
H
)
...
@@ -116,7 +118,7 @@ for i in range(1,NB_ITERATION+1):
...
@@ -116,7 +118,7 @@ for i in range(1,NB_ITERATION+1):
G2
.
nodes
[
n
][
"
pos
"
]
=
pos
[
n
]
G2
.
nodes
[
n
][
"
pos
"
]
=
pos
[
n
]
H
=
G2
.
copy
()
H
=
G2
.
copy
()
if
VERBOSE
:
print
(
df_data
)
edge_feature
=
{
hash_func
([
int
(
row
.
u
),
int
(
row
.
v
)]):[
row
[
"
p_{0}
"
.
format
(
i
)]
for
i
in
range
(
1
,
NB_ITERATION
+
1
)]
for
ix
,
row
in
df_data
.
iterrows
()}
edge_feature
=
{
hash_func
([
int
(
row
.
u
),
int
(
row
.
v
)]):[
row
[
"
p_{0}
"
.
format
(
i
)]
for
i
in
range
(
1
,
NB_ITERATION
+
1
)]
for
ix
,
row
in
df_data
.
iterrows
()}
G
,
_
=
pp
.
prep_graph
(
G
,
maincc
=
True
)
G
,
_
=
pp
.
prep_graph
(
G
,
maincc
=
True
)
...
...
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