-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_models.jl
87 lines (75 loc) · 2.21 KB
/
test_models.jl
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
include("modulos/testing_models.jl")
include("modulos/datasets.jl")
include("modulos/attributes_from_dataset.jl")
#=
hay diferentes extracciones:
· :A1 (aproximación 1)
· :A21 (aproximación 2 extracción 1)
· :A22 (aproximación 2 extracción 2)
etc...
=#
extraction = :A33;
dataset_name="datasets/faces.data";
change = false;
if extraction==:A1
x = 6;
y = 7;
elseif extraction==:A21
x = 42;
y = 43;
elseif (extraction==:A22 || extraction==:A23)
x = 36;
y = 37;
elseif extraction==:A31
x = 48;
y = 49;
elseif extraction==:A32
x = 66;
y = 67;
elseif extraction==:A33
x = 72;
y = 73;
elseif extraction==:A34
x = 84;
y = 85;
end;
if (!isfile(dataset_name) || change)
createDataset(dataset_name,extraction);
end;
dataset = readdlm(dataset_name,',');
inputs = convert(Array{Float64,2}, dataset[:,1:x]);
targets = convert(Array{Any,1},dataset[:,y]);
seed!(1);
numFolds = 10;
#=
Posibles representaciones
· ninguna o :All = saca todo por pantalla.
· :AccStd = accuracy y su std.
· :F1Std = F1 y su std.
· :AccF1 = accuracy y F1.
· :Plot3D = solo para svm con kernel polinómico.
Para sacar los gráficos 3D:
sudo apt-get install python3-matplotlib
Pkg.add("PyPlot") || Pkg.build("PyPlot")
=#
# Entrenamos knn
testingModels(:KNN, Dict("maxNeighbors" => 20), inputs, targets, numFolds; rep=:All);
# Entrenamos los arboles de decision
testingModels(:DecisionTree, Dict("maxDepth" => 20), inputs, targets, numFolds; rep=:All);
# Entrenamos svm
modelHyperparameters = Dict();
modelHyperparameters["kernel"] = "rbf";
modelHyperparameters["kernelDegree"] = 15;
modelHyperparameters["maxGamma"] = 10;
testingModels(:SVM, modelHyperparameters, inputs, targets, numFolds; rep=:All);
# Entrenamos las RR.NN.AA.
modelHyperparameters = Dict();
modelHyperparameters["fstNeuron"] = 1;
modelHyperparameters["maxNNxlayer"] = 16;
modelHyperparameters["layers"] = 1;
testingModels(:ANN, modelHyperparameters, inputs, targets, numFolds; rep=:All);
modelHyperparameters = Dict();
modelHyperparameters["fstNeuron"] = 6;
modelHyperparameters["maxNNxlayer"] = 12;
modelHyperparameters["layers"] = 2;
testingModels(:ANN, modelHyperparameters, inputs, targets, numFolds; rep=:All);