Skip to content

Instantly share code, notes, and snippets.

@freedomtowin
Created April 19, 2018 15:24
Show Gist options
  • Save freedomtowin/6040d6ade6c6434b8952285e0ff21f42 to your computer and use it in GitHub Desktop.
Save freedomtowin/6040d6ade6c6434b8952285e0ff21f42 to your computer and use it in GitHub Desktop.
def poly_least_sqs_loss(x,y,w):
hypothesis = w[0]*x[:,0:1] + w[1]*(x[:,1:2]) + w[2]*(x[:,1:2])**w[3]
loss = hypothesis-y
return np.sum(loss**2)/len(y)
start_time = time.time()
X = train[['sqft_living']].values
y = train[["price"]].values
model = kernel_optimizer(X,y,poly_least_sqs_loss,num_param=4)
model.add_intercept()
model.adjust_uniform_random_low_high(0,2)
model.kernel_optimize_(optimizer=pid_linear_combination)
end_time = time.time()
print("time:",end_time-start_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment