# API choice: \`inversePredict(mod,Xnew)\` vs \`predict(mod,Xnew;inv=true)\`?

**URL:** <https://discourse.julialang.org/t/api-choice-inversepredict-mod-xnew-vs-predict-mod-xnew-inv-true/86123>\
**Category:** Machine Learning\
**Created:** [August 22, 2022, 9:38am UTC](https://discourse.julialang.org/t/api-choice-inversepredict-mod-xnew-vs-predict-mod-xnew-inv-true/86123 "2022-08-22T09:38:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [August 22, 2022, 9:38am UTC](https://discourse.julialang.org/t/api-choice-inversepredict-mod-xnew-vs-predict-mod-xnew-inv-true/86123/1 "2022-08-22T09:38:11Z")

</div>

For a ML library, which would be the arguments in favour to use a new specific function name for the inverse prediction for a model (e.g. a zero-mean/unit variance scaler), something like `inversePrediction(mod,Xnew)`, and which arguments would be in favour to just use a keyword argument to the already employed `predict` function, something like `predict(mod,Xnew;inv=true)` ?

Some context:

- I use only `predict(mod)` (and eventually `predict(mod,Xnew)` for models that generalise to new data) for unsupervised models and so-called transformers without distinguishing between them
- I use camel case
- MLJ and scikit-learn use `inverse_transform`
- I care more to user-friendly than performance

---

<div class="post-metadata">

**Author:** ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)\
**Post date:** [August 22, 2022, 9:29pm UTC](https://discourse.julialang.org/t/api-choice-inversepredict-mod-xnew-vs-predict-mod-xnew-inv-true/86123/2 "2022-08-22T21:29:26Z")

</div>

I think a keyword argument is not ideal because, in general, the “inverse” operation operates on different types, and outputs objects of different types. I don’t generally expect keyword options to effect behaviour in that way.

From a user’s perspective I cannot see much difference.

If you do go for kwarg, I’d vote for “inverse=” rather than “inv=”.

My only other comment is that the use of camelCase for function names in Julia is [not recommended](https://docs.julialang.org/en/v1/manual/style-guide/#Use-naming-conventions-consistent-with-Julia-base/) but I guess you know that already 🙂

---

<div class="post-metadata">

**Author:** ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)\
**Post date:** [August 23, 2022, 12:01am UTC](https://discourse.julialang.org/t/api-choice-inversepredict-mod-xnew-vs-predict-mod-xnew-inv-true/86123/3 "2022-08-23T00:01:22Z")

</div>

Oh, and I think StatsAPI and elsewhere, `reconstruct` is used, which I think is a good name, since generally the inverse is not really an inverse, but only a one-sided inverse, or approximate, and so forth.
