# Analysis of fish dataset using deep learning with PyTorch

Lets see!! in which we are predicting the weight of fish using various factors such as height,width,length.For analysis we are using one of the framework called as PyTorch and there are various framework available Tensorflow which is developed by Google for the deep learning purpose.

PyTorch is an open source machine learning library used for developing and training neural network based deep learning models. It is primarily developed by Facebook’s AI research group.it is very well suited for the OOP kind of approach with torch.nn.Module gives us the ability to define reusable modules

for starting with PyTorch you can go through with some of the basic functions from https://medium.com/@aditya.nagraj1999/different-pytorchs-tensor-functions-30245f1f89f3

You can go through the Documentation of PyTorch :

We shall implement Linear Regression:

what is Linear regression?

The two factors that are involved in simple linear regression analysis are designated x and y. The equation that describes how y is related to x is known as the regression model.

Simple Equation:y = β0 +β1x

where:

β0 is the y-intercept of the regression line.

β1 is the slope.

Ε(y) is the mean or expected value of y for a given value of x.

First of all we shall import necessary library and start the process

Let’s see a shape of our dataframe.

# Step 2: Prepare the dataset for training

We need to convert the data from the Pandas dataframe into a PyTorch tensors for training. To do this, the first step is to convert it numpy arrays. this following function will perform the conversion to numpy arrays.

Convert the numpy arrays `inputs_array` and `targets_array` into PyTorch tensors. Make sure that the data type is `torch.float32`.

Now we’ll convert torch tensor to tensor Dataset.

# Step 3: Create a Linear Regression Model

Lets s create a object to the above class

Now we’ll define an `evaluate` function, which will perform the validation phase, and a `fit` function which will perform the entire training process.

# Step 4: Train the model to fit the data

Now we can vary the learning rate by 1e-3,1e-4,1e-5 and we can do hyperparametry and improve the accuracy.

# Step 5: Make predictions using the trained model

Now we will predict the values of target and the predicted weights and we can check the accuracy

We can improve the accuracy by increasing the number of epochs and varying learning rates.

References:

https://jovian.ml/aakashns/03-logistic-regression
https://pytorch.org/docs/stable/
https://www.freeCodeCamp.org/
https://machinelearningmastery.com/