Python တွင် cramer's v တွက်ချက်နည်း


Cramer’s V သည် nominal variable နှစ်ခုကြားရှိ ပေါင်းစည်းမှု၏ ခိုင်ခံ့မှုကို အတိုင်းအတာတစ်ခုဖြစ်သည်။

၎င်းသည် 0 မှ 1 ရှိရာ၊

  • 0 သည် ကိန်းရှင်နှစ်ခုကြားတွင် ဆက်စပ်မှုမရှိကြောင်း ညွှန်ပြသည်။
  • 1 သည် ကိန်းရှင်နှစ်ခုကြားတွင် ခိုင်မာသော ဆက်နွယ်မှုကို ညွှန်ပြသည်။

အောက်ပါအတိုင်း တွက်ချက်သည်။

Cramer’s V = √ (X 2 /n) / min(c-1၊ r-1)

ရွှေ-

  • X 2 Chi square ကိန်းဂဏန်း
  • n: စုစုပေါင်းနမူနာအရွယ်အစား
  • r- လိုင်းအရေအတွက်
  • c- ကော်လံအရေအတွက်

ဤသင်ခန်းစာသည် Python ရှိ အရေးပေါ်ဇယားအတွက် Cramer’s V ကို တွက်ချက်ခြင်း၏ ဥပမာအချို့ကို ပေးသည်။

ဥပမာ 1- 2×2 ဇယားအတွက် Cramer’s V

အောက်ပါကုဒ်သည် 2×2 ဇယားအတွက် Cramer’s V တွက်ချက်နည်းကို ပြသသည်-

 #load necessary packages and functions
import scipy. stats as stats
import numpy as np

#create 2x2 table
data = np. array ([[7,12], [9,8]])

#Chi-squared test statistic, sample size, and minimum of rows and columns
X2 = stats. chi2_contingency (data, correction= False )[0]
n = np. sum (data)
minDim = min( data.shape )-1

#calculate Cramer's V
V = np. sqrt ((X2/n) / minDim)

#display Cramer's V
print(V)

0.1617

Cramer’s V သည် 0.1617 ဖြစ်သည်၊ ၎င်းသည် ဇယားရှိ variable နှစ်ခုကြားတွင် အတော်လေးအားနည်းသော ဆက်စပ်မှုကို ညွှန်ပြသည်။

ဥပမာ 2- ပိုကြီးသောဇယားများအတွက် Cramer’s V

မည်သည့်အရွယ်အစားအတွက်မဆို Cramer’s V ကိုတွက်ချက်ရန် CramerV လုပ်ဆောင်ချက်ကို အသုံးပြုနိုင်ကြောင်း သတိပြုပါ။

အောက်ပါကုဒ်သည် Cramer’s V ကို 2 တန်းနှင့် ကော်လံ 3 ခုပါသော ဇယားတစ်ခုအတွက် မည်သို့တွက်ချက်ရမည်ကို ပြသသည်-

 #load necessary packages and functions
import scipy. stats as stats
import numpy as np

#create 2x2 table
data = np. array ([[6,9], [8, 5], [12, 9]])

#Chi-squared test statistic, sample size, and minimum of rows and columns
X2 = stats. chi2_contingency (data, correction= False )[0]
n = np. sum (data)
minDim = min( data.shape )-1

#calculate Cramer's V
V = np. sqrt ((X2/n) / minDim)

#display Cramer's V
print(V)

0.1775

Cramer ၏ V သည် 0.1775 ဖြစ်လာသည်။

ဤဥပမာသည် အတန်း 2 နှင့် ကော်လံ 3 ခုပါသော ဇယားကို အသုံးပြုထားသော်လည်း တူညီသောကုဒ်သည် မည်သည့်အတိုင်းအတာ၏ဇယားအတွက်မဆို အဆင်ပြေကြောင်း သတိပြုပါ။

ထပ်လောင်းအရင်းအမြစ်များ

Python ရှိ Chi Square လွတ်လပ်ရေးစမ်းသပ်မှု
Python တွင် Chi-square goodness-of-fit စမ်းသပ်မှု
Python တွင် Fisher ၏အတိအကျစမ်းသပ်မှု

မှတ်ချက်တစ်ခုထည့်ပါ။

သင့် email လိပ်စာကို ဖော်ပြမည် မဟုတ်ပါ။ လိုအပ်သော ကွက်လပ်များကို * ဖြင့်မှတ်သားထားသည်