A feature is useful when two nearby points that share a label agree on it, and two nearby points with different labels disagree on it. Relief scores every feature with exactly that idea, using one nearest same-class neighbor (the hit) and one nearest other-class neighbor (the miss) for each sample.
Implement relief_weights(X, y). It returns one weight per feature.
For each sample i:
j, add (|X[i, j] - X[miss, j]| - |X[i, j] - X[hit, j]|) / range_j to w[j], where range_j = max - min of feature j.Divide the total by n.
X is 2-D with at least two rows, y has one label per row, otherwise raise ValueError.n.Compute the full distance vector from sample i, set its own entry to infinity, then mask by the label to pick hits and misses.
No results yet
Run your code to check it against the examples, or submit to run every test.