Objective. We identify two linked problems related to estimating the phase of the alpha rhythm when the signal after a specific event is unknown (real-time case), or corrupted (offline analysis). We propose methods to estimate the phase prior to such events. Approach. Machine learning is used to mimic a non-causal signal-processing chain with a purely causal one. Main results. We demonstrate the ability of these methods to estimate instantaneous phase from an electroencephalography signal subjected to very minor pre-processing with higher accuracy than more standard signal-processing methods. Significance. Phase estimation of EEG-rhythms is a challenge due to non-stationarity and low signal to noise ratio. The methods presented enable scientists and engineers to achieve relatively low error by optimizing causal phase estimation on a non-causally processed signal for a real-time experiments and offline analysis.