This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.