Python - Regression - Polynomial

Data:

Salary list from job position (11 rows)

Mission:

How to predict the probability of salary when a job position (level) added to the list

Library used:

  • Pandas
  • Matplotlib
  • Numpy
  • Scikit

Code:

import pandas as pd
from sklearn.preprocessing import PolynomialFeatures
import numpy as np
import matplotlib.pyplot as plt

url = 'https://raw.githubusercontent.com/kokocamp/vlog120/main/vlog120.csv'
vlog120 = pd.read_csv(url)
vlog120.describe()
#vlog120.head()

X = vlog120['Level']
y = vlog120['Gaji']
print(y)

derajat = 4
poly_fit = np.poly1d(np.polyfit(X,y, derajat))
xx = np.linspace(0, 13, 100000)
plt.plot(xx, poly_fit(xx), c='r',linestyle='-')
plt.title('Polynomial')
plt.xlabel('Level')
plt.ylabel('Gaji')
plt.grid(True)
plt.scatter(X, y)
plt.show()

print( poly_fit(12) )

I wrapped the scenario in a Youtube video below.


Click this link (http://paparadit.blogspot.com/2020/11/the-algorithms-of-machine-learning.html), if you want to check out for other algorithms. Thank you for for visiting this blog & subs my channel.

Labels: ,


PS: If you've benefit from this blog,
you can support it by making a small contribution.

Enter your email address to receive feed update from this blog:

Post a Comment

 

Post a Comment

Leave comments here...