ISE529 Predictive Analytics 2024 Fall Homework 6

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

ISE529 Predictive Analytics

2024 Fall

Homework 6

Due by: Dec. 3, 2024, 11:59 PM

1. (30 points)

Fit a neural network to the Default.csv data set. Default is response variable. Split the data into 70% training set and 30% test set. Use tensorflow.keras library to build your neural network with the following specification for the hyperparameters:

n a single hidden layer with 10 neurons

n dropout regularization rate 40%

n activation function: ReLu and Sigmoid

n epochs 30

n batchsize 128

n validation split 0.2

Tasks:

n Perform prediction with test data set.

n Plot training and test error curves.

n Show test set accuracy.

n Compare the test set accuracy of your neural network model with that of linear logistic regression.

2. (70 points)

You need to use the CARC-HPC cluster computers to complete this modeling work.

Concrete Dataset

n Dataset info and download: https://data.mendeley.com/datasets/5y9wdsg2zt/2

The CNN Network

n Develop your own CNN model to classify all classes with tensorflow.keras library.

n Provide the training and test confusion matrices.

n Provide the test accuracy and confusion matrix to a text file.

n Provide the Loss curves for training and validation (you can use a single plot for these two curves)

n Expected results: High 90’s for training, validation, and testing without overfitting or underfitting.

Submit:

n Python file(s) (.py)

n Confusion matrix image (.png or .jpg)

n Curve image(s) (.png or .jpg)

n The text file with all the metrics

n The SLURM/.OUT files used for the CARC-HPC cluster execution

Rubric per Part and Overall:

n Header in the code (5pts)

n Comments in the code (10pts)

n Running code without errors (20pts)

n Executes requirements & produces required output information (35pts)

Template code: refer to mnist-cnn-example.py in Brightspace.

Intall TensorFlow in terminalpip install tensorflow

from tensorflow.keras.datasets import mnist

from tensorflow.keras.utils import to_categorical

from tensorflow.keras import layers

from tensorflow.keras import models

(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

#------------- training tensor and normalization

train_images = train_images.reshape((60000, 28, 28, 1))

train_images = train_images.astype( 'float32') / 255

#------------ test tensor and normalization

test_images = test_images.reshape((10000, 28, 28, 1))

test_images = test_images.astype( 'float32') / 255

#------------- string to numerical

train_labels = to_categorical(train_labels)

test_labels = to_categorical(test_labels)

#-------------- Creating the CNN model --------------------------------------

model = models.Sequential()

model.add(layers.Conv2D(32, (3, 3), activation= 'relu', input_shape=(28, 28,

1)))

model.add(layers.MaxPooling2D((2, 2)))

model.add(layers.Conv2D(64, (3, 3), activation= 'relu'))

model.add(layers.MaxPooling2D((2, 2)))

model.add(layers.Conv2D(64, (3, 3), activation= 'relu'))

model.add(layers.Flatten())

model.add(layers.Dense(64, activation= 'relu'))

model.add(layers.Dense(10, activation= 'softmax'))

#--------------- Configuring the model compilation --------------------------

-

model.compile (optimizer= 'rmsprop', loss= 'categorical_crossentropy',

metrics=[ 'accuracy'])

#--------------- Training ---------------------------------------

model.fit (train_images, train_labels, epochs=5, batch_size=64)

#---------------- Testing predictions ----------------------------

predictions = model.predict (test_images)

test_loss, test_acc = model.evaluate (test_images, test_labels)

print("Test accuracy: %f", test_acc)



发表评论

电子邮件地址不会被公开。 必填项已用*标注