-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiple_log.py
More file actions
25 lines (19 loc) · 776 Bytes
/
Copy pathmultiple_log.py
File metadata and controls
25 lines (19 loc) · 776 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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
# Load iris dataset
iris = load_iris()
# Split dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)
# Fit logistic regression model
model = LogisticRegression(multi_class='multinomial', solver='lbfgs',max_iter=1000)
model.fit(X_train, y_train)
# Make predictions on test set
y_pred = model.predict(X_test)
# Calculate accuracy of model
accuracy = accuracy_score(y_test, y_pred)
print(f"Accuracy of model: {accuracy}")