I trained a decision tree with weights using RandomizedSearchCV:
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=2019) grid = RandomizedSearchCV(tree, params, n_iter=100, scoring="average_precision", cv=skf, verbose=1, n_jobs=-1, random_state=2019) grid.fit(X_train, y_train, weights)
Then I used
model = grid.best_estimator_ y_pred = model.predict(X_test)
to check model performance on test set. However, when I refitted best estimator:
model = grid.best_estimator_ model.fit(X_train, y_train, weights)
and set the threshold to 0.999, I saw an improvement by almost 10%. My question: Is that aproach correct? Do I have to retrain the model when using weights or is there a way to do it automatically?