Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dist_params, dist_params_train = ut.getDistribution(x_train, y_train, x_control_train)
eps = 0.01
L = math.ceil(tau/eps)
z_1 = sum(x_control_train)/(float(len(x_control_train)))
z_0 = 1 - z_1
p, q = [0,0],[0,0]
paramsOpt, samples = [], []
maxAcc = 0
maxGamma = 0
span = self.getRange(eps, tau)
for (a,b) in span:
acc, gamma = 0, 0
#print("-----",a,b)
samples = ut.getRandomSamples(dist_params_train)
#try :
params = self.gradientDescent(dist_params, a, b, samples, z_0, z_1)
#print(params)
y_res = []
for x in x_train:
t = self.getValueForX(dist_params, a,b, params, samples, z_0, z_1, x, 0)
if t > 0 :
y_res.append(1)
else:
y_res.append(-1)
acc = ut.getAccuracy(y_train, y_res)
gamma = self.getGamma(y_train, y_res, x_control_train)
#print(acc, gamma)