-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathArguments.py
More file actions
137 lines (89 loc) · 2.96 KB
/
Arguments.py
File metadata and controls
137 lines (89 loc) · 2.96 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
from sys import argv
from m3gp.MahalanobisDistanceClassifier import MahalanobisDistanceClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeRegressor
#
# By using this file, you are agreeing to this product's EULA
#
# This product can be obtained in https://github.com/jespb/Python-M3GP
#
# Copyright ©2019-2025 J. E. Batista
#
# Operators to be used by the models
# Only these operators are available. To add mode, edit m3gp.Node.calculate(self, sample)
#OPERATORS = [("+",2),("-",2),("*",2),("/",2),("log2",1), ("max", 3)] # Example
OPERATORS = [("+",2),("-",2),("*",2),("/",2)] # Default
# Initial Maximum depth
MAX_DEPTH = 6
# Number of models in the population
POPULATION_SIZE = 500
# Maximum number of iterations
MAX_GENERATION = 100
# Fraction of the dataset to be used as training (used by Main_M3GP_standalone.py)
TRAIN_FRACTION = 0.70
# Number of individuals to be used in the tournament
TOURNAMENT_SIZE = 5
# Number of best individuals to be automatically moved to the next generation
ELITISM_SIZE = 1
# Shuffle the dataset (used by Main_M3GP_standalone.py)
SHUFFLE = True
# Dimensions maximum depth
LIMIT_DEPTH=17
# Number of runs (used by Main_M3GP_standalone.py)
RUNS = 30
# Verbose
VERBOSE = True
# Number of CPU Threads to be used
THREADS = 1
# Minimum number of dimensions
DIM_MIN = 1
# An unreachable number of dimensions
DIM_MAX = 9999
# Random state
RANDOM_STATE = 42
# Models wrapped by the M3GP models
MODEL = [MahalanobisDistanceClassifier(), RandomForestClassifier(max_depth=6), DecisionTreeRegressor(max_depth=6)][0]
MODEL_NAME = MODEL.__class__.__name__
# Fitness used by the M3GP models
FITNESS_TYPE = ["Accuracy", "MSE", "WAF", "2FOLD"][0]
DATASETS_DIR = "datasets/"
OUTPUT_DIR = "results/"
DATASETS = ["heart.csv"]
OUTPUT = "Classification"
if "-dsdir" in argv:
DATASETS_DIR = argv[argv.index("-dsdir")+1]
if "-odir" in argv:
OUTPUT_DIR = argv[argv.index("-odir")+1]
if "-d" in argv:
DATASETS = argv[argv.index("-d")+1].split(";")
if "-runs" in argv:
RUNS = int(argv[argv.index("-runs")+1])
if "-op" in argv:
OPERATORS = argv[argv.index("-op")+1].split(";")
for i in range(len(OPERATORS)):
OPERATORS[i] = OPERATORS[i].split(",")
OPERATORS[i][1] = int(OPERATORS[i][1])
if "-md" in argv:
MAX_DEPTH = int(argv[argv.index("-md")+1])
if "-ps" in argv:
POPULATION_SIZE = int(argv[argv.index("-ps")+1])
if "-mg" in argv:
MAX_GENERATION = int(argv[argv.index("-mg")+1])
if "-tf" in argv:
TRAIN_FRACTION = float(argv[argv.index("-tf")+1])
if "-ts" in argv:
TOURNAMENT_SIZE = int(argv[argv.index("-ts")+1])
if "-es" in argv:
ELITISM_SIZE = int(argv[argv.index("-es")+1])
if "-dontshuffle" in argv:
SHUFFLE = False
if "-s" in argv:
VERBOSE = False
if "-t" in argv:
THREADS = int(argv[argv.index("-t")+1])
if "-dmin" in argv:
DIM_MIN = int(argv[argv.index("-dmin")+1])
if "-dmax" in argv:
DIM_MAX = int(argv[argv.index("-dmax")+1])
if "-rs" in argv:
RANDOM_STATE = int(argv[argv.index("-rs")+1])