source: orange/Orange/OrangeWidgets/Regression/OWRandomForestRegression.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 1.5 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1"""
2<name>Random Forest Regression</name>
3<description>Random forest regression.</description>
4<icon>icons/RandomForest.png</icon>
5<contact>Marko Toplak (marko.toplak(@at@)gmail.com)</contact>
6<priority>320</priority>
7<keywords>bagging, ensemble</keywords>
8
9"""
10
11from OWRandomForest import *
12
13class OWRandomForestRegression(OWRandomForest):
14    def __init__(self, parent=None, signalManager=None, title="Random forest regression"):
15        OWRandomForest.__init__(self, parent, signalManager, title)
16       
17        self.inputs = [("Data", ExampleTable, self.setData),
18                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
19       
20        self.outputs = [("Learner", orange.Learner),
21                        ("Random Forest Classifier", orange.Classifier)]
22
23    def setData(self, data):
24        self.data = self.isDataWithClass(data, orange.VarTypes.Continuous, checkMissing=True) and data or None
25       
26        if self.data:
27            learner = self.constructLearner()
28            pb = OWGUI.ProgressBar(self, iterations=self.trees)
29            learner.callback = pb.advance
30            try:
31                self.classifier = learner(self.data)
32                self.classifier.name = self.name
33            except Exception, (errValue):
34                self.error(str(errValue))
35                self.classifier = None
36            pb.finish()
37        else:
38            self.classifier = None
39
40        self.send("Random Forest Classifier", self.classifier)
41       
Note: See TracBrowser for help on using the repository browser.