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

Add metadata to OpStandardScaler to allow for descaling #378

Merged
merged 11 commits into from
Aug 5, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ class OpScalarStandardScaler

val std = scalerModel.std.toArray
erica-chiu marked this conversation as resolved.
Show resolved Hide resolved
val mean = scalerModel.mean.toArray
if (std.length == 1) {
val stdMean = std.head
val meanMean = mean.head
val scalingArgs = LinearScalerArgs(1 / stdMean, - meanMean / stdMean)
val meta = ScalerMetadata(ScalingType.Linear, scalingArgs).toMetadata()
setMetadata(meta)
}

// Since is a UnaryEstimator, exactly one value will be in std and mean
erica-chiu marked this conversation as resolved.
Show resolved Hide resolved
val stdVal = std.head
val meanVal = mean.head
val scalingArgs = LinearScalerArgs(1 / stdVal, - meanVal / stdVal)
val meta = ScalerMetadata(ScalingType.Linear, scalingArgs).toMetadata()
setMetadata(meta)

new OpScalarStandardScalerModel(
std = std,
Expand Down