source: orange/Orange/testing/regression/tests_20/reference_MeasureAttribute3.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 1.4 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1# Description: Shows how to measure the attribute quality in regression problems
2# Category:    statistics
3# Classes:     MeasureAttribute, MeasureAttribute_MSE
4# Uses:        measure-c
5# Referenced:  MeasureAttribute.htm
6
7import orange, random
8data = orange.ExampleTable("measure-c")
9
10data2 = orange.ExampleTable(data)
11nulls = [(0, 1, 24, 25), (24, 25), range(24, 34), (24, 25)]
12for attr in range(len(nulls)):
13    for e in nulls[attr]:
14        data2[e][attr]="?"
15
16names = [a.name for a in data.domain.attributes]
17attrs = len(names)
18print
19print ("%30s"+"%15s"*attrs) % (("",) + tuple(names))
20fstr = "%30s" + "%15.4f"*attrs
21
22def printVariants(meas):
23    print fstr % (("- no unknowns:",) + tuple([meas(i, data) for i in range(attrs)]))
24
25    meas.unknownsTreatment = meas.IgnoreUnknowns
26    print fstr % (("- ignore unknowns:",) + tuple([meas(i, data2) for i in range(attrs)]))
27
28    meas.unknownsTreatment = meas.ReduceByUnknowns
29    print fstr % (("- reduce unknowns:",) + tuple([meas(i, data2) for i in range(attrs)]))
30
31    meas.unknownsTreatment = meas.UnknownsToCommon
32    print fstr % (("- unknowns to common:",) + tuple([meas(i, data2) for i in range(attrs)]))
33    print
34   
35print "MSE"
36printVariants(orange.MeasureAttribute_MSE())
37
38print "Relief"
39meas = orange.MeasureAttribute_relief()
40print fstr % (("- no unknowns:",) + tuple([meas(i, data) for i in range(attrs)]))
41print fstr % (("- with unknowns:",) + tuple([meas(i, data2) for i in range(attrs)]))
42print
Note: See TracBrowser for help on using the repository browser.