Step1: Importing the Libraries
import numpy as np
import pandas as pd
import pandas as pd
Numpy is for performing numerical calculations.
Pandas is for reading CSV files.
Step 2: Reading the CSV files
data = pd.read_csv('Sample scores.csv')
Step 3: Linear regression using SKLEARN
from sklearn.linear_model import LinearRegression
Step 4: Data-Visualization
import plotly.express as px
fig = px.scatter(data,x='Overs', y='Scores')
fig.show()
Step 5: Creating dataframes
linear_reg = LinearRegression()
x = data.Overs.values.reshape(-1,1)
y = data.Scores.values.reshape(-1,1)
x = data.Overs.values.reshape(-1,1)
y = data.Scores.values.reshape(-1,1)
Step 6 : Applying formula on dataframes
linear_reg.fit(x,y)
Step 7: Prediction of 20th over
next_salary = linear_reg.predict([[19]])
print(int(next_salary))
print(int(next_salary))
Output: 8 runs will be 20th over score.
Thanks for reading this article💗
Fullcode : Cricket score prediction
Please provide data set
ReplyDeleteuploaded on telegram
Delete