Changeset 9118:4967c9ff2e68 in orange


Ignore:
Timestamp:
10/18/11 16:42:17 (3 years ago)
Author:
mocnik <mocnik@…>
Branch:
default
Convert:
c1d73676af011fff74ee2899daf968cc6a5cca7e
Message:

Fixed for problems when having less that 10 instances and wanted to do 10fold cross validation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/evaluation/reliability.py

    r8911 r9118  
    7777 
    7878.. autoclass:: Learner 
     79    :members: 
     80 
     81Reliability estimation scoring methods 
     82====================================== 
    7983 
    8084.. autofunction:: get_pearson_r 
    8185 
    8286.. autofunction:: get_pearson_r_by_iterations 
     87 
     88.. autofunction:: get_spearman_r 
    8389 
    8490Referencing 
     
    166172<http://journals.cambridge.org/abstract_S0269888909990154>`_ 
    167173*The Knowledge Engineering Review* 25(1), 27-47. 
     174 
    168175""" 
    169176import Orange 
     
    743750     
    744751    :rtype: :class:`Orange.evaluation.reliability.Learner` 
    745      
    746     .. function:: internal_cross_validation 
    747      
    748     .. function:: internal_cross_validation_testing 
    749752    """ 
    750753    def __init__(self, box_learner, name="Reliability estimation", 
     
    779782    def internal_cross_validation(self, examples, folds=10): 
    780783        """ Performs the ususal internal cross validation for getting the best 
    781         reliability estimate. Returns the id of the method that scored the  
     784        reliability estimate. It uses the reliability estimators defined in  
     785        estimators attribute. Returns the id of the method that scored the  
    782786        best. """ 
    783787        res = Orange.evaluation.testing.cross_validation([self], examples, folds=folds) 
     
    799803        for fold in xrange(folds): 
    800804            data = examples.select(cv_indices, fold) 
    801             res = Orange.evaluation.testing.cross_validation([self], data) 
     805            if len(data) < 10: 
     806                res = Orange.evaluation.testing.leave_one_out([self], data) 
     807            else: 
     808                res = Orange.evaluation.testing.cross_validation([self], data) 
    802809            results = get_pearson_r(res) 
    803810            for r, _, _, method in results: 
     
    827834    def __call__(self, example, result_type=Orange.core.GetValue): 
    828835        """ 
    829         Classifiy and estimate a new instance. When you chose  
     836        Classify and estimate a new instance. When you chose  
    830837        Orange.core.GetBoth or Orange.core.getProbabilities, you can access  
    831838        the reliability estimates inside probabilities.reliability_estimate. 
Note: See TracChangeset for help on using the changeset viewer.