# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Classification challenge!

# 1. Logistic Regression 
# 1. SVC
# 1. Decision Tree Classifier
# 1. RandomForestClassifier
# 1. KNeighborsClassifier
# 1. Gradient Boosting Classifier
# 1. "Neural Net": MLPClassifier
# 1. "Naive Bayes": GaussianNB(),
# 1. "AdaBoost": AdaBoostClassifier()**

# + _cell_guid="79c7e3d0-c299-4dcb-8224-4455121ee9b0" _uuid="d629ff2d2480ee46fbb7e2d37f6b5fab8052498a"
# Logistic Regression 
# SVC
# Decision Tree Classifier
# RandomForestClassifier
# KNeighborsClassifier
# Gradient Boosting Classifier
# "Neural Net": MLPClassifier
# "Naive Bayes": GaussianNB(),
# "AdaBoost": AdaBoostClassifier(),
# -

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Data
dataframe = pd.read_csv("../input/heart.csv")
dataframe.head()

dataframe.shape

dataframe.info()

dataframe.isna().sum()

# Test train split
from sklearn.model_selection import train_test_split

X = dataframe.iloc[:,:13]
y = dataframe['target']
X.head()
y.head()

X.shape

X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.3, random_state=40)

# ### Logistic Regression Implementation 

from sklearn.linear_model import LogisticRegression
clf = LogisticRegression()

clf.fit(X_train,y_train)

predictions = clf.predict(X_test)

from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)

# ## SVC

from sklearn.svm import SVC

clf = SVC()

clf.fit(X_train,y_train)

predictions = clf.predict(X_test)

from sklearn.metrics import confusion_matrix, accuracy_score

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)

# # Decision Tree Classifier

from sklearn.tree import DecisionTreeClassifier

clf = DecisionTreeClassifier()

clf.fit(X_train, y_train)

predictions = clf.predict(X_test)

from sklearn.metrics import confusion_matrix, accuracy_score

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)

# ## Random Forest Classifier

from sklearn.ensemble import RandomForestClassifier

clf = RandomForestClassifier()

clf.fit(X_train, y_train)

predictions= clf.predict(X_test)

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)



# ## Gradient Boot Classifier

from sklearn.ensemble import GradientBoostingClassifier

clf = GradientBoostingClassifier()

clf.fit(X_train, y_train)

predictions = clf.predict(X_test)

from sklearn.metrics import confusion_matrix, accuracy_score

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)

# ## KNeighbours Classifier

from sklearn.neighbors import KNeighborsClassifier

clf = KNeighborsClassifier()

clf.fit(X_train, y_train)

predictions = clf.predict(X_test)

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)

# ## Gaussian NB (Naive Bayes)

from sklearn.naive_bayes import GaussianNB

clf = GaussianNB()

clf.fit(X_train, y_train)

predictions = clf.predict(X_test)

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)

# ## Gussian Process Classifier

from sklearn.gaussian_process import GaussianProcessClassifier

clf = GaussianProcessClassifier()

clf.fit(X_train, y_train)

predictions = clf.predict(X_test)

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)

# ## AdaBoost Classifier

from sklearn.ensemble import AdaBoostClassifier

clf = AdaBoostClassifier()

clf.fit(X_train, y_train)

predictions = clf.predict(X_test)

confusion_matrix(y_test, predictions)

accuracy_score(y_test, predictions)



StarcoderdataJupyterScriptsDedupFiltered