Untitled


SUBMITTED BY: Guest

DATE: June 25, 2021, 2:05 p.m.

FORMAT: Text only

SIZE: 542 Bytes

HITS: 438

  1. #Generate Toy Dataset
  2. import pylab
  3. import numpy
  4. x = numpy.linspace(-1,1,100)
  5. signal = 2 + x + 2 * x * x
  6. noise = numpy.random.normal(0, 0.1, 100)
  7. y = signal + noise
  8. pylab.plot(signal,'b');
  9. pylab.plot(y,'g')
  10. pylab.plot(noise, 'r')
  11. pylab.xlabel("x")
  12. pylab.ylabel("y")
  13. pylab.legend(["Without Noise", "With Noise", "Noise"], loc = 2)
  14. x_train = x[0:80]
  15. y_train = y[0:80]
  16. # Model with degree 1
  17. pylab.figure()
  18. degree = 2
  19. X_train = numpy.column_stack([numpy.power(x_train,i) for i in xrange(0,degree)])
  20. https://pastebin.com/6SjnevJS

comments powered by Disqus