我正在努力解决这个问题。我有一个看起来像这样的熊猫数组
delta_n column_1 ...
0 10 10 ...
1 20 0
2 30 0
Run Code Online (Sandbox Code Playgroud)
现在我有一个数字,假设我搜索delta_n=20.5并且我想选择最接近 delta_n 数字的行。
我的输出应该是:
1 20 0
Run Code Online (Sandbox Code Playgroud)
我试过了,df.loc[20.5]但因为它不在 pd 数据框中,所以它不起作用。
谢谢,R
我有几个关于随机森林回归模型中的随机网格搜索的问题。我的参数网格如下所示:
random_grid = {'bootstrap': [True, False],
'max_depth': [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, None],
'max_features': ['auto', 'sqrt'],
'min_samples_leaf': [1, 2, 4],
'min_samples_split': [2, 5, 10],
'n_estimators': [130, 180, 230]}
Run Code Online (Sandbox Code Playgroud)
和我的 RandomizedSearchCV 代码如下:
# Use the random grid to search for best hyperparameters
# First create the base model to tune
from sklearn.ensemble import RandomForestRegressor
rf = RandomForestRegressor()
# Random search of parameters, using 3 fold cross validation,
# search across 100 different combinations, and use …Run Code Online (Sandbox Code Playgroud)