Skip to content

Commit 643b8ad

Browse files
author
Yam Peleg
committed
hunga bunga
1 parent 0e08243 commit 643b8ad

7 files changed

Lines changed: 75 additions & 59 deletions

File tree

.idea/workspace.xml

Lines changed: 62 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
X_r, y_r = gen_reg_data(10, 3, 100, 3, sum, 0.3)
1616

1717

18-
18+
"""
1919
# ---------- Classification ----------
2020
2121
clf = HungaBungaClassifier()
22-
clf.fit(X_c, y_r)
22+
clf.fit(X_c, y_c)
2323
print(clf.predict(X_c))
24-
24+
"""
2525

2626

2727
# ---------- Regression ----------
2828

2929
mdl = HungaBungaRegressor()
30-
mdl.fit(X_c, y_r)
30+
mdl.fit(X_r, y_r)
3131
print(mdl.predict(X_c))
3232

3333

hunga_bunga/__init__.pyc

53 Bytes
Binary file not shown.

hunga_bunga/classification.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
(SGDClassifier,
3232
{'loss': ['hinge', 'log', 'modified_huber', 'squared_hinge'],
3333
'alpha': [0.0001, 0.001, 0.1],
34-
'penalty_12none': penalty_12none
34+
'penalty': penalty_12none
3535
}),
3636

3737
(LogisticRegression,
38-
{'penalty_12': penalty_12, 'max_iter': max_iter, 'tol': tol, 'warm_start': warm_start, 'C':C, 'solver': ['liblinear']
38+
{'penalty': penalty_12, 'max_iter': max_iter, 'tol': tol, 'warm_start': warm_start, 'C':C, 'solver': ['liblinear']
3939
}),
4040

4141
(Perceptron,
42-
{'penalty_all': penalty_all, 'alpha': alpha, 'n_iter': n_iter, 'eta0': eta0, 'warm_start': warm_start
42+
{'penalty': penalty_all, 'alpha': alpha, 'n_iter': n_iter, 'eta0': eta0, 'warm_start': warm_start
4343
}),
4444

4545
(PassiveAggressiveClassifier,
@@ -73,7 +73,7 @@
7373
}),
7474

7575
(LinearSVC,
76-
{ 'C': C, 'penalty_12': penalty_12, 'tol': tol, 'max_iter': max_iter,
76+
{ 'C': C, 'penalty': penalty_12, 'tol': tol, 'max_iter': max_iter,
7777
'loss': ['hinge', 'squared_hinge'],
7878
})
7979
]
@@ -176,7 +176,7 @@
176176

177177
def run_all_classifiers(x, y, small = True, normalize_x = True, n_jobs=cpu_count()-1, brain=False, test_size=0.2, n_splits=5, upsample=True, scoring=None, verbose=False):
178178
all_params = (linear_models_n_params_small if small else linear_models_n_params) + (nn_models_n_params_small if small else nn_models_n_params) + ([] if small else gaussianprocess_models_n_params) + neighbor_models_n_params + (svm_models_n_params_small if small else svm_models_n_params) + (tree_models_n_params_small if small else tree_models_n_params)
179-
return main_loop(all_params, StandardScaler().fit_transform(x) if normalize_x else x, y, isClassification=True, n_jobs=n_jobs, verbose=False, brain=brain)
179+
return main_loop(all_params, StandardScaler().fit_transform(x) if normalize_x else x, y, isClassification=True, n_jobs=n_jobs, verbose=verbose, brain=brain, test_size=test_size, n_splits=n_splits, upsample=upsample, scoring=scoring)
180180

181181

182182
class HungaBungaClassifier(ClassifierMixin):
@@ -195,6 +195,7 @@ def __init__(self, brain=False, test_size = 0.2, n_splits = 5, random_state=None
195195

196196
def fit(self, x, y):
197197
self.model = run_all_classifiers(x, y, normalize_x=self.normalize_x, test_size=self.test_size, n_splits=self.n_splits, upsample=self.upsample, scoring=self.scoring, verbose=self.verbose, brain=self.brain, n_jobs=self.n_jobs)[0]
198+
return self
198199

199200
def predict(self, x):
200201
return self.model.predict(x)

hunga_bunga/classification.pyc

43 Bytes
Binary file not shown.

hunga_bunga/regression.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525

2626
linear_models_n_params = [
27-
(LinearRegression, normalize),
27+
(LinearRegression, {'normalize': normalize}),
2828

2929
(Ridge,
30-
{'alpha': alpha, 'normaliz': normalize, 'tol': tol,
30+
{'alpha': alpha, 'normalize': normalize, 'tol': tol,
3131
'solver': ['svd', 'cholesky', 'lsqr', 'sparse_cg', 'sag']
3232
}),
3333

@@ -107,7 +107,7 @@
107107
]
108108

109109
linear_models_n_params_small = [
110-
(LinearRegression, normalize),
110+
(LinearRegression, {'normalize': normalize}),
111111

112112
(Ridge,
113113
{'alpha': alpha_small, 'normalize': normalize

hunga_bunga/regression.pyc

1 Byte
Binary file not shown.

0 commit comments

Comments
 (0)