Professional Documents
Culture Documents
Over Fitting
Over Fitting
http://localhost:8080/home/admin/2/print
import scipy as sp
data = sp.genfromtxt("/home/akira/Desktop/web_traffic.csv",
delimiter="\t"); data
x = data[:, 0]; y = data[:, 1]
sp.sum(sp.isnan(y))
x = x[~sp.isnan(y)]
y = y[~sp.isnan(y)]; sp.sum(sp.isnan(y))
l = len(x); print l
plt = []
for k in xrange(l):
plt += [(x[k], y[k])]
var('a b')
model(x) = a*x+b
print find_fit(plt, model)
a = 2.596192127749366; b = 989.0248710628711
g1=plot(a*x+b, (x, 0, 750))
g2=scatter_plot(plt, markersize=1)
(g1+g2).show()
735
[a == 2.596192127749366, b == 989.0248710628711]
1 of 5
20150502 13:24
-- Sage
http://localhost:8080/home/admin/2/print
import scipy as sp
data = sp.genfromtxt("/home/akira/Desktop/web_traffic.csv",
delimiter="\t"); data
x = data[:, 0]; y = data[:, 1]
sp.sum(sp.isnan(y))
x = x[~sp.isnan(y)]
y = y[~sp.isnan(y)]; sp.sum(sp.isnan(y))
l = len(x); print l
plt = []
for k in xrange(l):
plt += [(x[k], y[k])]
2 of 5
20150502 13:24
-- Sage
http://localhost:8080/home/admin/2/print
var('a b c')
model(x) = a*x^2+b*x+c
print find_fit(plt, model)
a = 0.01053222150887223; b = -5.2654565002831655; c =
1974.7608169610032
g1=plot(a*x^2+b*x+c, (x, 0, 750))
g2=scatter_plot(plt, markersize=1)
(g1+g2).show()
735
[a == 0.01053222150887223, b == -5.2654565002831655, c ==
1974.7608169610032]
import scipy as sp
data = sp.genfromtxt("/home/akira/Desktop/web_traffic.csv",
3 of 5
20150502 13:24
-- Sage
http://localhost:8080/home/admin/2/print
delimiter="\t"); data
x = data[:, 0]; y = data[:, 1]
sp.sum(sp.isnan(y))
x = x[~sp.isnan(y)]
y = y[~sp.isnan(y)]; sp.sum(sp.isnan(y))
l = len(x); print l
plt = []
for k in xrange(l):
plt += [(x[k], y[k])]
var('a b c d')
model(x) = a*x^3+b*x^2+c*x+d
print find_fit(plt, model)
a = 3.0496012888344957e-05; b = -0.023589379315108457; c =
4.94226007658219; d = 1333.2879737755277
g1=plot(a*x^3+b*x^2+c*x+d, (x, 0, 750))
g2=scatter_plot(plt, markersize=1)
(g1+g2).show()
735
[a == (3.0496012888344957e-05), b == -0.023589379315108457, c ==
4.94226007658219, d == 1333.2879737755277]
4 of 5
20150502 13:24
-- Sage
http://localhost:8080/home/admin/2/print
#
#
5 of 5
20150502 13:24