Created
August 9, 2020 09:20
-
-
Save ksdkamesh99/225da7857f662db2a1aac84036c1a86a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importing the necessary libraries | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.datasets import load_iris | |
from sklearn.model_selection import train_test_split | |
# Load the iris dataset from sklearn datasets | |
dataset=load_iris() | |
# Getting Feature Names | |
names=dataset.feature_names | |
# Loading features and labels from the dataset | |
features=dataset.data | |
labels=dataset.target | |
# Splitting labels and features to training and testing sets | |
feature_train,feature_test,label_train,label_test=train_test_split(features,labels,test_size=0.2,random_state=42) | |
# Initialising Logistic Regression Model with maximum iterations as 500 | |
model=LogisticRegression(max_iter=500) | |
# Fitting Model or Training Model with training features and labels | |
model.fit(feature_train,label_train) | |
# Predicting the labels for the testing features | |
label_pred=model.predict(feature_test) | |
# Finding the accuracy score for predicted ones vs testing ones | |
from sklearn.metrics import accuracy_score | |
accuracy_score(label_pred,label_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment