array_nd<T> repmat(const array_nd<T>& a, const size_array& sz) { CHECK (sz.length() <= a.ndims(), eshape()); array_nd<T> c(a); for (size_t i = 0; i < sz.length(); i++) { array_nd<T> tmp(c); for (size_t j = 0; j < sz[i]; j++) c = cat<T>(i, c, tmp); } return c; }
void eval(const array <pos>& nn, const nn_options& opt) { msg::in_line(info, "evaluating"); const size_array at = (0, _, opt.at_step, _, opt.at_max); array <T> recall(at.length(), T()); T R = .95; array <T> rat = (R, _, opt.rat_step, _, opt.rat_max); array <T> freq(rat.length()); size_t FL = freq.length(); size_t N = nn.length(), C = dist.length(), J = dist[0].columns(); T rank = 0, lower = 0, upper = 0, approx = 0; for (size_t n = 0; n < N; n++) { msg::progress(info, n, N); pos quot = nn[n]; for (size_t c = 0; c < C; c++) { array <T> d = dist[c].as_rows()[n]; T dq = d[quot % J], dl = min(d); T r = find(d < dq).length(); rank += r; recall[r > at]++; freq[(min(dq / dl, opt.rat_max) - R) / opt.rat_step]++; lower += dl; upper += max(d); approx += dq; quot /= J; } } T S = C * N; msg::done(info); msg::rank(info, rank / S, J); msg::bounds(info, lower / S, approx / S, upper / S); if (opt.recall) msg::recall(info, at, 1 - recall / S); if (opt.ratio) msg::ratio(info, rat, freq / S); }