Phi-Koeffizient

term_id: phi_coefficient

Category: basic_concepts

Definition

Der Phi-Koeffizient (φ) ist ein Maß für den Zusammenhang zwischen zwei binären Variablen und dient als Pearson-Korrelationskoeffizient für dichotome Variablen. Er reicht von -1 bis +1, wobei 0 keinen Zusammenhang anzeigt.

Summary

Ein statistisches Maß für den Zusammenhang zwischen zwei binären Variablen.

Key Concepts

  • Binäre Variablen
  • Korrelation
  • Kontingenztabelle
  • Assoziationsstärke

Use Cases

  • Bewertung der Leistung eines binären Klassifizierers über die Genauigkeit hinaus
  • Analyse von Zusammenhängen in Umfragedaten mit Ja/Nein-Antworten
  • Merkmalsauswahl in Datensätzen mit kategorialen Eingaben

Code Example

1
2
3
4
5
6
7
8
import numpy as np
from scipy.stats import chi2_contingency
# Example: Calculate phi coefficient from a 2x2 confusion matrix
tn, fp, fn, tp = 90, 10, 5, 95
matrix = [[tn, fp], [fn, tp]]
chi2, p, dof, expected = chi2_contingency(matrix)
phi = np.sqrt(chi2 / (tn + fp + fn + tp))
print(f'Phi coefficient: {phi:.3f}')