ex-2

PHOTO EMBED

Thu Aug 08 2024 05:28:45 GMT+0000 (Coordinated Universal Time)

Saved by @signup

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import MinMaxScaler,StandardScaler,OneHotEncoder
from sklearn.preprocessing import LabelEncoder
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer

#Set Seed for reproducability
np.random.seed(42)
#Create synthetic dataset 
data={
    'Age':np.random.randint(29,77,size=200),
    'Sex':np.random.choice(['Male','Female'],size=200),
    'ChestPainType':np.random.choice(['ATA','NAP','ASY','TA'],size=200),
    'RestingBP':np.random.randint(94,200,size=200),
    'Cholesterol':np.random.randint(126,564,size=200),
    'FastingBS':np.random.choice([0,1],size=200),
    'RestingECG':np.random.choice(['Normal','ST','LVH'],size=200),
    'MaxHR':np.random.randint(71,202,size=200),
    'ExerciseAngina':np.random.choice(['N','Y'],size=200),
    'Oldpeak':np.random.uniform(0,6.2,size=200),
    'ST_Slope':np.random.choice(['Up','Flat','Down'],size=200),
    'HeartAttack':np.random.choice([0,1],size=200)
}

#Convert to DataFrame
df=pd.DataFrame(data)
df.head()
content_copyCOPY