Text this: An Algorithm for Restoring a Function from Different Functionals for Predicting Rare Events in the Economy