Changeset 7452:a78fb83203fb in orange
 Timestamp:
 02/04/11 13:39:55 (3 years ago)
 Branch:
 default
 Convert:
 bbff1b86a6625bf0f070de2c8c1d1925ed75b633
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

orange/Orange/probability/distributions.py
r7416 r7452 87 87 petal width 0.100 2.500 1.199 88 88 89 Methods90 91 89 .. class:: Orange.probability.distribution.DomainBasicAttrStat 92 90 … … 171 169 resembles conditional probabilities of classes given the feature value. 172 170 173 174 =================175 General Contingency Matrix176 =================177 178 171 Here's what all contingency matrices share in common. 179 172 180 Attributes 173 .. class:: Orange.probability.distribution.Contingency 174 175 The base class is, once for a change, not abstract. Its constructor expects 176 two feature descriptors, the first one for the outer and the second for 177 the inner feature. It initializes empty distributions and it's up to you 178 to fill them. This is, for instance, how to manually reproduce results of 179 the script at the top of the page. 181 180 182 181 .. attribute:: outerVariable … … 208 207 209 208 .. attribute:: varType 210 209 211 210 The varType for the outer feature (discrete, continuous...); 212 211 varType equals outerVariable.varType and outerDistribution.varType. … … 250 249 Other methods 251 250 251 .. class:: Orange.probability.distributions.Contingency 252 252 253 .. method:: add(outer_value, inner_value[, weight]) 253 254 … … 269 270 3 <0.667, 0.333> 270 271 4 <0.667, 0.333> 271 272 273 =================274 Contingency275 =================276 277 The base class is, once for a change, not abstract. Its constructor expects278 two feature descriptors, the first one for the outer and the second for279 the inner feature. It initializes empty distributions and it's up to you280 to fill them. This is, for instance, how to manually reproduce results of281 the script at the top of the page.282 272 283 273 .. _distributionscontingency2: code/distributionscontingency2.py … … 295 285 and updates innerDistribution and outerDistribution. 296 286 297 298 =================299 ContingencyClass300 =================301 302 ContingencyClass is an abstract base class for contingency matrices303 that contain the class, either as the inner or the outer304 feature. If offers a function for making filing the contingency clearer.305 306 After reading through the rest of this page you might ask yourself307 why do we need to separate the classes ContingencyAttrClass,308 ContingencyClassAttr and ContingencyAttrAttr,309 given that the underlying matrix is the same. This is to avoid confusion310 about what is in the inner and the outer variable.311 Contingency matrices are most often used to compute probabilities of conditional312 classes or features. By separating the classes and giving them specialized313 methods for computing the probabilities that are most suitable to compute314 from a particular class, the user (ie, you or the method that gets passed315 the matrix) is relieved from checking what kind of matrix it got, that is,316 where is the class and where's the feature.317 318 319 287 .. class:: Orange.probability.distribution.ContingencyClass 288 289 ContingencyClass is an abstract base class for contingency matrices 290 that contain the class, either as the inner or the outer 291 feature. If offers a function for making filing the contingency clearer. 292 293 After reading through the rest of this page you might ask yourself 294 why do we need to separate the classes ContingencyAttrClass, 295 ContingencyClassAttr and ContingencyAttrAttr, 296 given that the underlying matrix is the same. This is to avoid confusion 297 about what is in the inner and the outer variable. 298 Contingency matrices are most often used to compute probabilities of conditional 299 classes or features. By separating the classes and giving them specialized 300 methods for computing the probabilities that are most suitable to compute 301 from a particular class, the user (ie, you or the method that gets passed 302 the matrix) is relieved from checking what kind of matrix it got, that is, 303 where is the class and where's the feature. 304 305 320 306 321 307 .. attribute:: classVar (read only) … … 337 323 338 324 339 =================340 ContingencyAttrClass341 =================342 343 ContingencyAttrClass is derived from ContingencyClass.344 Here, feature is the outer variable (hence variable=outerVariable)345 and class is the inner (classVar=innerVariable), so this form of346 contingency matrix is suitable for computing the conditional probabilities347 of classes given a value of a feature.348 349 Calling add_attrclass(v, c) is here equivalent to calling add(v, c).350 In addition to this, the class supports computation of contingency from instances,351 as you have already seen in the example at the top of this page.352 325 353 326 .. class:: Orange.probability.distribution.ContingencyClass 327 328 ContingencyAttrClass is derived from ContingencyClass. 329 Here, feature is the outer variable (hence variable=outerVariable) 330 and class is the inner (classVar=innerVariable), so this form of 331 contingency matrix is suitable for computing the conditional probabilities 332 of classes given a value of a feature. 333 334 Calling add_attrclass(v, c) is here equivalent to calling add(v, c). 335 In addition to this, the class supports computation of contingency from instances, 336 as you have already seen in the example at the top of this page. 337 354 338 355 339 .. method:: ContingencyAttrClass(feature, class_attribute) … … 443 427 444 428 445 =================446 ContingencyClassAttr447 =================448 449 ContingencyClassAttr is similar to ContingencyAttrClass except that here450 the class is the outer and the feature the inner variable.451 As a consequence, this form of contingency matrix is suitable452 for computing conditional probabilities of feature values given class.453 Constructor and add_attrclass nevertheless get the arguments454 in the same order as for ContingencyAttrClass, that is,455 feaure first, class second.456 457 458 429 .. class:: Orange.probability.distribution.ContingencyClassAttr 430 431 ContingencyClassAttr is similar to ContingencyAttrClass except that here 432 the class is the outer and the feature the inner variable. 433 As a consequence, this form of contingency matrix is suitable 434 for computing conditional probabilities of feature values given class. 435 Constructor and add_attrclass nevertheless get the arguments 436 in the same order as for ContingencyAttrClass, that is, 437 feaure first, class second. 438 459 439 460 440 ..method:: ContingencyClassAttr(attribute, class_attribute) … … 524 504 525 505 526 =================527 ContingencyAttrAttr528 =================529 530 ContingencyAttrAttr stores contingency matrices in which none531 of the features is the class. This is rather similar to Contingency,532 except that it has an additional constructor and method for getting533 the conditional probabilities.534 535 506 .. class:: Orange.probability.distribution.ContingencyAttrAttr 507 508 ContingencyAttrAttr stores contingency matrices in which none 509 of the features is the class. This is rather similar to Contingency, 510 except that it has an additional constructor and method for getting 511 the conditional probabilities. 536 512 537 513 .. method:: ContingencyAttrAttr(outer_variable, inner_variable) … … 655 631 additional fields and a constructor that computes the contingencies. 656 632 657 658 .. attribute:: classIsOuter (read only) 659 660 Tells whether the class is the outer or the inner featue. 661 Effectively, this tells whether the elements of the list 662 are ContingencyAttrClass or ContingencyClassAttr. 663 664 .. attribute:: classes 665 666 Contains the distribution of class values on the entire dataset. 667 668 ..method:: DomainContingency(instances[, weightID][, classIsOuter=01]) 633 .. class:: DomainContingency(instances[, weightID][, classIsOuter=01]) 669 634 670 635 Constructor needs to be given a list of instances. … … 673 638 It then iterates through instances and computes the contingencies. 674 639 675 ..method:: normalize 676 677 Calls normalize for each contingency. 640 .. attribute:: classIsOuter (read only) 641 642 Tells whether the class is the outer or the inner featue. 643 Effectively, this tells whether the elements of the list 644 are ContingencyAttrClass or ContingencyClassAttr. 645 646 .. attribute:: classes 647 648 Contains the distribution of class values on the entire dataset. 649 650 .. method:: normalize 651 652 Calls normalize for each contingency. 678 653 679 654 The following script will print the contingencies for features … … 691 666 To compute the distribution of feature values given the class, 692 667 one needs to get a list of ContingencyClassAttr. 693 694 part of **distributionscontingency8.py** (uses monk1.tab)::695 668 696 669 Note that classIsOuter cannot be given as positional argument, … … 713 686 DistributionList, \ 714 687 ComputeDomainContingency, \ 715 ConditionalProbabilityEstimator, \716 ConditionalProbabilityEstimator_ByRows, \717 ConditionalProbabilityEstimator_FromDistribution, \718 ConditionalProbabilityEstimatorConstructor, \719 ConditionalProbabilityEstimatorConstructor_ByRows, \720 ConditionalProbabilityEstimatorConstructor_loess, \721 ConditionalProbabilityEstimatorList, \722 688 Contingency, \ 723 689 ContingencyAttrAttr, \
Note: See TracChangeset
for help on using the changeset viewer.