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

Revision 9952:986e9cd806f4, 802 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 use meta-attributes with orange.Example
2# Category:    basic classes, meta-attributes
3# Classes:     Example
4# Uses:        lenses
5# Referenced:  Example.htm
6
7import orange, random
8
9random.seed(0)
10
11data = orange.ExampleTable("lenses")
12
13id = -42
14# Note that this is wrong. Id should be assigned by
15# id = orange.newmetaid()
16# We only do this so that the script gives the same output each time it's run
17
18for example in data:
19    example[id] = orange.Value(random.random())
20
21print data[0]
22
23print orange.getClassDistribution(data)
24print orange.getClassDistribution(data, id)
25
26w = orange.FloatVariable("w")
27data.domain.addmeta(id, w)
28
29print data[0]
30
31print data[0][id]
32print data[0][w]
33print data[0]["w"]
34
35data[0][id] = orange.Value(w, 2.0)
36data[0][id] = "2.0"
37data[0][id] = 2.0
38
Note: See TracBrowser for help on using the repository browser.