Changeset 4060:5e021a849cac in orange


Ignore:
Timestamp:
08/07/07 14:16:25 (7 years ago)
Author:
blaz <blaz.zupan@…>
Branch:
default
Convert:
3de681725a3c3f6d7cd44c4e36d54682aeb817a7
Message:

changed description for evaluation, added one more example

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/doc/ofb/regression.htm

    r2826 r4060  
    1818classifiers, and evaluation techniques are not much different 
    1919either.</p> 
     20 
     21<h2>Few Simple Regressors</h2> 
    2022 
    2123<p>Let us start with <index name="regression/regression 
     
    101103</xmp> 
    102104 
     105<h2>Evaluation and Scoring</h2> 
     106 
    103107<p>For our third and last example for regression, let us see how we 
    104108can use cross-validation testing and for a score function use <index>mean 
     
    135139 
    136140<xmp class="code">Learner        MSE 
    137 default         862.838 
    138 regression tree 53.378 
    139 k-NN (k=5)      23.285 
    140 </xmp> 
    141  
    142 <p>Currently, mean squared error is the only evaluation function we 
    143 provide for regression. If you need to implement something more 
    144 advanced or meaningful for your data, you should check how 
    145 <code>MSE</code> is implemented in <code>orngStat</code>: it really 
    146 takes only about a single line of code to compute this statistics, so 
    147 you should have no problems implementing your scoring functions.</p> 
     141default         84.777 
     142regression tree 40.096 
     143k-NN (k=5)      17.532 
     144</xmp> 
     145 
     146<p>Other scoring techniques are available to evaluate the success of 
     147regression. Script below uses a range of them, plus features a nice 
     148implementation where a list of scoring techniques is defined 
     149independetly from the code that reports on the results.</p> 
     150 
     151<p class="header">part of <a href="regression4.py">regression4.py</a> (uses <a href= 
     152"housing.tab">housing.tab</a>)</p> 
     153<xmp class="code">lr = orngRegression.LinearRegressionLearner(name="lr") 
     154rt = orngTree.TreeLearner(measure="retis", mForPruning=2, 
     155                          minExamples=20, name="rt") 
     156maj = orange.MajorityLearner(name="maj") 
     157knn = orange.kNNLearner(k=10, name="knn") 
     158learners = [maj, lr, rt, knn] 
     159 
     160# evaluation and reporting of scores 
     161results = orngTest.learnAndTestOnTestData(learners, train, test) 
     162scores = [("MSE", orngStat.MSE), 
     163          ("RMSE", orngStat.RMSE), 
     164          ("MAE", orngStat.MAE), 
     165          ("RSE", orngStat.RSE), 
     166          ("RRSE", orngStat.RRSE), 
     167          ("RAE", orngStat.RAE), 
     168          ("R2", orngStat.R2)] 
     169 
     170print "Learner  " + "".join(["%-7s" % s[0] for s in scores]) 
     171for i in range(len(learners)): 
     172    print "%-8s " % learners[i].name + "".join(["%6.3f " % s[1](results)[i] for s in scores]) 
     173</xmp> 
     174 
     175<p>Here, we used a number of different scores, including:</P> 
     176<ul> 
     177  <li>MSE - mean squared errror</li> 
     178  <li>RMSE - root mean squared error</li> 
     179  <li>MAE - mean absolute error</li> 
     180  <li>RSE - relative squared error</li> 
     181  <li>RRSE - root relative squared error</li> 
     182  <li>RAE - relative absolute error</li> 
     183  <li>R2 - coefficient of determinatin, also referred to as R-squared</li> 
     184</ul> 
     185<p>For precise definition of these measures, see <a href="../modules/orngStat.htm">orngStat documentation</a>. Running the script above yields:</p> 
     186 
     187<xmp class="code">Learner  MSE    RMSE   MAE    RSE    RRSE   RAE    R2 
     188maj      84.777  9.207  6.659  1.004  1.002  1.002 -0.004 
     189lr       23.729  4.871  3.413  0.281  0.530  0.513  0.719 
     190rt       40.096  6.332  4.569  0.475  0.689  0.687  0.525 
     191knn      17.244  4.153  2.670  0.204  0.452  0.402  0.796 
     192</xmp> 
    148193 
    149194<hr><br><p class="Path"> 
Note: See TracChangeset for help on using the changeset viewer.