<jupyter_start><jupyter_text>Importing Dataset<jupyter_code>import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
dataset = pd.read_csv("../input/insurance/insurance.csv")
print(dataset.head())
X = dataset.iloc[:, 0:6].values
y = dataset.iloc[:, 6:7].values
X
y<jupyter_output><empty_output><jupyter_text>Data Preprocessing<jupyter_code>from sklearn.preprocessing import LabelEncoder

labelencoder_X_1 = LabelEncoder()
X[:, 1] = labelencoder_X_1.fit_transform(X[:, 1])
labelencoder_X_4 = LabelEncoder()
X[:, 4] = labelencoder_X_4.fit_transform(X[:, 4])
X
from sklearn.preprocessing import OneHotEncoder
from sklearn.compose import ColumnTransformer

columnTransformer = ColumnTransformer([('encoder', OneHotEncoder(), [5])], remainder='passthrough')
X = np.array(columnTransformer.fit_transform(X), dtype = np.str)
X = X[:, 1:]
X

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
from sklearn.preprocessing import MinMaxScaler
sc = MinMaxScaler((0,1))
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

y_train = sc.fit_transform(y_train)
y_test = sc.transform(y_test)<jupyter_output><empty_output><jupyter_text>Creating the Neural Network<jupyter_code>import keras
from keras.models import Sequential
from keras.layers import Dense

model = Sequential()
    
# Adding the input layer and the first hidden layer
model.add(Dense(units = 128, activation = 'relu'))
    
# Adding the second hidden layer
model.add(Dense(units = 64, activation = 'relu'))

# Adding the third hidden layer
    
model.add(Dense(units = 32, activation = 'relu'))
    
# Adding the output layer
model.add(Dense(units = 1, activation = 'linear'))
    
# Compiling the ANN
model.compile(loss='mean_absolute_error', optimizer='adam', metrics=['mean_absolute_error'])<jupyter_output>Using TensorFlow backend.<jupyter_text>Evaluating the Neural Network<jupyter_code>modelplot = model.fit(x = X_train, y = y_train, batch_size = 16, epochs = 150)
y_pred = model.predict(X_test)


from sklearn.metrics import mean_absolute_error 

print("Model Mean Absolute Error: " + str(mean_absolute_error(y_test, y_pred, sample_weight=None, multioutput='uniform_average')))
plt.plot(modelplot.history['mean_absolute_error'])
plt.title('Loss Function Over Epochs')
plt.ylabel('MAE value')
plt.xlabel('No. epoch')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.121998450813323, 'fraction_numerical': 0.012393493415956624, 'mean_word_length': 6.574780058651027, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '73536', 'license': 'MIT', 'n_tokens_mistral': 921, 'n_tokens_neox': 881, 'n_words': 199, 'path': 'Deep Learning using Tensorflow Keras/Medical-Cost-Predictor-using-Neural-Network/Medical Cost Predictor.ipynb', 'repo_name': 'Storiesbyharshit/Deep-Learning', 'size': '2582'}