Beispiel #1
0
def test_load_parquet():
    mean_absolute_error = 85.94534216005789
    mean_squared_error = 11474.89611670205
    root_mean_squared_error = 107.12094154133472

    regmet = RegressionMetrics()
    df = pd.read_parquet(
        os.path.join(
            os.path.join(TEST_DATA_PATH, "metrics", "2021-02-12.parquet")))
    regmet.add(df["predictions"].to_list(), df["targets"].to_list())

    assert regmet.count == len(df["predictions"].to_list())
    assert regmet.mean_squared_error() == pytest.approx(
        mean_squared_error, 0.01)

    assert regmet.mean_absolute_error() == pytest.approx(
        mean_absolute_error, 0.01)
    assert regmet.root_mean_squared_error() == pytest.approx(
        root_mean_squared_error, 0.01)

    msg = regmet.to_protobuf()
    new_regmet = RegressionMetrics.from_protobuf(msg)
    assert regmet.count == new_regmet.count
    assert regmet.mean_squared_error() == new_regmet.mean_squared_error()
    assert regmet.root_mean_squared_error(
    ) == new_regmet.root_mean_squared_error()
    assert regmet.mean_absolute_error() == new_regmet.mean_absolute_error()
Beispiel #2
0
 def from_protobuf(
     cls,
     message,
 ):
     return ModelMetrics(
         confusion_matrix=ConfusionMatrix.from_protobuf(
             message.scoreMatrix),
         regression_metrics=RegressionMetrics.from_protobuf(
             message.regressionMetrics),
         model_type=message.modelType,
     )
Beispiel #3
0
def test_empty_protobuf_should_return_none():
    empty_message = RegressionMetricsMessage()
    assert RegressionMetrics.from_protobuf(empty_message) is None