If your data suggest that the stock is trading at a discount due to irrationality, then you have a perfect opportunity to buy lots of an underpriced stock.
But, given enough data-informed trades that would otherwise be proditable, the law of large numbers suggests that an overall strategy will still be sound. You can afford to have the market be irrational here and there if you really are correctly forecasting earnings in advance most of the time.