aek-auto-mlbuilder 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aek_auto_mlbuilder/__init__.py +2 -1
- aek_auto_mlbuilder/random_forest.py +50 -0
- {aek_auto_mlbuilder-0.4.0.dist-info → aek_auto_mlbuilder-0.5.0.dist-info}/METADATA +1 -1
- {aek_auto_mlbuilder-0.4.0.dist-info → aek_auto_mlbuilder-0.5.0.dist-info}/RECORD +7 -6
- {aek_auto_mlbuilder-0.4.0.dist-info → aek_auto_mlbuilder-0.5.0.dist-info}/WHEEL +0 -0
- {aek_auto_mlbuilder-0.4.0.dist-info → aek_auto_mlbuilder-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {aek_auto_mlbuilder-0.4.0.dist-info → aek_auto_mlbuilder-0.5.0.dist-info}/top_level.txt +0 -0
aek_auto_mlbuilder/__init__.py
CHANGED
@@ -3,4 +3,5 @@ from .utils import split_data
|
|
3
3
|
from .linear_regression import LinearRegressor
|
4
4
|
from .logistic_regression import LogisticClassifier
|
5
5
|
from .decision_tree import DecisionTreeModel
|
6
|
-
from.
|
6
|
+
from .knn import KNNModel
|
7
|
+
from .random_forest import RandomForestModel
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
|
2
|
+
from .base import BaseModel
|
3
|
+
|
4
|
+
class RandomForestModel(BaseModel):
|
5
|
+
"""
|
6
|
+
Random Forest model for classification or regression
|
7
|
+
Use task either "classification" or "regression"
|
8
|
+
brute force method is using
|
9
|
+
"""
|
10
|
+
def __init__(self, task="classification", param_grid=None):
|
11
|
+
super().__init__()
|
12
|
+
self.task = task
|
13
|
+
self.param_grid = param_grid or {
|
14
|
+
"n_estimators": [50, 100, 200],
|
15
|
+
"max_depth": [None, 5, 10],
|
16
|
+
"min_samples_split": [2, 5],
|
17
|
+
"min_samples_leaf": [1, 2]
|
18
|
+
}
|
19
|
+
def train(self, X, y):
|
20
|
+
best_score = -float("inf")
|
21
|
+
best_model = None
|
22
|
+
|
23
|
+
if self.task.lower() == "classification":
|
24
|
+
ModelClass = RandomForestClassifier
|
25
|
+
elif self.task.lower() == "regression":
|
26
|
+
ModelClass = RandomForestRegressor
|
27
|
+
else:
|
28
|
+
raise ValueError("task must be 'classification' or 'regression'")
|
29
|
+
|
30
|
+
for n_estimators in self.param_grid["n_estimators"]:
|
31
|
+
for max_depth in self.param_grid["max_depth"]:
|
32
|
+
for min_samples_split in self.param_grid["min_samples_split"]:
|
33
|
+
for min_samples_leaf in self.param_grid["min_samples_leaf"]:
|
34
|
+
model = ModelClass(
|
35
|
+
n_estimators=n_estimators,
|
36
|
+
max_depth=max_depth,
|
37
|
+
min_samples_split=min_samples_split,
|
38
|
+
min_samples_leaf=min_samples_leaf,
|
39
|
+
random_state=42,
|
40
|
+
n_jobs=-1
|
41
|
+
)
|
42
|
+
model.fit(X, y)
|
43
|
+
score = model.score(X, y)
|
44
|
+
if score > best_score:
|
45
|
+
best_score = score
|
46
|
+
best_model = model
|
47
|
+
self.best_model = best_model
|
48
|
+
self.best_score = best_score
|
49
|
+
return self.best_model
|
50
|
+
|
@@ -1,12 +1,13 @@
|
|
1
|
-
aek_auto_mlbuilder/__init__.py,sha256=
|
1
|
+
aek_auto_mlbuilder/__init__.py,sha256=3PnTM35_4WWLjfmiJiTOaQmP3IDG9EcQnu0sdf3zFjc,272
|
2
2
|
aek_auto_mlbuilder/base.py,sha256=GgMdAoceRjwz3i9rVQ0RAjvn5ZdRS-sAkLWjymbE8s0,385
|
3
3
|
aek_auto_mlbuilder/decision_tree.py,sha256=OImOHaREz2jWcANXVC6VKcatFJfzrtyCHJKXNA5-hoI,1606
|
4
4
|
aek_auto_mlbuilder/knn.py,sha256=bNADSq2Ce6stmiWoumRgJbyCmp5SjsbvtTDq3cimKAk,1722
|
5
5
|
aek_auto_mlbuilder/linear_regression.py,sha256=MtOSRiXDIJPd3abnz4yNT4DBtrkmvEy00Kbx4AFk4Kg,1259
|
6
6
|
aek_auto_mlbuilder/logistic_regression.py,sha256=lp9-e9p9QrqL20DmhIJaSnra1SwyMiOdTfOMlgYsNQA,1707
|
7
|
+
aek_auto_mlbuilder/random_forest.py,sha256=uvU4faNdoeMgzqrGJ85qchV3tRBaLFwSVKE3WPGWJ74,2018
|
7
8
|
aek_auto_mlbuilder/utils.py,sha256=NcoM3b4Ng1Ogk3iKuz9DcMVwppGRqOLRp5g9jBCkWxY,190
|
8
|
-
aek_auto_mlbuilder-0.
|
9
|
-
aek_auto_mlbuilder-0.
|
10
|
-
aek_auto_mlbuilder-0.
|
11
|
-
aek_auto_mlbuilder-0.
|
12
|
-
aek_auto_mlbuilder-0.
|
9
|
+
aek_auto_mlbuilder-0.5.0.dist-info/licenses/LICENSE,sha256=eSVo2jJj9FB1xvr0zZ9U1fXkyjjnT6-WM3O4HSFKJOc,133
|
10
|
+
aek_auto_mlbuilder-0.5.0.dist-info/METADATA,sha256=XTcPqhg1yCDERdm4Jd8FFCjlspXGMHTnSKebb7MuEY8,1400
|
11
|
+
aek_auto_mlbuilder-0.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
12
|
+
aek_auto_mlbuilder-0.5.0.dist-info/top_level.txt,sha256=2ZY5rMRnVvrAH2GRGUbd6n9ey8cg_uk5iJwke0hQzFE,19
|
13
|
+
aek_auto_mlbuilder-0.5.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|