Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: min_samples_split must be at least 2 or in (0, 1], got 1 #8041

Closed
avaranovich opened this issue Dec 12, 2016 · 1 comment
Closed

Comments

@avaranovich
Copy link

avaranovich commented Dec 12, 2016

Description

Getting the following error, while trying to specify the min_samples_split parameter, and trying to fit (some featues of X are int, some are float. The type of y is float.)
ValueError: min_samples_split must be at least 2 or in (0, 1], got 1

Steps/Code to Reproduce

from sklearn.grid_search import GridSearchCV
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.metrics import mean_squared_error
from time import time

tuned_params = {'n_estimators': [5000, 10000], 
                'max_depth': [2, 4], 
                'min_samples_split': [1, 2],
                'learning_rate': [0.001, 0.01]}

print("# Tuning hyper-parameters for mean_squared_error")

gscv = GridSearchCV(GradientBoostingRegressor(loss = 'ls', random_state=0), 
                    tuned_params, cv=5, scoring='mean_squared_error')

gscv.fit(X, y)

Versions

Linux-4.4.0-51-generic-x86_64-with-debian-stretch-sid
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
NumPy 1.11.1
SciPy 0.17.1
Scikit-Learn 0.18.1

@jnothman
Copy link
Member

you can't split on a minimum of 1 sample. You can split on a minimum of 1.0 x n_samples samples. That error message should say (0.0, 1.0] (fixed in 96cc49f). If you intended 1.0 you should have used that, not 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants