Напомним, точность Multiclass модель
Я хочу вычислить точность отзыва в контексте мультикласса:
def GetDocument(link):
dataframe = pd.read_csv(link, encoding = "ISO-8859-1", sep = ',')
return dataframe
Y_test = GetDocument('lstm_res.csv')
y_score = GetDocument('cnn_res.csv')
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import average_precision_score
# For each class
precision = dict()
recall = dict()
average_precision = dict()
for i in range(n_classes):
precision[i], recall[i], _ = precision_recall_curve(Y_test[:, i],
y_score[:, i])
average_precision[i] = average_precision_score(Y_test[:, i], y_score[:, i])
# A "micro-average": quantifying score on all classes jointly
precision["micro"], recall["micro"], _ = precision_recall_curve(Y_test.ravel(),
y_score.ravel())
average_precision["micro"] = average_precision_score(Y_test, y_score,
average="micro")
print('Average precision score, micro-averaged over all classes: {0:0.2f}'
.format(average_precision["micro"]))
Однако я получаю следующую ошибку:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-319cf7b60667> in <module>()
7 average_precision = dict()
8 for i in range(110):
----> 9 precision[i], recall[i], _ = precision_recall_curve(Y_test[:, i],
10 y_score[:, i])
11 average_precision[i] = average_precision_score(Y_test[:, i], y_score[:, i])
/export/home/opt/jupyterhub/conda/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
2137 return self._getitem_multilevel(key)
2138 else:
-> 2139 return self._getitem_column(key)
2140
2141 def _getitem_column(self, key):
/export/home/opt/jupyterhub/conda/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_column(self, key)
2144 # get column
2145 if self.columns.is_unique:
-> 2146 return self._get_item_cache(key)
2147
2148 # duplicate columns & possible reduce dimensionality
/export/home/opt/jupyterhub/conda/lib/python3.6/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
1838 """Return the cached item, item represents a label indexer."""
1839 cache = self._item_cache
-> 1840 res = cache.get(item)
1841 if res is None:
1842 values = self._data.get(item)
TypeError: unhashable type: 'slice'
Несколько советов? Спасибо