python - Scikit learn Error Message 'Precision and F-score are ill-defined and being set to 0.0 in labels' -
im working on binary classification model, classifier naive bayes. have balanced dataset following error message when predict:
undefinedmetricwarning: precision , f-score ill-defined , being set 0.0 in labels no predicted samples. 'precision', 'predicted', average, warn_for)
i'm using gridsearch cv k-fold 10. test set , predictions contain both classes, don't understand message. i'm working on same dataset, train/test split, cv , random seed 6 other models , work perfect. data ingested externally dataframe, randomize , seed fixed. naive bayes classification model class file @ beginning of before code snippet.
x_train, x_test, y_train, y_test, len_train, len_test = \ train_test_split(data['x'], data['y'], data['len'], test_size=0.4) pipeline = pipeline([ ('classifier', multinomialnb()) ]) cv=stratifiedkfold(len_train, n_folds=10) len_train = len_train.reshape(-1,1) len_test = len_test.reshape(-1,1) params = [ {'classifier__alpha': [0, 0.0001, 0.001, 0.01]} ] grid = gridsearchcv( pipeline, param_grid=params, refit=true, n_jobs=-1, scoring='accuracy', cv=cv, ) nb_fit = grid.fit(len_train, y_train) preds = nb_fit.predict(len_test) print(confusion_matrix(y_test, preds, labels=['1','0'])) print(classification_report(y_test, preds))
i 'forced' python alter shape of series, maybe culprit?
Comments
Post a Comment