Cluster-based foreshock discrimination model with flexible time horizon and mainshock magnitudes