Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code a neural network with Keras. To do this, youll complete the given Python script named create_model.py, shown below. import pandas as pd from keras.models

Code a neural network with Keras. To do this, youll complete the given Python script named create_model.py, shown below.

import pandas as pd from keras.models import Sequential from keras.layers import * training_data_df = pd.read_csv("sales_data_training_scaled.csv") X = training_data_df.drop('total_earnings', axis=1).values Y = training_data_df[['total_earnings']].values # Define the model model =
 
# Train the model
model.fit()
 
# Load the test data
# Load the separate test data set
test_data_df = pd.read_csv("sales_data_test_scaled.csv")
 
X_test = test_data_df.drop('total_earnings', axis=1).values
Y_test = test_data_df[['total_earnings']].values
 

First, on line five, use the Python package, Pandas library, (click here Links to an external site.for more information) to load the pre-scaled data from a CSV file. Each row of the dataset contains several features that describe each video game and then the total earnings value for that game. You want to split that data into two separate arrays: one with just the input features for each game and one with just the expected earnings.

On line seven, to get just the input features, we grab all of the columns of the training data but drop the total earnings column. Then, on line eight, extract just the total earnings column as shown. Now, X contains all the input features for each game, and Y contains only the expected earnings for each game. Now, you can build a neural network starting on line 11.

Incorporate the following parameters into your model definition:

use a sequential model

use nine inputs and one output

make the model dense

use the ReLU activation function for the hidden layers

use the linear activation function for the output layer.

Train your model using both X and Y as well as the following:

50 epochs

shuffle=True; this action will make Keras shuffle the data randomly during each epoch

verbose = 2; this tells Keras to print detailed information during the processing. Take a screenshot of these messages for your submission.

Evaluate your neural network model using model.evaluate(...) method. Print out the MSE for the test dataset.

test_error_rate = model.evaluate() print("The mean squared error (MSE) for the test data set is: {}".format(test_error_rate))

Save your trained model. You will submit this model as part of your assignment.

# Save the model to disk model.save("trained_model.h5") print("Model saved to disk.") 

Next, you will load your trained model to make predictions. The prediction information is stored in proposed_new_product.csv and consists of one row

Complete the final segment of Python code. Be sure to rescale your final prediction using the two parameters during the scaling of the training and testing data sets.

import pandas as pd from keras.models

import load_model

model = load_model('trained_model.h5')

X = pd.read_csv("proposed_new_product.csv").values prediction = model.predict()

# Grab just the first element of the first prediction (since we only have one)

prediction = prediction[][]

# Re-scale the data from the 0-to-1 range back to dollars

# These constants are from when the data was originally scaled down to the 0-to-1 range

prediction = prediction + _____

prediction = prediction / _____ print("Earnings Prediction for Proposed Product - ${}".format(prediction))

Please include an summary of your findings, a screenshot showing the verbose run-time outputs, the testing MSE, and your final prediction

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago