Return predictions for the model. Parameters ---------- data: dict[str, value] or list[dict[str, value]] Dictionary of data to use for predictions, where the keys are the names of the input features. For batch predictons, use a list of such d
(self, data, state: _Optional[_MLState] = None)
| 190 | |
| 191 | |
| 192 | def predict(self, data, state: _Optional[_MLState] = None): |
| 193 | """ |
| 194 | Return predictions for the model. |
| 195 | |
| 196 | Parameters |
| 197 | ---------- |
| 198 | data: dict[str, value] or list[dict[str, value]] |
| 199 | Dictionary of data to use for predictions, where the keys are the names of the input features. |
| 200 | For batch predictons, use a list of such dictionaries. |
| 201 | |
| 202 | state : MLState |
| 203 | Optional state object as returned by ``make_state()``. |
| 204 | |
| 205 | Returns |
| 206 | ------- |
| 207 | dict[str, value] |
| 208 | Predictions as a dictionary where each key is the output feature name. |
| 209 | |
| 210 | list[dict[str, value]] |
| 211 | For batch prediction, returns a list of the above dictionaries. |
| 212 | |
| 213 | Examples |
| 214 | -------- |
| 215 | .. sourcecode:: python |
| 216 | |
| 217 | data = {"bedroom": 1.0, "bath": 1.0, "size": 1240} |
| 218 | predictions = model.predict(data) |
| 219 | |
| 220 | data = [ |
| 221 | {"bedroom": 1.0, "bath": 1.0, "size": 1240}, |
| 222 | {"bedroom": 4.0, "bath": 2.5, "size": 2400}, |
| 223 | ] |
| 224 | batch_predictions = model.predict(data) |
| 225 | |
| 226 | """ |
| 227 | _MLModel._check_predict_data(data) |
| 228 | |
| 229 | return _MLModel._get_predictions( |
| 230 | self._proxy, _MLModel._update_float16_multiarray_input_to_float32, data, state |
| 231 | ) |
| 232 | |
| 233 | |
| 234 | def make_state(self) -> _MLState: |