Safety checks for classification algorithms (Fix #9252)