Click here to Skip to main content
15,877,966 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

On scikit learn, I run through this issue:
       if not (0 < max_samples <= X.shape[0]):
--> 306             raise ValueError("max_samples must be in (0, n_samples]")
    307 
    308         # Store validated integer row sampling value

ValueError: max_samples must be in (0, n_samples]


However my X.shape[0] is >= max_samples.

#
bgclassifier = BaggingClassifier(base_estimator=pipeline, n_estimators=100,
                                 max_features=10,
                                 max_samples=5,
                                 random_state=1, n_jobs=5)


What I have tried:

I have tried to lookup a solution on stackoverflow but the most similar issue is for max_features.
I changed my max_samples from 10 to 5 to make it equal to X.shape[0].
Posted
Updated 26-Aug-21 21:19pm
Comments
Richard MacCutchan 27-Aug-21 3:37am    
The message is telling you that the value of max_samples is not in the range of the two values you provided.

1 solution

YOu can't say
if a < b < c
Python doesn't understand that and tries to compare the result of a < b with c and gets the wrong result.
Try
if a < b and b < c
 
Share this answer
 
Comments
Richard MacCutchan 27-Aug-21 3:36am    
That is a valid expression in Python; section 6.10 at 6. Expressions — Python 3.9.6 documentation[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900