stanfordnlp/CoreNLP · error · RuntimeException
Classifier is not initialized
Error message
Classifier is not initialized
What it means
A guard error signaling that cross-validation or testing code in ColumnDataClassifier was invoked before a classifier was trained or loaded; the `classifier` field is null because neither trainClassifier nor loadClassifier ran first.
Solutions
- Call trainClassifier or loadClassifier before testing/evaluation
- Check the pipeline order so training precedes cross-validation
- For command-line use, supply both trainFile and testFile or a serializedClassifier
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:2216 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/cd72bcc8894332b9.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:2216
}
List<String[]> devTestLineInfos = lineInfos.subList(start, end);
Pair<Double,Double> accuracies = testExamples(cl, devTest, devTestLineInfos);
accuracySum += accuracies.first();
macroF1Sum += accuracies.second();
}
double averageAccuracy = accuracySum / numFolds;
double averageMacroF1 = macroF1Sum / numFolds;
NumberFormat nf2 = new DecimalFormat("0.00000");
logger.info("Average accuracy/micro-averaged F1: " + nf2.format(averageAccuracy));
logger.info("Average macro-averaged F1: " + nf2.format(averageMacroF1));
logger.info("");
return new Pair<>(averageAccuracy, averageMacroF1);
}
public String classOf(Datum<String,String> example) {
if (classifier == null) {
throw new RuntimeException("Classifier is not initialized");
}
return classifier.classOf(example);
}
public Counter<String> scoresOf(Datum<String,String> example) {
if (classifier == null) {
throw new RuntimeException("Classifier is not initialized");
}
return classifier.scoresOf(example);
}
public Classifier<String,String> getClassifier() {
if (classifier == null) {
throw new RuntimeException("Classifier is not initialized");
}
return classifier;
}
View on GitHub (pinned to 1b7edd19c4)