Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Conversation

@felipeapcar
Copy link

Most recent numpy version works with np.int64 or np.int32 insted of just np.int, thats was generating an error when using class spaces.

#Test
from sklearn.ensemble import GradientBoostingClassifier
from skopt import BayesSearchCV
from skopt.space import Real, Categorical, Integer
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

Cargar el dataset de iris

iris = load_iris()

Dividir los datos en entrenamiento y prueba

X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.3, random_state=42)

Definir el modelo de árbol de decisiones

clf = GradientBoostingClassifier()

param_space = {
'learning_rate': Real(1e-5, 1, prior = 'log-uniform'),
'n_estimators': Integer(20, 1_500),
'subsample': Real(0.05, 1),
'max_depth': Integer(1, 10),
}

Realizar la búsqueda bayesiana

bayes_dt = BayesSearchCV(clf, param_space, n_iter=50, cv=5, n_jobs=-1)

Ajustar el modelo

bayes_dt.fit(X_train, y_train)

Imprimir los mejores hiperparámetros y la puntuación del modelo

print('Mejores hiperparámetros:', bayes_dt.best_params_)
print('Puntuación del modelo:', bayes_dt.best_score_)

#End of test

If you keep using np.int insted of np.int64 or np.int32 thats will show an error saying that numpy has no method called int.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.