Is there a way calculate metrics like ROC AUC and r2_score against elastic-search index?

I am working on pipeline within elastic-search, and want to calculate ROC_AUC and R2 scores per interval/bucket and visualize it within Kibana. What is the best way to proceed with this task? Is it possible to do it within elastic or should I do the calculations outside and record the score?

I'm not an expert on statistics, but I don't think this is possible out of the box.

I'd open an enhancement request here and describe your use-case https://github.com/elastic/elasticsearch/issues/new

Thanks