-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
lazy_custom_deep_classification.py
72 lines (53 loc) · 2.35 KB
/
lazy_custom_deep_classification.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
import os
import nnetsauce as ns
from sklearn.datasets import load_breast_cancer, load_iris, load_wine, load_digits
from sklearn.model_selection import train_test_split
from time import time
print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")
load_models = [load_breast_cancer, load_iris, load_wine, load_digits]
# without preprocessing
for model in load_models:
print(f"\n Calling {model.__name__}")
data = model()
X = data.data
y= data.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = .3, random_state = 13)
clf = ns.LazyDeepClassifier(n_layers=3, verbose=0,
ignore_warnings=True,
n_hidden_features=3,
estimators=["RandomForestClassifier",
"ExtraTreesClassifier",
"RandomForestRegressor"])
start = time()
models = clf.fit(X_train, X_test, y_train, y_test)
print(f"\nElapsed: {time() - start} seconds\n")
print(models)
for model in load_models:
print(f"\n Calling {model.__name__}")
data = model()
X = data.data
y= data.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = .3, random_state = 13)
clf = ns.LazyDeepClassifier(n_layers=3, verbose=0,
ignore_warnings=True,
n_hidden_features=3)
start = time()
models = clf.fit(X_train, X_test, y_train, y_test)
print(f"\nElapsed: {time() - start} seconds\n")
print(models)
# with preprocessing
for model in load_models:
print(f"\n Calling {model.__name__}")
data = model()
X = data.data
y= data.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = .3, random_state = 13)
clf = ns.LazyDeepClassifier(n_layers=3, verbose=0,
ignore_warnings=True,
n_hidden_features=10,
estimators="all",
preprocess = True)
start = time()
models, predictions = clf.fit(X_train, X_test, y_train, y_test)
print(f"\nElapsed: {time() - start} seconds\n")
print(models)