Video on Machine Learning Algorithms in Tamil – இயந்திர வழிக் கற்றல் நெறிமுறைகள் அறிமுகம் – காணொளி

Introduction to Machine Learning Algorithms in Tamil
Simple Linear regression
Multiple Linear Regression

இயந்திர வழிக் கற்றல் நெறிமுறைகள் அறிமுகம்

மேலும் அறிய, பின் வரும் இணைப்புகள், நிரல்களைக் காண்க.

 

Machine Learning – பகுதி 4


import matplotlib.pyplot as plt
x=[[6],[8],[10],[14],[18],[21]]
y=[[7],[9],[13],[17.5],[18],[24]]
plt.figure()
plt.title('Pizza price statistics')
plt.xlabel('Diameter (inches)')
plt.ylabel('Price (dollars)')
plt.plot(x,y,'.')
plt.axis([0,25,0,25])
plt.grid(True)
plt.show()


import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
x = [[6], [8], [10], [14], [18]]
y = [[7], [9], [13], [17.5], [18]]
model = LinearRegression()
model.fit(x,y)
plt.figure()
plt.title('Pizza price statistics')
plt.xlabel('Diameter (inches)')
plt.ylabel('Price (dollars)')
plt.plot(x,y,'.')
plt.plot(x,model.predict(x),'–')
plt.axis([0,25,0,25])
plt.grid(True)
plt.show()
print ("Predicted price = ",model.predict([[21]]))


from sklearn.linear_model import LinearRegression
import numpy as np
x = [[6], [8], [10], [14], [18]]
y = [[7], [9], [13], [17.5], [18]]
model = LinearRegression()
model.fit(x,y)
print ("Residual sum of squares = ",np.mean((model.predict(x)- y) ** 2))
print ("Variance = ",np.var([6, 8, 10, 14, 18], ddof=1))
print ("Co-variance = ",np.cov([6, 8, 10, 14, 18], [7, 9, 13, 17.5, 18])[0][1])
print ("X_Mean = ",np.mean(x))
print ("Y_Mean = ",np.mean(y))


from sklearn.linear_model import LinearRegression
import numpy as np
from numpy.linalg import inv,lstsq
from numpy import dot, transpose
x = [[6], [8], [10], [14], [18]]
y = [[7], [9], [13], [17.5], [18]]
model = LinearRegression()
model.fit(x,y)
x_test = [[8], [9], [11], [16], [12]]
y_test = [[11], [8.5], [15], [18], [11]]
print ("Score = ",model.score(x_test, y_test))

view raw

04_scoring.py

hosted with ❤ by GitHub


from sklearn.linear_model import LinearRegression
from numpy.linalg import lstsq
import numpy as np
x = [[6, 2], [8, 1], [10, 0], [14, 2], [18, 0]]
y = [[7], [9], [13], [17.5], [18]]
model = LinearRegression()
model.fit(x,y)
x1 = [[8, 2], [9, 0], [11, 2], [16, 2], [12, 0]]
y1 = [[11], [8.5], [15], [18], [11]]
predictions = model.predict([[8, 2], [9, 0], [12, 0]])
print ("values of Predictions: ",predictions)
print ("values of β1, β2: ",lstsq(x, y, rcond=None)[0])
print ("Score = ",model.score(x1, y1))

%d bloggers like this: