anomaly_scores.weighted_rmse_score

class WeightedRMSEScore(feature_weights=None, **kwargs)[source]

Bases: RMSEScore

Calculate the RMSE of given reconstruction errors manipulated with specified weights.

feature_weights

Weight definition for input features.

Type:

Dict[str, float]

Weights can be chosen from [0, infinity). Defaults to None.

Configuration example:

train:
  anomaly_score:
    name: weighted_rmse
    params:
      feature_weights:
        feature_1: 2.0
        feature_2: 0.5
        feature_3: 1.0  # If a feature should not be weighted it can also be omitted.
apply_weights_to_squared_residuals(x)[source]

Applies specified weights to squared std-scaled x, if x is a pandas DataFrame and the features acutally occur in x’s columns.

x (pd.DataFrame): DataFrame of reconstruction errors.

Return type:

DataFrame

Returns:

pd.DataFrame weighted version of x.

fit(x, y=None)[source]

Calculate standard deviation and mean on weighted training data

Parameters:
  • x (DataFrame) – DataFrame with differences between prediction and actual sensor values

  • y (Optional[Series]) – not used, labels indicating whether sample is normal (True) or anomalous (False).

  • variable_name_features (Dict[str, List[str]]) – Mapping of input feature names that change during preprocessing. Example: Angle features might be transformed into [feature_name_sin, feature_name_cos. Defaults to an empty dictionary.

Return type:

WeightedRMSEScore

scale_with_std(x)[source]

Scale the input data with the fitted standard deviation of the training data.

Return type:

DataFrame

transform(x)[source]

Calculate the RMSE based on the weighted deviation matrix.

Parameters:

x (DataFrame) – Dataframe with differences between prediction and actual sensor values

Returns:

weighted RMSE for each sample.