source: orange/Orange/OrangeWidgets/Regression/OWRandomForestRegression.py @ 11627:3c08b4b7e5ff

Revision 11627:3c08b4b7e5ff, 1.5 KB checked in by Ales Erjavec <ales.erjavec@…>, 9 months ago (diff)

Code style fixes for Random forest widgets.

Line 
1"""
2<name>Random Forest Regression</name>
3<description>Random forest regression.</description>
4<icon>icons/RandomForestRegression.svg</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,
15                 title="Random forest regression"):
16        OWRandomForest.__init__(self, parent, signalManager, title)
17
18        self.inputs = [("Data", ExampleTable, self.setData),
19                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
20
21        self.outputs = [("Learner", orange.Learner),
22                        ("Random Forest Classifier", orange.Classifier)]
23
24    def setData(self, data):
25        self.data = self.isDataWithClass(data, orange.VarTypes.Continuous, checkMissing=True) and data or None
26       
27        if self.data:
28            learner = self.constructLearner()
29            self.progressBarInit()
30            learner.callback = lambda v: self.progressBarSet(100.0 * v)
31            try:
32                self.classifier = learner(self.data)
33                self.classifier.name = self.name
34            except Exception, (errValue):
35                self.error(str(errValue))
36                self.classifier = None
37            self.progressBarFinished()
38        else:
39            self.classifier = None
40
41        self.send("Random Forest Classifier", self.classifier)
Note: See TracBrowser for help on using the repository browser.