0% found this document useful (0 votes)
12 views3 pages

vertopal.com_IBA Practical Set A 14th Dec

qwqe

Uploaded by

hardikmurariya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

vertopal.com_IBA Practical Set A 14th Dec

qwqe

Uploaded by

hardikmurariya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Question2

import pandas as pd
import numpy as np

dicti = {'IS_PCM' : [1,1,1,0,0,0,0,1,0,1],


'Aggregate Marks' : [98,97.8,95.6,89,85,98.9,99,95,87.8,94],
'Science Marks' : [97,99,94,87,86,97,99,90,94,90],
'Maths Marks' : [98,95,98,94,84,99,100,95,80,98],
'Gender' : [1,1,0,1,1,0,0,1,1,1]}

data = pd.DataFrame(data = dicti)


data

IS_PCM Aggregate Marks Science Marks Maths Marks Gender


0 1 98.0 97 98 1
1 1 97.8 99 95 1
2 1 95.6 94 98 0
3 0 89.0 87 94 1
4 0 85.0 86 84 1
5 0 98.9 97 99 0
6 0 99.0 99 100 0
7 1 95.0 90 95 1
8 0 87.8 94 80 1
9 1 94.0 90 98 1

data.head()

IS_PCM Aggregate Marks Science Marks Maths Marks Gender


0 1 98.0 97 98 1
1 1 97.8 99 95 1
2 1 95.6 94 98 0
3 0 89.0 87 94 1
4 0 85.0 86 84 1

data.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 10 entries, 0 to 9
Data columns (total 5 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 IS_PCM 10 non-null int64
1 Aggregate Marks 10 non-null float64
2 Science Marks 10 non-null int64
3 Maths Marks 10 non-null int64
4 Gender 10 non-null int64
dtypes: float64(1), int64(4)
memory usage: 532.0 bytes

data.shape
(10, 5)

data.describe()

IS_PCM Aggregate Marks Science Marks Maths Marks


Gender
count 10.000000 10.000000 10.000000 10.000000
10.000000
mean 0.500000 94.010000 93.300000 94.100000
0.700000
std 0.527046 5.027137 4.808557 6.723921
0.483046
min 0.000000 85.000000 86.000000 80.000000
0.000000
25% 0.000000 90.250000 90.000000 94.250000
0.250000
50% 0.500000 95.300000 94.000000 96.500000
1.000000
75% 1.000000 97.950000 97.000000 98.000000
1.000000
max 1.000000 99.000000 99.000000 100.000000
1.000000

from sklearn.linear_model import LogisticRegression

x = data.drop('IS_PCM', axis = 1)
y = data['IS_PCM']

model = LogisticRegression()

model.fit(x,y)

LogisticRegression()

y_pred = model.predict(x)

model.predict([[90, 85, 95, 1]])[0]

C:\Users\harsh\anaconda3\Lib\site-packages\sklearn\base.py:464:
UserWarning: X does not have valid feature names, but
LogisticRegression was fitted with feature names
warnings.warn(

from sklearn.metrics import accuracy_score, precision_score,


confusion_matrix, f1_score, recall_score

accuracy = accuracy_score(y,y_pred)
accuracy

0.7
conf_matrix = confusion_matrix(y,y_pred)
conf_matrix

array([[3, 2],
[1, 4]], dtype=int64)

f1 = f1_score(y,y_pred)
f1

0.7272727272727272

precision = precision_score(y,y_pred)
precision

0.6666666666666666

recall = recall_score(y,y_pred)
recall

0.8

tn, tp, fn, fp = conf_matrix.ravel()


specificity = tn / (tn + fn)
specificity

0.75

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy