-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogisticRegression.py
More file actions
30 lines (23 loc) · 817 Bytes
/
logisticRegression.py
File metadata and controls
30 lines (23 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Logistic regression practice
print("Importing libraries...")
from sklearn.datasets import load_digits
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
import seaborn as sns
print("Loading dataset...")
digits = load_digits()
print("Orgainizing training data...")
x_train, x_test, y_train, y_test = train_test_split(digits.data, digits.target, test_size=0.2)
print("Training model...")
model = LogisticRegression(max_iter=100000)
model.fit(x_train, y_train)
y_predicted = model.predict(x_test)
model.score(x_test,y_test)
cm = confusion_matrix(y_test, y_predicted)
plt.figure(figsize=(10,7))
sns.heatmap(cm, annot=True)
plt.xlabel("Prediction")
plt.ylabel("Reality")
plt.show()