-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
maskomic
committed
Sep 23, 2021
1 parent
948c0c8
commit 9e5b52a
Showing
20 changed files
with
178 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Scripts | ||
|
||
Every dataset type has its own folder for run scripts due to different setting for MIL, MNIST and toy datasets. | ||
|
||
# Evaluation of results | ||
|
||
This folder contains evaluation scripts. | ||
|
||
## One-sample evaluation | ||
|
||
To evaluate a single results file (or all results file in a folder), use `evaluate_performance_single.jl` script which computes AUC-ROC, AUC-PR, F score and others for given results file. | ||
|
||
To find the best model for a particular dataset, use `evaluate_single_model.jl`. | ||
|
||
### Examples | ||
``` | ||
# evaluation of vae_basic model on Fox dataset | ||
$ julia scripts/evaluate_single_model.jl vae_basic Fox | ||
# evaluation of knn_basic model on MNIST dataset, leave-one-in method, normal class 1 | ||
$ julia scripts/evaluate_single_model.jl knn_basic MNIST nothing 1 leave-one-in | ||
``` | ||
|
||
To find the best model based on some criteria (aggregation, score, distance etc.), use the third argument, groupkey (should be `Symbol` type). | ||
|
||
``` | ||
# evaluation of vae_basic model on Fox dataset based on aggregation | ||
$ julia scripts/evaluate_single_model.jl vae_basic Fox aggregation | ||
# evaluation of knn_basic model on MNIST dataset, leave-one-in method, normal class 1 based on distance | ||
$ julia scripts/evaluate_single_model.jl knn_basic MNIST distance 1 leave-one-in | ||
``` | ||
|
||
## MIL results | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using DrWatson | ||
@quickactivate | ||
using GroupAD | ||
using GroupAD.Evaluation | ||
using ArgParse | ||
using DataFrames | ||
using PrettyTables | ||
|
||
s = ArgParseSettings() | ||
@add_arg_table! s begin | ||
"modelname" | ||
arg_type = String | ||
help = "model name" | ||
default = "vae_basic" | ||
"dataset" | ||
default = "Fox" | ||
arg_type = String | ||
help = "dataset" | ||
"groupkey" | ||
default = :nothing | ||
arg_type = Symbol | ||
help = "group key, e.g. `:aggregation`" | ||
"class" | ||
default = 1 | ||
arg_type = Int | ||
help = "class for MNIST" | ||
"method" | ||
default = "leave-one-in" | ||
arg_type = String | ||
help = "method: leave-one-in or leave-one-out" | ||
end | ||
parsed_args = parse_args(ARGS, s) | ||
@unpack modelname, dataset, groupkey, class, method = parsed_args | ||
|
||
mill_datasets = [ | ||
"BrownCreeper", "CorelBeach", "CorelAfrican", "Elephant", "Fox", "Musk1", "Musk2", | ||
"Mutagenesis1", "Mutagenesis2", "Newsgroups1", "Newsgroups2", "Newsgroups3", "Protein", | ||
"Tiger", "UCSBBreastCancer", "Web1", "Web2", "Web3", "Web4", "WinterWren" | ||
] | ||
|
||
""" | ||
evaluate_single_model(modelname, dataset; groupkey = nothing, class=1, method="leave-one-in") | ||
Given `modelname` and `dataset` (+ `class` and `method` for MNIST dataset), finds the best model | ||
and prints it. If `groupkey` is provided, finds the best models based on `groupkey`. | ||
""" | ||
function evaluate_single_model(modelname, dataset; groupkey = nothing, class=1, method="leave-one-in") | ||
if groupkey == :nothing | ||
if dataset in mill_datasets | ||
df = mill_results(modelname, [dataset]) | ||
elseif dataset == "MNIST" | ||
folder = datadir("experiments", "contamination-0.0", modelname, "MNIST", method, "class_index=$(class+1)") | ||
df = find_best_model(folder) |> DataFrame | ||
elseif dataset == "toy" | ||
nothing | ||
else | ||
error("Dataset \"$dataset\" for model \"$modelname\" not found.") | ||
end | ||
else | ||
if dataset in mill_datasets | ||
df = mill_results(modelname, [dataset], groupkey) | ||
elseif dataset == "MNIST" | ||
folder = datadir("experiments", "contamination-0.0", modelname, "MNIST", method, "class_index=$(class+1)") | ||
df = find_best_model(folder, groupkey) |> DataFrame | ||
elseif dataset == "toy" | ||
nothing | ||
else | ||
error("Dataset \"$dataset\" for model \"$modelname\" not found.") | ||
end | ||
end | ||
|
||
println("Full results DataFrame:") | ||
pdf_full = pretty_table(df) | ||
if groupkey == :nothing | ||
println("Small results DataFrame:") | ||
pdf_small = pretty_table(df[:, [:val_AUC_mean, :val_AUPRC_mean, :test_AUC_mean, :test_AUPRC_mean]]) | ||
else | ||
println("Small results DataFrame:") | ||
pdf_small = pretty_table(df[:, [groupkey, :val_AUC_mean, :val_AUPRC_mean, :test_AUC_mean, :test_AUPRC_mean]]) | ||
end | ||
end | ||
|
||
evaluate_single_model(modelname, dataset; groupkey = groupkey, class=class, method=method) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.