source: orange/Orange/OrangeWidgets/Data/OWDataInfo.py @ 11748:467f952c108d

Revision 11748:467f952c108d, 3.3 KB checked in by blaz <blaz.zupan@…>, 6 months ago (diff)

Changes in headers, widget descriptions text.

RevLine 
[11748]1import Orange
2import OWGUI
3from OWWidget import *
4import sys
[8042]5
[11748]6NAME = "Info"
7DESCRIPTION = """Displays basic information about data set on the input. Shows
8sample size, and number and type of features."""
9ICON = "icons/DataInfo.svg"
10PRIORITY = 80
11CATEGORY = "Data"
12MAINTAINER = "Ales Erjavec"
13MAINTAINER_EMAIL = "ales.erjavec < at > fri.uni-lj.si"
14INPUTS = [("Data", Orange.data.Table, "data")]
15OUTPUTS = []
[8042]16
17
18class OWDataInfo(OWWidget):
19    def __init__(self, parent=None, signalManager=None, name="Info"):
20        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0)
21       
[9546]22        self.inputs = [("Data", ExampleTable, self.data)]
[8042]23        self.rowcount = 0
24        self.columncount = 0
25        self.discattrcount = 0
26        self.contattrcount = 0
27        self.stringattrcount = 0
28        self.metaattrcount = 0
29        self.classattr = "No"
30       
31        box = OWGUI.widgetBox(self.controlArea, "Data Set Size", addSpace=True)
32        OWGUI.label(box, self, '<table><tr><td width="150">Samples (rows):</td><td align="right" width="60">%(rowcount)7i</td></tr>\
[11748]33                                <tr><td>Features (columns):</td><td align="right">%(columncount)7i</td></tr></table>')
[8042]34       
[11748]35        box = OWGUI.widgetBox(self.controlArea, "Features")
36        OWGUI.label(box, self, '<table><tr><td width="150">Discrete:</td><td align="right" width="60">%(discattrcount)7i</td></tr>\
37                                <tr><td>Continuous:</td><td align="right">%(contattrcount)7i</td></tr>\
38                                <tr><td>String:</td><td align="right">%(stringattrcount)7i</td></tr>\
[8042]39                                <tr><td> </td></tr>\
[11748]40                                <tr><td>Meta features:</td><td align="right">%(metaattrcount)7i</td></tr>\
41                                <tr><td>Class variable present:</td><td align="right">%(classattr)7s</td></tr></table>')
[8042]42#        OWGUI.separator(box)
43#        OWGUI.label(box, self, '<table><tr><td width="100">Meta attributes:</td><td align="right" width="50">%(metaattrcount)7i</td></tr>\
44#                                <tr><td>Class attribute:</td><td align="right">%(classattr)7s</td></tr></table>')
45#       
46        OWGUI.rubber(self.controlArea)
47        self.resize(200, 200)
48       
49        self.loadSettings()
[11748]50
[8042]51    def data(self, data):
52        if data:
53            self.rowcount = len(data)
54            self.columncount = len(list(data.domain.attributes) + data.domain.getmetas().keys())
55            self.discattrcount = len([attr for attr in data.domain.attributes if attr.varType == orange.VarTypes.Discrete])
56            self.contattrcount = len([attr for attr in data.domain.attributes if attr.varType == orange.VarTypes.Continuous])
57            self.stringattrcount = len([attr for attr in data.domain.attributes if attr.varType == orange.VarTypes.String])
58            self.metaattrcount = len(data.domain.getmetas())
59            self.classattr = "Yes" if data.domain.classVar else "No"
60        else:
61            self.rowcount = 0
62            self.columncount = 0
63            self.discattroutn = 0
64            self.contattrcount = 0
65            self.stringattrcount = 0
66            self.metaattrcount = 0
67            self.classattr = "No"
68           
69if __name__ == "__main__":
70    app = QApplication(sys.argv)
71    w = OWDataInfo()
[11748]72    data = Orange.data.Table("iris.tab")
[8042]73    w.data(data)
74    w.show()
[9044]75    app.exec_()
Note: See TracBrowser for help on using the repository browser.