Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.12][ML] Fix a bug in upgrade from pre 6.3 state for the lat_long function #1684

Merged
merged 1 commit into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
if the time series has non-diurnal seasonality. (See {ml-pull}1634[#1634].)
* Compute importance of hyperparameters optimized in the fine parameter tuning step.
(See {ml-pull}1627[#1627].)
* Correct upgrade for pre-6.3 state for lat_long anomaly anomaly detectors. (See
{ml-pull}1681[#1681].)

== {es} version 7.11.0

Expand Down
6 changes: 6 additions & 0 deletions include/maths/CTimeSeriesModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ class MATHS_EXPORT CUnivariateTimeSeriesModel : public CModel {

//! Get the residual model.
const CPrior& residualModel() const;

//! Get the decay rate controllers.
const TDecayRateController2Ary* decayRateControllers() const;
//@}

private:
Expand Down Expand Up @@ -681,6 +684,9 @@ class MATHS_EXPORT CMultivariateTimeSeriesModel : public CModel {

//! Get the residual model.
const CMultivariatePrior& residualModel() const;

//! Get the decay rate controllers.
const TDecayRateController2Ary* decayRateControllers() const;
//@}

private:
Expand Down
12 changes: 11 additions & 1 deletion lib/maths/CTimeSeriesModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,11 @@ const CPrior& CUnivariateTimeSeriesModel::residualModel() const {
return *m_ResidualModel;
}

const CUnivariateTimeSeriesModel::TDecayRateController2Ary*
CUnivariateTimeSeriesModel::decayRateControllers() const {
return m_Controllers.get();
}

CUnivariateTimeSeriesModel::CUnivariateTimeSeriesModel(const CUnivariateTimeSeriesModel& other,
std::size_t id,
bool isForForecast)
Expand Down Expand Up @@ -2751,7 +2756,7 @@ bool CMultivariateTimeSeriesModel::acceptRestoreTraverser(const SModelRestorePar
RESTORE_SETUP_TEARDOWN(
CONTROLLER_OLD_TAG,
m_Controllers = std::make_unique<TDecayRateController2Ary>(),
core::CPersistUtils::restore(CONTROLLER_6_3_TAG, *m_Controllers, traverser),
core::CPersistUtils::restore(CONTROLLER_OLD_TAG, *m_Controllers, traverser),
/**/)
RESTORE_SETUP_TEARDOWN(
TREND_OLD_TAG, m_TrendModel.push_back(TDecompositionPtr()),
Expand Down Expand Up @@ -2849,6 +2854,11 @@ const CMultivariatePrior& CMultivariateTimeSeriesModel::residualModel() const {
return *m_ResidualModel;
}

const CMultivariateTimeSeriesModel::TDecayRateController2Ary*
CMultivariateTimeSeriesModel::decayRateControllers() const {
return m_Controllers.get();
}

CMultivariateTimeSeriesModel::EUpdateResult
CMultivariateTimeSeriesModel::updateTrend(const CModelAddSamplesParams& params,
const TTimeDouble2VecSizeTrVec& samples) {
Expand Down
12 changes: 11 additions & 1 deletion lib/maths/unittest/CTimeSeriesModelTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ BOOST_AUTO_TEST_CASE(testPersist) {
// TODO LOG_DEBUG(<< "Correlates");
}

BOOST_AUTO_TEST_CASE(testUpgrade) {
BOOST_AUTO_TEST_CASE(testUpgradeFrom6p2) {
// Test upgrade is minimally disruptive. We test the upgraded model
// predicted confidence intervals verses the values we obtain from
// the previous model. Note the confidence interval depends on both
Expand Down Expand Up @@ -1830,6 +1830,11 @@ BOOST_AUTO_TEST_CASE(testUpgrade) {
boost::lexical_cast<double>(interval[j]), 0.0001);
}
}
BOOST_TEST_REQUIRE(restoredModel.decayRateControllers() != nullptr);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].checks() != 0);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].checks() != 0);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].dimension() == 1);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].dimension() == 1);
}

LOG_DEBUG(<< "Multivariate");
Expand Down Expand Up @@ -1879,6 +1884,11 @@ BOOST_AUTO_TEST_CASE(testUpgrade) {
boost::lexical_cast<double>(interval[j]), 0.0001);
}
}
BOOST_TEST_REQUIRE(restoredModel.decayRateControllers() != nullptr);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].checks() != 0);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].checks() != 0);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].dimension() == 3);
BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].dimension() == 3);
}
}

Expand Down