Skip to Content
개발자를 위한 필수 수학
book

개발자를 위한 필수 수학

by 토머스 닐드, 박해선
June 2024
Beginner to intermediate
352 pages
9h 29m
Korean
Hanbit Media, Inc.
Content preview from 개발자를 위한 필수 수학
245
6
로지스틱 회귀와 분류
예제
6-15
로지스틱 회귀 모델의
p
값 계산하기
import pandas as pd
from math import log, exp
from scipy.stats import chi2
patient_data = list(pd.read_csv('https://bit.ly/33ebs2R', delimiter=",").itertuples())
# 훈련된 로지스틱 회귀 모델의 계수
b0 = -3.17576395
b1 = 0.69267212
def logistic_function(x):
p = 1.0 / (1.0 + exp(-(b0 + b1 * x)))
return p
# 훈련 후 로그 가능도 계산하기
log_likelihood_fit = sum(log(logistic_function(p.x)) * p.y +
log(1.0 - logistic_function(p.x)) * (1.0 - p.y)
for p in patient_data)
# 훈련 전 로그 가능도 계산하기
likelihood = sum(p.y for p in patient_data) / len(patient_data)
log_likelihood = sum(log(likelihood) * p.y + log(1.0 - likelihood) * (1.0 - p.y) \
for p in
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AI를 위한 필수 수학

AI를 위한 필수 수학

할라 넬슨

Publisher Resources

ISBN: 9791169212502