<jupyter_start><jupyter_text>Importing the Dataset<jupyter_code>df = pd.read_csv("Lumpy skin disease data.csv")
df.head()
df.describe()
df.info()
df.isna().sum(axis=0)
df.columns<jupyter_output><empty_output><jupyter_text>Dropping Unnecessary Columns<jupyter_code>df.drop(columns=['region','country','reportingDate','X5_Ct_2010_Da','X5_Bf_2010_Da'],inplace=True)
df.head()
df.corr()<jupyter_output><empty_output><jupyter_text>Exploratory Data Analysis<jupyter_code>plt.figure(figsize=(3,3),dpi=150)
plt.style.use('dark_background')
sns.countplot(x='lumpy', data = df)
plt.xlabel('Lumpiness classes')
plt.ylabel('count of each class')
plt.title('Lumpiness class distribution')
plt.figure(figsize=(15, 15))
heatmap = sns.heatmap(df.corr(), vmin= -1, vmax = 1, annot=True)
heatmap.set_title('Correlation Heatmap', fontdict={'fontsize':12})<jupyter_output><empty_output><jupyter_text>Partitioning the dataset into training and test sets<jupyter_code>X=df.iloc[:,:-1]
y=df.iloc[:,-1]
print("//Independent features//")
print(X.head())
print("\n\n//Dependent feature//")
print(y.head())<jupyter_output>//Independent features//
           x          y   cld   dtr  ...   vap   wet  elevation  dominant_land_cover
0  90.380931  22.437184  41.6  12.8  ...  15.7  0.00        147                    2
1  87.854975  22.986757  40.5  13.3  ...  16.3  0.00        145                    2
2  85.279935  23.610181  27.3  13.6  ...  13.0  0.98        158                    2
3  81.564510  43.882221  45.3  12.8  ...   0.9  4.64        178                    2
4  81.161057  43.834976  38.8  13.2  ...   1.2  1.69        185                    3

[5 rows x 14 columns]


//Dependent feature//
0    1
1    1
2    1
3    1
4    1
Name: lumpy, dtype: int64<jupyter_text>Train Test Split<jupyter_code>X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=0)<jupyter_output><empty_output><jupyter_text>Feature Scaling<jupyter_code>scaler=StandardScaler()
X_train=scaler.fit_transform(X_train)
X_test=scaler.transform(X_test)
# Logistic Regression
lr=LogisticRegression()
lr_mdl=lr.fit(X_train,y_train)
lr_pred=lr.predict(X_test)
lr_con_matrix=confusion_matrix(y_test,lr_pred)
lr_acc=accuracy_score(y_test,lr_pred)
print("Confusion Matrix",'\n',lr_con_matrix)
print('\n')
print("Accuracy of Logistic Regression: ",lr_acc*100,'\n')
print(classification_report(y_test,lr_pred))
#Random Forest Classfier
rf = RandomForestClassifier()
rf.fit(X_train,y_train)
rf_pred = rf.predict(X_test)
rf_con_matrix = confusion_matrix(y_test, rf_pred)
rf_acc = accuracy_score(y_test, rf_pred)
print("Confusion Matrix\n",rf_con_matrix)
print("\n")
print("Accuracy of Random Forest:",rf_acc*100,'\n')
print(classification_report(y_test,rf_pred))
#DecisionTreeClassifier
dt = DecisionTreeClassifier()
dt.fit(X_train, y_train)
dt_pred = dt.predict(X_test)
dt_con_matrix = confusion_matrix(y_test, dt_pred)
dt_acc = accuracy_score(y_test, dt_pred)
print("Confusion Matrix\n",dt_con_matrix)
print("\n")
print("Accuracy of Decision Tree Classifier:",dt_acc*100,'\n')
print(classification_report(y_test,dt_pred))
y_score1 = lr.predict_proba(X_test)[:,1]
y_score2 = rf.predict_proba(X_test)[:,1]
y_score3 = dt.predict_proba(X_test)[:,1]

false_positive_rate1, true_positive_rate1, threshold1 = roc_curve(y_test, y_score1)
false_positive_rate2, true_positive_rate2, threshold2 = roc_curve(y_test, y_score2)
false_positive_rate3, true_positive_rate3, threshold3 = roc_curve(y_test, y_score3)

plt.figure(figsize=(5,5),dpi=150)
plt.title('Receiver Operating Characteristic (ROC) Curve')
plt.plot(false_positive_rate1,true_positive_rate1, color='red', label = "Logistic Regression")
plt.plot(false_positive_rate2,true_positive_rate2, color='blue', label = "Random Forest")
plt.plot(false_positive_rate3,true_positive_rate3, color='green', label = "Decision Tree")
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],linestyle='--')
plt.axis('tight')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
mdl_evl = pd.DataFrame({'Model': ['Logistic Regression','Random Forest', 'Decision Tree'], 'Accuracy': [lr_acc*100,rf_acc*100,dt_acc*100]})
mdl_evl
pal=['red','blue','green']
fig, ax = plt.subplots(figsize=(20,10))
sns.barplot(x="Model",y="Accuracy",palette=pal,data=mdl_evl)
plt.title('Model Accuracy')
plt.xlabel('Model')
plt.ylabel('Accuracy')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.149496336996337, 'fraction_numerical': 0.059981684981684984, 'mean_word_length': 5.670229007633588, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '30619', 'license': 'MIT', 'n_tokens_mistral': 1885, 'n_tokens_neox': 1717, 'n_words': 272, 'path': 'Lumpy Skin Disease Prediction/Model/Lumpy_Skin_Disease_Prediction.ipynb', 'repo_name': 'yagyesh-bobde/ML-Crate', 'size': '4368'}