Przejdź do treści
Biblioteka skilli
Dane i analityka · Analiza

imbalanced-data

/imbalanced-data

Obsługuje niezrównoważone klasy przez przesuwanie progu, ważenie i ocenę opartą na krzywej PR zamiast odruchowego resamplingu, gdy klasa pozytywna jest rzadka, a trafność wygląda zwodniczo wysoko.

Repozytorium
AI-SKILLS ↗
Licencja
MIT
Ostatnia zmiana repozytorium
05.09.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 05.09.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Obsługuje niezrównoważone klasy przez przesuwanie progu, ważenie i ocenę opartą na krzywej PR zamiast odruchowego resamplingu, gdy klasa pozytywna jest rzadka, a trafność wygląda zwodniczo wysoko.

Oryginalny opis (EN)

Handle skewed classes with threshold moving, weighting, and PR-based evaluation instead of reflexive resampling. Use when the positive class is rare and accuracy looks deceptively high.

Jak działa

  1. Method
  2. Boundaries
Sekcje z nagłówków SKILL.md, w oryginale · 56 linii, 386 słów
Podgląd SKILL.md
---
name: imbalanced-data
description: Handle skewed classes with threshold moving, weighting, and PR-based evaluation instead of reflexive resampling. Use when the positive class is rare and accuracy looks deceptively high.
---

# Imbalanced data

With 1% positives, "always predict negative" scores 99% accuracy. The
cure is rarely synthetic data; it is evaluating correctly, weighting
costs, and choosing the operating threshold deliberately.

## Method

1. **Fix the evaluation first.** PR curves and PR-AUC, precision and
   recall at the deployment threshold, per the cost table from
   ml-problem-framing; never accuracy, and treat ROC-AUC with
   suspicion at heavy skew (it barely moves when false positives
   grow by thousands against a huge negative pool). Keep the test
   set at the *natural* imbalance whatever you do to train (see
   train-test-discipline).
2. **Move the threshold before touching the data.** A well-calibrated
   model at natural imbalance plus a cost-derived threshold
   (minimize expected cost on validation) solves many "imbalance
   problems" outright. Sweep the threshold, plot cost vs threshold,
   pick the minimum; revisit when costs or base rates change.
3. **Weight before you resample.** Class weights
   (inverse-frequency or cost-ratio) in the loss are equivalent to
   oversampling without duplicating rows, supported natively by most
   learners (`class_weight`, `scale_pos_weight`). This is the
   default second move; it changes nothing about the data pipeline.
4. **Resample only with care, inside the fold.** Random undersampling
   of negatives works at massive scale (and speeds training);
   SMOTE-class synthesis helps sometimes on tabular data and harms
   whenever synthetic points cross the true boundary. All resampling
   fits inside cross-validation folds on train only; resampling
   before splitting leaks duplicated/synthetic neighbors into test
   (see cross-validation).
5. **Recalibrate after any reweighting.** Weights and resampling
   distort predicted probabilities away from true base rates; if
   probabilities feed thresholds or expected values, recalibrate on
   an untouched validation slice (see model-evaluation calibration).
6. **Buy more positives where it is cheapest.** Longer time windows,
   related-event labels, hard-negative mining to sharpen the
   boundary, or targeted labeling of model-uncertain cases (active
   learning); a hundred real positives beat ten thousand synthetic
   ones. At extreme rarity (<0.01%), reconsider the frame: anomaly
   detection or tiered rules-then-model funnels (see
   ml-problem-framing).

## Boundaries

- Imbalance is not the problem when both classes are plentiful in
  absolute terms; a 1:100 ratio with a million positives needs
  nothing special.
- If the minority class is undersampled *in collection* (label bias,
  censoring), no algorithm recovers what was never observed; that is
  a data acquisition problem.
- Base rates drift; a threshold tuned at 1% positives misfires at 3%
  (see drift-monitoring), so monitor the rate itself.

Wersje

RepozytoriumWynikLicencja
Ta strona · Amey-Thakur/AI-SKILLS90MIT
param087/agent-ml-skills100MIT

Migawka bazy z 13.11.2026 · wersja paczki 8f0adaec3cc3 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 85model-evaluation
    Ocenia klasyfikatory i regresory uczciwie: macierz pomyłek, precyzję, czułość, F1, ROC-AUC wobec PR-AUC, kalibrację i przedziały ufności.
  • 100class-imbalance-handling-for-rare-signal-events
    Obsługuje niezbalansowane klasy przy przewidywaniu rzadkich zdarzeń, takich jak zatrzymania handlu lub flash crash: ważenie kosztów, undersampling i rekalibracja prawdopodobieństw.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.