Поэтому мои данные несбалансированы, поскольку 1190 экземпляров помечены цифрой 5. Для классификации я использую SVC от scikit. Проблема в том, что я не знаю, как правильно сбалансировать свои данные, чтобы точно вычислить точность, отзыв, точность и показатель f1 для многоклассового случая. Поэтому я попробовал следующие подходы:
Сначала:
clf = SVC(kernel='linear', C= 1)
clf.fit(X, y)
prediction = clf.predict(X_test)
from sklearn.metrics import precision_score, \
recall_score, confusion_matrix, classification_report, \
accuracy_score, f1_score
print 'Accuracy:', accuracy_score(y_test, prediction)
print 'F1 score:', f1_score(y_test, prediction)
print 'Recall:', recall_score(y_test, prediction)
print 'Precision:', precision_score(y_test, prediction)
print '\n clasification report:\n', classification_report(y_test,prediction)
print '\n confussion matrix:\n',confusion_matrix(y_test, prediction)
F1 score:/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:676: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1".
sample_weight=sample_weight)
/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1172: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1".
sample_weight=sample_weight)
/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1082: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1".
sample_weight=sample_weight)
0.930416613529
/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1172:
DeprecationWarning: The default `weighted` averaging is deprecated,
and from version 0.18, use of precision, recall or F-score with
multiclass or multilabel data or pos_label=None will result in an
exception. Please set an explicit value for `average`, one of (None,
'micro', 'macro', 'weighted', 'samples'). In cross validation use, for
instance, scoring="f1_weighted" instead of scoring="f1"
Как правильно работать с несбалансированными данными, чтобы правильно вычислить показатели классификатора?
Я работаю над задачей анализа настроений, данные выглядят так: [code]label instances 5 1190 4 838 3 239 1 204 2 127 [/code] Поэтому мои данные несбалансированы, поскольку 1190 экземпляров помечены цифрой 5. Для классификации я использую SVC от scikit. Проблема в том, что я не знаю, как правильно сбалансировать свои данные, чтобы точно вычислить точность, отзыв, точность и показатель f1 для многоклассового случая. Поэтому я попробовал следующие подходы: Сначала: [code]wclf = SVC(kernel='linear', C= 1, class_weight={1: 10}) wclf.fit(X, y) weighted_prediction = wclf.predict(X_test)
F1 score:/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:676: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1". sample_weight=sample_weight) /usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1172: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1". sample_weight=sample_weight) /usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1082: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1". sample_weight=sample_weight) 0.930416613529 [/code] Однако я получаю такие предупреждения: [code]/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1172: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1" [/code] Как правильно работать с несбалансированными данными, чтобы правильно вычислить показатели классификатора?
Использование Scikit-learn для классификации бинарной проблемы. Получение идеальной классификации_репорта (все 1's). И все же прогноз дает 0,36 . Как это может быть? Тем не менее, я не думаю, что это так, так как F1 и другие столбцы оценки, а также...
function st_makeenvelope (двойная точность, двойная точность, двойная точность, двойная точность, целое число) не существует
Подсказка: Никакая функция не соответствует данным имени и типам аргументов. Вам может потребоваться добавить явные типы....
У меня есть классификатор 6 классов. Моими целевыми классами будут классы 1 и 2. Могу ли я суммировать значения TP, FN, FP классов 1 и 2 и вычислить точность и отзыв на основе совокупных значений? Или мне нужно будет вернуться к классификатору и...
Я работаю над проектом по прогнозированию должностей на основе набора данных, содержащего 39 функций и 33 уникальных должностей в качестве целевых меток. Набор данных содержит 20 000 строк и включает как числовые, так и категориальные столбцы.
Вот...
Я использую модель Yolov8 для обучения, и у меня есть собственный набор данных для этого.
Но есть проблема с набором данных, мой набор данных не сбалансирован, и по этой причине я не получаю необходимых результатов, я имею в виду, что я не получаю...