MCPcopy
hub / github.com/ddbourgin/numpy-ml / predict

Method predict

numpy_ml/nonparametric/kernel_regression.py:53–70  ·  view source on GitHub ↗

Generate predictions for the targets associated with the rows in `X`. Parameters ---------- X : :py:class:`ndarray ` of shape `(N', M')` An array of `N'` examples to generate predictions on Returns ------- y : :py:

(self, X)

Source from the content-addressed store, hash-verified

51 self.parameters = {"X": X, "y": y}
52
53 def predict(self, X):
54 """
55 Generate predictions for the targets associated with the rows in `X`.
56
57 Parameters
58 ----------
59 X : :py:class:`ndarray <numpy.ndarray>` of shape `(N', M')`
60 An array of `N&#x27;` examples to generate predictions on
61
62 Returns
63 -------
64 y : :py:class:`ndarray <numpy.ndarray>` of shape `(N&#x27;, ...)`
65 Predicted targets for the `N&#x27;` rows in `X`
66 """
67 K = self.kernel
68 P = self.parameters
69 sim = K(P["X"], X)
70 return (sim * P["y"][:, None]).sum(axis=0) / sim.sum(axis=0)

Callers 1

plot_regressionFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected