@@ -104,8 +104,6 @@ class MATHS_EXPORT CModelAddSamplesParams {
104104 using TDouble2VecWeightsAryVec = std::vector<maths_t ::TDouble2VecWeightsAry>;
105105
106106public:
107- CModelAddSamplesParams ();
108-
109107 // ! Set whether or not the data are integer valued.
110108 CModelAddSamplesParams& integer (bool integer);
111109 // ! Get the data type.
@@ -133,15 +131,15 @@ class MATHS_EXPORT CModelAddSamplesParams {
133131
134132private:
135133 // ! The data type.
136- maths_t ::EDataType m_Type;
134+ maths_t ::EDataType m_Type = maths_t ::E_MixedData ;
137135 // ! True if the data are non-negative false otherwise.
138- bool m_IsNonNegative;
136+ bool m_IsNonNegative = false ;
139137 // ! The propagation interval.
140- double m_PropagationInterval;
138+ double m_PropagationInterval = 1.0 ;
141139 // ! The trend sample weights.
142- const TDouble2VecWeightsAryVec* m_TrendWeights;
140+ const TDouble2VecWeightsAryVec* m_TrendWeights = nullptr ;
143141 // ! The prior sample weights.
144- const TDouble2VecWeightsAryVec* m_PriorWeights;
142+ const TDouble2VecWeightsAryVec* m_PriorWeights = nullptr ;
145143};
146144
147145// ! \brief The extra parameters needed by CModel::probability.
@@ -178,6 +176,8 @@ class MATHS_EXPORT CModelProbabilityParams {
178176
179177 // ! Add whether a value's bucket is empty.
180178 CModelProbabilityParams& addBucketEmpty (const TBool2Vec& empty);
179+ // ! Set whether or not the values' bucket is empty.
180+ CModelProbabilityParams& bucketEmpty (const TBool2Vec1Vec& empty);
181181 // ! Get whether the values' bucket is empty.
182182 const TBool2Vec1Vec& bucketEmpty () const ;
183183
@@ -200,14 +200,19 @@ class MATHS_EXPORT CModelProbabilityParams {
200200 // ! Get the most anomalous correlate if there is one.
201201 TOptionalSize mostAnomalousCorrelate () const ;
202202
203- // ! Set whether or not to update the anomaly model.
204- CModelProbabilityParams& updateAnomalyModel (bool update);
205- // ! Get whether or not to update the anomaly model.
206- bool updateAnomalyModel () const ;
203+ // ! Set whether or not to use multibucket features.
204+ CModelProbabilityParams& useMultibucketFeatures (bool use);
205+ // ! Get whether or not to use multibucket features.
206+ bool useMultibucketFeatures () const ;
207+
208+ // ! Set whether or not to use the anomaly model.
209+ CModelProbabilityParams& useAnomalyModel (bool use);
210+ // ! Get whether or not to use the anomaly model.
211+ bool useAnomalyModel () const ;
207212
208213private:
209214 // ! The entity tag (if relevant otherwise 0).
210- std::size_t m_Tag;
215+ std::size_t m_Tag = 0 ;
211216 // ! The coordinates' probability calculations.
212217 TProbabilityCalculation2Vec m_Calculations;
213218 // ! The confidence interval to use when detrending.
@@ -220,8 +225,48 @@ class MATHS_EXPORT CModelProbabilityParams {
220225 TSize2Vec m_Coordinates;
221226 // ! The most anomalous coordinate (if there is one).
222227 TOptionalSize m_MostAnomalousCorrelate;
223- // ! Whether or not to update the anomaly model.
224- bool m_UpdateAnomalyModel;
228+ // ! Whether or not to use multibucket features.
229+ bool m_UseMultibucketFeatures = true ;
230+ // ! Whether or not to use the anomaly model.
231+ bool m_UseAnomalyModel = true ;
232+ };
233+
234+ // ! \brief Describes the result of the model probability calculation.
235+ struct MATHS_EXPORT SModelProbabilityResult {
236+ using TDouble4Vec = core::CSmallVector<double , 4 >;
237+ using TSize1Vec = core::CSmallVector<std::size_t , 1 >;
238+ using TTail2Vec = core::CSmallVector<maths_t ::ETail, 2 >;
239+
240+ // ! \brief Wraps up a feature label and probability.
241+ struct MATHS_EXPORT SFeatureProbability {
242+ using TStrCRef = boost::reference_wrapper<const std::string>;
243+ SFeatureProbability ();
244+ SFeatureProbability (const std::string& label, double probability);
245+ TStrCRef s_Label;
246+ double s_Probability = 1.0 ;
247+ };
248+ using TFeatureProbability4Vec = core::CSmallVector<SFeatureProbability, 4 >;
249+
250+ SModelProbabilityResult () = default ;
251+ SModelProbabilityResult (double probability,
252+ bool conditional,
253+ const TFeatureProbability4Vec& featureProbabilities,
254+ const TTail2Vec& tail,
255+ const TSize1Vec& mostAnomalousCorrelate);
256+
257+ // ! The overall result probability.
258+ double s_Probability = 1.0 ;
259+ // ! True if the probability depends on the correlation between two
260+ // ! time series and false otherwise.
261+ bool s_Conditional = false ;
262+ // ! The probabilities for each individual feature.
263+ TFeatureProbability4Vec s_FeatureProbabilities;
264+ // ! The tail of the current bucket probability.
265+ TTail2Vec s_Tail;
266+ // ! The identifier of the time series correlated with this one which
267+ // ! has the smallest probability in the current bucket (if and only
268+ // ! if the result depends on the correlation structure).
269+ TSize1Vec s_MostAnomalousCorrelate;
225270};
226271
227272// ! \brief The model interface.
@@ -355,10 +400,7 @@ class MATHS_EXPORT CModel {
355400 virtual bool probability (const CModelProbabilityParams& params,
356401 const TTime2Vec1Vec& time,
357402 const TDouble2Vec1Vec& value,
358- double & probability,
359- TTail2Vec& tail,
360- bool & conditional,
361- TSize1Vec& mostAnomalousCorrelate) const = 0;
403+ SModelProbabilityResult& result) const = 0;
362404
363405 // ! Get the Winsorisation weight to apply to \p value,
364406 // ! if appropriate.
@@ -499,14 +541,11 @@ class MATHS_EXPORT CModelStub : public CModel {
499541 const TForecastPushDatapointFunc& forecastPushDataPointFunc,
500542 std::string& messageOut);
501543
502- // ! Returns 1.0 .
544+ // ! Returns true .
503545 virtual bool probability (const CModelProbabilityParams& params,
504546 const TTime2Vec1Vec& time,
505547 const TDouble2Vec1Vec& value,
506- double & probability,
507- TTail2Vec& tail,
508- bool & conditional,
509- TSize1Vec& mostAnomalousCorrelate) const ;
548+ SModelProbabilityResult& result) const ;
510549
511550 // ! Returns empty.
512551 virtual TDouble2Vec
0 commit comments