votes up 1

max value is less than min value

Package:
Exception Class:
ValueError

Raise code

        Invariants can later be validated against particular implementations by
        calling :meth:`IInterface.validateInvariants`.

        For example::

             def check_range(ob):
                 if ob.max < ob.min:
                     raise ValueError("max value is less than min value")

             class IRange(Interface):
                 min = Attribute("The min value")
                 max = Attribute("The max value")

                 invariant(check_range)
🙏 Scream for help to Ukraine
Today, 2nd July 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Ways to fix

votes up 0 votes down

Summary: When calling the partial_fit method of the SGD classifier make sure that the early stopping is set to false.

Code to reproduce the error:

import numpy as np
from sklearn.linear_model import SGDClassifier
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import make_pipeline


X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
Y = np.array([1, 1, 2, 2])
# here we are initializing SGD classifier with early_stopping set to True
clf = SGDClassifier(max_iter=1000, tol=1e-3,early_stopping=True) 
clf.partial_fit(X, Y,classes=[1,2])
print(sgd.predict([[-0.8, -1]]))

Fixed working code.

import numpy as np
from sklearn.linear_model import SGDClassifier
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import make_pipeline


X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
Y = np.array([1, 1, 2, 2])
# here we are initializing SGD classifier with early_stopping set to False
clf = SGDClassifier(max_iter=1000, tol=1e-3,early_stopping=False)
clf.partial_fit(X, Y,classes=[1,2])
print(clf.predict([[-0.8, -1]]))
May 18, 2021 kellemnegasi answer
kellemnegasi 30.0k

Add a possible fix

Please authorize to post fix