Guest User

Untitled

a guest
Jun 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. from pylab import *
  2. data = array(
  3. [[1,4.9176,1.0,3.4720,0.998,1.0,7,4,42,3,1,0,25.9],
  4. [2,5.0208,1.0,3.5310,1.50,2.0,7,4,62,1,1,0,29.5],
  5. [3,4.5429,1.0,2.2750,1.175,1.0,6,3,40,2,1,0,27.9],
  6. [4,4.5573,1.0,4.050,1.232,1.0,6,3,54,4,1,0,25.9],
  7. [5,5.0597,1.0,4.4550,1.121,1.0,6,3,42,3,1,0,29.9],
  8. [6,3.8910,1.0,4.4550,0.988,1.0,6,3,56,2,1,0,29.9],
  9. [7,5.8980,1.0,5.850,1.240,1.0,7,3,51,2,1,1,30.9],
  10. [8,5.6039,1.0,9.520,1.501,0.0,6,3,32,1,1,0,28.9],
  11. [9,16.4202,2.5,9.80,3.420,2.0,10,5,42,2,1,1,84.9],
  12. [10,14.4598,2.5,12.80,3.0,2.0,9,5,14,4,1,1,82.9],
  13. [11,5.8282,1.0,6.4350,1.225,2.0,6,3,32,1,1,0,35.9],
  14. [12,5.303,1.0,4.9883,1.552,1.0,6,3,30,1,2,0,31.5],
  15. [13,6.2712,1.0,5.520,0.975,1.0,5,2,30,1,2,0,31.0],
  16. [14,5.9592,1.0,6.6660,1.121,2.0,6,3,32,2,1,0,30.9],
  17. [15,5.050,1.0,5.0,1.020,0.0,5,2,46,4,1,1,30.0],
  18. [16,5.6039,1.0,9.520,1.501,0.0,6,3,32,1,1,0,28.9],
  19. [17,8.2464,1.5,5.150,1.664,2.0,8,4,50,4,1,0,36.9],
  20. [18,6.6969,1.5,6.9020,1.488,1.5,7,3,22,1,1,1,41.9],
  21. [19,7.7841,1.5,7.1020,1.376,1.0,6,3,17,2,1,0,40.5],
  22. [20,9.0384,1.0,7.80,1.50,1.5,7,3,23,3,3,0,43.9],
  23. [21,5.9894,1.0,5.520,1.256,2.0,6,3,40,4,1,1,37.5],
  24. [22,7.5422,1.5,4.0,1.690,1.0,6,3,22,1,1,0,37.9],
  25. [23,8.7951,1.5,9.890,1.820,2.0,8,4,50,1,1,1,44.5]])
  26.  
  27.  
  28. x = zeros( (len(data[:,4]) ,2))
  29. x[:,0] ,x[:,1] = 1, data[:,4]
  30. y = array(data)[:,-1]
  31. theta = array([100.0,100.0])
  32. alpha = 0.4
  33. iternum = 100
  34. for i in range(iternum):
  35. theta -= alpha*dot(transpose(x),(dot(x,theta)-y))
  36. print theta
Add Comment
Please, Sign In to add comment