/// <summary> /// Create <see cref="RootCause"/>, which localizes root causes using decision tree algorithm. /// </summary> /// <param name="catalog">The anomaly detection catalog.</param> /// <param name="src">Root cause's input. The data is an instance of <see cref="Microsoft.ML.TimeSeries.RootCauseLocalizationInput"/>.</param> /// <param name="beta">Beta is a weight parameter for user to choose. It is used when score is calculated for each root cause item. The range of beta should be in [0,1]. For a larger beta, root cause point which has a large difference between value and expected value will get a high score. On the contrary, for a small beta, root cause items which has a high relative change will get a high score.</param> /// <param name="anomalyDeltaThreshold">A threshold to determine whether the point should be root cause. If the point's delta is equal to or larger than anomalyDeltaThreshold multiplies anomaly dimension point's delta, this point is treated as a root cause. Different threshold will turn out different result. Users can choose the delta according to their data and requirment. </param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[LocalizeRootCause](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/LocalizeRootCause.cs)] /// ]]> /// </format> /// </example> public static RootCause LocalizeRootCause(this AnomalyDetectionCatalog catalog, RootCauseLocalizationInput src, double beta = 0.5, double anomalyDeltaThreshold = 0.95) { IHostEnvironment host = CatalogUtils.GetEnvironment(catalog); //check the root cause input CheckRootCauseInput(host, src); //check beta host.CheckUserArg(beta >= 0 && beta <= 1, nameof(beta), "Must be in [0,1]"); //find out the root cause RootCauseAnalyzer analyzer = new RootCauseAnalyzer(src, beta, anomalyDeltaThreshold); RootCause dst = analyzer.Analyze(); return(dst); }
/// <summary> /// Outputs an ordered list of <see cref="RootCause"/>s. The order corresponds to which prepared cause is most likely to be the root cause. /// </summary> /// <param name="catalog">The anomaly detection catalog.</param> /// <param name="src">Root cause's input. The data is an instance of <see cref="Microsoft.ML.TimeSeries.RootCauseLocalizationInput"/>.</param> /// <param name="beta">Beta is a weight parameter for user to choose. It is used when score is calculated for each root cause item. The range of beta should be in [0,1]. For a larger beta, root cause point which has a large difference between value and expected value will get a high score. On the contrary, for a small beta, root cause items which has a high relative change will get a high score.</param> /// <param name="rootCauseThreshold">A threshold to determine whether the point should be root cause. The range of this threshold should be in [0,1]. /// If the point's delta is equal to or larger than rootCauseThreshold multiplied by anomaly dimension point's delta, this point is treated as a root cause. Different threshold will turn out different results. Users can choose the delta according to their data and requirments.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[LocalizeRootCauseMultipleDimensions](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/LocalizeRootCauseMultipleDimensions.cs)] /// ]]> /// </format> /// </example> public static List <RootCause> LocalizeRootCauses(this AnomalyDetectionCatalog catalog, RootCauseLocalizationInput src, double beta = 0.5, double rootCauseThreshold = 0.95) { IHostEnvironment host = CatalogUtils.GetEnvironment(catalog); //check the root cause input CheckRootCauseInput(host, src); //check parameters host.CheckUserArg(beta >= 0 && beta <= 1, nameof(beta), "Must be in [0,1]"); host.CheckUserArg(rootCauseThreshold >= 0 && rootCauseThreshold <= 1, nameof(rootCauseThreshold), "Must be in [0,1]"); //find out the possible causes RootCauseAnalyzer analyzer = new RootCauseAnalyzer(src, beta, rootCauseThreshold); return(analyzer.AnalyzePossibleCauses()); }