Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions vizier/_src/algorithms/designers/gp/yjt.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,24 @@ def optimal_transformation(
lambdas = preprocessing.PowerTransformer(
method, standardize=False).fit(data).lambdas_.astype(dtype)

logging.info('Optimal lambda was: %s', lambdas)
logging.info('Optimal lambda was: %s, %s', lambdas, lambdas.dtype)

if dimension == 1:
# Make it a scalar, so we don't end up with batch_shape = [1] in the
# bijector.
lambdas = lambdas.item()
if method == 'yeo-johnson':
warp = tfsb.YeoJohnson(lambdas)
# Cast the default values of `rho` and `shift` to the same dtype as `data`
# to avoid dtype mismatch errors.
warp = tfsb.YeoJohnson(
lambdas, rho=np.asarray(2.0, dtype=dtype), shift=np.asarray(1.0, dtype)
)
elif method == 'box-cox':
warp = tfsb.YeoJohnson(lambdas, shift=.0)
# Cast the default values of `rho` and `shift` to the same dtype as `data`
# to avoid dtype mismatch errors.
warp = tfsb.YeoJohnson(
lambdas, rho=np.asarray(2.0, dtype), shift=np.asarray(0.0, dtype)
)
else:
raise ValueError(f'Unknown method: {method}')

Expand Down
Loading