Ignore:
Timestamp:
03/18/11 14:53:13 (3 years ago)
Author:
markotoplak
Branch:
default
Convert:
5ddd67ca8e82c904ae3837cdc2e4cc8d9856626b
Message:

Imputation for 2.5.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/doc/Orange/rst/code/imputation-complex.py

    r7568 r7764  
    7171 
    7272print "*** TREE-BASED IMPUTATION ***" 
    73 import orngTree 
     73 
    7474imputer = Orange.feature.imputation.ImputerConstructor_model() 
    75 imputer.learnerContinuous = imputer.learnerDiscrete = orngTree.TreeLearner(minSubset = 20) 
     75imputer.learner_continuous = imputer.learner_discrete = Orange.classification.tree.TreeLearner(minSubset=20) 
    7676imputer = imputer(table) 
    7777print "Example w/ missing values" 
     
    9090print "*** BAYES and AVERAGE IMPUTATION ***" 
    9191imputer = Orange.feature.imputation.ImputerConstructor_model() 
    92 imputer.learnerContinuous = Orange.classification.majority.MajorityLearner() 
    93 imputer.learnerDiscrete = Orange.classification.bayes.NaiveLearner() 
     92imputer.learner_continuous = Orange.regression.mean.MeanLearner() 
     93imputer.learner_discrete = Orange.classification.bayes.NaiveLearner() 
    9494imputer = imputer(table) 
    9595print "Example w/ missing values" 
     
    112112imputer.models[table.domain.index("T-OR-D")] = tord 
    113113 
    114 import orngTree 
     114 
    115115len_domain = Orange.data.Domain(["MATERIAL", "SPAN", "ERECTED", "LENGTH"], table.domain) 
    116116len_data = Orange.data.Table(len_domain, table) 
    117117len_tree = Orange.classification.tree.TreeLearner(len_data, minSubset=20) 
    118118imputer.models[table.domain.index("LENGTH")] = len_tree 
    119 orngTree.printTxt(len_tree) 
     119print len_tree 
    120120 
    121 spanVar = table.domain["SPAN"] 
    122 def computeSpan(ex, rw): 
     121span_var = table.domain["SPAN"] 
     122def compute_span(ex, rw): 
    123123    if ex["TYPE"] == "WOOD" or ex["PURPOSE"] == "WALK": 
    124         return orange.Value(spanVar, "SHORT") 
     124        return orange.Value(span_var, "SHORT") 
    125125    else: 
    126         return orange.Value(spanVar, "MEDIUM") 
     126        return orange.Value(span_var, "MEDIUM") 
    127127 
    128 imputer.models[table.domain.index("SPAN")] = computeSpan 
     128imputer.models[table.domain.index("SPAN")] = compute_span 
    129129 
    130130for i in range(20, 25): 
Note: See TracChangeset for help on using the changeset viewer.