source: orange/Orange/testing/regression/tests_20/reference_pp-censoring.py @ 9952:986e9cd806f4

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

Tests moved and renamed from orange 20.

Line 
1# Description: Shows how to add weight that reflect the confidence in examples in presence of censoring
2# Category:    preprocessing, survival analysis, censoring, weighting
3# Classes:     Preprocessor, Preprocessor_addCensorWeight
4# Uses:        wpbc
5# Referenced:  preprocessing.htm
6
7import orange
8data = orange.ExampleTable("wpbc")
9
10time = data.domain["time"]
11fail = data.domain.classVar.values.index("R")
12
13data2, weightID = orange.Preprocessor_addCensorWeight(
14   data, 0, # 0 = no initial weights
15   eventValue = fail, timeVar=time, maxTime = 20,
16   method = orange.Preprocessor_addCensorWeight.KM)
17   
18print "class\ttime\tweight"
19for ex in data2.select(recur="N", time=(0, 10)):
20    print "%s\t%5.2f\t%5.3f" % (ex.getclass(), float(ex["time"]), ex.getmeta(weightID))
21print
Note: See TracBrowser for help on using the repository browser.