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)
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

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 31.6k

Add a possible fix

Please authorize to post fix