= w_0 + w_1x_1 + w_2x_2 + \cdots$
import numpy as np
import pandas as pd
target = '타겟명'
x = data.drop(target, axis = 1)
y = data.loc[:, target]
x_train, x_val, y_train, y_val = train_test_split(x, y, test_size = .3, random_state = 2022)
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression # 라이브러리.모듈.함수이름
from sklearn.metrics import *
model = LogisticRegression()
model.fit(x_train, y_train)
pred = model.predict(x_val)
confusion_matrix(y_val, pred)
print(classification_report(y_val, pred)) # print 필수
precision recall f1-score support
0 0.87 0.98 0.92 300
1 0.67 0.24 0.35 59
accuracy 0.86 359
macro avg 0.77 0.61 0.63 359
weighted avg 0.83 0.86 0.83 359
# 정분류율
accuracy_score(y_val, pred)
# 정밀도
precision_score(y_val, pred, pos_label = 1) # pos_label: positive label의 약자. 기준 지정. default=1
# 재현율
recall_score(y_val, pred, pos_label = 1)
# f1 점수
f1_score(y_val, pred, pos_label = 1)