from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression # Loa
from sklearn import datasets
from sklearn.modelselection import traintestsplit
from sklearn.linearmodel import LogisticRegression
Load the iris dataset
iris = datasets.load_iris()
X, y = iris.data, iris.target
Split the dataset into training and testing sets
Xtrain, Xtest, ytrain, ytest = traintestsplit(X, y)
Create a logistic regression model and fit it to the training data
model = LogisticRegression()
model.fit(Xtrain, ytrain)
Evaluate the model on the testing data
score = model.score(Xtest, ytest)
print("Accuracy: ", score)
1
vote
Mustafa alqaysy
shared this idea