Commits

Andrej T. committed abcc457

Updated 'start', 'load-data' and 'basic-exploration' tutorials (with related code examples) to comply with the 2.5 architecture.

Comments (0)

Files changed (10)

docs/tutorial/rst/basic-exploration.rst

 examples. If you are curious how we do this, here is the code
 (:download:`sample_adult.py <code/sample_adult.py>`)::
 
-   import orange
-   data = orange.ExampleTable("adult")
-   selection = orange.MakeRandomIndices2(data, 0.03)
+   import Orange
+   data = Orange.core.ExampleTable("adult")
+   selection = Orange.core.MakeRandomIndices2(data, 0.03)
    sample = data.select(selection, 0)
    sample.save("adult_sample.tab")
 
 values, and class distribution. Below is the script that does all
 this (:download:`data_characteristics.py <code/data_characteristics.py>`, :download:`adult_sample.tab <code/adult_sample.tab>`)::
 
-   import orange
-   data = orange.ExampleTable("adult_sample")
+   import Orange
+   data = Orange.core.ExampleTable("adult_sample")
    
    # report on number of classes and attributes
    print "Classes:", len(data.domain.classVar.values)
    # count number of continuous and discrete attributes
    ncont=0; ndisc=0
    for a in data.domain.attributes:
-       if a.varType == orange.VarTypes.Discrete:
+       if a.varType == Orange.core.VarTypes.Discrete:
            ndisc = ndisc + 1
        else:
            ncont = ncont + 1
 through the attributes (variable ``a`` is an iteration variable that in is
 each loop associated with a single attribute).  The field ``varType``
 contains the type of the attribute; for discrete attributes, ``varType``
-is equal to ``orange.VarTypes.Discrete``, and for continuous ``varType`` is
-equal to ``orange.VarTypes.Continuous``.
+is equal to ``Orange.core.VarTypes.Discrete``, and for continuous ``varType`` is
+equal to ``Orange.core.VarTypes.Continuous``.
 
 To obtain the number of instances for each class, we first
 initialized a vector c that would of the length equal to the number of
 
    print "Continuous attributes:"
    for a in range(len(data.domain.attributes)):
-       if data.domain.attributes[a].varType == orange.VarTypes.Continuous:
+       if data.domain.attributes[a].varType == Orange.core.VarTypes.Continuous:
            d = 0.; n = 0
            for e in data:
                if not e[a].isSpecial():
 out in a readable form (part of :download:`data_characteristics3.py <code/data_characteristics3.py>`)::
 
    print "\nNominal attributes (contingency matrix for classes:", data.domain.classVar.values, ")"
-   cont = orange.DomainContingency(data)
+   cont = Orange.core.DomainContingency(data)
    for a in data.domain.attributes:
-       if a.varType == orange.VarTypes.Discrete:
+       if a.varType == Orange.core.VarTypes.Discrete:
            print "  %s:" % a.name
            for v in range(len(a.values)):
                sum = 0
 defined. Let us use this function to compute the proportion of missing
 values per each attribute (:download:`report_missing.py <code/report_missing.py>`)::
 
-   import orange
-   data = orange.ExampleTable("adult_sample")
+   import Orange
+   data = Orange.core.ExampleTable("adult_sample")
    
    natt = len(data.domain.attributes)
    missing = [0.] * natt
 -------------------------------
 
 For some of the tasks above, Orange can provide a shortcut by means of
-``orange.DomainDistributions`` function which returns an object that
+``Orange.core.DomainDistributions`` function which returns an object that
 holds averages and mean square errors for continuous attributes, value
 frequencies for discrete attributes, and for both number of instances
 where specific attribute has a missing value.  The use of this object
 is exemplified in the following script (:download:`data_characteristics4.py <code/data_characteristics4.py>`)::
 
-   import orange
-   data = orange.ExampleTable("adult_sample")
-   dist = orange.DomainDistributions(data)
+   import Orange
+   data = Orange.core.ExampleTable("adult_sample")
+   dist = Orange.core.DomainDistributions(data)
    
    print "Average values and mean square errors:"
    for i in range(len(data.domain.attributes)):
-       if data.domain.attributes[i].varType == orange.VarTypes.Continuous:
+       if data.domain.attributes[i].varType == Orange.core.VarTypes.Continuous:
            print "%s, mean=%5.2f +- %5.2f" % \
                (data.domain.attributes[i].name, dist[i].average(), dist[i].error())
    
    print "\nFrequencies for values of discrete attributes:"
    for i in range(len(data.domain.attributes)):
        a = data.domain.attributes[i]
-       if a.varType == orange.VarTypes.Discrete:
+       if a.varType == Orange.core.VarTypes.Discrete:
            print "%s:" % a.name
            for j in range(len(a.values)):
                print "  %s: %d" % (a.values[j], int(dist[i][j]))

docs/tutorial/rst/code/data_characteristics.py

 # Uses:        adult_sample.tab
 # Referenced:  basic_exploration.htm
 
-import orange
-data = orange.ExampleTable("adult_sample.tab")
+import Orange
+data = Orange.core.ExampleTable("adult_sample.tab")
 print "Classes:", len(data.domain.classVar.values)
 print "Attributes:", len(data.domain.attributes), ",",
 
 # count number of continuous and discrete attributes
 ncont = 0; ndisc = 0
 for a in data.domain.attributes:
-    if a.varType == orange.VarTypes.Discrete:
+    if a.varType == Orange.core.VarTypes.Discrete:
         ndisc = ndisc + 1
     else:
         ncont = ncont + 1

docs/tutorial/rst/code/data_characteristics2.py

 # Uses:        adult_sample.tab
 # Referenced:  basic_exploration.htm
 
-import orange
-data = orange.ExampleTable("adult_sample.tab")
+import Orange
+data = Orange.core.ExampleTable("adult_sample.tab")
 print "Classes:", len(data.domain.classVar.values)
 print "Attributes:", len(data.domain.attributes), ",",
 
 # count number of continuous and discrete attributes
 ncont = 0; ndisc = 0
 for a in data.domain.attributes:
-    if a.varType == orange.VarTypes.Discrete:
+    if a.varType == Orange.core.VarTypes.Discrete:
         ndisc = ndisc + 1
     else:
         ncont = ncont + 1

docs/tutorial/rst/code/data_characteristics3.py

 # Classes:     DomainContingency
 # Referenced:  basic_exploration.htm
 
-import orange
-data = orange.ExampleTable("adult_sample.tab")
+import Orange
+data = Orange.core.ExampleTable("adult_sample.tab")
 
 print "Continuous attributes:"
 for a in range(len(data.domain.attributes)):
-    if data.domain.attributes[a].varType == orange.VarTypes.Continuous:
+    if data.domain.attributes[a].varType == Orange.core.VarTypes.Continuous:
         d = 0.; n = 0
         for e in data:
             if not e[a].isSpecial():
         print "  %s, mean=%3.2f" % (data.domain.attributes[a].name, d / n)
 
 print "\nNominal attributes (contingency matrix for classes:", data.domain.classVar.values, ")"
-cont = orange.DomainContingency(data)
+cont = Orange.core.DomainContingency(data)
 for a in data.domain.attributes:
-    if a.varType == orange.VarTypes.Discrete:
+    if a.varType == Orange.core.VarTypes.Discrete:
         print "  %s:" % a.name
         for v in range(len(a.values)):
             sum = 0

docs/tutorial/rst/code/data_characteristics4.py

 # Uses:        adult_sample.tab
 # Referenced:  basic_exploration.htm
 
-import orange
-data = orange.ExampleTable("adult_sample.tab")
-dist = orange.DomainDistributions(data)
+import Orange
+data = Orange.core.ExampleTable("adult_sample.tab")
+dist = Orange.core.DomainDistributions(data)
 
 print "Average values and mean square errors:"
 for i in range(len(data.domain.attributes)):
-    if data.domain.attributes[i].varType == orange.VarTypes.Continuous:
+    if data.domain.attributes[i].varType == Orange.core.VarTypes.Continuous:
         print "%s, mean=%5.2f +- %5.2f" % \
           (data.domain.attributes[i].name, dist[i].average(), dist[i].error())
 
 print "\nFrequencies for values of discrete attributes:"
 for i in range(len(data.domain.attributes)):
     a = data.domain.attributes[i]
-    if a.varType == orange.VarTypes.Discrete:
+    if a.varType == Orange.core.VarTypes.Discrete:
         print "%s:" % a.name
         for j in range(len(a.values)):
             print "  %s: %d" % (a.values[j], int(dist[i][j]))

docs/tutorial/rst/code/lenses.py

 # Classes:     ExampleTable
 # Referenced:  load_data.htm
 
-import orange
-data = orange.ExampleTable("lenses")
+import Orange
+data = Orange.core.ExampleTable("lenses")
 print "Attributes:",
 for i in data.domain.attributes:
     print i.name,

docs/tutorial/rst/code/report_missing.py

 # Uses:        adult_sample.tab
 # Referenced:  basic_exploration.htm
 
-import orange
-data = orange.ExampleTable("adult_sample.tab")
+import Orange
+data = Orange.core.ExampleTable("adult_sample.tab")
 
 natt = len(data.domain.attributes)
 missing = [0.] * natt

docs/tutorial/rst/code/sample_adult.py

 # Classes:     ExampleTable, MakeRandomIndices2
 # Referenced:  basic_exploration.htm
 
-import orange
-data = orange.ExampleTable("adult_sample.tab")
-selection = orange.MakeRandomIndices2(data, 0.03)
+import Orange
+data = Orange.core.ExampleTable("adult_sample.tab")
+selection = Orange.core.MakeRandomIndices2(data, 0.03)
 sample = data.select(selection, 0)
 sample.save("adult_sample_sampled.tab")

docs/tutorial/rst/load-data.rst

 Python. In the interactive Python shell, import Orange and the data
 file:
 
->>> import orange
->>> data = orange.ExampleTable("lenses")
+>>> import Orange
+>>> data = Orange.core.ExampleTable("lenses")
 >>>
 
 This creates an object called data that holds your data set and
 reads lenses data, prints out names of the attributes and class, and
 lists first 5 data instances (:download:`lenses.py <code/lenses.py>`)::
 
-   import orange
-   data = orange.ExampleTable("lenses")
+   import Orange
+   data = Orange.core.ExampleTable("lenses")
    print "Attributes:",
    for i in data.domain.attributes:
        print i.name,
 :download:`car.names <code/car.names>` and run the following code::
 
    > python
-   >>> car_data = orange.ExampleTable("car")
+   >>> car_data = Orange.core.ExampleTable("car")
    >>> print car_data.domain.attributes
    <buying, maint, doors, persons, lugboot, safety>
    >>>
 spreadsheet, you may now store your C4.5 data file to a Orange native
 (.tab) format:
 
->>> orange.saveTabDelimited ("car.tab", car_data)
+>>> Orange.core.saveTabDelimited ("car.tab", car_data)
 >>>
 
 Similarly, saving to C4.5 format is possible through ``orange.saveC45``.
 located. You may either need to specify absolute path of your data
 files, like (type your commands in Interactive Window):
 
->>> car_data = orange.ExampleTable("c:/orange/car")
+>>> car_data = Orange.core.ExampleTable("c:/orange/car")
 >>>
 
 or set a working directory through Python's os library:

docs/tutorial/rst/start.rst

 type import Orange, brackets are in the following to denote shell's
 prompt):
 
->>> import orange
+>>> import Orange
 >>> 
 
 If this leaves no error and warning, Orange and python are properly