Skip to content

Interpret.plot_predictions with transformed variables #821

Answered by GStechschulte
SanBertero asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @SanBertero thanks for the question and notebook.

Is there a way to control this either way? Say, keep Y(X) in its original scale, or plot it as a function of the transformed X?

To keep Y on its original scale, you could pass an inverse transform function to the transforms parameter, e.g.

# model_5.formula = Formula('scale(Y) ~ scale(X)')

y_mean = np.mean(Y)
y_std = np.std(Y)

inv_transform = lambda x: x*y_std + y_mean

fig, ax = bmb.interpret.plot_predictions(
    model_5,results_5,
    'X',
    pps=True,
    prob=0.9, 
    transforms={"scale(Y)": inv_transform}
)

I had a case come up where I wanted to normalize log(x). scale(log(x)) seems to work for the inference model, but th…

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@SanBertero
Comment options

@GStechschulte
Comment options

@GStechschulte
Comment options

@SanBertero
Comment options

@SanBertero
Comment options

Answer selected by SanBertero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants