Skip to content

Commit

Permalink
Use linspace instead of arange
Browse files Browse the repository at this point in the history
  • Loading branch information
Etsuji Nakai committed Oct 24, 2015
1 parent 5665485 commit 85f145a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/02-square_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_dataset(num):

# 平方根平均二乗誤差(Root mean square error)を計算
def rms_error(dataset, f):
err = 0
err = 0.0
for index, line in dataset.iterrows():
x, y = line.x, line.y
err += 0.5 * (y - f(x))**2
Expand Down Expand Up @@ -76,12 +76,12 @@ def f(x):
subplot.scatter(train_set.x, train_set.y, marker='o', color='blue')

# 真の曲線を表示
linex = np.arange(0,1.01,0.01)
linex = np.linspace(0,1,101)
liney = np.sin(2*np.pi*linex)
subplot.plot(linex, liney, color='green', linestyle='--')

# 多項式近似の曲線を表示
linex = np.arange(0,1.01,0.01)
linex = np.linspace(0,1,101)
liney = f(linex)
label = "E(RMS)=%.2f" % rms_error(train_set, f)
subplot.plot(linex, liney, color='red', label=label)
Expand Down

0 comments on commit 85f145a

Please sign in to comment.