Skip to content

Commit 5f9fa17

Browse files
version 0.17.2 with self.n_classes_
1 parent 8511e4d commit 5f9fa17

13 files changed

+250
-228
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# version 0.17.2
2+
3+
- `self.n_classes_ = len(np.unique(y))` # for compatibility with sklearn
4+
15
# version 0.17.1
26

37
- `preprocess`ing for all `LazyDeep*`

nnetsauce/boosting/adaBoostClassifier.py

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def fit(self, X, y, sample_weight=None, **kwargs):
248248
# training
249249
n, p = X.shape
250250
self.n_classes = len(np.unique(y))
251+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
251252

252253
if sample_weight is None:
253254
w_m = np.repeat(1.0 / n, n)

nnetsauce/custom/customClassifier.py

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def fit(self, X, y, sample_weight=None, **kwargs):
187187
"""
188188

189189
output_y, scaled_Z = self.cook_training_set(y=y, X=X, **kwargs)
190+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
190191

191192
# if sample_weights, else: (must use self.row_index)
192193
if sample_weight is not None:

nnetsauce/deep/deepClassifier.py

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def fit(self, X, y):
101101
if isinstance(X, np.ndarray):
102102
X = pd.DataFrame(X)
103103

104+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
105+
104106
# init layer
105107
self.stacked_obj = CustomClassifier(
106108
obj=self.stacked_obj,

nnetsauce/glm/glmClassifier.py

+2
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ def fit(self, X, y, **kwargs):
221221
y
222222
), "y must contain only integers" # change is_factor and subsampling everywhere
223223

224+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
225+
224226
self.beta_ = None
225227

226228
n, p = X.shape

nnetsauce/lazypredict/lazydeepClassifier.py

+218-218
Large diffs are not rendered by default.

nnetsauce/lazypredict/lazydeepRegressor.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class LazyDeepRegressor(Custom, RegressorMixin):
9191
estimators: list, optional (default='all')
9292
list of Estimators names or just 'all' (default='all')
9393
94-
preprocess: bool
94+
preprocess: bool
9595
preprocessing is done when set to True
9696
9797
n_jobs : int, when possible, run in parallel
@@ -264,7 +264,7 @@ def fit(self, X_train, X_test, y_train, y_test):
264264
]
265265

266266
if self.preprocess is True:
267-
267+
268268
for name, model in tqdm(self.regressors): # do parallel exec
269269
start = time.time()
270270
try:
@@ -305,7 +305,7 @@ def fit(self, X_train, X_test, y_train, y_test):
305305
row_sample=self.row_sample,
306306
seed=self.seed,
307307
backend=self.backend,
308-
)
308+
)
309309

310310
for _ in range(self.n_layers):
311311
layer_regr = deepcopy(
@@ -331,9 +331,13 @@ def fit(self, X_train, X_test, y_train, y_test):
331331

332332
layer_regr.fit(X_train, y_train)
333333

334-
pipe = Pipeline(steps=[("preprocessor", preprocessor),
335-
("regressor", layer_regr)])
336-
334+
pipe = Pipeline(
335+
steps=[
336+
("preprocessor", preprocessor),
337+
("regressor", layer_regr),
338+
]
339+
)
340+
337341
pipe.fit(X_train, y_train)
338342

339343
self.models[name] = pipe
@@ -376,7 +380,7 @@ def fit(self, X_train, X_test, y_train, y_test):
376380
print(name + " model failed to execute")
377381
print(exception)
378382

379-
else: # no preprocessing
383+
else: # no preprocessing
380384

381385
for name, model in tqdm(self.regressors): # do parallel exec
382386
start = time.time()

nnetsauce/multitask/multitaskClassifier.py

+2
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ def fit(self, X, y, sample_weight=None, **kwargs):
189189

190190
assert mx.is_factor(y), "y must contain only integers"
191191

192+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
193+
192194
output_y, scaled_Z = self.cook_training_set(y=y, X=X, **kwargs)
193195

194196
self.n_classes_ = len(np.unique(y))

nnetsauce/multitask/simplemultitaskClassifier.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def fit(self, X, y, sample_weight=None, **kwargs):
105105

106106
assert mx.is_factor(y), "y must contain only integers"
107107

108-
self.scaled_X_ = self.X_scaler_.fit_transform(X)
108+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
109109

110-
self.n_classes_ = len(np.unique(y))
110+
self.scaled_X_ = self.X_scaler_.fit_transform(X)
111111

112112
# multitask response
113113
Y = mo.one_hot_encode2(y, self.n_classes_)

nnetsauce/randombag/randomBagClassifier.py

+2
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ def fit(self, X, y, **kwargs):
200200

201201
assert mx.is_factor(y), "y must contain only integers"
202202

203+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
204+
203205
# training
204206
self.n_classes = len(np.unique(y))
205207

nnetsauce/ridge2/ridge2Classifier.py

+2
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ def fit(self, X, y, solver="L-BFGS-B", **kwargs):
323323

324324
assert mx.is_factor(y), "y must contain only integers"
325325

326+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
327+
326328
output_y, scaled_Z = self.cook_training_set(y=y, X=X, **kwargs)
327329

328330
self.n_classes = len(np.unique(y))

nnetsauce/ridge2/ridge2MultitaskClassifier.py

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def fit(self, X, y, **kwargs):
178178

179179
assert mx.is_factor(y), "y must contain only integers"
180180

181+
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
182+
181183
output_y, scaled_Z = self.cook_training_set(y=y, X=X, **kwargs)
182184

183185
n_X, p_X = X.shape

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from codecs import open
44
from os import path
55

6-
__version__ = '0.17.1'
6+
__version__ = '0.17.2'
77

88
# get the dependencies and installs
99
here = path.abspath(path.dirname(__file__))

0 commit comments

Comments
 (0)