<jupyter_start><jupyter_text>"Heart Attack Analysis & Prediction Dataset"> "[Kaggle]"- toc:true- branch: master- badges: true- comments: true- author: <NAME> & <NAME>- categories: [Colab, Kaggle Code Review]<jupyter_code># !mkdir "/content/drive/MyDrive/Kaggle/Data/Heart Attack Analysis & Prediction Dataset"
# !unzip "/content/drive/MyDrive/Kaggle/Data/Heart Attack Analysis & Prediction Dataset.zip" -d "/content/drive/MyDrive/Kaggle/Data/Heart Attack Analysis & Prediction Dataset/"
from google.colab import drive
drive.mount('/content/drive')<jupyter_output><empty_output><jupyter_text>1.Library & Data Load<jupyter_code>import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
import seaborn as sns

from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier

from sklearn.preprocessing import StandardScaler

from sklearn.metrics import accuracy_score, confusion_matrix

from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVC
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import cross_val_score

import warnings
warnings.filterwarnings('ignore')
heart=pd.read_csv('/content/drive/MyDrive/Kaggle/Data/Heart Attack Analysis & Prediction Dataset/heart.csv')
o2Saturation=pd.read_csv('/content/drive/MyDrive/Kaggle/Data/Heart Attack Analysis & Prediction Dataset/o2Saturation.csv')
heart.info()
heart.drop_duplicates(inplace=True)
heart.describe()
plt.figure(figsize=(16,8))
sns.heatmap(heart.corr(),annot=True)
plt.show()<jupyter_output><empty_output><jupyter_text>2. 모델링<jupyter_code>X = heart.iloc[:, 0: -1]
y = heart.iloc[:, -1:]
X_train,X_test, y_train, y_test= train_test_split(X,y,test_size=0.2,random_state=2)<jupyter_output><empty_output><jupyter_text>https://mkjjo.github.io/python/2019/01/10/scaler.htmlhttps://blog.naver.com/chlxogns92/221767376389<jupyter_code>pipe_svc=make_pipeline(StandardScaler(),
                       SVC(random_state=1))
param_C_range=[0,1,2,3,4,5,6,7,8,9,10]
param_gamma_range=[0.005,0, 0.1, 0.015]

param_grid=[{'svc__C' : param_C_range,
             'svc__kernel':['linear']},
            {'svc__C':param_C_range,
             'svc__gamma':param_gamma_range,
             'svc__kernel':['rbf']                
            }]
gs=GridSearchCV(estimator=pipe_svc,
                param_grid=param_grid,
                scoring='accuracy',
                cv=10,
                n_jobs=-1)

gs=gs.fit(X_train,y_train)
print(gs.best_score_)
print(gs.best_params_)
clf=gs.best_estimator_
clf.fit(X_train,y_train)
print(clf.score(X_test,y_test) )
confusion_matrix(y_test,clf.predict(X_test))
clf.score(X_test,y_test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12611607142857142, 'fraction_numerical': 0.023065476190476192, 'mean_word_length': 5.1533180778032035, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 2, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '667179', 'license': 'Apache-2.0', 'n_tokens_mistral': 1029, 'n_tokens_neox': 971, 'n_words': 148, 'path': '_notebooks/2021_12_31_Heart_Attack_Analysis_&_Prediction_Dataset.ipynb', 'repo_name': 'JoGyeongDeok/PigDuck', 'size': '2701'}