{"record":{"id":"823dbccb3d759b5b","repo":"stanfordnlp/CoreNLP","slug":"prior-is-specified-to-be-ae-lasso-or-g-lasso-but","errorCode":null,"errorMessage":"prior is specified to be ae-lasso or g-lasso, but function does not support feature grouping","messagePattern":"prior is specified to be ae-lasso or g-lasso, but function does not support feature grouping","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/optimization/SGDWithAdaGradAndFOBOS.java","lineNumber":324,"sourceCode":"    double[] testUpdateCache = null, currentRateCache = null, bCache = null;\n    sumGradSquare = new double[initial.length];\n    prevGrad = new double[initial.length];\n    prevDeltaX = new double[initial.length];\n    if (useAdaDelta) {\n      sumDeltaXSquare = new double[initial.length];\n      if (prior != Prior.NONE && prior != Prior.GAUSSIAN) {\n        throw new UnsupportedOperationException(\"useAdaDelta is currently only supported for Prior.NONE or Prior.GAUSSIAN\"); \n      }\n    }\n\n    int[][] featureGrouping = null;\n    if (prior != Prior.LASSO && prior != Prior.NONE) {\n      testUpdateCache = new double[initial.length];\n      currentRateCache = new double[initial.length];\n    }\n    if (prior != Prior.LASSO && prior != Prior.RIDGE && prior != Prior.GAUSSIAN) {\n      if (!(f instanceof HasFeatureGrouping)) {\n        throw new UnsupportedOperationException(\"prior is specified to be ae-lasso or g-lasso, but function does not support feature grouping\");\n      }\n      featureGrouping = ((HasFeatureGrouping)f).getFeatureGrouping();\n    }\n    if (prior == Prior.sgLASSO) {\n      bCache = new double[initial.length];\n    }\n\n    System.arraycopy(initial, 0, x, 0, x.length);\n\n    int numBatches =  1;\n    if (f instanceof AbstractStochasticCachingDiffUpdateFunction) {\n      if (totalSamples > 0)\n        numBatches = totalSamples / bSize;\n    }\n\n    boolean have_max = (maxIterations > 0 || numPasses > 0);\n\n    if (!have_max){","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/optimization/SGDWithAdaGradAndFOBOS.java#L306-L342","documentation":"SGDWithAdaGradAndFOBOS.minimize() throws this UnsupportedOperationException when the prior is an ae-lasso or g-lasso grouped regularizer but the objective function does not implement HasFeatureGrouping. Grouped lasso penalties need to know feature groups, which are supplied by the function via getFeatureGrouping().","triggerScenarios":"Passing a differentiable function (e.g. a plain LogisticObjectiveFunction) to minimize() while prior is set to Prior.aeLASSO or Prior.gLASSO, so the cast to HasFeatureGrouping is impossible.","commonSituations":"Selecting a grouped-lasso prior for a model type that never grouped its features; using an older custom objective function written before HasFeatureGrouping existed.","solutions":["Use an objective function implementation that implements HasFeatureGrouping and returns valid feature groups","Change the prior to Prior.LASSO, Prior.RIDGE, or Prior.GAUSSIAN which need no grouping","Implement HasFeatureGrouping on your custom function and return a feature grouping"],"exampleFix":"// before\noptimizer.setPrior(Prior.gLASSO);\noptimizer.minimize(new MyPlainFunction(), ...);\n// after\noptimizer.setPrior(Prior.gLASSO);\noptimizer.minimize(new MyGroupedFunction implements HasFeatureGrouping(), ...);","handlingStrategy":"validation","validationCode":"if ((prior == Prior.aeLASSO || prior == Prior.gLASSO) && !(f instanceof HasFeatureGrouping)) { throw new IllegalArgumentException(\"function must implement HasFeatureGrouping for grouped lasso priors\"); }","typeGuard":"boolean supportsGroupedLasso(ObjectiveFunction f) { return f instanceof HasFeatureGrouping; }","tryCatchPattern":null,"preventionTips":["Only use grouped-lasso priors with functions that implement HasFeatureGrouping","Document which priors each objective function supports","Fall back to plain Prior.LASSO when grouping is unavailable"],"tags":["java","optimization","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}