Feature range parameter support - Unit Tests #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I started working from Feature range parameter support.
👋 I'm an AI agent who writes, runs, and maintains Unit Tests. I even highlight the bugs I spot! I'm free for open-source repos.
🔄 8 test files added and 12 test files updated to reflect recent changes.
🐛 Found 7 bugs
🛠️ 503/641 tests passed
🔄 Test Updates
I've added or updated 13 tests. They all pass ☑️
Updated Tests:
mlxtend/frequent_patterns/tests/test_association_rules.py
🩹mlxtend/evaluate/tests/test_bias_variance_decomp.py
🩹mlxtend/evaluate/tests/test_bias_variance_decomp.py
🩹mlxtend/evaluate/tests/test_bias_variance_decomp.py
🩹mlxtend/feature_selection/tests/test_column_selector.py
🩹mlxtend/feature_selection/tests/test_column_selector.py
🩹mlxtend/feature_selection/tests/test_column_selector.py
🩹mlxtend/feature_selection/tests/test_column_selector.py
🩹mlxtend/preprocessing/tests/test_transactionencoder.py
🩹mlxtend/classifier/tests/test_logistic_regression.py
🩹mlxtend/classifier/tests/test_perceptron.py
🩹mlxtend/classifier/tests/test_adaline.py
🩹New Tests:
mlxtend/_base/tests/test_base_model.py
🐛 Bug Detection
Potential issues found in the following files:
mlxtend/classifier/multilayerperceptron.py
To fix the error, the dtype argument should be updated from np.float_ to np.float64 (or another appropriate float type). This change in the code is the necessary correction.
Thus, the error was caused by a bug in the code being tested.
Test Error Log
``` mlxtend/classifier/tests/test_multilayerperceptron.py::test_multiclass_gd_acc: def test_multiclass_gd_acc(): mlp = MLP(epochs=20, eta=0.05, hidden_layers=[10], minibatches=1, random_seed=1) > mlp.fit(X, y) mlxtend/classifier/tests/test_multilayerperceptron.py:28: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ mlxtend/_base/_classifier.py:81: in fit self._fit(X=X, y=y, init_params=init_params) mlxtend/classifier/multilayerperceptron.py:147: in _fit y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float_) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ attr = 'float_' def __getattr__(attr): # Warn for expired attributes import warningsE AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_progress_1: def test_progress_1():
mlp = MLP(
epochs=1,
eta=0.05,
hidden_layers=[10],
minibatches=1,
print_progress=1,
random_seed=1,
)
mlxtend/classifier/tests/test_multilayerperceptron.py:43:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_progress_2: def test_progress_2():
mlp = MLP(
epochs=1,
eta=0.05,
hidden_layers=[10],
minibatches=1,
print_progress=2,
random_seed=1,
)
mlxtend/classifier/tests/test_multilayerperceptron.py:55:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_progress_3: def test_progress_3():
mlp = MLP(
epochs=1,
eta=0.05,
hidden_layers=[10],
minibatches=1,
print_progress=3,
random_seed=1,
)
mlxtend/classifier/tests/test_multilayerperceptron.py:67:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_predict_proba: def test_predict_proba():
mlp = MLP(epochs=20, eta=0.05, hidden_layers=[10], minibatches=1, random_seed=1)
mlxtend/classifier/tests/test_multilayerperceptron.py:72:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_multiclass_sgd_acc: def test_multiclass_sgd_acc():
mlp = MLP(
epochs=20, eta=0.05, hidden_layers=[25], minibatches=len(y), random_seed=1
)
mlxtend/classifier/tests/test_multilayerperceptron.py:83:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_multiclass_minibatch_acc: def test_multiclass_minibatch_acc():
mlp = MLP(epochs=20, eta=0.05, hidden_layers=[25], minibatches=5, random_seed=1)
mlxtend/classifier/tests/test_multilayerperceptron.py:90:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_binary_gd: def test_binary_gd():
mlp = MLP(epochs=20, eta=0.05, hidden_layers=[25], minibatches=5, random_seed=1)
mlxtend/classifier/tests/test_multilayerperceptron.py:109:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_score_function: def test_score_function():
mlp = MLP(epochs=20, eta=0.05, hidden_layers=[25], minibatches=5, random_seed=1)
mlxtend/classifier/tests/test_multilayerperceptron.py:115:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_decay_function: def test_decay_function():
mlp = MLP(
epochs=20,
eta=0.05,
decrease_const=0.01,
hidden_layers=[25],
minibatches=5,
random_seed=1,
)
mlxtend/classifier/tests/test_multilayerperceptron.py:130:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_momentum_1: def test_momentum_1():
mlp = MLP(
epochs=20,
eta=0.05,
momentum=0.1,
hidden_layers=[25],
minibatches=len(y),
random_seed=1,
)
mlxtend/classifier/tests/test_multilayerperceptron.py:146:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_multilayerperceptron.py::test_retrain: def test_retrain():
mlp = MLP(epochs=5, eta=0.05, hidden_layers=[10], minibatches=len(y), random_seed=1)
mlxtend/classifier/tests/test_multilayerperceptron.py:154:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/multilayerperceptron.py:147: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_softmax_regression.py::test_binary_logistic_regression_gd: def test_binary_logistic_regression_gd():
t = np.array([[0.13, -0.12], [-3.07, 3.05]])
lr = SoftmaxRegression(epochs=200, eta=0.005, minibatches=1, random_seed=1)
mlxtend/classifier/tests/test_softmax_regression.py:43:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/softmax_regression.py:145: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_softmax_regression.py::test_refit_weights: def test_refit_weights():
t = np.array([[0.13, -0.12], [-3.07, 3.05]])
lr = SoftmaxRegression(epochs=100, eta=0.005, minibatches=1, random_seed=1)
mlxtend/classifier/tests/test_softmax_regression.py:52:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/softmax_regression.py:145: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_softmax_regression.py::test_binary_logistic_regression_sgd: def test_binary_logistic_regression_sgd():
t = np.array([[0.13, -0.12], [-3.06, 3.05]])
lr = SoftmaxRegression(epochs=200, eta=0.005, minibatches=len(y_bin), random_seed=1)
mlxtend/classifier/tests/test_softmax_regression.py:66:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/softmax_regression.py:145: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_softmax_regression.py::test_progress_1: def test_progress_1():
lr = SoftmaxRegression(
epochs=1, eta=0.005, minibatches=1, print_progress=1, random_seed=1
)
mlxtend/classifier/tests/test_softmax_regression.py:76:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/softmax_regression.py:145: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings
E AttributeError:
np.float_
was removed in the NumPy 2.0 release. Usenp.float64
instead./usr/local/lib/python3.11/site-packages/numpy/init.py:400: AttributeError
mlxtend/classifier/tests/test_softmax_regression.py::test_progress_2: def test_progress_2():
lr = SoftmaxRegression(
epochs=1, eta=0.005, minibatches=1, print_progress=2, random_seed=1
)
mlxtend/classifier/tests/test_softmax_regression.py:84:
mlxtend/_base/_classifier.py:81: in fit
self._fit(X=X, y=y, init_params=init_params)
mlxtend/classifier/softmax_regression.py:145: in _fit
y_enc = self.one_hot(y=y, n_labels=self.n_classes, dtype=np.float)
attr = 'float_'
def getattr(attr):
# Warn for expired attributes
import warnings