-
Notifications
You must be signed in to change notification settings - Fork 0
ICP 8
In this ICP, we have learnt about what is deep learning, applications of it, how it works, Introduction to Keras Library and its basic operations. Installation procedure.
-
Python version 3
-
Pycharm
-
Anaconda
-
Github
-
Keras
-
Tensorflow
1.Use the use case in the class:
a.Add more Dense layers to the existing code and check how the accuracy changes.
(a) For the above case, the data set considered is diabetes.csv
(b) Link for the above data set is given below.
https://umkc.box.com/s/3cvfiwc81lhgygc67deyeqs8m858lld0
Below the source code without adding the additional dense layers.
(c) The accuracy value is as shown below before adding additional dense layers.
(d) Importing the necessary libraries in Python which are NumPy, Pandas, Keras and Sklearn.
(e) Reading the CSV as a pandas data frame.
(f) Splitting the data into test and train.
(g) 25% of the dataset in test and remaining is training split.
(h) Initializing the Sequential Model.
(i) We used hidden layers and one output layer.
(j) Hyperparameters used are Number of neurons: 20,10,50 Input Dim: 8, Activation: Relu and Activation for output: Sigmoid.
(k) Iterated through the no of neurons list and added two new layers for each of it with Activation: Relu.
(l) Accuracy with one hidden layer has got improved from 0.67 to 0.75 as shown below.
2.Change the data source to Breast Cancer dataset available in the source folder and make required changes
(a) For the above case, the data set considered is Breas Cancer.csv
(b) Link for the above data set is given below.
https://umkc.box.com/s/3cvfiwc81lhgygc67deyeqs8m858lld0
(c) Importing the necessary libraries in Python which are Pandas, Keras and Sklearn.
(d) Reading the CSV as a pandas data frame.
(e) Dividing the data source into X and Y variables.
(f) In the given dataset Target Variable is the diagnosis. So, the Y variable will be Diagnosis.
(g) Slicing the features for x variables and y variable accordingly.
(h) Dropping the NAN column from the X data frame as it is not significant for the model.
(i) In the given dataset the target variable is in Categorical from but we would be requiring it in the numerical form in order to train the model. So, using the Lambda function mapped the 'M' to 0 and 'B' to 1. Also, the verified the value counts to the before and after.
(j) Splitting the data into test and train.
(k) 25% of the dataset in test and remaining is training split.
(l) Initializing the Sequential Model.
(m) We used only one hidden layer and one output layer.
(n) Hyperparameters used are Number of neurons: 50, Input Dim: 29, Activation: Relu and Activation for output: Sigmoid.
Found out the binary_crossentropy loss as 31 and Accuracy with one hidden layer, we got around 93%
3.Normalize the data before feeding the data to the model and check how the normalization change your accuracy (code given below).
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
(a) For the above case, the data set considered is Breas Cancer.csv
(b) Link for the above data set is given below.
https://umkc.box.com/s/3cvfiwc81lhgygc67deyeqs8m858lld0
(c) Importing the necessary libraries in Python which are Pandas, Keras and Sklearn.
(d) Reading the CSV as a pandas data frame.
For Normalization, StandarScaler library is imported and the function is applied as shown below.
sc=StandardScaler()
sc.fit(x)
x_norm=sc.transform(x)
print(x_norm)
(e) Dividing the data source into X and Y variables.
(f) In the given dataset Target Variable is the diagnosis. So, the Y variable will be Diagnosis.
(g) Slicing the features for x variables and y variable accordingly.
(h) Dropping the NAN column from the X data frame as it is not significant for the model.
(i) In the given dataset the target variable is in Categorical from but we would be requiring it in the numerical form in order to train the model. So, using the Lambda function mapped the 'M' to 0 and 'B' to 1. Also, the verified the value counts to the before and after.
(j) Splitting the data into test and train.
(k) 25% of the dataset in test and remaining is training split.
(l) Initializing the Sequential Model.
(m) We used only one hidden layer and one output layer.
(n) Hyperparameters used are Number of neurons: 50, Input Dim: 29, Activation: Relu and Activation for output: Sigmoid.
The accuracy value has changed from 0.93 to 0.96