-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
83 lines (76 loc) · 1.83 KB
/
example.py
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
import sklearn.ensemble
import sklearn.neighbors
import sklearn.neural_network
import sklearn.preprocessing
import sklearn.tree
from classicdata import (
USPS,
ImageSegmentation,
Ionosphere,
LetterRecognition,
MagicGammaTelescope,
PenDigits,
RobotNavigation,
)
from classicexperiments import Estimator, Evaluation, Experiment
# Prepare datasets.
datasets = [
Ionosphere(),
LetterRecognition(),
MagicGammaTelescope(),
PenDigits(),
RobotNavigation(),
ImageSegmentation(),
USPS(),
]
# Prepare estimators.
estimators = [
Estimator(
name="Dummy",
estimator_class=sklearn.dummy.DummyClassifier,
parameters={},
),
Estimator(
name="5-nn",
estimator_class=sklearn.neighbors.KNeighborsClassifier,
parameters={"n_neighbors": 5},
),
Estimator(
name="Tree",
estimator_class=sklearn.tree.DecisionTreeClassifier,
parameters={},
),
Estimator(
name="Forest",
estimator_class=sklearn.ensemble.AdaBoostClassifier,
parameters={},
),
Estimator(
name="MLP",
estimator_class=sklearn.neural_network.MLPClassifier,
parameters={},
),
Estimator(
name="KernelSVM",
estimator_class=sklearn.svm.SVC,
parameters={"kernel": "sigmoid"},
),
]
# Prepare experiments.
experiments = [
Experiment(
dataset=dataset,
estimator=estimator,
estimation_function=sklearn.model_selection.cross_val_score,
parameters={},
scaler=sklearn.preprocessing.StandardScaler(),
)
for estimator in estimators
for dataset in datasets
]
# Prepare evaluation.
evaluation = Evaluation(experiments=experiments, base_dir="evaluation")
# Run evaluation.
evaluation.run()
# Present results.
evaluation.present(table_format="github")