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

Method predict

numpy_ml/linear_models/linear_regression.py:218–236  ·  view source on GitHub ↗

Use the trained model to generate predictions on a new collection of data points. Parameters ---------- X : :py:class:`ndarray ` of shape `(Z, M)` A dataset consisting of `Z` new examples, each of dimension `M`. Returns

(self, X)

Source from the content-addressed store, hash-verified

216 return self
217
218 def predict(self, X):
219 """
220 Use the trained model to generate predictions on a new collection of
221 data points.
222
223 Parameters
224 ----------
225 X : :py:class:`ndarray <numpy.ndarray>` of shape `(Z, M)`
226 A dataset consisting of `Z` new examples, each of dimension `M`.
227
228 Returns
229 -------
230 y_pred : :py:class:`ndarray <numpy.ndarray>` of shape `(Z, K)`
231 The model predictions for the items in `X`.
232 """
233 # convert X to a design matrix if we're fitting an intercept
234 if self.fit_intercept:
235 X = np.c_[np.ones(X.shape[0]), X]
236 return X @ self.beta

Callers 5

plot_bayesFunction · 0.95
plot_regressionFunction · 0.95
plot_regressionFunction · 0.95
plot_knnFunction · 0.95
test_linear_regressionFunction · 0.95

Calls

no outgoing calls

Tested by 1

test_linear_regressionFunction · 0.76