W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
demo_python_ml_traintest_4.py:
import numpy import matplotlib.pyplot as plt numpy.random.seed(2) x = numpy.random.normal(3, 1, 100) y = numpy.random.normal(150, 40, 100) / x train_x = x[:80] train_y = y[:80] test_x = x[80:] test_y = y[80:] mymodel = numpy.poly1d(numpy.polyfit(train_x, train_y, 3)) myline = numpy.linspace(0, 6, 100) plt.scatter(train_x, train_y) plt.plot(myline, mymodel(myline)) plt.show()
[email protected]
:/home/python#python demo_python_ml_traintest_4.py