| 247 | }; |
| 248 | |
| 249 | class TFeaturesTransformer { |
| 250 | private: |
| 251 | ETransformationType TransformationType; |
| 252 | TTransformationParameters TransformationParameters; |
| 253 | |
| 254 | public: |
| 255 | Y_SAVELOAD_DEFINE(TransformationType, TransformationParameters); |
| 256 | |
| 257 | TFeaturesTransformer() = default; |
| 258 | |
| 259 | TFeaturesTransformer(const ETransformationType transformationType, |
| 260 | const TTransformationParameters transformationParameters) |
| 261 | : TransformationType(transformationType) |
| 262 | , TransformationParameters(transformationParameters) |
| 263 | { |
| 264 | } |
| 265 | |
| 266 | double Transformation(const double value) const { |
| 267 | switch (TransformationType) { |
| 268 | case ETransformationType::TT_IDENTITY: { |
| 269 | return value; |
| 270 | } |
| 271 | case ETransformationType::TT_SIGMA: { |
| 272 | const double valueWithoutOffset = value - TransformationParameters.FeatureOffset; |
| 273 | const double transformedValue = valueWithoutOffset / (fabs(valueWithoutOffset) + TransformationParameters.FeatureNormalizer); |
| 274 | return TransformationParameters.RegressionIntercept + TransformationParameters.RegressionFactor * transformedValue; |
| 275 | } |
| 276 | } |
| 277 | Y_ASSERT(0); |
| 278 | return 0.; |
| 279 | } |
| 280 | }; |
| 281 | |
| 282 | class TFeaturesTransformerLearner { |
| 283 | private: |