import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
'ignore')
warnings.filterwarnings(
= pd.read_csv('_data/08.csv')
dataset = dataset.iloc[:, :-1].values
x = dataset.iloc[:, -1].values y
Logistic Regression
machine learning
preprocessing
from sklearn.model_selection import train_test_split
= train_test_split(x, y, test_size=0.25) x_train, x_test, y_train, y_test
from sklearn.preprocessing import StandardScaler
= StandardScaler()
sc
= sc.fit_transform(x_train)
x_train = sc.transform(x_test) x_test
Modeling
from sklearn.linear_model import LogisticRegression
= LogisticRegression()
classifier classifier.fit(x_train, y_train)
LogisticRegression()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
LogisticRegression()
Predict
from sklearn.metrics import confusion_matrix, accuracy_score
= classifier.predict(x_test)
y_pred print(confusion_matrix(y_test, y_pred))
accuracy_score(y_test, y_pred)
[[52 9]
[12 27]]
0.79