gridsearchcv

Get individual models and customized score in GridSearchCV and RandomizedSearchCV [duplicate]

邮差的信 提交于 2020-07-20 04:33:46
问题 This question already has an answer here : Retrieving specific classifiers and data from GridSearchCV (1 answer) Closed 3 days ago . GridSearchCV and RandomizedSearchCV has best_estimator_ that : Returns only the best estimator/model Find the best estimator via one of the simple scoring methods : accuracy, recall, precision, etc. Evaluate based on training sets only I would like to enrich those limitations with My own definition of scoring methods Evaluate further on test set rather than

Optimise custom gaussian processes kernel in scikit using gridsearch

人走茶凉 提交于 2020-06-17 09:51:11
问题 I'm working with Gaussian processes and when I use the scikit-learn GP modules I struggle to create and optimise custom kernels using gridsearchcv . The best way to describe this problem is using the classic Mauna Loa example where the appropriate kernel is constructed using a combination of already defined kernels such as RBF and RationalQuadratic . In that example the parameters of the custom kernel are not optimised but treated as given. What if I wanted to run a more general case where I

Why we should call split() function during passing StratifiedKFold() as a parameter of GridSearchCV?

醉酒当歌 提交于 2020-06-16 05:55:26
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 12 days ago . What I am trying to do? I am trying to use StratifiedKFold() in GridSearchCV() . Then, what does confuse me? When we use K Fold Cross Validation, we just pass the number of CV inside GridSearchCV() like the following. grid_search_m = GridSearchCV(rdm_forest_clf, param_grid, cv=5, scoring='f1', return_train_score=True, n_jobs=2) Then, when I will need to use StratifiedKFold() ,

How to plot sklearn's GridSearchCV results vs params?

北城以北 提交于 2020-04-13 14:58:26
问题 def show3D(searcher, grid_param_1, grid_param_2, name_param_1, name_param_2, rot=0): scores_mean = searcher.cv_results_['mean_test_score'] scores_mean = np.array(scores_mean).reshape(len(grid_param_2), len(grid_param_1)) scores_sd = searcher.cv_results_['std_test_score'] scores_sd = np.array(scores_sd).reshape(len(grid_param_2), len(grid_param_1)) print('Best params = {}'.format(searcher.best_params_)) print('Best score = {}'.format(scores_mean.max())) _, ax = plt.subplots(1,1) # Param1 is

How to plot sklearn's GridSearchCV results vs params?

*爱你&永不变心* 提交于 2020-04-13 14:54:26
问题 def show3D(searcher, grid_param_1, grid_param_2, name_param_1, name_param_2, rot=0): scores_mean = searcher.cv_results_['mean_test_score'] scores_mean = np.array(scores_mean).reshape(len(grid_param_2), len(grid_param_1)) scores_sd = searcher.cv_results_['std_test_score'] scores_sd = np.array(scores_sd).reshape(len(grid_param_2), len(grid_param_1)) print('Best params = {}'.format(searcher.best_params_)) print('Best score = {}'.format(scores_mean.max())) _, ax = plt.subplots(1,1) # Param1 is

How to plot sklearn's GridSearchCV results vs params?

拈花ヽ惹草 提交于 2020-04-13 14:52:13
问题 def show3D(searcher, grid_param_1, grid_param_2, name_param_1, name_param_2, rot=0): scores_mean = searcher.cv_results_['mean_test_score'] scores_mean = np.array(scores_mean).reshape(len(grid_param_2), len(grid_param_1)) scores_sd = searcher.cv_results_['std_test_score'] scores_sd = np.array(scores_sd).reshape(len(grid_param_2), len(grid_param_1)) print('Best params = {}'.format(searcher.best_params_)) print('Best score = {}'.format(scores_mean.max())) _, ax = plt.subplots(1,1) # Param1 is

What can I do to change dot in comma?

北慕城南 提交于 2020-03-04 23:16:22
问题 Good morning! I'm new of python, I use Spyder 4.0 to build neural network. In the script below I use the random forest in order to do feature importances. So the values importances are the ones that tell me what is the importance of each features. Unfortunatly I can't upload the dataset, but I can tell you that there are 18 features and 1 label, both are phisical quantyties and it's a regression problem. I want to export in a excel file the variable importances , but when I do it (simply

What can I do to change dot in comma?

和自甴很熟 提交于 2020-03-04 23:15:59
问题 Good morning! I'm new of python, I use Spyder 4.0 to build neural network. In the script below I use the random forest in order to do feature importances. So the values importances are the ones that tell me what is the importance of each features. Unfortunatly I can't upload the dataset, but I can tell you that there are 18 features and 1 label, both are phisical quantyties and it's a regression problem. I want to export in a excel file the variable importances , but when I do it (simply

make custom scorer with GridSearchCV

╄→гoц情女王★ 提交于 2019-12-13 18:13:09
问题 I have the code below where I’m trying to use a custom scorer I defined “custom_loss_five” with GridSearchCV to tune hyper parameters. I have the example code below. I also have some sample data. I’m getting an error 'numpy.dtype' object has no attribute 'base_dtype’. I think this is because I’m mixing keras code with sklearn. I’m also using this same “custom_loss_five” function to train a neural network. So that’s why I used keras. If anyone could point out the issue and let me know how to

How to get the selected features in GridSearchCV in sklearn in python

只谈情不闲聊 提交于 2019-12-10 17:03:49
问题 I am using recurive feature elimination with cross validation (rfecv) as the feature selection technique with GridSearchCV . My code is as follows. X = df[my_features_all] y = df['gold_standard'] x_train, x_test, y_train, y_test = train_test_split(X, y, random_state=0) k_fold = StratifiedKFold(n_splits=5, shuffle=True, random_state=0) clf = RandomForestClassifier(random_state = 42, class_weight="balanced") rfecv = RFECV(estimator=clf, step=1, cv=k_fold, scoring='roc_auc') param_grid = {