extract_history function

Computes history for a fitted model