Skip to content

How to best get class mapping for pickled StackedModel #5850

Answered by markotoplak
JoergPeisker asked this question in Q&A
Discussion options

You must be logged in to vote

To get predictions, the most Orange-like way is to prepare your data for prediction in an Orange Table and then just calling it with the data, for example as stackedmodel(data). This returns class label indices, which you can then transform to values, like this:

import Orange
import Orange.classification
import Orange.ensembles.stack
iris = Orange.data.Table("iris")
lr = Orange.classification.LogisticRegressionLearner()
stack = Orange.ensembles.stack.StackedLearner([lr], aggregate=lr)
stackedmodel = stack(iris[:140])

# use the model
predictions = stackedmodel(iris[140:])
print(predictions)

# to get classes from indices
values = stackedmodel.domain.class_var.values
print([values[int(v)] …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JoergPeisker
Comment options

Answer selected by JoergPeisker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants