Statistics¶
This section documents the statistics components of the dummy module.
statistics
¶
Defines sklearn.dummy statistics interoperability.
This module provides utilities for integrating scikit-learn dummy models with Nextmv statistics.
FUNCTION | DESCRIPTION |
---|---|
DummyRegressorStatistics |
Creates a Nextmv statistics object from a sklearn.dummy.DummyRegressor model. |
DummyRegressorStatistics
¶
DummyRegressorStatistics(
model: DummyRegressor,
X: Iterable,
y: Iterable,
sample_weight: float = None,
run_duration_start: Optional[float] = None,
) -> Statistics
Creates a Nextmv statistics object from a sklearn.dummy.DummyRegressor model.
You can import the DummyRegressorStatistics
function directly from dummy
:
The statistics returned are quite basic, and should be extended
according to the custom metrics that the user wants to track. The optional
run_duration_start
parameter can be used to set the start time of the
whole run.
PARAMETER | DESCRIPTION |
---|---|
|
The sklearn DummyRegressor model.
TYPE:
|
|
The input samples.
TYPE:
|
|
The target values.
TYPE:
|
|
The sample weights, by default None.
TYPE:
|
|
The start time of the run, by default None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Statistics
|
The Nextmv statistics object. |
Examples:
>>> from sklearn.dummy import DummyRegressor
>>> from nextmv_sklearn.dummy import DummyRegressorStatistics
>>> import numpy as np
>>>
>>> # Create a dummy regressor
>>> model = DummyRegressor(strategy='mean')
>>> X = np.array([[1, 2], [3, 4], [5, 6]])
>>> y = np.array([1, 2, 3])
>>> model.fit(X, y)
>>>
>>> # Create statistics object
>>> start_time = time.time()
>>> # ... perform operations
>>> stats = DummyRegressorStatistics(model, X, y, run_duration_start=start_time)
>>> print(stats.result.custom["score"]) # Access the model score