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
a12ebebc
Commit
a12ebebc
authored
3 years ago
by
Fize Jacques
Browse files
Options
Downloads
Patches
Plain Diff
debug
parent
299c9dcd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eval_mixed_model.py
+24
-13
24 additions, 13 deletions
eval_mixed_model.py
run_eval_mixed_model.sh
+2
-2
2 additions, 2 deletions
run_eval_mixed_model.sh
with
26 additions
and
15 deletions
eval_mixed_model.py
+
24
−
13
View file @
a12ebebc
...
@@ -36,6 +36,8 @@ parser.add_argument("nb_nodes",type=int)
...
@@ -36,6 +36,8 @@ parser.add_argument("nb_nodes",type=int)
parser
.
add_argument
(
"
nb_edges
"
,
type
=
int
)
parser
.
add_argument
(
"
nb_edges
"
,
type
=
int
)
parser
.
add_argument
(
"
nb_com
"
,
type
=
int
)
parser
.
add_argument
(
"
nb_com
"
,
type
=
int
)
parser
.
add_argument
(
"
alpha
"
,
type
=
float
)
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
(
"
-v
"
,
"
--verbose
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
action
=
"
store_true
"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -44,8 +46,9 @@ GRAPH_NODE_NB = args.nb_nodes
...
@@ -44,8 +46,9 @@ GRAPH_NODE_NB = args.nb_nodes
GRAPH_EDGE_NB
=
args
.
nb_edges
GRAPH_EDGE_NB
=
args
.
nb_edges
ALPHA
=
args
.
alpha
ALPHA
=
args
.
alpha
NB_COM
=
args
.
nb_com
NB_COM
=
args
.
nb_com
NB_ITERATION
=
3
NB_ITERATION
=
args
.
nb_iterations
VERBOSE
=
args
.
verbose
VERBOSE
=
args
.
verbose
FEATURES
=
set
(
args
.
features
.
split
(
"
,
"
))
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
])]))
...
@@ -113,23 +116,31 @@ y_train = traintest_split.train_labels
...
@@ -113,23 +116,31 @@ y_train = traintest_split.train_labels
X_test
=
traintest_split
.
test_edges
X_test
=
traintest_split
.
test_edges
y_test
=
traintest_split
.
test_labels
y_test
=
traintest_split
.
test_labels
if
"
pos
"
in
FEATURES
:
pos
=
nx
.
get_node_attributes
(
G
,
"
pos
"
)
dist_X_train
=
np
.
asarray
([
dist
(
pos
[
ed
[
0
]],
pos
[
ed
[
1
]])
for
ed
in
X_train
]).
reshape
(
-
1
,
1
)
dist_X_test
=
np
.
asarray
([
dist
(
pos
[
ed
[
0
]],
pos
[
ed
[
1
]])
for
ed
in
X_test
]).
reshape
(
-
1
,
1
)
pos
=
nx
.
get_node_attributes
(
G
,
"
pos
"
)
X_train
=
np
.
concatenate
((
X_train
,
dist_X_train
),
axis
=
1
)
dist_X_train
=
np
.
asarray
([
dist
(
pos
[
ed
[
0
]],
pos
[
ed
[
1
]])
for
ed
in
X_train
]).
reshape
(
-
1
,
1
)
X_test
=
np
.
concatenate
((
X_test
,
dist_X_test
),
axis
=
1
)
dist_X_test
=
np
.
asarray
([
dist
(
pos
[
ed
[
0
]],
pos
[
ed
[
1
]])
for
ed
in
X_test
]).
reshape
(
-
1
,
1
)
if
"
centrality
"
in
FEATURES
:
centrality
=
nx
.
degree_centrality
(
G
)
centrality_X_train
=
np
.
asarray
([[
centrality
[
ed
[
0
]],
centrality
[
ed
[
1
]]]
for
ed
in
X_train
])
centrality_X_test
=
np
.
asarray
([[
centrality
[
ed
[
0
]],
centrality
[
ed
[
1
]]]
for
ed
in
X_test
])
X_train
=
np
.
concatenate
((
X_train
,
centrality_X_train
),
axis
=
1
)
X_test
=
np
.
concatenate
((
X_test
,
centrality_X_test
),
axis
=
1
)
centrality
=
nx
.
degree_centrality
(
G
)
if
"
it_probs
"
:
centrality_X_train
=
np
.
asarray
([[
centrality
[
ed
[
0
]],
centrality
[
ed
[
1
]]]
for
ed
in
X_train
])
if_not
=
[
0
for
i
in
range
(
NB_ITERATION
-
1
)]
centrality_X_test
=
np
.
asarray
([[
centrality
[
ed
[
0
]],
centrality
[
ed
[
1
]]]
for
ed
in
X_test
])
feature_X_train
=
np
.
asarray
([
(
edge_feature
[
hash_func
(
ed
)]
if
hash_func
(
ed
)
in
edge_feature
else
if_not
)
for
ed
in
X_train
])
feature_X_test
=
np
.
asarray
([
(
edge_feature
[
hash_func
(
ed
)]
if
hash_func
(
ed
)
in
edge_feature
else
if_not
)
for
ed
in
X_test
])
if_not
=
[
0
for
i
in
range
(
NB_ITERATION
-
1
)]
X_train
=
np
.
concatenate
((
X_train
,
feature_X_train
),
axis
=
1
)
feature_X_train
=
np
.
asarray
([
(
edge_feature
[
hash_func
(
ed
)]
if
hash_func
(
ed
)
in
edge_feature
else
if_not
)
for
ed
in
X_train
])
X_test
=
np
.
concatenate
((
X_test
,
feature_X_test
),
axis
=
1
)
feature_X_test
=
np
.
asarray
([
(
edge_feature
[
hash_func
(
ed
)]
if
hash_func
(
ed
)
in
edge_feature
else
if_not
)
for
ed
in
X_test
])
##ADD centrality and distance to X train
X_train
=
np
.
concatenate
((
X_train
,
dist_X_train
,
centrality_X_train
),
axis
=
1
)
X_test
=
np
.
concatenate
((
X_test
,
dist_X_test
,
centrality_X_test
),
axis
=
1
)
classifier_dict
=
{
classifier_dict
=
{
...
...
This diff is collapsed.
Click to expand it.
run_eval_mixed_model.sh
+
2
−
2
View file @
a12ebebc
...
@@ -5,7 +5,7 @@ do
...
@@ -5,7 +5,7 @@ do
for
nbcom
in
2 3 4 5
for
nbcom
in
2 3 4 5
do
do
echo
"alpha= "
$alpha
", nb_com= "
$nbcom
echo
"alpha= "
$alpha
", nb_com= "
$nbcom
python eval_mixed_model.py 100 200
$nbcom
$alpha
python eval_mixed_model.py 100 200
$nbcom
$alpha
-f
pos,centrality,it_probs
python eval_mixed_model.py 300 600
$nbcom
$alpha
python eval_mixed_model.py 300 600
$nbcom
$alpha
-f
pos,centrality,it_probs
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