Skip to content
Snippets Groups Projects
Commit 51f782cc authored by David Schäfer's avatar David Schäfer
Browse files

fixing the failing ML test by doing to many dios -> pandas

conversions in order to work around some current limitations
of the former
parent 0ff6fb79
No related branches found
No related tags found
4 merge requests!193Release 1.4,!188Release 1.4,!32WIP: Plot rework,!24Dios integration
Pipeline #3146 failed with stage
in 6 minutes and 30 seconds
import dios
import joblib
import pandas as pd
import numpy as np
from saqc.funcs.register import register
# NEW
from sklearn.ensemble import RandomForestClassifier
import joblib
from saqc.funcs.register import register
def _refCalc(reference, window_values):
# Helper function for calculation of moving window values
......@@ -61,8 +61,16 @@ def flagML(data, field, flagger, references, window_values: int, window_flags: i
# forward-orientation not possible, so right-orientation on reversed data an reverse result
# Add context information for field+references
df = df.to_df()
for i in [field] + references:
df = pd.concat([df, _refCalc(reference=df[i], window_values=window_values)], axis=1)
ref = _refCalc(reference=df[i], window_values=window_values).to_df()
df = pd.concat([df, ref], axis=1)
# TODO:
# replace the above version with its DictOfSeries -> DataFrame
# conversions as soon as merging/joining is available in dios
# for i in [field] + references:
# df = pd.concat([df, _refCalc(reference=df[i], window_values=window_values)], axis=1)
# remove rows that contain NAs (new ones occured during predictor calculation)
df = df.dropna(axis=0, how="any")
......
......@@ -11,7 +11,7 @@ from test.common import TESTFLAGGER
def test_flagML(flagger):
### CREATE MWE DATA
data = pd.read_feather("ressources/machine_learning/data/soil_moisture_mwe.feather")
data = data.set_index(pd.DatetimeIndex(data.Time))
data = data.set_index(pd.DatetimeIndex(data.Time)).to_dios()
flags_raw = data[["SM1_Flag", "SM2_Flag", "SM3_Flag"]]
flags_raw.columns = ["SM1", "SM2", "SM3"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment