diff options
author | alex-sh <alex-sh@yandex-team.ru> | 2022-02-10 16:50:03 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:03 +0300 |
commit | 88ee78b1a163eaddee7e880ac73943456040fce0 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/linear_regression/unimodal.h | |
parent | 3196904c9f5bf7aff7374eeadcb0671589581f61 (diff) | |
download | ydb-88ee78b1a163eaddee7e880ac73943456040fce0.tar.gz |
Restoring authorship annotation for <alex-sh@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/linear_regression/unimodal.h')
-rw-r--r-- | library/cpp/linear_regression/unimodal.h | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/library/cpp/linear_regression/unimodal.h b/library/cpp/linear_regression/unimodal.h index 2cb3c531df..e11b1118f6 100644 --- a/library/cpp/linear_regression/unimodal.h +++ b/library/cpp/linear_regression/unimodal.h @@ -1,59 +1,59 @@ -#pragma once - -#include "linear_regression.h" - -struct TGreedyParams { - double LowerBound = 0; - double UpperBound = 0; - size_t StepsCount = 0; - - double Point(const size_t step) const; -}; - -struct TOptimizationParams { - TGreedyParams ModeParams; - TGreedyParams NormalizerParams; - - double OptimizationShrinkage = 1e-2; - double RegressionShrinkage = 1e-5; - - size_t IterationsCount = 1000; - +#pragma once + +#include "linear_regression.h" + +struct TGreedyParams { + double LowerBound = 0; + double UpperBound = 0; + size_t StepsCount = 0; + + double Point(const size_t step) const; +}; + +struct TOptimizationParams { + TGreedyParams ModeParams; + TGreedyParams NormalizerParams; + + double OptimizationShrinkage = 1e-2; + double RegressionShrinkage = 1e-5; + + size_t IterationsCount = 1000; + TOptimizationParams() = default; - + static TOptimizationParams Default(const TVector<double>& values) { - TOptimizationParams optimizationParams; - - optimizationParams.ModeParams.LowerBound = 0; - optimizationParams.ModeParams.UpperBound = values.size(); - optimizationParams.ModeParams.StepsCount = values.size() + 1; - - optimizationParams.NormalizerParams.LowerBound = 0.5; - optimizationParams.NormalizerParams.UpperBound = values.size() * 2; - optimizationParams.NormalizerParams.StepsCount = values.size() * 2 + 1; - - return optimizationParams; - } - + TOptimizationParams optimizationParams; + + optimizationParams.ModeParams.LowerBound = 0; + optimizationParams.ModeParams.UpperBound = values.size(); + optimizationParams.ModeParams.StepsCount = values.size() + 1; + + optimizationParams.NormalizerParams.LowerBound = 0.5; + optimizationParams.NormalizerParams.UpperBound = values.size() * 2; + optimizationParams.NormalizerParams.StepsCount = values.size() * 2 + 1; + + return optimizationParams; + } + static TOptimizationParams Default(const TVector<double>& values, const TVector<double>& arguments) { - Y_ASSERT(values.size() == arguments.size()); - - TOptimizationParams optimizationParams; - - optimizationParams.ModeParams.LowerBound = *MinElement(arguments.begin(), arguments.end()); - optimizationParams.ModeParams.UpperBound = *MaxElement(arguments.begin(), arguments.end()); - optimizationParams.ModeParams.StepsCount = arguments.size() + 1; - - optimizationParams.NormalizerParams.UpperBound = optimizationParams.ModeParams.UpperBound - optimizationParams.ModeParams.LowerBound; - optimizationParams.NormalizerParams.StepsCount = arguments.size() * 2 + 1; - optimizationParams.NormalizerParams.LowerBound = optimizationParams.NormalizerParams.UpperBound / optimizationParams.NormalizerParams.StepsCount; - - return optimizationParams; - } -}; - + Y_ASSERT(values.size() == arguments.size()); + + TOptimizationParams optimizationParams; + + optimizationParams.ModeParams.LowerBound = *MinElement(arguments.begin(), arguments.end()); + optimizationParams.ModeParams.UpperBound = *MaxElement(arguments.begin(), arguments.end()); + optimizationParams.ModeParams.StepsCount = arguments.size() + 1; + + optimizationParams.NormalizerParams.UpperBound = optimizationParams.ModeParams.UpperBound - optimizationParams.ModeParams.LowerBound; + optimizationParams.NormalizerParams.StepsCount = arguments.size() * 2 + 1; + optimizationParams.NormalizerParams.LowerBound = optimizationParams.NormalizerParams.UpperBound / optimizationParams.NormalizerParams.StepsCount; + + return optimizationParams; + } +}; + double MakeUnimodal(TVector<double>& values, const TOptimizationParams& optimizationParams); double MakeUnimodal(TVector<double>& values); - + double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments, const TOptimizationParams& optimizationParams); double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments); |