def get_weights(target, actual, bins = 10, cap = 10, match = True):
	target_counts, target_bins = np.histogram(target, bins=bins)
	counts, _ = np.histogram(actual, bins=target_bins)
	counts = (1.0 * counts)
	counts = np.array([max(a, 0.0001) for a in counts])
	multiplier = np.array((target_counts / counts).tolist() + [1.0])

	weights = np.array([min(multiplier[target_bins.searchsorted(point) - 1], cap) for point in actual])
	# weights = np.array([target_bins.searchsorted(point) for point in actual])

	if match:
		weights *= (len(target) / np.sum(weights))

	return weights
Get the profile for the User.
dataset/ETHPy150Open ml-slac/deep-jets/training/viz/performance.py/get_weights--crossover with--dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/accounts/models.py/_get_profile