More tabs
This commit is contained in:
parent
30ac9af1f9
commit
1985c1273b
@ -49,7 +49,7 @@ def iwls(y, x, family, offset=1.0, ini_betas=None, tol=1.0e-8, max_iter=200, wi=
|
|||||||
if isinstance(family, Binomial):
|
if isinstance(family, Binomial):
|
||||||
y = family.link._clean(y)
|
y = family.link._clean(y)
|
||||||
if isinstance(family, Poisson):
|
if isinstance(family, Poisson):
|
||||||
y_off = y/offset
|
y_off = y/offset
|
||||||
y_off = family.starting_mu(y_off)
|
y_off = family.starting_mu(y_off)
|
||||||
v = family.predict(y_off)
|
v = family.predict(y_off)
|
||||||
mu = family.starting_mu(y)
|
mu = family.starting_mu(y)
|
||||||
@ -58,13 +58,13 @@ def iwls(y, x, family, offset=1.0, ini_betas=None, tol=1.0e-8, max_iter=200, wi=
|
|||||||
v = family.predict(mu)
|
v = family.predict(mu)
|
||||||
|
|
||||||
while diff > tol and n_iter < max_iter:
|
while diff > tol and n_iter < max_iter:
|
||||||
n_iter += 1
|
n_iter += 1
|
||||||
w = family.weights(mu)
|
w = family.weights(mu)
|
||||||
z = v + (family.link.deriv(mu)*(y-mu))
|
z = v + (family.link.deriv(mu)*(y-mu))
|
||||||
w = np.sqrt(w)
|
w = np.sqrt(w)
|
||||||
if type(x) != np.ndarray:
|
if type(x) != np.ndarray:
|
||||||
w = sp.csr_matrix(w)
|
w = sp.csr_matrix(w)
|
||||||
z = sp.csr_matrix(z)
|
z = sp.csr_matrix(z)
|
||||||
wx = spmultiply(x, w, array_out=False)
|
wx = spmultiply(x, w, array_out=False)
|
||||||
wz = spmultiply(z, w, array_out=False)
|
wz = spmultiply(z, w, array_out=False)
|
||||||
if wi is None:
|
if wi is None:
|
||||||
|
@ -47,14 +47,14 @@ def golden_section(a, c, delta, function, tol, max_iter, int_score=False):
|
|||||||
while np.abs(diff) > tol and iters < max_iter:
|
while np.abs(diff) > tol and iters < max_iter:
|
||||||
iters += 1
|
iters += 1
|
||||||
if int_score:
|
if int_score:
|
||||||
b = np.round(b)
|
b = np.round(b)
|
||||||
d = np.round(d)
|
d = np.round(d)
|
||||||
|
|
||||||
score_a = function(a)
|
score_a = function(a)
|
||||||
score_b = function(b)
|
score_b = function(b)
|
||||||
score_c = function(c)
|
score_c = function(c)
|
||||||
score_d = function(d)
|
score_d = function(d)
|
||||||
|
|
||||||
if score_b <= score_d:
|
if score_b <= score_d:
|
||||||
opt_val = b
|
opt_val = b
|
||||||
opt_score = score_b
|
opt_score = score_b
|
||||||
@ -73,7 +73,7 @@ def golden_section(a, c, delta, function, tol, max_iter, int_score=False):
|
|||||||
#d = np.round(b)
|
#d = np.round(b)
|
||||||
|
|
||||||
#if int_score:
|
#if int_score:
|
||||||
# opt_val = np.round(opt_val)
|
# opt_val = np.round(opt_val)
|
||||||
output.append((opt_val, opt_score))
|
output.append((opt_val, opt_score))
|
||||||
diff = score_b - score_d
|
diff = score_b - score_d
|
||||||
score = opt_score
|
score = opt_score
|
||||||
|
Loading…
Reference in New Issue
Block a user