Lab assignment #2 - SaitejaswiK/CSEE5590_Python-DL_Lab GitHub Wiki
Team #5
Name: Saitejaswi K
Class ID: 16
Name: Kartheek Katta
Class ID: 12
Name: Aanchal Tiwari
Class ID: 38
Objective:
The main objective of this lab tutorial is a walk through of basics of deep learning, how to create a neural network, how tensorflow helps in plotting the loss and accuracy of the model, various hyper parameters required for the model, how changing the hyper parameters affect the model accuracy.
Technologies/IDE's used:
- Python 3.7
- Pycharm IDE
Libraries used:
- Numpy
- Pandas
- Keras library
Workflow:
The workflow of the any machine learning algorithm in this lab assignment is as follows:
- As per the workflow, initially, a dataset is taken, pre-processing on the dataset like calculating the null values, replacing the obtained null values, correlation in between features are performed.
- Next step is splitting the whole dataset into two different parts namely training and testing, where the model is trained based on the trained dataset and it is being validated on the test data.
- Now, the model is being fit, and corresponding metrics are calculated.
Program 1:
Implement the Linear Regression with any data set of your choice except the datasets being discussed in the class or source code.
Initially, the data is loaded is into pandas dataframe, using label encoder, converting all the non-numerical data into numerical data. In this step pre-processing of data is being done.
Splitting the data using the train_test_split for validation and training data.
Plot the loss and then change the below parameter and report your view how the result changes in each case
a.learning rate
b.batch size
c.optimizer
d.activation function
The above are the two models where I have changed the hyper parameters. using the hyper parameters now, just fit the model as follows.
Show the graph in TensorBoard
Adding this part of code activates the tensorboard and corresponding plots are obtained.
Results:
Here are the results obtained:
Accuracy obtained:
After changing the Hyper parameters:
Program 2:
Implement Logistic Regression with any data set of your choice.
a. Show the graph in TensorBoard
b. Show the Loss in TensorBoard
c. use score=model.evaluate(x_text,y_test)and then print(‘test accuracy’, score[1])to print the accuracy
d. Change three hyperparameter and report how the accuracy changes
To complete this question, the workflow is same as the above question, pre-processing the data, converting non-numerical data into numerical data, fitting the model, evaluating the scores.
Training and test data:
Fitting the model:
Change of Hyper parameters:
Fitting the model and evaluating scores:
Tensorflow:
Results:
Here are the results of the above model.
**Accuracy: **
Results obtained after the change of Hyper parameters:
Program 3:
Implement the text classification with CNN model on Spam text classification dataset or Reuters dataset.
Spam dataset have two columns namely Category and Message where Category is of two different classes, Ham or Spam and message is the message.
Converting non-numerical data into numerical data
Necessary Steps for a CNN model:
CNN Model:
Results:
Program 4:
Implement the text classification with LSTM modelon Spam text classification dataset or Reuters dataset.
Same as the above model but just changing the model to LSTM.
Results:
Program 5:
Compare the results of CNN and LSTM models, for the text classification and describe, which model is best for the text classification based on your results.
CNN Model proved to be more efficient
- RNN model gave 0.9675 accuracy
- CNN model gave 0.9987 accuracy
Reason
Program 6:
Implement the image classification with CNN model, with a new dataset which is not used in the class.
Preparing the train and test data:
Creating the network model:
Fitting the model and accuracy:
Tensorflow:
Results:
Here are the results obtained:
Accuracy:
References: