vertopal.com_IBA Practical Set A 14th Dec
vertopal.com_IBA Practical Set A 14th Dec
import pandas as pd
import numpy as np
data.head()
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()
x = data.drop('IS_PCM', axis = 1)
y = data['IS_PCM']
model = LogisticRegression()
model.fit(x,y)
LogisticRegression()
y_pred = model.predict(x)
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(
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
0.75