"""
The purpose of this model was to use the dataset to predict whether or not someone had breast cancer based on a variety of features. My initial plan was to review the dataset for any columns that would need to be dropped then to test for correllations and work on gradient boosting from there. Since the outcome was so positive I did not go forward with testing other models.
"""
import matplotlib.pyplot as plt 
import pandas as pd
import seaborn as sns

from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
from sklearn.metrics import classification_report, confusion_matrix 
from sklearn.ensemble import RandomForestClassifier
from sklearn import ensemble
from sklearn import *
from sklearn.metrics import accuracy_score, f1_score
from statistics import mean
from sklearn.ensemble import GradientBoostingClassifier
import numpy as np

df = pd.read_csv('/kaggle/input/breastcancercsv/breastcancer.csv')

#Immediately I am looking for columns to drop that I do not believe will help with my analysis

df = df.drop(['id'], axis=1)
df.head()

df['diagnosis'] = df['diagnosis'].replace({'B': 0, 'M': 1})
"""
 This heatmap graphic is a great tool that I used to determine what features I would keep in for my model
"""
#Now I will begin reviewing the metrics for each of these to see their correllation to the predicted value
df_heat = df.corr()
plt.figure(figsize=(30,15))
sns.heatmap(df_heat, annot=True, cmap='coolwarm')
#From the above graphic I will begin removing variables that have poor cor to what im trying to predict


df = df.drop(['fractal_dimension_mean', 'texture_se', 'smoothness_se', 'symmetry_se', 'fractal_dimension_se'], axis=1)
X = df.drop(['diagnosis'], axis=1)
y = df['diagnosis']

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=10, shuffle=True)
GBRmodel = ensemble.GradientBoostingClassifier(
    n_estimators = 300,
    learning_rate = 0.01,
    max_depth = 6,
    min_samples_split = 5, 
    min_samples_leaf = 30,
    max_features = 6,
    loss = 'deviance'
)



GBRmodelname = 'GradientBoosting'
GBRmodel.fit(X_train, y_train)
prediction = GBRmodel.predict(X_test)
metrics.plot_confusion_matrix(GBRmodel, X_test, y_test)
print(classification_report(y_test, prediction))
"""
From this output I was quite satisified. Especially since when predicting a disease you would want to minimize false negatives which was done well by this model.
"""