Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
@avaranovich

Description

@avaranovich

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions