Spaces:
Running
Running
File size: 16,648 Bytes
db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 e3bf489 db1f0f8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
---
title: Metrics
---
In machine learning, it's essential to evaluate the performance of a model to ensure it's accurate, reliable, and effective. There are various metrics to measure model performance, each with its strengths and limitations. Here's an overview of popular metrics, their pros and cons, and examples of tasks that apply to each.
For a quick [Overview](#overview) of metrics by use cases.
## Accuracy
Accuracy measures the ratio of correctly predicted observation to the total observations.
::: columns
::: {.column width="50%"}
Pros:
* Simplest and most intuitive metric.
:::
::: {.column width="50%"}
Cons:
* Can be misleading in the presence of imbalanced classes.
:::
:::
Example tasks:
* General classification tasks where classes are balanced.
* Entry-level benchmarking
## Mean Squared Error (MSE)
MSE measures the average squared difference between predicted and actual values.
::: columns
::: {.column width="50%"}
Pros:
* Easy to calculate
* Sensitive to outliers
:::
::: {.column width="50%"}
Cons:
* Can be heavily influenced by extreme values
:::
:::
Example tasks:
* Regression tasks, such as predicting house prices or stock prices
* Time series forecasting
## Mean Absolute Error (MAE)
MAE measures the average absolute difference between predicted and actual values.
::: columns
::: {.column width="50%"}
Pros:
* Robust to outliers
* Easy to interpret
:::
::: {.column width="50%"}
Cons:
* Can be sensitive to skewness in the data
:::
:::
Example tasks:
* Regression tasks, such as predicting house prices or stock prices
* Time series forecasting
## Mean Absolute Percentage Error (MAPE)
MAPE measures the average absolute percentage difference between predicted and actual values.
::: columns
::: {.column width="50%"}
Pros:
* Easy to interpret
* Sensitive to relative errors
:::
::: {.column width="50%"}
Cons:
* Can be sensitive to outliers
:::
:::
Example tasks:
* Regression tasks, such as predicting house prices or stock prices
* Time series forecasting
## Binary Crossentropy
Binary Crossentropy measures the error rate between the true label and the predicted probability for binary classification tasks.
::: columns
::: {.column width="50%"}
Pros:
* Effective for measuring performance on binary classification problems.
* Directly optimizes the classification threshold.
:::
::: {.column width="50%"}
Cons:
* Not suitable for multi-class classification tasks.
* Sensitive to the balance of classes in the dataset.
:::
:::
Example tasks:
* Predicting customer churn (yes or no).
* Medical diagnostics with binary outcomes.
## Categorical Crossentropy
Categorical Crossentropy is used to measure the error rate between the true label and the predicted probabilities for multi-class classification tasks where each class is mutually exclusive.
::: columns
::: {.column width="50%"}
Pros:
* Well-suited for multi-class classification problems.
* Directly optimizes probability distribution across all classes.
:::
::: {.column width="50%"}
Cons:
* Requires one-hot encoding of labels.
* Can be computationally intensive with many class labels.
:::
:::
Example tasks:
* Image classification with multiple classes.
* Text classification into various categories.
## Sparse Categorical Crossentropy
Sparse Categorical Crossentropy is similar to Categorical Crossentropy but used for multi-class classification tasks where the classes are encoded as integers, not one-hot vectors.
::: columns
::: {.column width="50%"}
Pros:
* More memory efficient than Categorical Crossentropy when dealing with many classes.
* Eliminates the need for one-hot encoding of labels.
:::
::: {.column width="50%"}
Cons:
* Not suitable for problems where multiple categories may be applicable to a single observation.
* Requires careful handling of class indices to ensure they are mapped correctly.
:::
:::
Example tasks:
* Classifying news articles into a predefined set of topics.
* Recognizing the type of product from its description in a single-label system.
## R-Squared (R²)
R² measures the proportion of variance in the dependent variable that's explained by the independent variables.
::: columns
::: {.column width="50%"}
Pros:
* Easy to interpret
* Sensitive to the strength of the relationship
:::
::: {.column width="50%"}
Cons:
* Can be sensitive to outliers
* Can be misleading for non-linear relationships
:::
:::
Example tasks:
* Regression tasks, such as predicting house prices or stock prices
* Feature selection
## Brier Score
The Brier Score measures the average squared difference between predicted and actual probabilities.
::: columns
::: {.column width="50%"}
Pros:
* Sensitive to the quality of the predictions
* Can handle multi-class classification tasks
:::
::: {.column width="50%"}
Cons:
* Can be sensitive to the choice of threshold
:::
:::
Example tasks:
* Multi-class classification tasks, such as image classification
* Multi-label classification tasks
## F1 Score
The F1 Score measures the harmonic mean of precision and recall.
::: columns
::: {.column width="50%"}
Pros:
* Sensitive to the balance between precision and recall
* Can handle imbalanced datasets
:::
::: {.column width="50%"}
Cons:
* Can be sensitive to the choice of threshold
:::
:::
Example tasks:
* Binary classification tasks, such as spam detection
* Multi-class classification tasks
## Matthews Correlation Coefficient (MCC)
MCC measures the correlation between predicted and actual labels.
::: columns
::: {.column width="50%"}
Pros:
* Sensitive to the quality of the predictions
* Can handle imbalanced datasets
:::
::: {.column width="50%"}
Cons:
* Can be sensitive to the choice of threshold
:::
:::
Example tasks:
* Binary classification tasks, such as spam detection
* Multi-class classification tasks
## Log Loss
Log Loss measures the average log loss between predicted and actual probabilities.
::: columns
::: {.column width="50%"}
Pros:
* Sensitive to the quality of the predictions
* Can handle multi-class classification tasks
:::
::: {.column width="50%"}
Cons:
* Can be sensitive to the choice of threshold
:::
:::
Example tasks:
* Multi-class classification tasks, such as image classification
* Multi-label classification tasks
## Area Under the Receiver Operating Characteristic Curve (AUC-ROC)
The AUC-ROC curve is a performance measurement for classification problems at various threshold settings.
::: columns
::: {.column width="50%"}
Pros:
* Measures the ability of the model to discriminate between classes.
* Useful for binary classification problems.
:::
::: {.column width="50%"}
Cons:
* Less effective when dealing with highly imbalanced datasets.
* Does not differentiate between types of errors.
:::
:::
Example tasks:
* Medical diagnosis classification.
* Spam detection in emails.
## Area Under the Precision-Recall Curve (AUC-PR)
The AUC-PR summarizes the precision-recall curve as a single number, which is the weighted average of precisions achieved at each threshold.
::: columns
::: {.column width="50%"}
Pros:
* Focuses on the positive class more than AUC-ROC, useful in imbalanced datasets.
:::
::: {.column width="50%"}
Cons:
* More complex to interpret and explain than AUC-ROC.
:::
:::
Example tasks:
* Information retrieval.
* Ranking tasks where positive class prevalence is low.
## Precision and Recall
Precision measures the ratio of correctly predicted positive observations to the total predicted positives. Recall measures the ratio of correctly predicted positive observations to all observations in actual class.
::: columns
::: {.column width="50%"}
Pros:
* Provide a more detailed understanding of model performance than accuracy, especially in imbalanced datasets.
:::
::: {.column width="50%"}
Cons:
* High precision can sometimes be achieved at the expense of recall, and vice versa (precision-recall trade-off).
:::
:::
Example tasks:
* Document classification.
* Customer churn prediction.
## Cohen’s Kappa
Cohen’s Kappa measures the agreement between two raters who each classify N items into C mutually exclusive categories.
::: columns
::: {.column width="50%"}
Pros:
* Accounts for the possibility of the agreement occurring by chance.
* More robust than simple accuracy.
:::
::: {.column width="50%"}
Cons:
* Can be difficult to interpret, especially with multiple classes.
:::
:::
Example tasks:
* Multi-rater reliability test.
* Medical image classification where multiple doctors provide diagnoses.
Here's the explanation of the additional metrics (BLEU, ROUGE, METEOR, MCC, Precision@k, Recall@k) in the format used previously in your document.
---
## BLEU (Bilingual Evaluation Understudy)
BLEU is a metric used to evaluate the quality of text which has been machine-translated from one natural language to another.
::: columns
::: {.column width="50%"}
Pros:
* Provides a quantitative measure for the quality of machine translation.
* Widely used and easy to compute.
:::
::: {.column width="50%"}
Cons:
* May not capture the fluency and grammaticality of the translation.
* Focuses more on precision than recall.
:::
:::
Example tasks:
* Machine translation evaluation.
* Automated text generation assessment.
## ROUGE (Recall-Oriented Understudy for Gisting Evaluation)
ROUGE is used to evaluate automatic summarization of texts as well as machine translation.
::: columns
::: {.column width="50%"}
Pros:
* Measures both the quality and quantity of match between reference and generated summaries.
* Supports evaluation of multiple types of summaries (extractive, abstractive).
:::
::: {.column width="50%"}
Cons:
* Can be biased towards extractive summarization techniques.
* Depends heavily on the quality of reference summaries.
:::
:::
Example tasks:
* Text summarization.
* Machine translation evaluation.
## METEOR (Metric for Evaluation of Translation with Explicit ORdering)
METEOR is a metric for evaluating machine translation that extends beyond simple overlap of vocabulary.
::: columns
::: {.column width="50%"}
Pros:
* Incorporates synonyms, stemming, and paraphrase matching.
* Aligns closely with human judgment compared to BLEU.
:::
::: {.column width="50%"}
Cons:
* More complex to compute than BLEU.
* Can require extensive linguistic resources.
:::
:::
Example tasks:
* Machine translation.
* Natural language generation.
## Matthews Correlation Coefficient (MCC)
MCC is a measure of the quality of binary classifications.
::: columns
::: {.column width="50%"}
Pros:
* Provides a balanced measure even if classes are of very different sizes.
* Considers true and false positives and negatives.
:::
::: {.column width="50%"}
Cons:
* Not applicable to multi-class classifications.
* Can be difficult to interpret in non-binary classification contexts.
:::
:::
Example tasks:
* Binary classification tasks such as spam detection.
* Medical imaging classification.
## Precision-k
Precision-k measures the proportion of relevant items found in the top-k recommendations of a system.
::: columns
::: {.column width="50%"}
Pros:
* Useful for evaluating ranking systems where the order of items is important.
* Easy to understand and implement.
:::
::: {.column width="50%"}
Cons:
* Does not consider the actual ranking of items beyond the cutoff of k.
* Sensitive to the choice of k.
:::
:::
Example tasks:
* Recommender systems.
* Search engine result ranking.
## Recall-k
Recall-k measures the proportion of relevant items that appear in the top-k recommendations out of all relevant items.
::: columns
::: {.column width="50%"}
Pros:
* Indicates the ability of a system to retrieve highly relevant items.
* Useful for systems where retrieving most relevant items is critical.
:::
::: {.column width="50%"}
Cons:
* Like precision-k, it is sensitive to the choice of k.
* Does not account for the relevance of items outside the top k.
:::
:::
Example tasks:
* Information retrieval.
* Content-based filtering in recommender systems.
## Overview
Below is a table outlining typical example cases in machine learning and the corresponding metrics that could be effectively used for evaluating model performance in each case. This table helps in quickly identifying which metrics are most applicable for a given type of task.
| Use Case | Relevant Metrics |
|------------------------------------------|---------------------------------------------------------------------------------------|
| **Predicting House Prices** | MSE, MAE, R² |
| **Stock Price Forecasting** | MSE, MAE, R² |
| **Medical Diagnosis Classification** | Accuracy, F1 Score, AUC-ROC, Cohen’s Kappa |
| **Spam Detection** | Precision, Recall, F1 Score, MCC, AUC-ROC |
| **Image Classification** | Accuracy, F1 Score, Brier Score, Log Loss, AUC-ROC |
| **Multi-label Classification** | F1 Score, Brier Score, Log Loss, AUC-PR |
| **Customer Churn Prediction** | Accuracy, Precision, Recall, F1 Score |
| **Document Classification** | Accuracy, Precision, Recall, F1 Score |
| **Ranking Tasks** | AUC-PR, Log Loss |
| **Multi-rater Reliability Tests** | Cohen’s Kappa |
| **Multi-class Text Classification** | Categorical Crossentropy, Sparse Categorical Crossentropy, Accuracy, F1 Score |
| **Binary Classification of Customer Data** | Binary Crossentropy, Accuracy, Precision, Recall, F1 Score |
| **Sentiment Analysis** | Accuracy, Precision, Recall, F1 Score, MAE, Log Loss |
| **Time Series Forecasting** | MSE, MAE, R², MAPE |
| **Anomaly Detection** | F1 Score, Precision, Recall, MCC |
| **Search Engine Ranking** | Precision-k, Recall-k, AUC-ROC, AUC-PR |
| **Natural Language Generation** | BLEU, ROUGE, METEOR |
| **Recommendation Systems** | Precision, Recall, F1 Score, AUC-ROC |
| **Real-time Bidding in Advertising** | Log Loss, ROC AUC |
| **User Engagement Prediction** | MSE, MAE, Log Loss, Brier Score |
| **Protein Structure Prediction** | Accuracy, MCC, F1 Score |
| **Drug Response Modeling** | MSE, MAE, R², Log Loss |
| **Credit Scoring** | AUC-ROC, Precision, Recall, F1 Score, Log Loss |
| **Fraud Detection** | Accuracy, Precision, Recall, F1 Score, AUC-ROC |
Each task is paired with metrics that are most appropriate based on the nature of the data and the specific requirements of the task.
This approach helps ensure that the evaluation of a model is not only accurate but also relevant to the goals of the analysis. |