Orange Forum • View topic - Type error using tree learner to predict values

Type error using tree learner to predict values

A place to ask questions about methods in Orange and how they are used and other general support.

Type error using tree learner to predict values

Postby sreastman » Fri Apr 19, 2013 15:39

Please excuse me if this is a repeat. The original post did not appear immediately as it usually does.

I am trying to run a Monte Carlo simulation to compare each quantile of a randomly generated set of attributes to the resulting quantile of a predicted class value. So far, it has worked for several learners, but not for the regression tree learner. I use a data file with at least one continuous attribute column and exactly one continuous class column to initialize the learner as follows:

data = Orange.data.Table("OptimizedPTSDbyPrideInDelinquency")
learner = Orange.regression.tree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2)

This proceeds successfully.

I notice to have the learner predict from a set of attributes, it needs a placeholder for class value. After experimentation I learned it doesn't matter what the placeholder is, so I added "" as follows:

for f in range(len(data.domain.features)):
attribute = random.uniform(lowerLimits[f], upperLimits[f])
attributes.append(attribute)
attributes.append("")
predicted_outcome = learner(attributes)

At this point I receive the following message:

Traceback (most recent call last):
File "Test-3.py", line 48, in <module>
predicted_outcome = learner(attributes)
File "C:\Python27\lib\site-packages\Orange\classificaiton\tree.py", line2609,
in __call__
return self.nativeClassifier(instance, result_type, *args, **kwargs)
TypeError: attribute error: example (and, optionally, return type) expected

What do I need to be doing differently?

Thanks--Steve

Re: Type error using tree learner to predict values

Postby Ales » Fri Apr 19, 2013 16:26

Try
Code: Select all
predicted_outcome = learner(Orange.data.Instance(data.domain, attributes))

Re: Type error using tree learner to predict values

Postby sreastman » Fri Apr 19, 2013 17:04

Thanks Ales.

That took care of it.

Steve


Return to Questions & Support



cron