Open 3D Engine MotionMatching Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
EMotionFX::MotionMatching::StandardScaler Class Reference

#include <FeatureMatrixStandardScaler.h>

Inherits EMotionFX::MotionMatching::FeatureMatrixTransformer.

Public Member Functions

 AZ_RTTI (StandardScaler, "{A0C7F056-94B0-43A1-8D12-B1A7B67AB92A}", FeatureMatrixTransformer)
 
bool Fit (const FeatureMatrix &featureMatrix, const Settings &settings={}) override
 
float Transform (float value, FeatureMatrix::Index column) const override
 
AZ::Vector2 Transform (const AZ::Vector2 &value, FeatureMatrix::Index column) const override
 
AZ::Vector3 Transform (const AZ::Vector3 &value, FeatureMatrix::Index column) const override
 
void Transform (AZStd::span< float > data) const override
 
FeatureMatrix Transform (const FeatureMatrix &featureMatrix) const override
 
FeatureMatrix InverseTransform (const FeatureMatrix &featureMatrix) const override
 
AZ::Vector2 InverseTransform (const AZ::Vector2 &value, FeatureMatrix::Index column) const override
 
AZ::Vector3 InverseTransform (const AZ::Vector3 &value, FeatureMatrix::Index column) const override
 
float InverseTransform (float value, FeatureMatrix::Index column) const override
 Input: Already transformed data, Output: Inverse transformed data (should match data before transform)
 
const AZStd::vector< float > & GetMeans () const
 
const AZStd::vector< float > & GetStandardDeviations () const
 
void SaveAsCsv (const char *filename, const AZStd::vector< AZStd::string > &columnNames={})
 
- Public Member Functions inherited from EMotionFX::MotionMatching::FeatureMatrixTransformer
 AZ_RTTI (FeatureMatrixTransformer, "{B19CDBB8-FA99-4CBD-86C1-640A3CC5988A}")
 
 AZ_CLASS_ALLOCATOR (FeatureMatrixTransformer, MotionMatchAllocator)
 
virtual bool Fit (const FeatureMatrix &featureMatrix, const Settings &settings)=0
 
virtual float Transform (float value, FeatureMatrix::Index column) const =0
 
virtual AZ::Vector2 Transform (const AZ::Vector2 &value, FeatureMatrix::Index column) const =0
 
virtual AZ::Vector3 Transform (const AZ::Vector3 &value, FeatureMatrix::Index column) const =0
 
virtual void Transform (AZStd::span< float > data) const =0
 
virtual FeatureMatrix Transform (const FeatureMatrix &in) const =0
 
virtual float InverseTransform (float value, FeatureMatrix::Index column) const =0
 Input: Already transformed data, Output: Inverse transformed data (should match data before transform)
 
virtual AZ::Vector2 InverseTransform (const AZ::Vector2 &value, FeatureMatrix::Index column) const =0
 
virtual AZ::Vector3 InverseTransform (const AZ::Vector3 &value, FeatureMatrix::Index column) const =0
 
virtual FeatureMatrix InverseTransform (const FeatureMatrix &in) const =0
 

Public Attributes

 AZ_CLASS_ALLOCATOR_DECL
 

Static Public Attributes

static constexpr float s_epsilon = AZ::Constants::FloatEpsilon
 

Detailed Description

The standard scaler can be used to normalize the feature matrix, the query vector and other data. It standardizes features by subtracting the mean and scaling to the unit variance. This implementation is mimicking the behavior of the standard scaler from scikit-learn (sklearn.preprocessing.StandardScaler). As we use floats by default, our errors are bigger, especially if the variance is small as this leads to a division by a small value. In case the calculated standard deviation for a given feature is smaller than the given s_epsilon value, the standard deviation gets force-set to 1.0 to avoid divisions by infinity and preserve the value when doing the transform -> inverse-transform roundtrip.

Member Function Documentation

◆ Fit()

bool EMotionFX::MotionMatching::StandardScaler::Fit ( const FeatureMatrix featureMatrix,
const Settings settings = {} 
)
overridevirtual

Prepare the transformer. This might e.g. run some statistical analysis and cache values that will be needed for actually transforming the data.

Implements EMotionFX::MotionMatching::FeatureMatrixTransformer.

◆ InverseTransform() [1/4]

AZ::Vector2 EMotionFX::MotionMatching::StandardScaler::InverseTransform ( const AZ::Vector2 &  value,
FeatureMatrix::Index  column 
) const
overridevirtual

◆ InverseTransform() [2/4]

AZ::Vector3 EMotionFX::MotionMatching::StandardScaler::InverseTransform ( const AZ::Vector3 &  value,
FeatureMatrix::Index  column 
) const
overridevirtual

◆ InverseTransform() [3/4]

FeatureMatrix EMotionFX::MotionMatching::StandardScaler::InverseTransform ( const FeatureMatrix featureMatrix) const
overridevirtual

◆ InverseTransform() [4/4]

float EMotionFX::MotionMatching::StandardScaler::InverseTransform ( float  value,
FeatureMatrix::Index  column 
) const
overridevirtual

Input: Already transformed data, Output: Inverse transformed data (should match data before transform)

Implements EMotionFX::MotionMatching::FeatureMatrixTransformer.

◆ Transform() [1/5]

void EMotionFX::MotionMatching::StandardScaler::Transform ( AZStd::span< float >  data) const
overridevirtual

◆ Transform() [2/5]

AZ::Vector2 EMotionFX::MotionMatching::StandardScaler::Transform ( const AZ::Vector2 &  value,
FeatureMatrix::Index  column 
) const
overridevirtual

◆ Transform() [3/5]

AZ::Vector3 EMotionFX::MotionMatching::StandardScaler::Transform ( const AZ::Vector3 &  value,
FeatureMatrix::Index  column 
) const
overridevirtual

◆ Transform() [4/5]

FeatureMatrix EMotionFX::MotionMatching::StandardScaler::Transform ( const FeatureMatrix featureMatrix) const
overridevirtual

◆ Transform() [5/5]

float EMotionFX::MotionMatching::StandardScaler::Transform ( float  value,
FeatureMatrix::Index  column 
) const
overridevirtual

Copy and transform the input data. Note: Use the version that can batch transform the most data. Expect significant performance losses when calling the granular versions on lots of data points.

Implements EMotionFX::MotionMatching::FeatureMatrixTransformer.


The documentation for this class was generated from the following file: