test for log reg
This commit is contained in:
@@ -3,9 +3,6 @@ AUTHOR: Morten Hjorth-Jensen {copyright, 1999-present|CC BY-NC} at Department of
|
||||
DATE: today
|
||||
|
||||
|
||||
!split
|
||||
===== Optimization problems, why? =====
|
||||
|
||||
!split
|
||||
===== Optimization, the central part of any Machine Learning algortithm =====
|
||||
|
||||
@@ -810,7 +807,7 @@ xb = np.c_[np.ones((100,1)), x]
|
||||
theta_linreg = np.linalg.inv(xb.T.dot(xb)).dot(xb.T).dot(y)
|
||||
print("Own inversion")
|
||||
print(theta_linreg)
|
||||
sgdreg = SGDRegressor(n_iter = 50, penalty=None, eta0=0.1)
|
||||
sgdreg = SGDRegressor(max_iter = 50, penalty=None, eta0=0.1)
|
||||
sgdreg.fit(x,y.ravel())
|
||||
print("sgdreg from scikit")
|
||||
print(sgdreg.intercept_, sgdreg.coef_)
|
||||
@@ -853,11 +850,6 @@ for epoch in range(n_epochs):
|
||||
print("theta from own sdg")
|
||||
print(theta)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
plt.plot(xnew, ypredict, "r-")
|
||||
plt.plot(xnew, ypredict2, "b-")
|
||||
plt.plot(x, y ,'ro')
|
||||
@@ -870,6 +862,9 @@ plt.show()
|
||||
!ec
|
||||
|
||||
|
||||
!split
|
||||
===== Logistic Regression example =====
|
||||
|
||||
|
||||
!split
|
||||
===== Using gradient descent methods, limitations =====
|
||||
|
||||
Reference in New Issue
Block a user