{"record":{"id":"cd72bcc8894332b9","repo":"stanfordnlp/CoreNLP","slug":"classifier-is-not-initialized","errorCode":null,"errorMessage":"Classifier is not initialized","messagePattern":"Classifier is not initialized","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/ColumnDataClassifier.java","lineNumber":2216,"sourceCode":"      }\n\n      List<String[]> devTestLineInfos = lineInfos.subList(start, end);\n      Pair<Double,Double> accuracies = testExamples(cl, devTest, devTestLineInfos);\n      accuracySum += accuracies.first();\n      macroF1Sum += accuracies.second();\n    }\n    double averageAccuracy = accuracySum / numFolds;\n    double averageMacroF1 = macroF1Sum / numFolds;\n    NumberFormat nf2 = new DecimalFormat(\"0.00000\");\n    logger.info(\"Average accuracy/micro-averaged F1: \" + nf2.format(averageAccuracy));\n    logger.info(\"Average macro-averaged F1: \" + nf2.format(averageMacroF1));\n    logger.info(\"\");\n    return new Pair<>(averageAccuracy, averageMacroF1);\n  }\n\n  public String classOf(Datum<String,String> example) {\n    if (classifier == null) {\n      throw new RuntimeException(\"Classifier is not initialized\");\n    }\n    return classifier.classOf(example);\n  }\n\n  public Counter<String> scoresOf(Datum<String,String> example) {\n    if (classifier == null) {\n      throw new RuntimeException(\"Classifier is not initialized\");\n    }\n    return classifier.scoresOf(example);\n  }\n\n  public Classifier<String,String> getClassifier() {\n    if (classifier == null) {\n      throw new RuntimeException(\"Classifier is not initialized\");\n    }\n    return classifier;\n  }\n","sourceCodeStart":2198,"sourceCodeEnd":2234,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/ColumnDataClassifier.java#L2198-L2234","documentation":"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.","triggerScenarios":"Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:2216 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}