finding corellation and plotting
This commit is contained in:
@@ -4,11 +4,16 @@ from sklearn.linear_model import LogisticRegression
|
|||||||
from sklearn.preprocessing import LabelEncoder
|
from sklearn.preprocessing import LabelEncoder
|
||||||
from sklearn.metrics import accuracy_score, classification_report
|
from sklearn.metrics import accuracy_score, classification_report
|
||||||
import pickle
|
import pickle
|
||||||
|
import statsmodels.api as sm
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
data = pd.read_excel('/Users/apple/Downloads/21092023-July_Sept.xlsx', sheet_name="op")
|
data = pd.read_excel('/Users/apple/Downloads/21092023-July_Sept.xlsx', sheet_name="op")
|
||||||
data = data.dropna()
|
data = data.dropna()
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
|
data.plot()
|
||||||
|
|
||||||
label_encoder = LabelEncoder()
|
label_encoder = LabelEncoder()
|
||||||
categorical_cols = ['Gender', 'Caste', 'Category', 'Marital Status', 'Blood Group']
|
categorical_cols = ['Gender', 'Caste', 'Category', 'Marital Status', 'Blood Group']
|
||||||
for col in categorical_cols:
|
for col in categorical_cols:
|
||||||
@@ -17,6 +22,11 @@ for col in categorical_cols:
|
|||||||
X = data[['Age', 'Gender', 'Caste', 'Category', 'Marital Status']]
|
X = data[['Age', 'Gender', 'Caste', 'Category', 'Marital Status']]
|
||||||
y = data['Test Result']
|
y = data['Test Result']
|
||||||
|
|
||||||
|
corr = X.corr()
|
||||||
|
print(corr)
|
||||||
|
sm.graphics.plot_corr(corr, xnames=list(corr.columns))
|
||||||
|
plt.show()
|
||||||
|
|
||||||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
||||||
|
|
||||||
model = LogisticRegression()
|
model = LogisticRegression()
|
||||||
@@ -26,6 +36,7 @@ y_pred = model.predict(X_test)
|
|||||||
|
|
||||||
accuracy = accuracy_score(y_test, y_pred)
|
accuracy = accuracy_score(y_test, y_pred)
|
||||||
classification_report_result = classification_report(y_test, y_pred)
|
classification_report_result = classification_report(y_test, y_pred)
|
||||||
|
#sns.heatmap(pd.DataFrame(classification_report_result).iloc[:-1, :].T, annot=True)
|
||||||
|
|
||||||
print(f"Accuracy: {accuracy}")
|
print(f"Accuracy: {accuracy}")
|
||||||
print("Classification Report:")
|
print("Classification Report:")
|
||||||
@@ -40,4 +51,4 @@ print(classification_report_result)
|
|||||||
|
|
||||||
# new_data = pd.DataFrame({'Age': [30], 'Gender': ['MALE'], 'Caste': ['SC'], 'Category': [''], 'Marital Status': ['Single']})
|
# new_data = pd.DataFrame({'Age': [30], 'Gender': ['MALE'], 'Caste': ['SC'], 'Category': [''], 'Marital Status': ['Single']})
|
||||||
# predicted_result = loaded_model.predict(new_data)
|
# predicted_result = loaded_model.predict(new_data)
|
||||||
# print(predicted_result)
|
# print(predicted_result)
|
||||||
|
|||||||
Reference in New Issue
Block a user