testting codes

This commit is contained in:
Morten Hjorth-Jensen
2021-09-21 10:54:28 +02:00
parent ca4dc3db8b
commit 249454d2dc
11 changed files with 129 additions and 36 deletions
+5 -5
View File
@@ -237,7 +237,7 @@ plt.show()
===== To think about =====
When you are comparing your own code with for example _Scikit-Learn_'s library, there are some minor things to keep in mind.
The example here shows how one can leave out or keep the intercept.
The example here shows how one can keep the intercept in order to compare own code.
!bc pycod
import numpy as np
@@ -316,10 +316,10 @@ for i in range(nlambdas):
print(RegRidge.coef_)
# Now plot the results
plt.figure()
plt.plot(np.log10(lambdas), MSEOwnRidgeTrain, label = 'MSE Ridge train')
plt.plot(np.log10(lambdas), MSEOwnRidgePredict, 'r--', label = 'MSE Ridge Test')
plt.plot(np.log10(lambdas), MSERidgeTrain, label = 'MSE Ridge train')
plt.plot(np.log10(lambdas), MSERidgePredict, 'r--', label = 'MSE Ridge Test')
plt.plot(np.log10(lambdas), MSEOwnRidgeTrain, 'b', label = 'MSE Ridge train')
plt.plot(np.log10(lambdas), MSEOwnRidgePredict, 'r', label = 'MSE Ridge Test')
plt.plot(np.log10(lambdas), MSERidgeTrain, 'y', label = 'MSE Ridge train')
plt.plot(np.log10(lambdas), MSERidgePredict, 'g', label = 'MSE Ridge Test')
plt.xlabel('log10(lambda)')
plt.ylabel('MSE')