Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/extend-widgets/rst/channels.rst

    r11439 r11593  
    1818******************** 
    1919 
    20 First, I do not like the name, but can't make up anything better. In 
    21 essence, the basic idea about "multi-input" channels is that they can 
     20In essence, the basic idea about "multi-input" channels is that they can 
    2221be used to connect them with several output channels. That is, if a 
    2322widget supports such a channel, several widgets can feed their input 
     
    2524 
    2625Say we want to build a widget that takes a data set and test 
    27 various predictive modelling techniques on it. A widget has to have an 
     26various predictive modeling techniques on it. A widget has to have an 
    2827input data channel, and this we know how to deal with from our 
    2928:doc:`previous <settings>` lesson. But, somehow differently, we 
     
    5049widget are defined by:: 
    5150 
    52     self.inputs = [("Data", ExampleTable, self.dataset), 
    53                    ("Learner", orange.Learner, self.learner, Multiple + Default)] 
     51    self.inputs = [("Data", Orange.data.Table, self.dataset), 
     52                   ("Learner", Orange.classification.Learner, 
     53                    self.learner, Multiple + Default)] 
    5454 
    5555Notice that everything is pretty much the same as it was with 
     
    6363channel for its type (more on default channels later). 
    6464 
    65 .. note:: :obj:`Default` flag here is used for illustration. Since *Learner* 
    66           channel is the only channel for a :class:`orange.Learner` type 
    67           it is also the default. 
     65.. note:: 
     66   :obj:`Default` flag here is used for illustration. Since *"Learner"* 
     67   channel is the only channel for a :class:`Orange.classification.Learner` 
     68   type it is also the default. 
    6869 
    6970How does the widget know from which widget did the token come from? 
     
    7172sending the token, and having a multi-input channel only tells Orange to 
    7273send a token together with sending widget id, the two arguments with 
    73 which the receiving function is called. For our :obj:`Learner` 
    74 channel the receiving function is :obj:`learner`, and this looks 
     74which the receiving function is called. For our *"Learner"* 
     75channel the receiving function is :func:`learner`, and this looks 
    7576like the following:: 
    7677 
     
    131132(:obj:`None`). Remember that sending an empty learner 
    132133essentially means that the link with the sending widget was removed, 
    133 hance we need to remove such learner from our list. If a non-empty 
     134hence we need to remove such learner from our list. If a non-empty 
    134135learner was sent, then it is either a new learner (say, from a widget 
    135136we have just linked to our learning curve widget), or an update 
     
    149150all that is needed is the augmenting the list:: 
    150151 
    151     self.scoring = [("Classification Accuracy", orngStat.CA), 
    152                     ("AUC", orngStat.AUC), 
    153                     ("BrierScore", orngStat.BrierScore), 
    154                     ("Information Score", orngStat.IS), 
    155                     ("Sensitivity", orngStat.sens), 
    156                     ("Specificity", orngStat.spec)] 
     152    self.scoring = [("Classification Accuracy", Orange.evaluation.scoring.CA), 
     153                    ("AUC", Orange.evaluation.scoring.AUC), 
     154                    ("BrierScore", Orange.evaluation.scoring.Brier_score), 
     155                    ("Information Score", Orange.evaluation.scoring.IS), 
     156                    ("Sensitivity", Orange.evaluation.scoring.Sensitivity), 
     157                    ("Specificity", Orange.evaluation.scoring.Specificity)] 
    157158 
    158159which is defined in the initialization part of the widget. The 
     
    178179is:: 
    179180 
    180     self.outputs = [("Sampled Data", ExampleTable), ("Other Data", ExampleTable)] 
     181    self.outputs = [("Sampled Data", Orange.data.Table), 
     182                    ("Other Data", Orange.data.Table)] 
    181183 
    182184We used this in the third incarnation of :download:`data sampler widget <OWDataSamplerC.py>`, 
    183 with essentially the only other change in the code in the :obj:`selection` and 
    184 :obj:`commit` functions:: 
     185with essentially the only other change in the code in the :func:`selection` and 
     186:func:`commit` functions:: 
    185187 
    186188    def selection(self): 
    187         indices = orange.MakeRandomIndices2(p0=self.proportion / 100.) 
     189        indices = Orange.data.sample.SubsetIndices2(p0=self.proportion / 100.) 
    188190        ind = indices(self.dataset) 
    189191        self.sample = self.dataset.select(ind, 0) 
     
    197199If a widget that has multiple channels of the same type is 
    198200connected to a widget that accepts such tokens, Orange Canvas opens a 
    199 window asking the user to confirm which channels to connect. The 
    200 channel mentioned in :obj:`self.outputs` is connected by 
    201 default. Hence, if we have just connected Data Sampler 
    202 (C) widget to a Data Table widget in a schema below: 
     201window asking the user to confirm which channels to connect. Hence, 
     202if we have just connected *Data Sampler (C)* widget to a Data Table 
     203widget in a schema below: 
    203204 
    204205.. image:: datasampler-totable.png 
     
    223224training data set channel will be the default one. 
    224225 
    225 When enlisting the input channel of the same type, the non-default 
     226When enlisting the input channel of the same type, the default 
    226227channels have a special flag in the channel specification list. So for 
    227228our new :download:`learning curve <OWLearningCurveB.py>` widget, the 
    228229channel specification is:: 
    229230 
    230     self.inputs = [("Train Data", ExampleTable, self.trainset, Default), 
    231                    ("Test Data", ExampleTable, self.testset), 
    232                    ("Learner", orange.Learner, self.learner, Multiple)] 
     231    self.inputs = [("Train Data", Orange.data.Table, self.trainset, Default), 
     232                   ("Test Data", Orange.data.Table, self.testset), 
     233                   ("Learner", Orange.classification.Learner, self.learner, Multiple)] 
    233234 
    234235That is, the :obj:`Train Data` channel is a single-token 
     
    240241.. image:: file-to-learningcurveb.png 
    241242 
    242 That is, no window with a query on which channels 
    243 to connect to will open. To find out which channels got connected, 
    244 double click on the green link between the two widgets: 
    245  
    246 .. image:: file-to-learningcurveb-channels.png 
     243That is, no window with a query on which channels to connect to will 
     244open, as the default *"Train Data"* was selected. 
Note: See TracChangeset for help on using the changeset viewer.