Repository navigation
Expand file tree
/
Copy pathsingle_al_cycle.py
More file actions
88 lines (83 loc) · 2.98 KB
/
Copy pathsingle_al_cycle.py
File metadata and controls
88 lines (83 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import random
import numpy as np
from active_learning.al_cycle_wrapper import train_and_eval_dataset
from active_learning.experiment_setup_lib import (
get_dataset,
standard_config,
init_logger,
)
from fake_experiment_oracle import FakeExperimentOracle
config = standard_config(
[
(
["--SAMPLING"],
{
"required": True,
"help": "Possible values: uncertainty, random, committe, boundary",
},
),
(["--DATASET_NAME"], {"required": True,}),
(
["--CLUSTER"],
{
"default": "dummy",
"help": "Possible values: dummy, random, mostUncertain, roundRobin",
},
),
(["--NR_LEARNING_ITERATIONS"], {"type": int, "default": 150000}),
(["--NR_QUERIES_PER_ITERATION"], {"type": int, "default": 150}),
(["--START_SET_SIZE"], {"type": int, "default": 1}),
(
["--MINIMUM_TEST_ACCURACY_BEFORE_RECOMMENDATIONS"],
{"type": float, "default": 0.7},
),
(
["--UNCERTAINTY_RECOMMENDATION_CERTAINTY_THRESHOLD"],
{"type": float, "default": 0.9},
),
(["--UNCERTAINTY_RECOMMENDATION_RATIO"], {"type": float, "default": 1 / 100}),
(["--SNUBA_LITE_MINIMUM_HEURISTIC_ACCURACY"], {"type": float, "default": 0.9}),
(
["--CLUSTER_RECOMMENDATION_MINIMUM_CLUSTER_UNITY_SIZE"],
{"type": float, "default": 0.7},
),
(
["--CLUSTER_RECOMMENDATION_RATIO_LABELED_UNLABELED"],
{"type": float, "default": 0.9},
),
(["--WITH_UNCERTAINTY_RECOMMENDATION"], {"action": "store_true"}),
(["--WITH_CLUSTER_RECOMMENDATION"], {"action": "store_true"}),
(["--WITH_SNUBA_LITE"], {"action": "store_true"}),
(["--PLOT"], {"action": "store_true"}),
(["--STOPPING_CRITERIA_UNCERTAINTY"], {"type": float, "default": 0.7}),
(["--STOPPING_CRITERIA_ACC"], {"type": float, "default": 0.7}),
(["--STOPPING_CRITERIA_STD"], {"type": float, "default": 0.7}),
(
["--ALLOW_RECOMMENDATIONS_AFTER_STOP"],
{"action": "store_true", "default": False},
),
(["--OUTPUT_DIRECTORY"], {"default": "tmp/"}),
(["--HYPER_SEARCH_TYPE"], {"default": "random"}),
(["--USER_QUERY_BUDGET_LIMIT"], {"type": float, "default": 200}),
]
)
init_logger("console")
if config.RANDOM_SEED == -2:
config.RANDOM_SEED = random.randint(0, 2147483647)
np.random.seed(config.RANDOM_SEED)
random.seed(config.RANDOM_SEED)
X_train, X_test, Y_train, Y_test, label_encoder_classes = get_dataset(
config.DATASETS_PATH, config.DATASET_NAME, config.RANDOM_SEED
)
score, Y_train = train_and_eval_dataset(
config.DATASET_NAME,
X_train,
X_test,
Y_train,
Y_test,
label_encoder_classes,
hyper_parameters=vars(config),
oracle=FakeExperimentOracle(),
)
print("Done with ", score)
print("Labels: ", Y_train)