I'm working on the multi-class prediction problem, with 6 output classes. These represent different types of land cover. The classification model is pixel-based and I have extracted different attributes from satellite imagery. I have created training dataset from the field data then trained my random forest model (using ranger R library).

My next step is to predict output classes over the whole study area. But here is the catch: I also want to "guide" the model so that proportions of the classes in the output are predefined. Additionally, I would like to have such constraints defined differently over the study area. For an example, my study area is city-wide and I know class proportions for each of the city-regions. Therefore, I would like that each city-region gets predictions based on its own predefined class proportions.

I'm looking for suggestions about what would be the best way to achieve this.


PS. I'm sorry if explained problem belongs more in the Geographic Information Systems section of the StackExchange, but I'm posting it here since I believe it is more statistically-related.

  • $\begingroup$ sounds like an interesting problem: best of luck with getting replies here: it seems unfortunately to me that this might require some bespoke modeling (but I hope I'm wrong)! $\endgroup$ Commented Jan 25, 2023 at 1:53

1 Answer 1


My first approach would be to use a multinomial logistic regression and defined a feature that corresponds to the a priori class proportion. For example, as a log-linear model, if $p_0$ is the simplex vector of class proportion, you could use the feature $x = \log(p_0)$. Then suppose you have a multinomial regression with only this feature, you would have $P(X = i) = \operatorname{softmax}(x * \beta)$. If $\beta=1$, you get back $P(X) = p_0$. Essentially $\beta$ tells you how informative that feature is, e.g. $\beta = 0$ you get back a uniform distribution. So one advantage of this approach is that you can learn $\beta$. And of course, you can add other features that are predictive of the class. They could be the predictions from your random forest model.

An alternative would be to go Bayesian, you could build a similar multinomial logistic regression, e.g.:

$$ P(X = i) = \operatorname{softmax}(log(\theta) + X * \beta) $$

Where $\theta$ corresponds to "true" proportions to be inferred, and $X * \beta$ the rest of your regression. The difference is that you would define a prior for $\theta$ based on the proportion that you expect. For example, something like:

$$ \theta \sim \operatorname{Dirichlet}(\alpha * p_0) $$

Where $\alpha$ is a predefined pseudo sample size that controls how informative the prior is. You could code such model using a probabilistic programming language such as Stan (or the R package brms, a wrapper of Stan).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.