@@ -13,16 +13,26 @@ def _vector(sensor_id: str, temperature: float, label: str | None = None) -> Fea
|
||||
|
||||
def predictor() -> Predictor:
|
||||
store = FeatureStore()
|
||||
store.add_batch([_vector("sensor.kitchen", 19.0), _vector("sensor.bedroom", 18.5)])
|
||||
store.add_batch(
|
||||
[
|
||||
_vector("sensor.kitchen", 19.0),
|
||||
_vector("sensor.kitchen", 20.0),
|
||||
_vector("sensor.bedroom", 18.5),
|
||||
]
|
||||
)
|
||||
pipeline = TrainingPipeline(store)
|
||||
pipeline.run("artifact_v1")
|
||||
return Predictor(pipeline)
|
||||
|
||||
|
||||
def test_predict_returns_expected_format() -> None:
|
||||
def test_predict_returns_statistical_forecast() -> None:
|
||||
p = predictor()
|
||||
result = p.predict("artifact_v1", _vector("sensor.kitchen", 21.0))
|
||||
assert result == "artifact_v1:sensor.kitchen:{'temperature': 21.0}"
|
||||
assert result.artifact_id == "artifact_v1"
|
||||
assert result.sensor_id == "sensor.kitchen"
|
||||
assert result.predictions == {"temperature": 22.0}
|
||||
assert 0.0 < result.confidence <= 1.0
|
||||
assert result.model_type == "statistical_baseline"
|
||||
|
||||
|
||||
def test_predict_rejects_unknown_sensor() -> None:
|
||||
@@ -45,4 +55,4 @@ def test_default_artifact_returns_last_registered() -> None:
|
||||
pipeline = TrainingPipeline(store)
|
||||
pipeline.run("first")
|
||||
pipeline.run("second")
|
||||
assert Predictor.default_artifact(pipeline).artifact_id == "second"
|
||||
assert Predictor.default_artifact(pipeline).artifact_id == "second"
|
||||
|
||||
Reference in New Issue
Block a user