I'm having a problem generating a graph using Python - Machine Learning - Naive Bayes model - I would plot an F1 for the different values of K, below we have the classifier that gives me the following outputs:
Mean Accuracy: 0.896551724138, Mean Precision: 0.63, Mean Recall: 0.425, Mean f1: 0.486031746032.
Naive Bayes Classifier
pipe = Pipeline([
('scaler', StandardScaler()),
('selector', SelectKBest()),
('reducer', PCA(random_state=42)),
('classifier', GaussianNB())
])
param_grid = {
'scaler': SCALER,
'selector__k': SELECTOR__K,
'reducer__n_components': REDUCER__N_COMPONENTS
}
# sss = StratifiedShuffleSplit
gnb_grid = GridSearchCV(pipe, param_grid, scoring='f1', cv=sss)
evaluate_model(gnb_grid, X, y, sss)
test_classifier(gnb_grid.best_estimator_, my_dataset, features_list)
Regardless of the data I used I would like to generate a graph with y = f1 score (cross validation) and x = K Best Features, the code below I tried contains an error and only shows me the graph but the data does not appear.
gnb_grid = []
# Plot number of features VS. cross-validation scores
plt.figure()
plt.xlabel("K Best Features")
plt.ylabel("f1 score (cross validation)")
plt.plot(gnb_grid, k_features)
plt.show()
I need to generate one like this from the photo. Thank you for any help you can get.