text_plain_output_1.png
from sklearn.preprocessing import OneHotEncoder

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df_insure = pd.read_csv('/kaggle/input/medical-insurance/med-insurance.csv')

x_train.shape

x_test.shape

from sklearn.preprocessing import OneHotEncoder
ohe = OneHotEncoder(drop='first')
x_train_array = ohe.fit_transform(x_train[['sex', 'smoker', 'region']]).toarray()
x_test_array = ohe.transform(x_test[['sex', 'smoker', 'region']]).toarray()

x_trainfeatures = pd.DataFrame(x_train_array, columns=['male', 'smokes', 'northwest', 'southeast', 'southwest'])
x_trainfeatures