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
deabb68e
Commit
deabb68e
authored
4 years ago
by
Fize Jacques
Browse files
Options
Downloads
Patches
Plain Diff
change script for eval mixed model
parent
5235a480
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
eval_mixed_model.py
+39
-19
39 additions, 19 deletions
eval_mixed_model.py
lib/link_prediction_eval.py
+2
-1
2 additions, 1 deletion
lib/link_prediction_eval.py
run_eval_mixed_model.sh
+0
-16
0 additions, 16 deletions
run_eval_mixed_model.sh
with
41 additions
and
36 deletions
eval_mixed_model.py
+
39
−
19
View file @
deabb68e
# coding = utf-8
import
argparse
import
time
import
pandas
as
pd
from
lib.random
import
mixed_model_spat_sbm
from
lib.erosion_model
import
eval_erosion_model
from
joblib
import
Parallel
,
delayed
import
networkx
as
nx
import
glob
from
tqdm
import
tqdm
from
lib.utils
import
load_edgelist
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
nb_nodes
"
,
type
=
int
)
parser
.
add_argument
(
"
nb_edges
"
,
type
=
int
)
parser
.
add_argument
(
"
nb_com
"
,
type
=
int
)
parser
.
add_argument
(
"
alpha
"
,
type
=
float
)
parser
.
add_argument
(
"
nb_iterations
"
,
type
=
int
)
parser
.
add_argument
(
'
-f
'
,
'
--features
'
,
help
=
'
Feature(s) used in the model training
'
,
type
=
str
)
parser
.
add_argument
(
"
graph_dir
"
)
parser
.
add_argument
(
"
output_filename
"
)
parser
.
add_argument
(
"
-f
"
,
"
--format
"
,
default
=
"
gml
"
,
choices
=
[
"
gexf
"
,
"
gml
"
,
"
txt
"
])
parser
.
add_argument
(
"
-t
"
,
"
--train-frac
"
,
default
=
0.9
,
type
=
float
)
parser
.
add_argument
(
"
-n
"
,
"
--nb-iteration
"
,
default
=
1
,
type
=
int
)
parser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
-t
"
,
"
--timeout
"
,
default
=
30
,
type
=
int
)
args
=
parser
.
parse_args
()
# COMMAND LINE ARGS VALUES
GRAPH_NODE_NB
=
args
.
nb_nodes
GRAPH_EDGE_NB
=
args
.
nb_edges
ALPHA
=
args
.
alpha
NB_COM
=
args
.
nb_com
NB_ITERATION
=
args
.
nb_iterations
VERBOSE
=
args
.
verbose
FEATURES
=
set
(
args
.
features
.
split
(
"
,
"
))
TIMEOUT
=
10
#args.timeout
args
=
parser
.
parse_args
()
fns
=
sorted
(
glob
.
glob
(
args
.
graph_dir
+
"
/*.
"
+
args
.
format
))
NB_ITERATION
=
args
.
nb_iteration
data
=
[]
def
evaluate
(
fn
):
if
args
.
format
==
"
txt
"
:
G
=
load_edgelist
(
path
=
fn
)
elif
args
.
format
==
"
gml
"
:
G
=
nx
.
read_gml
(
fn
)
else
:
G
=
nx
.
read_gexf
(
fn
)
G
=
nx
.
convert_node_labels_to_integers
(
G
)
auc_sbm
,
auc_spat
,
auc_our_model
=
eval_erosion_model
(
G
,
NB_ITERATION
)
nb_edges
=
G
.
size
()
nb_nodes
=
len
(
G
)
nb_com
=
G
.
graph
[
"
nb_com
"
]
alpha
=
G
.
graph
[
"
alpha
"
]
return
[
nb_nodes
,
nb_edges
,
nb_com
,
alpha
,
fn
,
auc_sbm
,
auc_spat
,
auc_our_model
]
G
=
mixed_model_spat_sbm
(
GRAPH_NODE_NB
,
GRAPH_EDGE_NB
,
NB_COM
,
alpha
=
ALPHA
)
deb
=
time
.
time
()
data
=
Parallel
(
n_jobs
=
4
,
backend
=
"
multiprocessing
"
)(
delayed
(
evaluate
)(
fn
)
for
fn
in
tqdm
(
fns
))
#data =[evaluate(fn) for fn in tqdm(fns)]
print
(
"
eval took
"
,
time
.
time
()
-
deb
)
print
(
eval_erosion_model
(
G
,
NB_ITERATION
))
df
=
pd
.
DataFrame
(
data
,
columns
=
"
nb_nodes nb_edges nb_com alpha fn auc_sbm auc_spat auc_our_model
"
.
split
())
df
.
to_csv
(
args
.
output_filename
,
sep
=
"
\t
"
)
This diff is collapsed.
Click to expand it.
lib/link_prediction_eval.py
+
2
−
1
View file @
deabb68e
...
...
@@ -15,8 +15,9 @@ def get_auc_heuristics(G,timeout=60):
try
:
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
:
except
Exception
as
e
:
print
(
"
Could not compute AUC !
"
)
print
(
e
)
return
auc_sbm
,
auc_spatial
...
...
This diff is collapsed.
Click to expand it.
run_eval_mixed_model.sh
deleted
100755 → 0
+
0
−
16
View file @
5235a480
#!/bin/bash
for
nb_iteration
in
2 3 4 5
do
for
feats
in
"it_probs"
"it_probs,pos"
"it_probs,centrality"
"it_probs,centrality,pos"
do
for
alpha
in
0 0.2 0.5 0.7 1
do
for
nbcom
in
2 3 4 5
do
echo
"alpha= "
$alpha
", nb_com= "
$nbcom
", conf= "
$conf
", nb_iteration= "
$nb_iteration
python eval_mixed_model.py 100 200
$nbcom
$alpha
$nb_iteration
-f
$feats
python eval_mixed_model.py 300 600
$nbcom
$alpha
$nb_iteration
-f
$feats
done
done
done
done
\ No newline at end of file
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