### Blog: Simplified machine learning (Part: 1)

Hello world, I’m Ankit back with another technical blog. In this series of blogs we will talk about machine learning, deep learning and neural networks. We will code, learn the inside and understand the concepts in the simplest way.

Before we start lets install few tools in your windows or Linux system. Let’s get start with installing Python followed by

Numpy (pip install numpy): For any work with matrices and math operations

Scipy (pip install scipy): For scientific and technical computing.

Pandas (pip install pandas) :Data handling, manipulation and analysis.

Matplotlib (pip install matplotlib):Data visualisation.

Scikit learn (pip install scikit-learn):Machine learning.

Keras(pip install keras):High-level neural networks API.

Super command:python -m pip install numpy scipy matplotlib ipython jupyter pandas sympy nose

Yeah done with installation so let’s start our journey with machine learning. Let me tell you its not enough for just read the blogs or watch tutorials. Whatever you will read or understand here must go and try it. So without wasting your time lets get to the point.

**Machine learning :**

Practice of using algorithms to analyze data, learn from data and then make determination or predication about new data.

1) Email spam classifiers

2) House price predication

3) sentiments analysis.

4) Most of the day today applications you are using including Gmail, Google photos, Instagram, Facebook, LinkedIn etc.

Machine learning is extracting features from data, understanding it. and where model learn from the input data.

**Deep Learning:**

Tool or technique to implement machine learning.

Sub field of machine learning, that’s uses algorithms inspired by the structure and function of the brains neural network.

Models in deep learning called as Artificial neural networks. These are the terms which are interchangeable to each other

1) Model Net

2) Ann

3) Neural net

Example:* Image recolonization Image classification*

Types of learning:

**1) Supervised learning **

Used data which is already being labeled.

Example:* Recognizing cat or dog from an image, the data set which is used to train have label data (images) of cat and dog. *** 2) Unsupervised learning**

Used data which is not labeled.

Example:

Recognizing cat or dog from an image, the data set which is used to train our model don’t have label data (images) of cat and dog. Model will extract features and patterns and automatically and classify them into dog or cat.

**Artificial Neural network:**

Artificial neural network are based on brains or bio-logical neural networks. It is collection of artificial neuron in different layers. All neurons are capable to process the input and transmit the signals to its next neurons.

The inputs are process layer by layer.

There are following layers.

1) Input layer :

First layer

2) Hidden layer :

Middle layer

3) Output layer :

Output layer or last layer

Program:

Using Keras Api to write neural network in few lines of code.

Here we are using Keras sequential Model.

Refer Program :

**Sequential Model:**

Linear stack of layers. And as we had seen ANN is a collection of neurons which is organized in layers.

**Keywords:***Dense*** = layers**:

*Dense is an object. Dense connects each input to each output. It is hidden layer as its connecting input layer to output layer*

**Input_shape**: *Shape of our data which we are going to pass in our model.*

*Activation function: **Nonlinear function which follow dense layer.*

**Different types of layer’s in ANN:**

1) Dense layer’s

2) Fully connected layer’s

3) Convolution layer’s

4) Pooling layer’s

5) Normalization layer’s

6) Recurrent Layer’s

etc.

Different layers performs different kinds transformation in ANN at different inputs. These layers give different behaviors at different inputs. Some are built to work with some specific type of data inputs.

Example.

1) CNN are use in image data (unstructured data)

2) Recurrent NN are good with time series data

3) Dense connects each input with each output within layer’s

Let’s see how we code a 3 layers NN. WE will use Keras Python NN Api.

Now consider we have to build a NN with 3 inputs, one hidden layers with 5 node, and output layer with2 nodes.

Program will look like below.

Activation function:

A-NN are inspired by neural network of our brain. And activation function is nothing but which activate certain neurons in our brain which take decisions.

Their main purpose of an activation function is to convert an input signal of a node to an output signal.

A Neural Network without Activation function would simply be a Linear regression Model. Linear function is just a polynomial of one degree, A linear function is easy to solve but it has limited capabilities and power.

As we are talking about machine learning and deep learning, we know that it comes up with lots of multi dimensional data, lots of complexity in structure of data which need more computing power.We are talking about lots of neurons and lots of hidden layers in model.

There are several activation function in NN. Depend on data and work we wanna to get done we used this activation function.

**1) Sigmoid or Logistic:**

Neurons can be between zero and one. Closer to one is more activated neuron, and closer to zero is less activated. It takes an input and if the input is a negative number than it transfer it to zero and if the number is very positive number than the sigmoid will transfer it very close to one. And if input is close to zero than sigmoid will transfer it in between 0 and 1. For sigmoid zero is the lower limit and one is the upper limit.

Program will look like below.

**2) ReLu -Rectified linear units**

Relu transfer input to zero or keep the input as it is. In short, it keeps the positive input and removes the negative input from the data.

Example :

If input is -2, 1

Relu will transfer -2 to 0 and keep 1 as it as.

The greater value positive number show more activated neuron and negative value shows less activated of no activated.

Program will look like below.

Here above is the one way we pass activation function.

Another way, check out below program, here we are adding activation layer.

model=Sequential()

model.add(dense(5,input_shape(3,)))

model.add(activation(‘relu’))

Click here (https://keras.io/activations/) to read more about Activation function

### Summary

#### Neural networks provide the possibility to solve complicated non-linear problems. They can be used in various areas such as signal classification, forecasting time series and pattern recognition. A neural network is a model inspired by the human brain and consists of multiple connected neurons. The network consists of a layer of input neurons, a layer of output neurons and a number of hidden layers in between.

In this section we learn basic of neural network, how to write a program for NN and its importance in deep learning. In next blog we will learn about Training our neural network and many more things.

**Hope you enjoyed this blog.**

Let’s share some love by sharing it with your friends and all those who need to read this blog. **Hit that clap button and follow me to get more articles on your feed**.

To connect with me on social media just search for Ankitkumar Singh Or click on below links.

Facebook || Instagram || LinkedIn

## Leave a Reply