stanfordnlp/CoreNLP · error · java.lang.UnsupportedOperationException
prior is specified to be ae-lasso or g-lasso, but function…
Error message
prior is specified to be ae-lasso or g-lasso, but function does not support feature grouping
What it means
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().
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
Example fix
// before optimizer.setPrior(Prior.gLASSO); optimizer.minimize(new MyPlainFunction(), ...); // after optimizer.setPrior(Prior.gLASSO); optimizer.minimize(new MyGroupedFunction implements HasFeatureGrouping(), ...);
Defensive patterns
Strategy: validation
Validate before calling
if ((prior == Prior.aeLASSO || prior == Prior.gLASSO) && !(f instanceof HasFeatureGrouping)) { throw new IllegalArgumentException("function must implement HasFeatureGrouping for grouped lasso priors"); } Type guard
boolean supportsGroupedLasso(ObjectiveFunction f) { return f instanceof HasFeatureGrouping; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Selecting a grouped-lasso prior for a model type that never grouped its features; using an older custom objective function written before HasFeatureGrouping existed.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Attempt to use ExternalFiniteDifference without passing…
- Doesn't support floats yet
- LogPrior.getSigmaSquaredM is undefined for any prior but…
- LogPrior.valueAt is undefined for prior of type
- If you want to ask for the probability, you must train a…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/823dbccb3d759b5b.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/optimization/SGDWithAdaGradAndFOBOS.java:324
double[] testUpdateCache = null, currentRateCache = null, bCache = null;
sumGradSquare = new double[initial.length];
prevGrad = new double[initial.length];
prevDeltaX = new double[initial.length];
if (useAdaDelta) {
sumDeltaXSquare = new double[initial.length];
if (prior != Prior.NONE && prior != Prior.GAUSSIAN) {
throw new UnsupportedOperationException("useAdaDelta is currently only supported for Prior.NONE or Prior.GAUSSIAN");
}
}
int[][] featureGrouping = null;
if (prior != Prior.LASSO && prior != Prior.NONE) {
testUpdateCache = new double[initial.length];
currentRateCache = new double[initial.length];
}
if (prior != Prior.LASSO && prior != Prior.RIDGE && prior != Prior.GAUSSIAN) {
if (!(f instanceof HasFeatureGrouping)) {
throw new UnsupportedOperationException("prior is specified to be ae-lasso or g-lasso, but function does not support feature grouping");
}
featureGrouping = ((HasFeatureGrouping)f).getFeatureGrouping();
}
if (prior == Prior.sgLASSO) {
bCache = new double[initial.length];
}
System.arraycopy(initial, 0, x, 0, x.length);
int numBatches = 1;
if (f instanceof AbstractStochasticCachingDiffUpdateFunction) {
if (totalSamples > 0)
numBatches = totalSamples / bSize;
}
boolean have_max = (maxIterations > 0 || numPasses > 0);
if (!have_max){View on GitHub (pinned to 1b7edd19c4)