@@ -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,41 @@ 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+ // ! The overall result probability.
251+ double s_Probability = 1.0 ;
252+ // ! True if the probability depends on the correlation between two
253+ // ! time series and false otherwise.
254+ bool s_Conditional = false ;
255+ // ! The probabilities for each individual feature.
256+ TFeatureProbability4Vec s_FeatureProbabilities;
257+ // ! The tail of the current bucket probability.
258+ TTail2Vec s_Tail;
259+ // ! The identifier of the time series correlated with this one which
260+ // ! has the smallest probability in the current bucket (if and only
261+ // ! if the result depends on the correlation structure).
262+ TSize1Vec s_MostAnomalousCorrelate;
225263};
226264
227265// ! \brief The model interface.
@@ -355,10 +393,7 @@ class MATHS_EXPORT CModel {
355393 virtual bool probability (const CModelProbabilityParams& params,
356394 const TTime2Vec1Vec& time,
357395 const TDouble2Vec1Vec& value,
358- double & probability,
359- TTail2Vec& tail,
360- bool & conditional,
361- TSize1Vec& mostAnomalousCorrelate) const = 0;
396+ SModelProbabilityResult& result) const = 0;
362397
363398 // ! Get the Winsorisation weight to apply to \p value,
364399 // ! if appropriate.
@@ -499,14 +534,11 @@ class MATHS_EXPORT CModelStub : public CModel {
499534 const TForecastPushDatapointFunc& forecastPushDataPointFunc,
500535 std::string& messageOut);
501536
502- // ! Returns 1.0 .
537+ // ! Returns true .
503538 virtual bool probability (const CModelProbabilityParams& params,
504539 const TTime2Vec1Vec& time,
505540 const TDouble2Vec1Vec& value,
506- double & probability,
507- TTail2Vec& tail,
508- bool & conditional,
509- TSize1Vec& mostAnomalousCorrelate) const ;
541+ SModelProbabilityResult& result) const ;
510542
511543 // ! Returns empty.
512544 virtual TDouble2Vec
0 commit comments