MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / top_k_error

Function top_k_error

tests/python_package_test/test_engine.py:35–39  ·  view source on GitHub ↗
(y_true, y_pred, k)

Source from the content-addressed store, hash-verified

33
34
35def top_k_error(y_true, y_pred, k):
36 if k == y_pred.shape[1]:
37 return 0
38 max_rest = np.max(-np.partition(-y_pred, k)[:, k:], axis=1)
39 return 1 - np.mean((y_pred[np.arange(len(y_true)), y_true] > max_rest))
40
41
42def constant_metric(preds, train_data):

Callers 1

Calls 1

partitionMethod · 0.80

Tested by

no test coverage detected