| 187 | |
| 188 | |
| 189 | class MLState: |
| 190 | def __init__(self, proxy) -> None: |
| 191 | """ |
| 192 | Holds state for an MLModel. |
| 193 | |
| 194 | The MLState class provides methods to read and write model state. |
| 195 | |
| 196 | See Also |
| 197 | -------- |
| 198 | ct.MLModel.predict |
| 199 | """ |
| 200 | self.__proxy__ = proxy |
| 201 | |
| 202 | def read_state( |
| 203 | self, |
| 204 | name: str, |
| 205 | ) -> _np.ndarray: |
| 206 | """ |
| 207 | Retrieve the value of a model state variable. |
| 208 | |
| 209 | Parameters |
| 210 | ---------- |
| 211 | name : str |
| 212 | The name of the state variable to read. |
| 213 | |
| 214 | Returns |
| 215 | ------- |
| 216 | numpy.ndarray |
| 217 | The value of the specified state variable as a NumPy array. |
| 218 | |
| 219 | Raises |
| 220 | ------ |
| 221 | RuntimeError |
| 222 | If the state cannot be read (e.g. invalid state name). |
| 223 | """ |
| 224 | return self.__proxy__.read_state(name) |
| 225 | |
| 226 | def write_state( |
| 227 | self, |
| 228 | name: str, |
| 229 | value: _np.ndarray, |
| 230 | ): |
| 231 | """ |
| 232 | Set the value of a model state variable. |
| 233 | |
| 234 | Parameters |
| 235 | ---------- |
| 236 | name : str |
| 237 | The name of the state variable to write. |
| 238 | |
| 239 | value : numpy.ndarray |
| 240 | The new value to assign to the state variable. |
| 241 | |
| 242 | Raises |
| 243 | ------ |
| 244 | RuntimeError |
| 245 | If the state cannot be written (e.g. invalid value, or invalid state name). |
| 246 | """ |