Time-dependent variational principle for predicting the expectation value of an observable, application to mean field theories