Text Classification
Transformers
PyTorch
TensorFlow
Safetensors
xlm-roberta
Generated from Trainer
text-embeddings-inference
Instructions to use papluca/xlm-roberta-base-language-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use papluca/xlm-roberta-base-language-detection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("papluca/xlm-roberta-base-language-detection") model = AutoModelForSequenceClassification.from_pretrained("papluca/xlm-roberta-base-language-detection", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
Create Puplica
Browse files
Puplica
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sklearn.metrics import confusion_matrix
|
| 2 |
+
|
| 3 |
+
# Данные
|
| 4 |
+
y_true = [0, 1, 0, 0, 1, 0, 1, 1, 0, 0] # Реальные метки
|
| 5 |
+
y_pred = [0, 0, 0, 0, 1, 0, 1, 1, 0, 1] # Предсказанные метки
|
| 6 |
+
|
| 7 |
+
# Матрица путаницы
|
| 8 |
+
cm = confusion_matrix(y_true, y_pred)
|
| 9 |
+
|
| 10 |
+
# Вывод
|
| 11 |
+
print("Матрица путаницы:")
|
| 12 |
+
print(cm)
|
| 13 |
+
|
| 14 |
+
# Прямой расчет FP и FN
|
| 15 |
+
FP = cm.sum(axis=0) - np.diag(cm) # Ложноположительные
|
| 16 |
+
FN = cm.sum(axis=1) - np.diag(cm) # Ложноотрицательные
|
| 17 |
+
|
| 18 |
+
print("\nФальшивые положительные (FP):", FP)
|
| 19 |
+
print("Фальшивые отрицательные (FN):", FN)
|