0% found this document useful (0 votes)
2 views

exp2b

The document outlines a machine learning workflow using Python, where data is preprocessed and split into training and testing sets. A Logistic Regression model is trained on the standardized training data and then used to make predictions on the test set. The performance of the model is evaluated using a confusion matrix and accuracy score, which is visualized with a heatmap.

Uploaded by

btechstencse
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

exp2b

The document outlines a machine learning workflow using Python, where data is preprocessed and split into training and testing sets. A Logistic Regression model is trained on the standardized training data and then used to make predictions on the test set. The performance of the model is evaluated using a confusion matrix and accuracy score, which is visualized with a heatmap.

Uploaded by

btechstencse
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import numpy as np

import pandas as pd
import matplotlib.pyplot as mtp

x=data.iloc[:,[2,3]].values
y=data.iloc[:,[4]].values

from sklearn.model_selection import train_test_split


x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.25,random_state=0)
x_train.shape

x_test.shape

y_test.shape

from sklearn.preprocessing import StandardScaler


st_x=StandardScaler()
x_train=st_x.fit_transform(x_train)
x_test=st_x.transform(x_test)
x_train.shape

from sklearn.linear_model import LogisticRegression


classifier=LogisticRegression()
classifier.fit(x_train,y_train)

y_pred=classifier.predict(x_test)

from sklearn.metrics import confusion_matrix


cf=confusion_matrix(y_test,y_pred)
cf

from sklearn.metrics import accuracy_score


import seaborn as sns
sns.heatmap(cf,annot=True)
print('The accuracy of our model:',format(accuracy_score(y_test,y_pred)))

You might also like