algorithm %s is not supported
Package:
scikit-learn
47032

Exception Class:
ValueError
Raise code
"""
Returns
-------
self : object
Fitted estimator.
"""
# Check that algorithm is supported
if self.algorithm not in ('SAMME', 'SAMME.R'):
raise ValueError("algorithm %s is not supported" % self.algorithm)
# Fit
return super().fit(X, y, sample_weight)
def _validate_estimator(self):
"""Check the estimator and set the base_estimator_ attribute."""
super()._validate_estimator(
Links to the raise (1)
https://github.com/scikit-learn/scikit-learn/blob/c67518350f91072f9d37ed09c5ef7edf555b6cf6/sklearn/ensemble/_weight_boosting.py#L440Ways to fix
Summary:
This exception can be thrown when calling fit on an instance of AdaBoostClassifier. When creating the instance of adaBoostClassifier, you have the option to set the value of the algorithm as an optional parameter. the value of this parameter can only be one of 2 values: 'SAMME' or 'SAMME.R'. If it's set to anything else, it will throw an exception.
Code to Reproduce the Error (Wrong):
from sklearn.ensemble._weight_boosting import AdaBoostClassifier
abc = AdaBoostClassifier(algorithm='alg')
X = np.array([[1, 2], [3, 4]])
y = np.array([1, 2])
abc.fit(X, y)
Error Message:
ValueError Traceback (most recent call last)
<ipython-input-50-a1eb30b3bbb9> in <module>()
4 X = np.array([[1, 2], [3, 4]])
5 y = np.array([1, 2])
----> 6 abc.fit(X, y)
/usr/local/lib/python3.7/dist-packages/sklearn/ensemble/_weight_boosting.py in fit(self, X, y, sample_weight)
433 # Check that algorithm is supported
434 if self.algorithm not in ('SAMME', 'SAMME.R'):
--> 435 raise ValueError("algorithm %s is not supported" % self.algorithm)
436
437 # Fit
ValueError: algorithm alg is not supported
Working Version (Right):
from sklearn.ensemble._weight_boosting import AdaBoostClassifier
abc = AdaBoostClassifier(algorithm='SAMME')
X = np.array([[1, 2], [3, 4]])
y = np.array([1, 2])
abc.fit(X, y)
Successful Output:
AdaBoostClassifier(algorithm='SAMME', base_estimator=None, learning_rate=1.0,
n_estimators=50, random_state=None)
Add a possible fix
Please authorize to post fix