[PYTHON]-(07) 데이터 마이닝[로지스틱회귀분석]
로지스틱 회귀분석
로지스틱 회귀는 선형회귀의 종속변수 Y를 연속형에서 범주형으로 확장한 개념이다.
로지스틱 회귀의 목적은 각 범주에 속할 확률을 추정하는 것이고, Y의 범주는 2개 뿐만 아니라 그 이상도 가능하다.
1. 개념
종속변수 Y = 로짓(loggit)으로 표현하고, 범주 0과 1에 속할 확률은 1-p와 p이다.
확률인 p는 당연 [0 ,1] 사이의 값을 갖고, q개의 예측변수들에 대한 선형함수는 아래와 같다.
하지만 우변항의 선형함수는 p가 [0,1] 사이의 값이라는 것을 보장하지 않기 때문에 비선형함수로 만들어줘야한다.
위 식을 로지스틱 반응함수라고 하고, 반드시 [0,1] 사이의 값을 갖는다.
다음은 오즈(odds)에 대한 내용이다.
범주 1에 속할 오즈는 아래와 같이 정의된다.
또한 사건의 오즈가 주어 졌을 때, 아래의 식으로 사건의 확률을 계산할 수 있다.
위 오즈로 구한 사건의 확률식을 비선형함수에 적용하면 오즈는 아래와 같이 정의된다.
위 식은 결과적으로 예측변수와 오즈 사이의 비례관계를 설명해 주고, 이는 백분율로 해석할 수 있다.
즉, 예측변수의 한 단위 증가는 오즈에서 $\beta*100\%$의 증가로 해석하는 것이다.
※ 마치 level - log 변환의 해석과 유사하다.
결과적으로 위 식에서 양쪽에 로그를 취해 표준화된 로지스틱 모형을 얻을 수 있다.
$log(Odds)$는 로짓이라고 부르며 $-\infty부터 \infty$ 사이의 값을 갖는다.
p에 대한 오즈와 로짓함수는 아래와 같다.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import font_manager, rc
# 한글깨짐
font_path = "C:/Windows/Fonts/NGULIM.TTF"
font = font_manager.FontProperties(fname=font_path).get_name()
rc('font', family=font)
plt.figure(figsize=(8,3))
x = np.linspace(-10, 10, 1000)
y = np.exp(x)
plt.subplot(1,2,2)
plt.plot(x,y)
plt.title('오즈')
x = np.linspace(-10, 10, 1000)
y = 1 / (1+np.exp(-x))
plt.subplot(1,2,1)
plt.plot(x,y)
plt.title('로짓')
Text(0.5, 1.0, '로짓')
/output_2_1.png)
2. 예제 : Titanic
[1] survived 생존 여부 0이면 사망, 1이면 생존
[2] pclass 객실 등급 1이면 1등급, 2이면 2등급, 3이면 3등급
[3] sex 성별 male이면 남자, female이면 여자
[4] age 나이
[5] sibsp 함께 탑승한 형제 및 배우자 수
[6] parch 함께 탑승한 자녀 및 부모 수
[7] fare 요금
[8] embarked 탑승지 이름 앞글자 C는 Cherbourg, Q는 Queenstown, S는 Southampton
[9] class 객실 등급 First면 1등급, Second면 2등급, Third면 3등급
[10] who 남자, 여자, 아이 man, woman, child
[11] adult_male 성인 남자인지 여부 True면 성인 남자, False면 그외
[12] deck 선실 번호 첫 알파벳 A, B, C, D, E, F, G
[13] embark_town 탑승지 이름 Cherbourg, Queenstown, Southampton
[14] alive 생존여부 no면 사망, yes면 생존
[15] alone 혼자 탑승했는지 여부 True면 혼자 탑승, False면 가족과 함께 탑승
import statsmodels.api as sm
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats
import math
from matplotlib import font_manager, rc
font_path = "C:/Windows/Fonts/NGULIM.TTF"
font = font_manager.FontProperties(fname=font_path).get_name()
rc('font', family=font)
2.1 데이터 확인 및 전처리
데이터 확인
titanic = sns.load_dataset('titanic')
df = titanic
df.info()
df.head()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 891 entries, 0 to 890
Data columns (total 15 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 survived 891 non-null int64
1 pclass 891 non-null int64
2 sex 891 non-null object
3 age 714 non-null float64
4 sibsp 891 non-null int64
5 parch 891 non-null int64
6 fare 891 non-null float64
7 embarked 889 non-null object
8 class 891 non-null category
9 who 891 non-null object
10 adult_male 891 non-null bool
11 deck 203 non-null category
12 embark_town 889 non-null object
13 alive 891 non-null object
14 alone 891 non-null bool
dtypes: bool(2), category(2), float64(2), int64(4), object(5)
memory usage: 80.7+ KB
| survived | pclass | sex | age | sibsp | parch | fare | embarked | class | who | adult_male | deck | embark_town | alive | alone | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 3 | male | 22.0 | 1 | 0 | 7.2500 | S | Third | man | True | NaN | Southampton | no | False |
| 1 | 1 | 1 | female | 38.0 | 1 | 0 | 71.2833 | C | First | woman | False | C | Cherbourg | yes | False |
| 2 | 1 | 3 | female | 26.0 | 0 | 0 | 7.9250 | S | Third | woman | False | NaN | Southampton | yes | True |
| 3 | 1 | 1 | female | 35.0 | 1 | 0 | 53.1000 | S | First | woman | False | C | Southampton | yes | False |
| 4 | 0 | 3 | male | 35.0 | 0 | 0 | 8.0500 | S | Third | man | True | NaN | Southampton | no | True |
- 데이터 타입이 bool(2), category(2), float64(2), int64(4), object(5)로 상당히 다양하다.
- age, fare을 제외하고 다른 변수 모두는 범주형이다.(sibsp, parch 변수는 범주형에 가깝다)
- age, embarked, deck, embark_town의 결측치가 존재한다.
변수제거 및 형변환
# 1. deck, alive 제거
df.drop(['deck', 'alive', 'class', 'embark_town'],axis=1, inplace=True)
# 2. 결측치 행 제거
df = df.dropna()
# 3. bool과 object형 카테고리# bool과 object형 카테고리형으로 변환
def trans_type(df, before_type_list, after_type):
df[df.select_dtypes(before_type_list).columns] = df.select_dtypes(before_type_list).astype(after_type)
# trans_type(df, ['category','bool'], 'object')
# trans_type(df, ['int'], 'float')
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 712 entries, 0 to 890
Data columns (total 11 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 survived 712 non-null int64
1 pclass 712 non-null int64
2 sex 712 non-null object
3 age 712 non-null float64
4 sibsp 712 non-null int64
5 parch 712 non-null int64
6 fare 712 non-null float64
7 embarked 712 non-null object
8 who 712 non-null object
9 adult_male 712 non-null bool
10 alone 712 non-null bool
dtypes: bool(2), float64(2), int64(4), object(3)
memory usage: 57.0+ KB
-
- 결측치가 너무 많고 class 등으로 대체가능한 deck 변수는 제거한다.
- survived와 alive, pclass와 class, embarked와 embark_town는 동일한 변수이므로 alive와 class, ebmark_town는 제거한다.
-
- 결측치 행 제거, 실제 분석에서는 이와 같이 임의로 제거하면 절대 안됨
-
- 형변환 모듈 생성(필요시 사용) : 현재 딱히 필요하지 않아 보류
- 형변환 모듈 생성(필요시 사용) : 현재 딱히 필요하지 않아 보류
describe에 왜도, 첨도, 결측, 중앙값 추가
def describe(df):
df_stats = df.describe().T
skew_rst = []
kurtosis_rst = []
null_rst = []
median_rst = []
for idx, val in enumerate(df_stats.index):
skew_rst.append(df[val].skew())
kurtosis_rst.append(df[val].kurtosis())
null_rst.append(df[val].isnull().sum())
median_rst.append(df[val].median())
df_stats['skewness'] = skew_rst # 대칭 분포는 왜도 0, 양수인 경우 오른쪽 꼬리가 김, 기준 = 절대값 1임. But 2까지도 허용
df_stats['kurtosis'] = kurtosis_rst # 정규분포의 첨도는 0(원래는 3) = 기준 절대값 7
df_stats['missing'] = null_rst
df_stats['median'] = median_rst
return(df_stats)
# 수치형 변수 확인
describe(df)
| count | mean | std | min | 25% | 50% | 75% | max | skewness | kurtosis | missing | median | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| survived | 712.0 | 0.404494 | 0.491139 | 0.00 | 0.00 | 0.00000 | 1.0 | 1.0000 | 0.390010 | -1.853105 | 0 | 0.00000 |
| pclass | 712.0 | 2.240169 | 0.836854 | 1.00 | 1.00 | 2.00000 | 3.0 | 3.0000 | -0.475604 | -1.410083 | 0 | 2.00000 |
| age | 712.0 | 29.642093 | 14.492933 | 0.42 | 20.00 | 28.00000 | 38.0 | 80.0000 | 0.388881 | 0.187949 | 0 | 28.00000 |
| sibsp | 712.0 | 0.514045 | 0.930692 | 0.00 | 0.00 | 0.00000 | 1.0 | 5.0000 | 2.515107 | 7.018185 | 0 | 0.00000 |
| parch | 712.0 | 0.432584 | 0.854181 | 0.00 | 0.00 | 0.00000 | 1.0 | 6.0000 | 2.614177 | 8.822003 | 0 | 0.00000 |
| fare | 712.0 | 34.567251 | 52.938648 | 0.00 | 8.05 | 15.64585 | 33.0 | 512.3292 | 4.667009 | 31.013377 | 0 | 15.64585 |
df.describe()
| survived | pclass | age | sibsp | parch | fare | |
|---|---|---|---|---|---|---|
| count | 712.000000 | 712.000000 | 712.000000 | 712.000000 | 712.000000 | 712.000000 |
| mean | 0.404494 | 2.240169 | 29.642093 | 0.514045 | 0.432584 | 34.567251 |
| std | 0.491139 | 0.836854 | 14.492933 | 0.930692 | 0.854181 | 52.938648 |
| min | 0.000000 | 1.000000 | 0.420000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 0.000000 | 1.000000 | 20.000000 | 0.000000 | 0.000000 | 8.050000 |
| 50% | 0.000000 | 2.000000 | 28.000000 | 0.000000 | 0.000000 | 15.645850 |
| 75% | 1.000000 | 3.000000 | 38.000000 | 1.000000 | 1.000000 | 33.000000 |
| max | 1.000000 | 3.000000 | 80.000000 | 5.000000 | 6.000000 | 512.329200 |
앞서 얘기했던 것 처럼 진정한 의미의 수치형 데이터는 age, fare이다. 살펴보면
-
- age의 range가 [0.42, 80]인 것으로 보아 소수점이 존재하는 나이가 있는 것으로 확인됨.
-
- fare 변수의 왜도와 첨도에 문제가 존재함 따라서 로그변환 필요성이 존재
로그변환
# 2.로그변환
df[['fare']] = np.log1p(df[['fare']])
# 1. age 변수 소수점 값 확인
df[titanic.age / round(titanic.age) != 1].dropna(axis=0).head(3)
C:\Users\opqrs\AppData\Local\Temp\ipykernel_64080\2683541580.py:2: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
df[['fare']] = np.log1p(df[['fare']])
C:\Users\opqrs\AppData\Local\Temp\ipykernel_64080\2683541580.py:5: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
df[titanic.age / round(titanic.age) != 1].dropna(axis=0).head(3)
| survived | pclass | sex | age | sibsp | parch | fare | embarked | who | adult_male | alone | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 57 | 0 | 3 | male | 28.50 | 0 | 0 | 2.107689 | C | man | True | True |
| 78 | 1 | 2 | male | 0.83 | 0 | 2 | 3.401197 | S | child | False | False |
| 111 | 0 | 3 | female | 14.50 | 1 | 0 | 2.737881 | C | child | False | False |
- age 변수의 소수점이 존재하나 이상치라 판단되지 않음
연속형 변수 히스토그램
# subplot
def subplot_dist(df, row_num, col_num, sns_plot):
plt.figure(figsize=(15, 8))
for idx, col in enumerate(list(df)):
plt.subplot(row_num, col_num, idx+1)
sns_plot(df[col])
temp = df.select_dtypes(['int', 'float'])
temp = df[['age','fare']]
subplot_dist(temp, 1, 2, sns.distplot )
describe(df)
C:\ProgramData\Anaconda3\lib\site-packages\seaborn\distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
warnings.warn(msg, FutureWarning)
C:\ProgramData\Anaconda3\lib\site-packages\seaborn\distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
warnings.warn(msg, FutureWarning)
| count | mean | std | min | 25% | 50% | 75% | max | skewness | kurtosis | missing | median | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| survived | 712.0 | 0.404494 | 0.491139 | 0.00 | 0.000000 | 0.000000 | 1.000000 | 1.000000 | 0.390010 | -1.853105 | 0 | 0.000000 |
| pclass | 712.0 | 2.240169 | 0.836854 | 1.00 | 1.000000 | 2.000000 | 3.000000 | 3.000000 | -0.475604 | -1.410083 | 0 | 2.000000 |
| age | 712.0 | 29.642093 | 14.492933 | 0.42 | 20.000000 | 28.000000 | 38.000000 | 80.000000 | 0.388881 | 0.187949 | 0 | 28.000000 |
| sibsp | 712.0 | 0.514045 | 0.930692 | 0.00 | 0.000000 | 0.000000 | 1.000000 | 5.000000 | 2.515107 | 7.018185 | 0 | 0.000000 |
| parch | 712.0 | 0.432584 | 0.854181 | 0.00 | 0.000000 | 0.000000 | 1.000000 | 6.000000 | 2.614177 | 8.822003 | 0 | 0.000000 |
| fare | 712.0 | 3.038214 | 0.951089 | 0.00 | 2.202765 | 2.812144 | 3.526361 | 6.240917 | 0.546960 | 0.737976 | 0 | 2.812144 |
/output_16_2.png)
- fare의 왜도 첨도가 상당히 완화되었다.
- age 분포에 문제 없음
종속변수 불균형 확인
df.survived.value_counts() / df.survived.value_counts().sum()
0 0.595506
1 0.404494
Name: survived, dtype: float64
종속변수의 클래스는 6:4 비율로 극심한 클래스 불균형은 없는 것으로 파악된다.
종속변수에 다른 범주형 변수 box plot으로 비율 시각화
def subplot_box(df, var_list, row_num, col_num): # var_list의 맨 처음은
plt.figure(figsize=(15,15))
for i in range(len(a)-1):
plt.subplot(row_num, col_num, i+1)
sns.barplot(x=a[i+1], y=a[0], data=df, errwidth=0)
a = ['survived', 'pclass', 'sex', 'sibsp', 'parch', 'who', 'adult_male', 'alone', 'embarked']
subplot_box(df, a, 4, 2)
/output_20_0.png)
범주형 변수 [‘survived’, ‘pclass’, ‘sex’, ‘sibsp’, ‘parch’, ‘who’, ‘adult_male’, ‘alone’] 의 각 범주별 생존률을 살펴보자
- pclass : 등급이 높을 수록 생존률이 높음
- sex : 여성의 생존률이 높음
- sibsp : 동승한 형제, 배우자의 수가 0~2명일 때 상대적으로 생존률이 높음
- parch : 동승한 부모, 자녀의 수가 0~3명일 때 상대적으로 생존률이 높음
- who : 여성 > 아이 > 남성 순으로 생존률이 높음
- adult_male : 남성 성인의 생존률이 낮음
- alone : 혼자 탑승한 고객의 생존률이 낮음
- embarked : 탑승지가 Cherbourg인 경우 생존률이 높음
Label 인코딩
col_list = ['sex','embarked', 'who','adult_male','alone']
def label_encoder(df, col_list):
from sklearn.preprocessing import LabelEncoder
for col in col_list:
lbe = LabelEncoder()
lbe.fit(df[col])
df[col] = lbe.transform(df[col])
label_encoder(df, col_list)
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 712 entries, 0 to 890
Data columns (total 11 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 survived 712 non-null int64
1 pclass 712 non-null int64
2 sex 712 non-null int32
3 age 712 non-null float64
4 sibsp 712 non-null int64
5 parch 712 non-null int64
6 fare 712 non-null float64
7 embarked 712 non-null int32
8 who 712 non-null int32
9 adult_male 712 non-null int64
10 alone 712 non-null int64
dtypes: float64(2), int32(3), int64(6)
memory usage: 58.4 KB
C:\Users\opqrs\AppData\Local\Temp\ipykernel_64080\299364307.py:7: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
df[col] = lbe.transform(df[col])
- 이어서 분석에 용이하도록 문자형 범주형 변수들을 레이블 인코딩해준다.
One-hot 인코딩
df.reset_index(inplace=True)
def oh_encoder(df, col_list):
from sklearn.preprocessing import OneHotEncoder
for col1 in col_list:
ohe = OneHotEncoder(sparse=False)
# fit_transform은 train에만 사용하고 test에는 학습된 인코더에 fit만 해야한다 ex) ohe.transform(test[['col]])
result = ohe.fit_transform(df[[col1]])
result = pd.DataFrame(result, columns=[df[[col1]].columns[0]+'_'+ str(col2) for col2 in ohe.categories_[0]])
df = pd.concat([df, result],axis=1)
return(df)
col_list = ['pclass','sex','embarked','who','adult_male','alone']
df = oh_encoder(df, col_list)
- 이어서 범주형 변수도 분석할 수 있도록 원핫인코딩을 통해 dummy 처리를 해준다.
히트맵 상관관계 확인
# 히트맵으로 상관관계 확인
cmap = sns.diverging_palette(240, 10, n=9, as_cmap=True)
mask = np.zeros_like(df.corr(), dtype=np.bool)
mask[np.triu_indices_from(mask)]=True
df_corr = df.corr()[(df.corr()<=-0.2)&(df.corr()>-1) | (df.corr()>=0.2)&(df.corr()!=1)]
plt.figure(figsize=(20,15))
sns.heatmap(df_corr, annot=True, cmap=cmap, mask=mask, linewidths=.5, fmt='.2f', annot_kws={'size':10})
df_corr.sort_values('survived', ascending=False)[['survived']].dropna()
C:\Users\opqrs\AppData\Local\Temp\ipykernel_64080\3218538142.py:3: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
mask = np.zeros_like(df.corr(), dtype=np.bool)
| survived | |
|---|---|
| adult_male_0 | 0.551151 |
| sex_0 | 0.536762 |
| who_2 | 0.495685 |
| fare | 0.337826 |
| pclass_1 | 0.297908 |
| who | 0.296082 |
| pclass_3 | -0.335364 |
| pclass | -0.356462 |
| sex | -0.536762 |
| sex_1 | -0.536762 |
| adult_male | -0.551151 |
| who_1 | -0.551151 |
| adult_male_1 | -0.551151 |
/output_26_2.png)
-
- sex, audlt_male, who1_1, who_2 변수가 상대적으로 가장 큰 상관관계가 있다.
- sex, audlt_male, who1_1, who_2 변수가 상대적으로 가장 큰 상관관계가 있다.
차원의 저주를 고려하여 변수 제거
df_logit = df.drop(['pclass_1','sex_0','embarked_0','who_0','adult_male_0','alone_0', 'pclass', 'sex', 'embarked', 'who', 'adult_male','alone', 'index'], axis=1)
차원의 저주 문제를 고려하여 원핫인코딩한 변수들 중 첫번째 변수를 제거하고 남은 변수들을 통해 회귀분석을 진행한다.
로지스틱 회귀분석
# 회귀분석을 위한 상수항 추가
df_logit = sm.add_constant(df_logit, has_constant='add')
feature_columns = df_logit.columns.difference(['survived'])
X = df_logit[feature_columns]
y = df.survived
model = sm.Logit(y, X)
result_model = model.fit()
result_model.summary()
Optimization terminated successfully.
Current function value: 0.417964
Iterations 6
| Dep. Variable: | survived | No. Observations: | 712 |
|---|---|---|---|
| Model: | Logit | Df Residuals: | 699 |
| Method: | MLE | Df Model: | 12 |
| Date: | Sun, 27 Nov 2022 | Pseudo R-squ.: | 0.3806 |
| Time: | 21:51:45 | Log-Likelihood: | -297.59 |
| converged: | True | LL-Null: | -480.45 |
| Covariance Type: | nonrobust | LLR p-value: | 6.727e-71 |
| coef | std err | z | P>|z| | [0.025 | 0.975] | |
|---|---|---|---|---|---|---|
| adult_male_1 | -1.4831 | 2.16e+07 | -6.88e-08 | 1.000 | -4.22e+07 | 4.22e+07 |
| age | -0.0263 | 0.010 | -2.654 | 0.008 | -0.046 | -0.007 |
| alone_1 | -0.3413 | 0.327 | -1.044 | 0.296 | -0.982 | 0.299 |
| const | 3.8762 | 1.013 | 3.825 | 0.000 | 1.890 | 5.862 |
| embarked_1 | -0.9173 | 0.609 | -1.505 | 0.132 | -2.112 | 0.277 |
| embarked_2 | -0.3518 | 0.290 | -1.212 | 0.226 | -0.921 | 0.217 |
| fare | 0.1196 | 0.205 | 0.585 | 0.559 | -0.281 | 0.521 |
| parch | -0.2928 | 0.153 | -1.918 | 0.055 | -0.592 | 0.006 |
| pclass_2 | -1.2024 | 0.371 | -3.245 | 0.001 | -1.929 | -0.476 |
| pclass_3 | -2.2326 | 0.436 | -5.125 | 0.000 | -3.086 | -1.379 |
| sex_1 | 0.0377 | 0.568 | 0.066 | 0.947 | -1.076 | 1.151 |
| sibsp | -0.6296 | 0.162 | -3.883 | 0.000 | -0.947 | -0.312 |
| who_1 | -1.4831 | 2.16e+07 | -6.88e-08 | 1.000 | -4.22e+07 | 4.22e+07 |
| who_2 | 0.1886 | 0.491 | 0.384 | 0.701 | -0.774 | 1.151 |
-
- adult_male_1, alone_1, embarked_1, embakred_2, fare, parch, sex_1, who_1, who_2 변수 모두 p-value가 0.05보다 높게 나와 통계적으로 유의한 변수가 아니다.
-
- 최종적으로 age, pclass_2, pclass_3, sibsp 변수가 최종적으로 선택되었다.
- 최종적으로 age, pclass_2, pclass_3, sibsp 변수가 최종적으로 선택되었다.
해석
-
- age가 1살 증가할 때 생존일 Logit이 -1.4831씩 증가하고,
이는 생존할 확률이 exp(-1.4831)=0.2269배 증가함을 의미한다.
- age가 1살 증가할 때 생존일 Logit이 -1.4831씩 증가하고,
-
- pclass_2가 1단위 증가할 때 Logit이 -1.2024 단위 증가하고,
이는 생존할 확률이 exp(-1.2024)=0.3005배 증가함을 의미한다.
- pclass_2가 1단위 증가할 때 Logit이 -1.2024 단위 증가하고,
-
- pclass_3가 1단위 증가할 때 Logit이 -2.2326 단위 증가하고,
이는 생존할 확률이 exp(-2.2326)=0.1072배 증가함을 의미한다.
- pclass_3가 1단위 증가할 때 Logit이 -2.2326 단위 증가하고,
-
- sibsp가 1단위 증가할 때 Logit이 -0.6296 단위 증가하고,
이는 생존할 확률이 exp(-0.6296)=0.5328배 증가함을 의미한다.
- sibsp가 1단위 증가할 때 Logit이 -0.6296 단위 증가하고,
Leave a comment