If you are using Scikit-Learn, you can easily use a lot of algorithms that are already made by some famous Researchers, Data Scientists, and other Machine Learning experts. Have you ever thought of building your algorithm instead of using a module like Scikit-Learn? All the Machine Learning Algorithms that Scikit-Learn provides are easy to use but to be a Machine Learning Expert in a brand like Google and Microsoft, you need to build your algorithms instead of using any package so that you could easily create an algorithm according to your needs. In this article, I will teach you how you can easily create your algorithms instead of using any package like Scikit-Learn provided with Python. I will create a Linear Regression Algorithm using mathematical equations, and I will not use Scikit-Learn in this task.

The role of a Data Scientist and a Machine Learning Expert are not just to fit a model and training and testing. These are only the basic stuff that you need to know. Without these, you cannot be called as a practitioner in Machine Learning. But if you started to build your algorithms, it will make you an ideal Expert of all.

Also Read: Audio Processing with Python.

What is a Linear Regression Algorithm?

A Linear Regression algorithm makes a prediction by simply computing a weighted sum of the input features, plus a constant called the bias term. In mathematics a linear regression algorithm looks like:

Linear Regression algorithmLinear Regression

Linear Regression Algorithm without Scikit-Learn

Let’s create our own linear regression algorithm, I will first create this algorithm using the mathematical equation. Then I will visualize our algorithm using the Matplotlib module in Python. I will only use the NumPy module in Python to build our algorithm because NumPy is used in all the mathematical computations in Python. I will start here by creating linear-looking data so that I can use that data in creating my Linear Regression Algorithm:

import numpy as np
​
X = 2 * np.random.rand(100, 1)
y = 4 + 3 * X + np.random.randn(100, 1)
​

Before moving forward let’s visualize this data:

import matplotlib as mpl
import matplotlib.pyplot as plt
plt.plot(X, y, "b.")
plt.xlabel("$x_1$", fontsize=18)
plt.ylabel("$y$", rotation=0, fontsize=18)
plt.axis([0, 2, 0, 15])
plt.show()

data

#by aman kharwal #linear regression #machine learning #python #algorithms

Linear Regression Algorithm without Scikit-Learn
6.90 GEEK