mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-01-14 20:28:13 -05:00
add new animation
This commit is contained in:
18
MachineLearning/NeuralNetworkRegression/simple_sample.py
Normal file
18
MachineLearning/NeuralNetworkRegression/simple_sample.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from sklearn.neural_network import MLPRegressor
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
# create Trainig Dataset
|
||||
train_x = [[x] for x in range(200)]
|
||||
train_y = [x[0]**2 for x in train_x]
|
||||
|
||||
# create neural net regressor
|
||||
reg = MLPRegressor(solver="lbfgs")
|
||||
reg.fit(train_x, train_y)
|
||||
|
||||
predict = reg.predict(train_x)
|
||||
|
||||
plt.plot(train_x, predict, "xr", label="result")
|
||||
plt.plot(train_x, train_y, label="Training data")
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
plt.show()
|
||||
17
MachineLearning/NeuralNetworkRegression/simple_sample2.py
Normal file
17
MachineLearning/NeuralNetworkRegression/simple_sample2.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from sklearn.neural_network import MLPRegressor
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
# create Trainig Dataset
|
||||
train_x = [[x, x, x] for x in range(200)]
|
||||
train_y = [[x[0]**2, x[1] ** 1.5, x[2] + 3] for x in train_x]
|
||||
|
||||
# create neural net regressor
|
||||
reg = MLPRegressor(solver="lbfgs")
|
||||
reg.fit(train_x, train_y)
|
||||
predict = reg.predict(train_x)
|
||||
|
||||
plt.plot(train_x, predict, "xr", label="result")
|
||||
plt.plot(train_x, train_y, label="Training data")
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user