How to use the aif360.algorithms.inprocessing.celisMeta.utils.getProbability function in aif360

To help you get started, we’ve selected a few aif360 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / AIF360 / aif360 / algorithms / inprocessing / celisMeta / FalseDiscovery.py View on Github external
def getExpectedGrad(self, dist_params, params, samples, mu,  z_0, z_1, a, b):
		u_1, u_2, l_1, l_2 = params[0], params[1], params[2], params[3]
		a, b = a[0], b[0]
		res1 = []
		res2 = []
		res3 = []
		res4 = []
		for x in samples:
				temp = np.append(np.append(x, 1), 1)
				prob_1_1 = ut.getProbability(dist_params, temp)

				temp = np.append(np.append(x, -1), 1)
				prob_m1_1 = ut.getProbability(dist_params, temp)

				temp = np.append(np.append(x, 1), 0)
				prob_1_0 = ut.getProbability(dist_params, temp)

				temp = np.append(np.append(x, -1), 0)
				prob_m1_0 = ut.getProbability(dist_params, temp)


				prob_y_1 = (prob_1_1 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
				#print(prob_y_1)

				prob_z_0 = (prob_m1_0 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
				prob_z_1 = (prob_m1_1 + prob_1_1) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)

				probc_m1_0 = prob_m1_0 / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
				probc_m1_1 = prob_m1_1 / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)

				c_0 = prob_y_1 - 0.5
				c_1 = u_1 * (probc_m1_0 - a*prob_z_0) + u_2 * (probc_m1_1 - a*prob_z_1)
github IBM / AIF360 / aif360 / algorithms / inprocessing / celisMeta / StatisticalRate.py View on Github external
a, b = a[0], b[0]
		l_1, l_2 = params[0], params[1]
		res1 = []
		res2 = []
		for x in samples:
			temp = np.append(np.append(x, 1), 1)
			prob_1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 1)
			prob_m1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, 1), 0)
			prob_1_0 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 0)
			prob_m1_0 = ut.getProbability(dist_params, temp)


			prob_y_1 = (prob_1_1 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
			#print(prob_y_1)

			prob_z_0 = (prob_m1_0 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
			prob_z_1 = (prob_m1_1 + prob_1_1) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)

			c_0 = prob_y_1 - 0.5
			c_1 = prob_z_0/z_0
			c_2 = prob_z_1/z_1

			t = math.sqrt((c_0 + c_1*l_1 + c_2*l_2)*(c_0 + c_1*l_1 + c_2*l_2) + mu*mu)
			t1 = (c_0 + c_1*l_1 + c_2*l_2) * c_1/t
			t2 = (c_0 + c_1*l_1 + c_2*l_2) * c_2/t
			#print(t1,t2)
github IBM / AIF360 / aif360 / algorithms / inprocessing / celisMeta / StatisticalRate.py View on Github external
def getExpectedGrad(self, dist_params, params, samples, mu,  z_0, z_1, a, b):
		a, b = a[0], b[0]
		l_1, l_2 = params[0], params[1]
		res1 = []
		res2 = []
		for x in samples:
			temp = np.append(np.append(x, 1), 1)
			prob_1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 1)
			prob_m1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, 1), 0)
			prob_1_0 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 0)
			prob_m1_0 = ut.getProbability(dist_params, temp)


			prob_y_1 = (prob_1_1 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
			#print(prob_y_1)

			prob_z_0 = (prob_m1_0 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
			prob_z_1 = (prob_m1_1 + prob_1_1) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
github IBM / AIF360 / aif360 / algorithms / inprocessing / celisMeta / FalseDiscovery.py View on Github external
def getValueForX(self, dist_params, a,b, params, samples,  z_0, z_1, x, flag):
				u_1, u_2, l_1, l_2 = params[0], params[1], params[2], params[3]
				#print (params)
				a, b = a[0], b[0]

				temp = np.append(np.append(x, 1), 1)
				prob_1_1 = ut.getProbability(dist_params, temp)

				temp = np.append(np.append(x, -1), 1)
				prob_m1_1 = ut.getProbability(dist_params, temp)

				temp = np.append(np.append(x, 1), 0)
				prob_1_0 = ut.getProbability(dist_params, temp)

				temp = np.append(np.append(x, -1), 0)
				prob_m1_0 = ut.getProbability(dist_params, temp)

				if (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1) == 0:
					print("Probability is 0.\n")
					return 0

				prob_y_1 = (prob_1_1 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
				#print(prob_y_1)
github IBM / AIF360 / aif360 / algorithms / inprocessing / celisMeta / StatisticalRate.py View on Github external
def getValueForX(self, dist_params, a,b, params, samples,  z_0, z_1, x, flag):
			a, b = a[0], b[0]
			l_1, l_2 = params[0], params[1]

			temp = np.append(np.append(x, 1), 1)
			prob_1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 1)
			prob_m1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, 1), 0)
			prob_1_0 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 0)
			prob_m1_0 = ut.getProbability(dist_params, temp)
			if (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1) == 0:
				#print("Probability is 0.\n")
				return 0


			prob_y_1 = (prob_1_1 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
			#print(prob_y_1)

			prob_z_0 = (prob_m1_0 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
			prob_z_1 = (prob_m1_1 + prob_1_1) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)

			c_0 = prob_y_1 - 0.5
			c_1 = prob_z_0/z_0
			c_2 = prob_z_1/z_1
			if flag==1:
				print(c_0, c_1, c_2, prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
github IBM / AIF360 / aif360 / algorithms / inprocessing / celisMeta / StatisticalRate.py View on Github external
def getValueForX(self, dist_params, a,b, params, samples,  z_0, z_1, x, flag):
			a, b = a[0], b[0]
			l_1, l_2 = params[0], params[1]

			temp = np.append(np.append(x, 1), 1)
			prob_1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 1)
			prob_m1_1 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, 1), 0)
			prob_1_0 = ut.getProbability(dist_params, temp)

			temp = np.append(np.append(x, -1), 0)
			prob_m1_0 = ut.getProbability(dist_params, temp)
			if (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1) == 0:
				#print("Probability is 0.\n")
				return 0


			prob_y_1 = (prob_1_1 + prob_1_0) / (prob_1_1 + prob_1_0 + prob_m1_0 + prob_m1_1)
			#print(prob_y_1)