In the rasa_nlu function , they call GridSearchCV.fit() with clf.fit() . It triggers some warnings, and I would like to catch and change to find out what causes them:

 Fitting 2 folds for each of 6 candidates, totalling 12 fits /home/mike/Programming/Rasa/myflaskapp/rasaenv/lib/python3.5/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples. 'precision', 'predicted', average, warn_for) /home/mike/Programming/Rasa/myflaskapp/rasaenv/lib/python3.5/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples. 'precision', 'predicted', average, warn_for) /home/mike/Programming/Rasa/myflaskapp/rasaenv/lib/python3.5/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples. 'precision', 'predicted', average, warn_for) /home/mike/Programming/Rasa/myflaskapp/rasaenv/lib/python3.5/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples. 'precision', 'predicted', average, warn_for) /home/mike/Programming/Rasa/myflaskapp/rasaenv/lib/python3.5/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples. 'precision', 'predicted', average, warn_for) /home/mike/Programming/Rasa/myflaskapp/rasaenv/lib/python3.5/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples. 'precision', 'predicted', average, warn_for) [Parallel(n_jobs=1)]: Done 12 out of 12 | elapsed: 0.1s finished 

Here is how GridSearchCV is built:

 cv_splits = self._num_cv_splits(y) #когда я распечатал его, он дал мне «2», мне ожидалось, что что-то более связанное с ярлыками GridSearchCV(SVC(C=1, probability=True, class_weight='balanced'), param_grid=tuned_parameters, n_jobs=num_threads, cv=cv_splits, scoring='f1_weighted', verbose=1) 

Where y is labels that have been converted to numbers.

 y: [1 0 2 1 1 1 1 1 1 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3] labels: ['greet', 'goodbye', 'inform', 'greet', 'greet', 'greet', 'greet', 'greet', 'greet', 'goodbye', 'goodbye', 'goodbye', 'goodbye', 'goodbye', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'inform', 'laughing', 'laughing'] 

Ideally, I would like to find out which warnings were triggered.

Update

At the moment I just tried to get the origin, I still have not found a way to capture the warning:

  y = self.transform_labels_str2num(labels) X = np.stack([example.get("text_features") for example in training_data.intent_examples]) self.clf = self._create_classifier(num_threads, y) try: fit_result = self.clf.fit(X, y) y_pred = self.clf.predict(X) print("set(y)-set(y_pred):\n",set(y)-set(y_pred)) 

But he just gives me an empty set()

Also need to use .predict(X) ? Does it clf.fit() from the clf.fit() results?

    1 answer 1

    This warning indicates that for at least one predictable class, not a single value from this class has been predicted.

    For example, in your case, in the prediction vector there are no elements of one or several classes.

    In such cases, it is impossible to count the F1 Score normally (the metric you have chosen), so the value of F1 Score for such a class is taken as 0.0 .

    To understand which classes are missing in the predictions:

     set(y_test) - set(y_predicted) 
    • Many thanks for this answer! How to create y_predicted ? - ThePassenger
    • @ Marine1, y_predicted = clf.predict (X_test) - MaxU
    • I think this is what I did, but when I set set(y_test) - set set(y_pred) , it is empty. But I have Warnings . Am I mistaken in X_test? I updated the code. - ThePassenger