def calc_specialist_weights(numsamps):
"""
Calculates vector of specialist weights.
Args:
numsamps: A nonnegative vector of ints, specifying the number of samples on which each specialist predicts.
Returns:
A vector of floats specifying each specialist's weight (1/(fraction of data supported)).
If numsamps[i] == 0 for some specialist i, the corresponding weight will be 0.
Note that the return value is invariant to the scaling of numsamps by a positive constant.
Similarly, calculating numsamps using a uniform random subsample of a dataset
will result in approximately the same return value as using the full dataset.
"""
weights = 1.0/numsamps
weights[np.isinf(weights)] = 0.0
return np.max(numsamps)*weights
评论列表
文章目录