<jupyter_start><jupyter_text>Spliting data<jupyter_code>features=dataset.iloc[:,:-1]
labels=dataset.iloc[:,[-1]]
features
feature_train,feature_test,label_train,label_test=train_test_split(features,labels,test_size=0.2,random_state=42)<jupyter_output><empty_output><jupyter_text>Logistic Regression<jupyter_code>model=LogisticRegression(max_iter=1000)
model.fit(feature_train,label_train)
label_pred=model.predict(feature_test)
m.accuracy_score(label_test,label_pred)
label_pred
label_test
print(m.classification_report(label_test,label_pred))
print(m.confusion_matrix(label_test,label_pred))<jupyter_output>[[25  4]
 [ 5 27]]<jupyter_text>KNN<jupyter_code>from sklearn.model_selection import GridSearchCV
knn=KNeighborsClassifier()
param={'n_neighbors':list(np.arange(1,20))}

model=GridSearchCV(knn,param_grid=param)
model.fit(feature_train,label_train)
model.best_params_
model=KNeighborsClassifier(n_neighbors=13)
model.fit(feature_train,label_train)
label_pred=model.predict(feature_test)
m.accuracy_score(label_test,label_pred)
label_pred_train=model.predict(feature_train)
m.accuracy_score(label_train,label_pred_train)
print(m.classification_report(label_test,label_pred))
print(m.confusion_matrix(label_test,label_pred))
label_pred
label_test<jupyter_output><empty_output><jupyter_text>Decision Tree<jupyter_code>from sklearn.model_selection import GridSearchCV
dt=DecisionTreeClassifier()
param={'max_depth':list(np.arange(1,20))}

model=GridSearchCV(dt,param_grid=param)
model.fit(feature_train,label_train)
model.best_params_
model=DecisionTreeClassifier(max_depth=8)
model.fit(feature_train,label_train)
label_pred=model.predict(feature_test)
m.accuracy_score(label_test,label_pred)
print(m.classification_report(label_test,label_pred))
print(m.confusion_matrix(label_test,label_pred))
label_pred
label_test<jupyter_output><empty_output><jupyter_text>SVM<jupyter_code>model=SVC(kernel='linear')
model.fit(feature_train,label_train)
label_pred=model.predict(feature_test)
m.accuracy_score(label_test,label_pred)
print(m.classification_report(label_test,label_pred))
print(m.confusion_matrix(label_test,label_pred))
label_pred
label_test<jupyter_output><empty_output><jupyter_text>Random Forest Classifier<jupyter_code>from sklearn.model_selection import GridSearchCV
rfc=RandomForestClassifier()
param={'n_estimators':[10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200],'max_depth':list(np.arange(1,20))}

model=GridSearchCV(rfc,param_grid=param)
model.fit(feature_train,label_train)
model.best_params_
model=model.best_estimator_
label_pred=model.predict(feature_test)
m.accuracy_score(label_test,label_pred)
print(m.classification_report(label_test,label_pred))
print(m.confusion_matrix(label_test,label_pred))
label_pred
label_test<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11798355380765105, 'fraction_numerical': 0.028244547729710405, 'mean_word_length': 21.384, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '66512', 'license': 'MIT', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1054, 'n_words': 75, 'path': 'heart.ipynb', 'repo_name': 'ksdkamesh99/Dava-Medicine-with-ML-', 'size': '2797'}