<jupyter_start><jupyter_text>Heart Disease Prediction. Collecting Data  Import neccessary libraries<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>Read data from '*.data' file<jupyter_code>columns = ['age', 'sex', 'cp', 'trestbps', 'chol', 'fbs', 'restecg', 'thalach', 'exang', 'oldpeak', 'slope', 'ca', 'thal', 'num']
data_clev = pd.read_csv("processed.cleveland.data", sep=",", names=columns)
data_hung = pd.read_csv("processed.hungarian.data", sep=",", names=columns)
data_swit = pd.read_csv("processed.switzerland.data", sep=",", names=columns)
data_va = pd.read_csv("processed.va.data", sep=",", names=columns)<jupyter_output><empty_output><jupyter_text>Displayed data<jupyter_code>data_clev.head(5)
data_hung.head(5)
data_swit.head(5)
data_va.head(5)<jupyter_output><empty_output><jupyter_text>Collect four dataset to one dataframe<jupyter_code>data_all = pd.concat([data_clev, data_hung, data_swit, data_va])
data_all.describe()
data_all.head(10)
data_all.shape<jupyter_output><empty_output><jupyter_text>Data preprocessing<jupyter_code>data = data_all.copy()
count = 0 
for i in data.columns:
    for j in data[i]:
        if j=="?":
            count += 1 
print("Missing value: ", count)
data.replace('?', 0, inplace = True)
count = 0 
for i in data.columns:
    for j in data[i]:
        if j=="?":
            count += 1 
print("Missing value: ", count)<jupyter_output>Missing value:  0<jupyter_text>Remove column 'num' to column 'target'<jupyter_code>target = data['num']
new_target = []
data = data.drop('num', axis = 1)
for i in target:
    if i>0:
        new_target.append(1)
    else:
        new_target.append(0)
data['target'] = new_target<jupyter_output><empty_output><jupyter_text>Save dataframe to 'alldata.csv' file<jupyter_code>data.to_csv('alldata.csv', encoding='utf-8', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15944355270197966, 'fraction_numerical': 0.00909577314071696, 'mean_word_length': 6.137404580152672, 'pattern_counts': {'":': 2, '<': 28, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '429492', 'license': 'CNRI-Python', 'n_tokens_mistral': 728, 'n_tokens_neox': 703, 'n_words': 131, 'path': 'preprocessing UCI/Collect_Data.ipynb', 'repo_name': 'anastasiatraverse/Heart-Disease-Prediction', 'size': '1869'}