Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ExplainGNNWithHighLevelConcepts
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
Service Desk
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
Ajay Umakanth
ExplainGNNWithHighLevelConcepts
Commits
e02b2136
There was an error fetching the commit references. Please try again later.
Commit
e02b2136
authored
5 months ago
by
AjUm-HEIDI
Browse files
Options
Downloads
Patches
Plain Diff
Update main files
parent
5ca9eabd
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
structured_datasets_experiment.py
+12
-2
12 additions, 2 deletions
structured_datasets_experiment.py
text_based_datasets_experiment.py
+12
-3
12 additions, 3 deletions
text_based_datasets_experiment.py
with
24 additions
and
5 deletions
structured_datasets_experiment.py
+
12
−
2
View file @
e02b2136
...
...
@@ -126,8 +126,18 @@ def experiment(datasetName: str, add_node_type = True, iterations: int = 1, crea
metrics
=
model
.
train_model
(
epochs
=
300
,
lr
=
0.001
)
original_labels
=
np
.
array
([
data
.
y
.
item
()
for
data
in
structuredDataset
.
dataset
])
predicted_labels
=
model
.
predict_all
().
clone
().
detach
().
cpu
().
numpy
()
cm
=
confusion_matrix
(
original_labels
,
predicted_labels
)
predicted_labels
=
model
.
predict_all
()
valid_original_labels
=
[]
valid_predicted_labels
=
[]
for
idx
,
predicted_label
in
enumerate
(
predicted_labels
):
if
predicted_label
is
not
None
:
valid_original_labels
.
append
(
original_labels
[
idx
])
valid_predicted_labels
.
append
(
predicted_label
.
item
())
cm
=
confusion_matrix
(
valid_original_labels
,
valid_predicted_labels
)
with
open
(
run_dir
/
f
"
gnn_results.csv
"
,
"
w
"
,
newline
=
""
)
as
f
:
writer
=
csv
.
writer
(
f
)
...
...
This diff is collapsed.
Click to expand it.
text_based_datasets_experiment.py
+
12
−
3
View file @
e02b2136
...
...
@@ -33,16 +33,25 @@ def run_gnn(structuredDataset: Base, entity_name, datasetName, results_dir):
print
(
"
Initializing GNN model...
"
)
model
=
GNN
(
structuredDataset
.
dataset
)
print
(
"
Training model...
"
)
metrics
=
model
.
train_model
(
epochs
=
150
,
lr
=
0.0
1
)
metrics
=
model
.
train_model
(
epochs
=
150
,
lr
=
0.0
01
,
show_progress
=
True
)
evaluations
[
"
gnn
"
]
=
metrics
[
entity_name
]
print
(
"
\n
Best Training
Metrics:
"
)
print
(
"
\n
GNN
Metrics:
"
)
for
metric
,
value
in
metrics
[
entity_name
].
items
():
print
(
f
"
{
metric
.
capitalize
()
}
:
{
value
:
.
4
f
}
"
)
original_labels
=
structuredDataset
.
dataset
[
entity_name
].
y
predicted_labels
=
model
.
predict_all
()
cm
=
confusion_matrix
(
original_labels
.
cpu
().
numpy
(),
predicted_labels
[
entity_name
].
cpu
().
numpy
())
valid_original_labels
=
[]
valid_predicted_labels
=
[]
for
idx
,
predicted_label
in
enumerate
(
predicted_labels
[
entity_name
]):
if
predicted_label
is
not
None
:
valid_original_labels
.
append
(
original_labels
[
idx
])
valid_predicted_labels
.
append
(
predicted_label
)
cm
=
confusion_matrix
(
valid_original_labels
,
valid_predicted_labels
)
print
(
"
Confusion Matrix:
"
)
print
(
cm
)
evaluations
[
"
confusion_matrix
"
]
=
cm
.
tolist
()
...
...
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