이 질문은 GLM 결과가 인쇄되는 방식, 즉 계수가 인쇄되는 순서에 관한 것입니다. "순서"란이 용어의 통계적 의미를 말하는 것이 아닙니다.
from pandas import *
import statsmodels.api as sm
import patsy as patsy
df = read_csv("http://vincentarelbundock.github.io/Rdatasets/csv/ggplot2/diamonds.csv")
y, X = patsy.dmatrices( 'price ~ cut', data = df )
sm.GLM( y, X, family= sm.families.Gaussian() ).fit().summary()
... 그리고 범주가 정렬 된 아래 출력을 생성합니다.
(보통), 좋음, 이상적, 프리미엄, 매우 좋음
====================================================================================
coef std err z P>|z| [95.0% Conf. Int.]
------------------------------------------------------------------------------------
Intercept 4358.7578 98.788 44.122 0.000 4165.137 4552.379
cut[T.Good] -429.8933 113.849 -3.776 0.000 -653.034 -206.753
cut[T.Ideal] -901.2158 102.412 -8.800 0.000 -1101.939 -700.493
cut[T.Premium] 225.4999 104.395 2.160 0.031 20.889 430.111
cut[T.Very Good] -376.9979 105.164 -3.585 0.000 -583.116 -170.880
====================================================================================
다음과 같이 주문하고 싶습니다.
(보통), 좋음, 매우 좋음, 프리미엄, 이상적
df = read.table( file = "http://vincentarelbundock.github.io/Rdatasets/csv/ggplot2/diamonds.csv",
sep = ",", header = TRUE)
df$cut = factor( df$cut, levels = c("Fair", "Good", "Very Good", "Premium", "Ideal"))
glm( price ~ cut, data = df, family = gaussian )
출력의 순서는 요인 순서를 따릅니다.
(보통), 좋음, 매우 좋음, 프리미엄, 이상적
Call: glm(formula = price ~ cut, family = gaussian, data = df)
Coefficients:
(Intercept) cutGood cutVery Good cutPremium cutIdeal
4358.8 -429.9 -377.0 225.5 -901.2
파이썬에서 어떻게합니까?
이것은 알려진 문제입니다. 나는 PR이 환영받을 것이라고 확신합니다. 여기서 대화를 계속할까요?
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다