{"record":{"id":"95cadc1a90dfb612","repo":"stanfordnlp/CoreNLP","slug":"minvalue-for-feature","errorCode":null,"errorMessage":"minValue for feature ","messagePattern":"minValue for feature ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/RVFDataset.java","lineNumber":197,"sourceCode":"    Arrays.fill(minValues, Double.POSITIVE_INFINITY);\n    Arrays.fill(maxValues, Double.NEGATIVE_INFINITY);\n\n    // first identify the max and min values for each feature.\n    // System.out.printf(\"number of datums: %d dataset size: %d\\n\",data.length,size());\n    for (int i = 0; i < size(); i++) {\n      // System.out.printf(\"datum %d length %d\\n\", i,data[i].length);\n      for (int j = 0; j < data[i].length; j++) {\n        int f = data[i][j];\n        if (values[i][j] < minValues[f])\n          minValues[f] = values[i][j];\n        if (values[i][j] > maxValues[f])\n          maxValues[f] = values[i][j];\n      }\n    }\n\n    for (int f = 0; f < featureIndex.size(); f++) {\n      if (minValues[f] == Double.POSITIVE_INFINITY)\n        throw new RuntimeException(\"minValue for feature \" + f + \" not assigned. \");\n      if (maxValues[f] == Double.NEGATIVE_INFINITY)\n        throw new RuntimeException(\"maxValue for feature \" + f + \" not assigned.\");\n    }\n\n    // now scale each value such that it's between 0 and 1.\n    for (int i = 0; i < size(); i++) {\n      for (int j = 0; j < data[i].length; j++) {\n        int f = data[i][j];\n        if (minValues[f] != maxValues[f])// the equality can happen for binary\n                                         // features which always take the value\n                                         // of 1.0\n          values[i][j] = (values[i][j] - minValues[f]) / (maxValues[f] - minValues[f]);\n      }\n    }\n\n    /*\n    for(int f = 0; f < featureIndex.size(); f++){\n      if(minValues[f] == maxValues[f])","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/RVFDataset.java#L179-L215","documentation":"During scaleFeatures, every feature is expected to have been observed at least once so a minimum value can be recorded; minValues[f] is initialized to +Infinity. If a feature appears in featureIndex but never in any datum's values, the minimum stays Infinity and the method throws rather than scale with undefined bounds. The message reports which feature index lacked an assigned minimum.","triggerScenarios":"Calling scaleFeatures (directly or via scaleDatum, which calls it when min/max are not cached) on an RVFDataset where some features registered in the featureIndex never occur with a value in any datum, e.g. empty datums or a featureIndex built with locked/extra entries.","commonSituations":"Merging datasets where the featureIndex was locked before all features were added, datums added with only labels and no features, or a feature only ever appearing with default 0 values that never populate the values arrays used for min/max scanning.","solutions":["Ensure every feature in the featureIndex occurs with at least one real value in the dataset before calling scaleFeatures (check with a scan over all datums)","Call scaleFeatures once on the full dataset (letting it compute and cache min/max) instead of scaleDatum per-datum, so bounds are computed over all data","Rebuild the dataset so the featureIndex contains only features actually observed in datums","If a feature legitimately has no data, remove it from featureIndex or seed min/max handling with sensible defaults"],"exampleFix":"// before\nds.add(new RVFDatum<>(new ClassicCounter<String>(), \"classA\")); // empty datum, features missing\nds.scaleFeatures();\n// after\nclassicCounts.remove(\"missingFeature\"); // ensure features seen in datums exist\nds.add(new RVFDatum<>(classicCounts, \"classA\"));\nds.scaleFeatures(); // all features have assigned min/max","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (int i = 0; i < ds.size(); i++) for (ClassifiableFeature f : ds.get(i).asFeatures()) seen.add(featureName);\nfor (int f = 0; f < ds.featureIndex().size(); f++) {\n  if (!seen.contains(ds.featureIndex().get(f))) throw new IllegalStateException(\"Feature \" + f + \" never observed; scaleFeatures will fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  ds.scaleFeatures();\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"minValue\")) {\n    logger.warning(\"Unobserved feature(s): rebuild dataset with observed features only\");\n  } else throw e;\n}","preventionTips":["Only add features to featureIndex when they occur in a datum","Call scaleFeatures once on the full dataset before any scaleDatum use","Validate datasets (ensureRealValues, min/max coverage) right after construction"],"tags":["java","stanford-nlp","machine-learning","feature-scaling"],"backgroundTag":"value-out-of-range","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}