org.lenskit.transform.normalize

## Class MeanVarianceNormalizer

• All Implemented Interfaces:
java.io.Serializable, VectorNormalizer

@Shareable
public class MeanVarianceNormalizer
extends AbstractVectorNormalizer
implements java.io.Serializable

Normalizes against the variance of the vector with optional smoothing as described in Hofmann ’04.

For user rating vectors, this normalization assumes that a user’s mean rating and variance are independent of actual preferences, and attempts to describe the preference of a rating by the distance of the rating from the mean, relative to the user’s normal rating variance.

Serialized Form
• ### Constructor Summary

Constructors
Constructor and Description
MeanVarianceNormalizer()
Initializes basic normalizer with no damping.
MeanVarianceNormalizer(double damping, double globalVariance)
Construct a new mean variance normalizer.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double getDamping()
Get the damping term.
double getGlobalVariance()
Get the global variance.
InvertibleFunction<Long2DoubleMap,Long2DoubleMap> makeTransformation(Long2DoubleMap reference)
Create a vector transformation that normalizes and denormalizes vectors with respect to a reference vector.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### MeanVarianceNormalizer

@Inject
public MeanVarianceNormalizer()

Initializes basic normalizer with no damping.

• #### MeanVarianceNormalizer

public MeanVarianceNormalizer(double damping,
double globalVariance)

Construct a new mean variance normalizer.

Parameters:
damping - damping factor to use. 0 for no damping, 5 for Hofmann’s implementation.
globalVariance - global variance to use in the damping calculations.
• ### Method Detail

• #### getDamping

public double getDamping()

Get the damping term.

Returns:
The damping term.
• #### getGlobalVariance

public double getGlobalVariance()

Get the global variance.

Returns:
The global variance from build time.
• #### makeTransformation

public InvertibleFunction<Long2DoubleMap,Long2DoubleMap> makeTransformation(Long2DoubleMap reference)
Description copied from interface: VectorNormalizer

Create a vector transformation that normalizes and denormalizes vectors with respect to a reference vector. The reference vector is used to compute any data needed for the normalization. For example, a mean-centering normalization will subtract the mean of the reference vector from any vector to which it is applied, and add back the reference mean when it is unapplied.

This allows transformations to be applied multiple times to different vectors and also unapplied.

If the reference vector is empty, the returned transformation should be the identity transform. Results are undefined if the reference vector is not complete or contains NaN values.

If the normalization needs to retain a copy of the sparse vector, it will take an immutable copy.

Specified by:
makeTransformation in interface VectorNormalizer
Parameters:
reference - The reference vector.
Returns:
A transformation built from the reference vector.