<jupyter_start><jupyter_text>PROBLEM STATEMENT You are working as a car salesman and you would like to develop a model to predict the total dollar amount that customers are willing to pay given the following attributes: - Customer Name- Customer e-mail- Country- Gender- Age- Annual Salary - Credit Card Debt - Net Worth The model should predict: - Car Purchase Amount   STEP 0: LIBRARIES IMPORT<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns<jupyter_output><empty_output><jupyter_text>STEP 1: IMPORT DATASET<jupyter_code>car_df = pd.read_csv('Car_Purchasing_Data.csv',  encoding='ISO-8859-1')

car_df
car_df.tail(10)
car_df.head(10)
car_df.describe()<jupyter_output><empty_output><jupyter_text>STEP 2: VISUALIZE DATASET<jupyter_code>sns.pairplot(car_df)<jupyter_output><empty_output><jupyter_text>STEP 3: CREATE TESTING AND TRAINING DATASET/DATA CLEANING<jupyter_code>## Dropping Unnecessary Data
X = car_df.drop(['Customer Name', 'Customer e-mail', 'Country','Car Purchase Amount'], axis = 1)
X
y = car_df['Car Purchase Amount']
y.shape
from sklearn.preprocessing import MinMaxScaler

scaler_x = MinMaxScaler()
X_scaled = scaler_x.fit_transform(X)
X_scaled
X_scaled.shape
scaler_x.data_max_
scaler_x.data_min_
y = y.values.reshape(-1,1)
scaler_y = MinMaxScaler()
y_scaled = scaler_y.fit_transform(y).reshape(-1,1)
y_scaled
y_scaled.shape<jupyter_output><empty_output><jupyter_text>STEP4: TRAINING THE MODEL<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y_scaled, test_size=0.25)
X_train.shape, X_test.shape, y_train.shape, y_test.shape
import tensorflow.keras
from keras.models import Sequential
from keras.layers import Dense

model = Sequential()
model.add(Dense(25, input_dim = 5, activation = 'relu'))
model.add(Dense(25, activation = 'relu'))
model.add(Dense(1, activation = 'linear'))
model.summary()
model.compile(optimizer='adam', loss='mean_squared_error')
epochs_hist = model.fit(X_train, y_train, epochs=20, batch_size=25,  verbose=1, validation_split=0.2)<jupyter_output>Epoch 1/20
12/12 [==============================] - 0s 7ms/step - loss: 0.1557 - val_loss: 0.0942
Epoch 2/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0682 - val_loss: 0.0450
Epoch 3/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0412 - val_loss: 0.0327
Epoch 4/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0309 - val_loss: 0.0232
Epoch 5/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0213 - val_loss: 0.0165
Epoch 6/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0152 - val_loss: 0.0125
Epoch 7/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0115 - val_loss: 0.0097
Epoch 8/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0093 - val_loss: 0.0085
Epoch 9/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0080 - val_loss: 0.0074
Epoch 10/20
12/12 [==============================] - 0s 3ms/step - loss: 0.0071 - val_loss: 0.0065
Epoch 11/20
12/12 [[...]<jupyter_text>STEP5: EVALUATING THE MODEL<jupyter_code>print(epochs_hist.history.keys())
plt.plot(epochs_hist.history['loss'])
plt.plot(epochs_hist.history['val_loss'])

plt.title('Model Loss Progression During Training/Validation')
plt.ylabel('Training and Validation Losses')
plt.xlabel('Epoch Number')
plt.legend(['Training Loss', 'Validation Loss'])

# Gender, Age, Annual Salary, Credit Card Debt, Net Worth 

# ***(Note that input data must be normalized)***

X_test_sample = np.array([[0, 0.4370344,  0.53515116, 0.57836085, 0.22342985]])
y_predict_sample = model.predict(X_test_sample)

print('Expected Purchase Amount=', y_predict_sample)
y_predict_sample_orig = scaler_y.inverse_transform(y_predict_sample)
print('Expected Purchase Amount=', y_predict_sample_orig)<jupyter_output>Expected Purchase Amount= [[0.38515678]]
Expected Purchase Amount= [[36346.133]]
{'fraction_non_alphanumeric': 0.19195201199700074, 'fraction_numerical': 0.07198200449887528, 'mean_word_length': 6.021052631578947, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '630595', 'license': 'MIT', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1451, 'n_words': 335, 'path': 'Neural-Networks/ARTIFICIAL NEURAL NETWORKS - CAR SALES PREDICTION.ipynb', 'repo_name': 'Vegitoss4/ML-Projects', 'size': '4001'}