Howdy World! welcome to my First Put up on Medium !
The long run is a thriller, however what if we may peek into it? Think about having a crystal ball — not the magical type, however one powered by Python and math! How superb wouldn’t it be to make use of easy mathematical rules to information your choices at the moment and form the long run you need?
Image your self as a modern-day fortune teller, utilizing the magic of numbers to foresee and affect what’s to come back. With the proper instruments, you may flip uncertainty into alternative and make knowledgeable decisions that result in your required outcomes. 🌟
On this put up I’ll clarify how one can predict the long run utilizing Arithmetic adopted by a easy tutorial on how to take action on Python. So seize your pondering caps and observe alongside.
Think about a newly worthwhile startup aiming to impress the traders on Shark Tank. The catch? They should make not less than 70 Lakhs in revenue this 12 months to safe funding. So, how can they predict their revenue and guarantee they meet this goal?
Enter Linear Regression — a strong approach that makes use of historic information to foretell future outcomes. Right here’s the way it works and why it’s excellent for our startup:
Linear Regression helps us estimate the worth of an unseen occasion based mostly on previous information. To make use of this method successfully, a couple of assumptions have to be met:
- Linearity: The info ought to present a linear development (both rising or reducing). Since our startup is steadily rising, we will safely assume the information is linear.
- Homoskedasticity: Don’t fear about this time period for now — I’ll cowl it in one other put up quickly!
- Non-Multicollinearity: If we’ve got a number of impartial variables (present information), they need to be impartial of one another.
Linear Regression minimizes a price operate utilizing a method known as Gradient Descent. When the worth of this price operate falls under a sure threshold, we all know we’ve reached our optimum answer.
The associated fee operate fashions the connection between dependent and impartial variables, giving us a mathematical equation. All we have to do is plug within the values we’re searching for to get our reply. Isn’t that fancy?
By using Linear Regression, our startup can predict whether or not they’ll hit the 70 Lakhs revenue mark. This not solely boosts their confidence but additionally offers a strong basis to current to the Sharks.
Now you know the way the long run is predicted however are you able to do it?
Here’s a step-by-step tutorial to foretell the income of the startup for this 12 months.
Think about the pattern information :
Let’s write some Code!
- Import the required libraries
Numpy is used to retailer information and carry out computation
Matplotlib is used to visualise information
Sklearn is used to carry out gradient descent and do the principle computation
# Import essential libraries
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
2. Initialize two lists, one listing incorporates the dependent variable (Income) and the opposite one incorporates the impartial variables (Yr)
X = np.array([[1], [2], [3], [4], [5], [6]]) # Indendent varible (Years)
y = np.array([4, 10, 25, 40, 48, 60]) #Dependent variable (Income)
3. Cut up the information — That is performed to scale back bias in calculating the mannequin parameters. At this stage don’t worry about it an excessive amount of.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
4. Apply linear regression
mannequin = LinearRegression()mannequin.match(X_train, y_train)
5. Predict the FUTURE
y_pred = mannequin.predict([[7]]) #right here 7 represents the seventh 12 months of prediction
print(y_pred)
6. Visualize the information
plt.scatter(X, y, shade='black') # Check information factors
plt.plot([[7]], y_pred ,shade='blue', linewidth=3) # Regression line
plt.title("Linear Regression")
plt.xlabel("X")
plt.ylabel("y")
plt.present()
Here’s a link to google collab pocket book in case you wish to see the implementation in a single go.
Properly properly properly, prove the Startup will make 71.5 Lakh this 12 months!!!! They will go to SHARK TANK!!!!!
So, that is it from me at the moment! If you happen to preferred this put up then do share it with your pals and continue to learn. See you subsequent time!!!