1. Steps for hyperparameter optimization using BayseOpt
Define the objective function
Define parameter space
Define the optimization objective function
define validation function (optional)
Execute the actual optimization process
2. There are three rules in the BayseOpt library that affect the definition of the objective function
3. Code
3.1 Import library and data
#基本工具
import numpy as np
import pandas as pd
import time
import os #修改环境设置
#算法/损失/评估指标等
import sklearn
from sklearn.ensemble import RandomForestRegressor asRFR
from sklearn.model_selection import KFold, cross_validate
#优化器
from bayes_opt import BayesianOptimization
data = pd.read_csv(r"C:\work-file\pythonProject\Demo练习\贝叶斯优化\train_encode.csv",index_col=0)X= data.iloc[:,:-1]
y = data.iloc[:,-1]
Because this library cannot use the random number seed to guarantee the same output every time, the results reproduced by different people may be different.