Skip to content

Commit

Permalink
version 0.17.2 with self.n_classes_
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrymoudiki committed Mar 5, 2024
1 parent 8511e4d commit 5f9fa17
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 228 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# version 0.17.2

- `self.n_classes_ = len(np.unique(y))` # for compatibility with sklearn

# version 0.17.1

- `preprocess`ing for all `LazyDeep*`
Expand Down
1 change: 1 addition & 0 deletions nnetsauce/boosting/adaBoostClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def fit(self, X, y, sample_weight=None, **kwargs):
# training
n, p = X.shape
self.n_classes = len(np.unique(y))
self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn

if sample_weight is None:
w_m = np.repeat(1.0 / n, n)
Expand Down
1 change: 1 addition & 0 deletions nnetsauce/custom/customClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def fit(self, X, y, sample_weight=None, **kwargs):
"""

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

# if sample_weights, else: (must use self.row_index)
if sample_weight is not None:
Expand Down
2 changes: 2 additions & 0 deletions nnetsauce/deep/deepClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def fit(self, X, y):
if isinstance(X, np.ndarray):
X = pd.DataFrame(X)

self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn

# init layer
self.stacked_obj = CustomClassifier(
obj=self.stacked_obj,
Expand Down
2 changes: 2 additions & 0 deletions nnetsauce/glm/glmClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def fit(self, X, y, **kwargs):
y
), "y must contain only integers" # change is_factor and subsampling everywhere

self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn

self.beta_ = None

n, p = X.shape
Expand Down
436 changes: 218 additions & 218 deletions nnetsauce/lazypredict/lazydeepClassifier.py

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions nnetsauce/lazypredict/lazydeepRegressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class LazyDeepRegressor(Custom, RegressorMixin):
estimators: list, optional (default='all')
list of Estimators names or just 'all' (default='all')
preprocess: bool
preprocess: bool
preprocessing is done when set to True
n_jobs : int, when possible, run in parallel
Expand Down Expand Up @@ -264,7 +264,7 @@ def fit(self, X_train, X_test, y_train, y_test):
]

if self.preprocess is True:

for name, model in tqdm(self.regressors): # do parallel exec
start = time.time()
try:
Expand Down Expand Up @@ -305,7 +305,7 @@ def fit(self, X_train, X_test, y_train, y_test):
row_sample=self.row_sample,
seed=self.seed,
backend=self.backend,
)
)

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

layer_regr.fit(X_train, y_train)

pipe = Pipeline(steps=[("preprocessor", preprocessor),
("regressor", layer_regr)])

pipe = Pipeline(
steps=[
("preprocessor", preprocessor),
("regressor", layer_regr),
]
)

pipe.fit(X_train, y_train)

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

else: # no preprocessing
else: # no preprocessing

for name, model in tqdm(self.regressors): # do parallel exec
start = time.time()
Expand Down
2 changes: 2 additions & 0 deletions nnetsauce/multitask/multitaskClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def fit(self, X, y, sample_weight=None, **kwargs):

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

self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn

output_y, scaled_Z = self.cook_training_set(y=y, X=X, **kwargs)

self.n_classes_ = len(np.unique(y))
Expand Down
4 changes: 2 additions & 2 deletions nnetsauce/multitask/simplemultitaskClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def fit(self, X, y, sample_weight=None, **kwargs):

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

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

self.n_classes_ = len(np.unique(y))
self.scaled_X_ = self.X_scaler_.fit_transform(X)

# multitask response
Y = mo.one_hot_encode2(y, self.n_classes_)
Expand Down
2 changes: 2 additions & 0 deletions nnetsauce/randombag/randomBagClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def fit(self, X, y, **kwargs):

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

self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn

# training
self.n_classes = len(np.unique(y))

Expand Down
2 changes: 2 additions & 0 deletions nnetsauce/ridge2/ridge2Classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ def fit(self, X, y, solver="L-BFGS-B", **kwargs):

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

self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn

output_y, scaled_Z = self.cook_training_set(y=y, X=X, **kwargs)

self.n_classes = len(np.unique(y))
Expand Down
2 changes: 2 additions & 0 deletions nnetsauce/ridge2/ridge2MultitaskClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def fit(self, X, y, **kwargs):

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

self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn

output_y, scaled_Z = self.cook_training_set(y=y, X=X, **kwargs)

n_X, p_X = X.shape
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from codecs import open
from os import path

__version__ = '0.17.1'
__version__ = '0.17.2'

# get the dependencies and installs
here = path.abspath(path.dirname(__file__))
Expand Down

0 comments on commit 5f9fa17

Please sign in to comment.