source: orange/orange/fixes/fix_changed_names.py @ 7750:f74d3a552fd5

Revision 7750:f74d3a552fd5, 35.8 KB checked in by lanz <lan.zagar@…>, 3 years ago (diff)

Added mapping for orange.GetValue, ...

Line 
1""" This fixer changes all occurrences of the form 'module.member' from the
2global dictionary MAPPING's keys and replaces them with the corresponding
3value. It adds the proper imports to make it available in the script
4
5For example this code::
6    import orange
7    import orngSVM
8    data = orange.ExampleTable("iris")
9    learner = orngSVM.SVMLearner(name='svm')
10   
11will be replaced with::
12    import Orange.data
13    import Orange.classification.svm
14    data =Orange.data.Table('iris')
15    learner =Orange.classification.svm.SVMLearner(name='svm')
16   
17Try to add as much name mappings as possible (This fixer is prefered
18(and will run before) the fix_orange_imports 
19   
20"""
21from lib2to3 import fixer_base
22from lib2to3 import fixer_util
23from lib2to3 import pytree
24from lib2to3.fixer_util import Name, Dot, Node, attr_chain, touch_import
25
26# keys must be in the form of 'orange.name' not name or orange.bla.name
27MAPPING = {"orange.ExampleTable": "Orange.data.Table",
28           "orange.Example": "Orange.data.Instance",
29           "orange.Domain": "Orange.data.Domain",
30           "orange.Value": "Orange.data.Value",
31           "orange.VarTypes": "Orange.data.Type",
32           "orange.Variable": "Orange.data.variable.Variable",
33           "orange.EnumVariable": "Orange.data.variable.Discrete",
34           "orange.FloatVariable": "Orange.data.variable.Continuous",
35           "orange.StringVariable": "Orange.data.variable.String",
36           "orange.PythonVariable": "Orange.data.variable.Python",
37           "orange.VarList": "Orange.data.variable.Variables",
38           "orange.GetValue": "Orange.classification.Classifier.GetValue",
39           "orange.GetProbabilities": "Orange.classification.Classifier.GetProbabilities",
40           "orange.GetBoth": "Orange.classification.Classifier.GetBoth",
41           
42           "orange.Distribution": "Orange.statistics.distribution.Distribution",
43           "orange.DiscDistribution": "Orange.statistics.distribution.Discrete",
44           "orange.ContDistribution": "Orange.statistics.distribution.Continuous",
45           "orange.GaussianDistribution": "Orange.statistics.distribution.Gaussian",
46           "orange.DomainDistributions": "Orange.statistics.distribution.Domain",
47           
48           "orange.BasicAttrStat": "Orange.statistics.basic.Variable",
49           "orange.DomainBasicAttrStat": "Orange.statistics.basic.Domain",
50           
51           "orange.ContingencyAttrAttr": "Orange.statistics.contingency.VarVar",
52           "orange.ContingencyClass": "Orange.statistics.contingency.Class",
53           "orange.ContingencyAttrClass": "Orange.statistics.contingency.VarClass",
54           "orange.ContingencyClassAttr": "Orange.statistics.contingency.ClassVar",
55           "orange.DomainContingency": "Orange.statistics.contingency.Domain",
56         
57           "orange.MeasureAttribute": "Orange.feature.scoring.Measure", 
58           "orange.MeasureAttribute_gainRatio": "Orange.feature.scoring.GainRatio",
59           "orange.MeasureAttribute_relief": "Orange.feature.scoring.Relief",
60           "orange.MeasureAttribute_info": "Orange.feature.scoring.InfoGain",
61           "orange.MeasureAttribute_gini": "Orange.feature.scoring.Gini",
62
63           "orange.MeasureAttribute_relevance": "Orange.feature.scoring.Relevance",
64           "orange.MeasureAttribute_cost": "Orange.feature.scoring.Cost",
65           "orange.MeasureAttribute_MSE": "Orange.feature.scoring.MSE",
66
67           "orngFSS.attMeasure": "Orange.feature.scoring.attMeasure",
68           "orngFSS.bestNAtts": "Orange.feature.selection.bestNAtts",
69           "orngFSS.attsAbovethreshold": "Orange.feature.selection.attsAbovethreshold",
70           "orngFSS.selectBestNAtts": "Orange.feature.selection.selectBestNAtts",
71           "orngFSS.selectAttsAboveThresh": "Orange.feature.selection.selectAttsAboveThresh",
72           "orngFSS.filterRelieff": "Orange.feature.selection.filterRelieff",
73           "orngFSS.FilterAttsAboveThresh": "Orange.feature.selection.FilterAttsAboveThresh",
74           "orngFSS.FilterAttsAboveThresh_Class": "Orange.feature.selection.FilterAttsAboveThresh_Class",
75           "orngFSS.FilterBestNAtts": "Orange.feature.selection.FilterBestNAtts",
76           "orngFSS.FilterBestNAtts_Class": "Orange.feature.selection.FilterBestNAtts_Class",
77           "orngFSS.FilterRelief": "Orange.feature.selection.FilterRelief",
78           "orngFSS.FilterRelief_Class": "Orange.feature.selection.FilterRelief_Class",
79           "orngFSS.FilteredLearner": "Orange.feature.selection.FilteredLearner",
80           "orngFSS.FilteredLearner_Class": "Orange.feature.selection.FilteredLearner_Class",
81           "orngFSS.FilteredClassifier": "Orange.feature.selection.FilteredClassifier",
82           "orngFSS.StepwiseLearner_Class": "Orange.classification.wrappers.StepwiseLearner",
83           "orngFSS.StepwiseLearner": "Orange.classification.wrappers.StepwiseLearner",
84           
85           "orange.ImputerConstructor_model": "Orange.feature.imputation.ImputerConstructor_model",
86           "orange.Imputer_model": "Orange.feature.imputation.Imputer_model",
87           "orange.Imputer_defaults": "Orange.feature.imputation.Imputer_defaults",
88           "orange.ImputerConstructor_asValue": "Orange.feature.imputation.ImputerConstructor_asValue",
89           "orange.ImputerConstructor_minimal": "Orange.feature.imputation.ImputerConstructor_minimal", 
90           "orange.ImputerConstructor_maximal": "Orange.feature.imputation.ImputerConstructor_maximal",
91           "orange.ImputerConstructor_average": "Orange.feature.imputation.ImputerConstructor_average",
92 
93           "orange.ExamplesDistance_Normalized": "Orange.distances.ExamplesDistance_Normalized",
94           "orange.ExamplesDistanceConstructor": "Orange.distances.ExamplesDistanceConstructor",
95           "orange.ExamplesDistance_Hamming": "Orange.distances.Hamming",
96           "orange.ExamplesDistance_DTW": "Orange.distances.DTW", 
97           "orange.ExamplesDistance_Euclidean": "Orange.distances.Euclidean", 
98           "orange.ExamplesDistance_Manhattan": "Orange.distances.Manhattan", 
99           "orange.ExamplesDistance_Maximal": "Orange.distances.Maximal", 
100           "orange.ExamplesDistance_Relief": "Orange.distances.Relief", 
101           
102           "orange.ExamplesDistanceConstructor_DTW": "Orange.distances.DTWConstructor", 
103           "orange.ExamplesDistanceConstructor_Euclidean": "Orange.distances.EuclideanConstructor", 
104           "orange.ExamplesDistanceConstructor_Hamming": "Orange.distances.HammingConstructor",
105           "orange.ExamplesDistanceConstructor_Manhattan": "Orange.distances.ManhattanConstructor",
106           "orange.ExamplesDistanceConstructor_Maximal": "Orange.distances.MaximalConstructor",
107           "orange.ExamplesDistanceConstructor_Relief": "Orange.distances.ReliefConstructor",
108           
109           "orngClustering.ExamplesDistanceConstructor_PearsonR": "Orange.distances.PearsonRConstructor",
110           "orngClustering.ExamplesDistance_PearsonR": "Orange.distances.PearsonR",
111           "orngClustering.ExamplesDistanceConstructor_SpearmanR": "Orange.distances.SpearmanRConstructor",
112           "orngClustering.ExamplesDistance_SpearmanR": "Orange.distances.SpearmanR",
113           
114           "orngClustering.KMeans": "Orange.clustering.kmeans.Clustering",
115           "orngClustering.kmeans_init_random": "Orange.clustering.kmeans.init_random",
116           "orngClustering.kmeans_init_diversity": "Orange.clustering.kmeans.init_diversity",
117           "orngClustering.KMeans_init_hierarchicalClustering": "Orange.clustering.kmeans.init_hclustering",
118           "orngClustering.data_center": "Orange.clustering.kmeans.data_center",
119           "orngClustering.plot_silhouette": "Orange.clustering.kmeans.plot_silhouette",
120           "orngClustering.score_distance_to_centroids": "Orange.clustering.kmeans.score_distance_to_centroids",
121           "orngClustering.score_silhouette": "Orange.clustering.kmeans.score_silhouette",
122           
123           "orange.HierarchicalClustering": "Orange.clustering.hierarchical.HierarchicalClustering",
124           "orngClustering.hierarchicalClustering": "Orange.clustering.hierarchical.clustering",
125           "orngClustering.hierarchicalClustering_attributes": "Orange.clustering.hierarchical.clustering_features",
126           "orngClustering.hierarchicalClustering_clusterList": "Orange.clustering.hierarchical.cluster_to_list",
127           "orngClustering.hierarchicalClustering_topClusters": "Orange.clustering.hierarchical.top_clusters",
128           "orngClustering.hierarhicalClustering_topClustersMembership": "Orange.clustering.hierarchical.top_cluster_membership",
129           "orngClustering.orderLeaves": "Orange.clustering.hierarchical.order_leaves",
130           
131           "orngSVM.RBFKernelWrapper": "Orange.classification.svm.kernels.RBFKernelWrapper",
132           "orngSVM.CompositeKernelWrapper": "Orange.classification.svm.kernels.CompositeKernelWrapper",
133           "orngSVM.KernelWrapper": "Orange.classification.svm.kernels.KernelWrapper",
134           "orngSVM.DualKernelWrapper": "Orange.classification.svm.kernels.DualKernelWrapper",
135           "orngSVM.PolyKernelWrapper": "Orange.classification.svm.kernels.PolyKernelWrapper",
136           "orngSVM.AdditionKernelWrapper": "Orange.classification.svm.kernels.AdditionKernelWrapper",
137           "orngSVM.MultiplicationKernelWrapper": "Orange.classification.svm.kernels.MultiplicationKernelWrapper",
138           "orngSVM.SparseLinKernel": "Orange.classification.svm.kernels.SparseLinKernel",
139           "orngSVM.BagOfWords": "Orange.classification.svm.kernels.BagOfWords",
140           
141           "orange.kNNLearner":"Orange.classification.knn.kNNLearner",
142           "orange.kNNClassifier":"Orange.classification.knn.kNNClassifier",
143           "orange.FindNearest_BruteForce":"Orange.classification.knn.FindNearest",
144           "orange.FindNearestConstructor_BruteForce":"Orange.classification.knn.FindNearestConstructor",
145           "orange.P2NN":"Orange.classification.knn.P2NN",
146           
147           "orange.BayesLearner":"Orange.classification.bayes.NaiveLearner",
148           "orange.BayesClassifier":"Orange.classification.bayes.NaiveClassifier",
149           "orngBayes.BayesLearner":"Orange.classification.bayes.NaiveLearner",
150           "orngBayes.BayesClassifier":"Orange.classification.bayes.NaiveClassifier",
151           "orngBayes.printModel": "Orange.classification.bayes.printModel",
152           
153           "orngNetwork.MdsTypeClass":"Orange.network.MdsTypeClass",
154           "orngNetwork.Network":"Orange.network.Network",
155           "orngNetwork.NetworkOptimization":"Orange.network.NetworkOptimization",
156           "orngNetwork.NetworkClustering":"Orange.network.NetworkClustering",
157           "orange.Graph":"Orange.network.Graph",
158           "orange.GraphAsList":"Orange.network.GraphAsList",
159           "orange.GraphAsMatrix":"Orange.network.GraphAsMatrix",
160           "orange.GraphAsTree":"Orange.network.GraphAsTree",
161           
162           "orngEnsemble.MeasureAttribute_randomForests":"Orange.ensemble.forest.ScoreFeature",
163           
164           "orange.TreeLearner": "Orange.classification.tree.TreeLearner",
165           "orange.TreeClassifier": "Orange.classification.tree.TreeClassifier",
166           "orange.C45Learner": "Orange.classification.tree.C45Learner",
167           "orange.C45Classifier": "Orange.classification.tree.C45Classifier",
168           "orange.C45TreeNode": "Orange.classification.tree.C45Node",
169           "orange.C45TreeNodeList": "C45NodeList",
170           "orange.TreeDescender": "Orange.classification.tree.Descender",
171           "orange.TreeDescender_UnknownMergeAsBranchSizes": "Orange.classification.tree.Descender_UnknownMergeAsBranchSizes",
172           "orange.TreeDescender_UnknownMergeAsSelector": "Orange.classification.tree.Descender_UnknownMergeAsSelector",
173           "orange.TreeDescender_UnknownToBranch": "Orange.classification.tree.Descender_UnknownToBranch",
174           "orange.TreeDescender_UnknownToCommonBranch": "Orange.classification.tree.Descender_UnknownToCommonBranch",
175           "orange.TreeDescender_UnknownToCommonSelector":"Orange.classification.tree.Descender_UnknownToCommonSelector",
176           "orange.TreeExampleSplitter":"Orange.classification.tree.Splitter",
177           "orange.TreeExampleSplitter_IgnoreUnknowns":"Orange.classification.tree.Splitter_IgnoreUnknowns",
178           "orange.TreeExampleSplitter_UnknownsAsBranchSizes":"Orange.classification.tree.Splitter_UnknownsAsBranchSizes",
179           "orange.TreeExampleSplitter_UnknownsAsSelecto":"Orange.classification.tree.Splitter_UnknownsAsSelector",
180           "orange.TreeExampleSplitter_UnknownsToAll":"Orange.classification.tree.Splitter_UnknownsToAll",
181           "orange.TreeExampleSplitter_UnknownsToBranch":"Orange.classification.tree.Splitter_UnknownsToBranch",
182           "orange.TreeExampleSplitter_UnknownsToCommon":"Orange.classification.tree.Splitter_UnknownsToCommon",
183           "orange.TreeExampleSplitter_UnknownsToRandom":"Orange.classification.tree.Splitter_UnknownsToRandom",
184           "orange.TreeNode":"Orange.classification.tree.Node",
185           "orange.TreeNodeList":"Orange.classification.tree.NodeList",
186           "orange.TreePruner":"Orange.classification.tree.Pruner",
187           "orange.TreePruner_SameMajority":"Orange.classification.tree.Pruner_SameMajority",
188           "orange.TreePruner_m":"Orange.classification.tree.Pruner_m",
189           "orange.TreeSplitConstructor":"Orange.classification.tree.SplitConstructor",
190           "orange.TreeSplitConstructor_Combined":"Orange.classification.tree.SplitConstructor_Combined",
191           "orange.TreeSplitConstructor_Measure":"Orange.classification.tree.SplitConstructor_Measure",
192           "orange.TreeSplitConstructor_Attribute":"Orange.classification.tree.SplitConstructor_Feature",
193           "orange.TreeSplitConstructor_ExhaustiveBinary":"Orange.classification.tree.SplitConstructor_ExhaustiveBinary",
194           "orange.TreeSplitConstructor_OneAgainstOthers":"Orange.classification.tree.SplitConstructor_OneAgainstOthers",
195           "orange.TreeSplitConstructor_Threshold":"Orange.classification.tree.SplitConstructor_Threshold",
196           "orange.TreeStopCriteria":"Orange.classification.tree.StopCriteria",
197           "orange.TreeStopCriteria_Python":"Orange.classification.tree.StopCriteria_Python",
198           "orange.TreeStopCriteria_common":"Orange.classification.tree.StopCriteria_common",
199           
200           "orange.MajorityLearner":"Orange.classification.majority.MajorityLearner",
201           "orange.DefaultClassifier":"Orange.classification.ConstantClassifier",
202           
203           "orange.LookupLearner":"Orange.classification.lookup.LookupLearner",
204           "orange.ClassifierByLookupTable":"Orange.classification.lookup.ClassifierByLookupTable",
205           "orange.ClassifierByLookupTable1":"Orange.classification.lookup.ClassifierByLookupTable1",
206           "orange.ClassifierByLookupTable2":"Orange.classification.lookup.ClassifierByLookupTable2",
207           "orange.ClassifierByLookupTable3":"Orange.classification.lookup.ClassifierByLookupTable3",
208           "orange.ClassifierByExampleTable":"Orange.classification.lookup.ClassifierByDataTable",
209
210           "orngLookup.lookupFromBound":"Orange.classification.lookup.lookup_from_bound",
211           "orngLookup.lookupFromExamples":"Orange.classification.lookup.lookup_from_data",
212           "orngLookup.lookupFromFunction":"Orange.classification.lookup.lookup_from_function",
213           "orngLookup.printLookupFunction":"Orange.classification.lookup.dump_lookup_function",
214           
215           "orange.AssociationRule" : "Orange.associate.AssociationRule",
216           "orange.AssociationRules" : "Orange.associate.AssociationRules",
217           "orange.AssociationRulesInducer" : "Orange.associate.AssociationRulesInducer",
218           "orange.AssociationRulesSparseInducer" : "Orange.associate.AssociationRulesSparseInducer",
219           "orange.ItemsetNodeProxy" : "Orange.associate.ItemsetNodeProxy",
220           "orange.ItemsetsSparseInducer" : "Orange.associate.ItemsetsSparseInducer",
221
222           "orngCN2.ruleToString": "Orange.classification.rules.ruleToString",
223           "orngCN2.LaplaceEvaluator": "Orange.classification.rules.LaplaceEvaluator",
224           "orngCN2.WRACCEvaluator": "Orange.classification.rules.WRACCEvaluator",
225           "orngCN2.mEstimate": "Orange.classification.rules.MEstimateEvaluator",
226           "orngCN2.RuleStopping_apriori": "Orange.classification.rules.RuleStopping_Apriori",
227           "orngCN2.LengthValidator": "Orange.classification.rules.LengthValidator",
228           "orngCN2.supervisedClassCheck": "Orange.classification.rules.supervisedClassCheck",
229           "orngCN2.CN2Learner": "Orange.classification.rules.CN2Learner",
230           "orngCN2.CN2Classifier": "Orange.classification.rules.CN2Classifier",
231           "orngCN2.CN2UnorderedLearner": "Orange.classification.rules.CN2UnorderedLearner",
232           "orngCN2.CN2UnorderedClassifier": "Orange.classification.rules.CN2UnorderedClassifier",
233           "orngCN2.RuleClassifier_bestRule": "Orange.classification.rules.RuleClassifier_BestRule",
234           "orngCN2.CovererAndRemover_multWeights": "Orange.classification.rules.CovererAndRemover_MultWeights",
235           "orngCN2.CovererAndRemover_addWeights": "Orange.classification.rules.CovererAndRemover_AddWeights",
236           "orngCN2.rule_in_set": "Orange.classification.rules.rule_in_set",
237           "orngCN2.rules_equal": "Orange.classification.rules.rules_equal",
238           "orngCN2.noDuplicates_validator": "Orange.classification.rules.NoDuplicatesValidator",
239           "orngCN2.ruleSt_setRules": "Orange.classification.rules.RuleStopping_SetRules",
240           "orngCN2.CN2SDUnorderedLearner": "Orange.classification.rules.CN2SDUnorderedLearner",
241#           "orngCN2.avg": "Orange.classification.rules.avg",
242#           "orngCN2.var": "Orange.classification.rules.var",
243#           "orngCN2.median": "Orange.classification.rules.median",
244#           "orngCN2.perc": "Orange.classification.rules.perc",
245           "orngCN2.createRandomDataSet": "Orange.classification.rules.createRandomDataSet",
246           "orngCN2.compParameters": "Orange.classification.rules.compParameters",
247           "orngCN2.computeDists": "Orange.classification.rules.computeDists",
248           "orngCN2.createEVDistList": "Orange.classification.rules.createEVDistList",
249           "orngCN2.CovererAndRemover_Prob": "Orange.classification.rules.CovererAndRemover_Prob",
250           "orngCN2.add_sub_rules": "Orange.classification.rules.add_sub_rules",
251           "orngCN2.CN2EVCUnorderedLearner": "Orange.classification.rules.CN2EVCUnorderedLearner",
252           
253           "orngMDS.KruskalStress": "Orange.projection.mds.KruskalStress",
254           "orngMDS.SammonStress": "Orange.projection.mds.SammonStress",
255           "orngMDS.SgnSammonStress": "Orange.projection.mds.SgnSammonStress",
256           "orngMDS.SgnRelStress": "Orange.projection.mds.SgnRelStress",
257           "orngMDS.PointList": "Orange.projection.mds.PointList",
258           "orngMDS.FloatListList": "Orange.projection.mds.FloatListList",
259           "orngMDS.PivotMDS": "Orange.projection.mds.PivotMDS",
260           "orngMDS.MDS": "Orange.projection.mds.MDS",
261           
262           "orngStat.AP" : "Orange.evaluation.scoring.AP",
263           "orngStat.AROC" : "Orange.evaluation.scoring.AROC",
264           "orngStat.AROCFromCDT" : "Orange.evaluation.scoring.AROCFromCDT",
265           "orngStat.AUC" : "Orange.evaluation.scoring.AUC",
266           "orngStat.AUCWilcoxon" : "Orange.evaluation.scoring.AUCWilcoxon",
267           "orngStat.AUC_binary" : "Orange.evaluation.scoring.AUC_binary",
268           "orngStat.AUC_i" : "Orange.evaluation.scoring.AUC_i",
269           "orngStat.AUC_ij" : "Orange.evaluation.scoring.AUC_ij",
270           "orngStat.AUC_iterations" : "Orange.evaluation.scoring.AUC_iterations",
271           "orngStat.AUC_matrix" : "Orange.evaluation.scoring.AUC_matrix",
272           "orngStat.AUC_multi" : "Orange.evaluation.scoring.AUC_multi",
273           "orngStat.AUC_pair" : "Orange.evaluation.scoring.AUC_pair",
274           "orngStat.AUC_single" : "Orange.evaluation.scoring.AUC_single",
275           "orngStat.AUC_x" : "Orange.evaluation.scoring.AUC_x",
276           "orngStat.BSS" : "Orange.evaluation.scoring.BSS",
277           "orngStat.BrierScore" : "Orange.evaluation.scoring.BrierScore",
278           "orngStat.CA" : "Orange.evaluation.scoring.CA",
279           "orngStat.CA_se" : "Orange.evaluation.scoring.CA_se",
280           "orngStat.CDT" : "Orange.evaluation.scoring.CDT",
281           "orngStat.ConfusionMatrix" : "Orange.evaluation.scoring.ConfusionMatrix",
282           "orngStat.F1" : "Orange.evaluation.scoring.F1",
283           "orngStat.Falpha" : "Orange.evaluation.scoring.Falpha",
284           "orngStat.Friedman" : "Orange.evaluation.scoring.Friedman",
285           "orngStat.IS" : "Orange.evaluation.scoring.IS",
286           "orngStat.IS_ex" : "Orange.evaluation.scoring.IS_ex",
287           "orngStat.MAE" : "Orange.evaluation.scoring.MAE",
288           "orngStat.MCC" : "Orange.evaluation.scoring.MCC",
289           "orngStat.ME" : "Orange.evaluation.scoring.ME",
290           "orngStat.MSE" : "Orange.evaluation.scoring.MSE",
291           "orngStat.MSE_old" : "Orange.evaluation.scoring.MSE_old",
292           "orngStat.McNemar" : "Orange.evaluation.scoring.McNemar",
293           "orngStat.McNemarOfTwo" : "Orange.evaluation.scoring.McNemarOfTwo",
294           "orngStat.NPV" : "Orange.evaluation.scoring.NPV",
295           "orngStat.PPV" : "Orange.evaluation.scoring.PPV",
296           "orngStat.R2" : "Orange.evaluation.scoring.R2",
297           "orngStat.RAE" : "Orange.evaluation.scoring.RAE",
298           "orngStat.RMSE" : "Orange.evaluation.scoring.RMSE",
299           "orngStat.RMSE_old" : "Orange.evaluation.scoring.RMSE_old",
300           "orngStat.ROCaddPoint" : "Orange.evaluation.scoring.ROCaddPoint",
301           "orngStat.ROCsFromCDT" : "Orange.evaluation.scoring.ROCsFromCDT",
302           "orngStat.ROCslope" : "Orange.evaluation.scoring.ROCslope",
303           "orngStat.RRSE" : "Orange.evaluation.scoring.RRSE",
304           "orngStat.RSE" : "Orange.evaluation.scoring.RSE",
305           "orngStat.TCbestThresholdsOnROCcurve" : "Orange.evaluation.scoring.TCbestThresholdsOnROCcurve",
306           "orngStat.TCcomputeROC" : "Orange.evaluation.scoring.TCcomputeROC",
307           "orngStat.TCthresholdlAverageROC" : "Orange.evaluation.scoring.TCthresholdlAverageROC",
308           "orngStat.TCverticalAverageROC" : "Orange.evaluation.scoring.TCverticalAverageROC",
309           "orngStat.Wilcoxon" : "Orange.evaluation.scoring.Wilcoxon",
310           "orngStat.WilcoxonPairs" : "Orange.evaluation.scoring.WilcoxonPairs",
311#           "orngStat.add" : "Orange.evaluation.scoring.add",
312#           "orngStat.checkArgkw" : "Orange.evaluation.scoring.checkArgkw",
313#           "orngStat.checkNonZero" : "Orange.evaluation.scoring.checkNonZero",
314           "orngStat.classProbabilitiesFromRes" : "Orange.evaluation.scoring.classProbabilitiesFromRes",
315           "orngStat.compare2AROCs" : "Orange.evaluation.scoring.compare2AROCs",
316           "orngStat.compare2AUCs" : "Orange.evaluation.scoring.compare2AUCs",
317           "orngStat.computeCDT" : "Orange.evaluation.scoring.computeCDT",
318           "orngStat.computeCalibrationCurve" : "Orange.evaluation.scoring.computeCalibrationCurve",
319           "orngStat.computeConfusionMatrices" : "Orange.evaluation.scoring.computeConfusionMatrices",
320           "orngStat.computeLiftCurve" : "Orange.evaluation.scoring.computeLiftCurve",
321           "orngStat.computeROC" : "Orange.evaluation.scoring.computeROC",
322           "orngStat.compute_CD" : "Orange.evaluation.scoring.compute_CD",
323           "orngStat.compute_friedman" : "Orange.evaluation.scoring.compute_friedman",
324           "orngStat.confusionChiSquare" : "Orange.evaluation.scoring.confusionChiSquare",
325           "orngStat.confusionMatrices" : "Orange.evaluation.scoring.confusionMatrices",
326           "orngStat.defaultLineTypes" : "Orange.evaluation.scoring.defaultLineTypes",
327           "orngStat.defaultPointTypes" : "Orange.evaluation.scoring.defaultPointTypes",
328#           "orngStat.frange" : "Orange.evaluation.scoring.frange",
329#           "orngStat.gettotsize" : "Orange.evaluation.scoring.gettotsize",
330#           "orngStat.gettotweight" : "Orange.evaluation.scoring.gettotweight",
331           "orngStat.graph_ranks" : "Orange.evaluation.scoring.graph_ranks",
332           "orngStat.isCDTEmpty" : "Orange.evaluation.scoring.isCDTEmpty",
333           "orngStat.learningCurve2PiCTeX" : "Orange.evaluation.scoring.learningCurve2PiCTeX",
334           "orngStat.learningCurveLearners2PiCTeX" : "Orange.evaluation.scoring.learningCurveLearners2PiCTeX",
335           "orngStat.legend2PiCTeX" : "Orange.evaluation.scoring.legend2PiCTeX",
336           "orngStat.legendLearners2PiCTeX" : "Orange.evaluation.scoring.legendLearners2PiCTeX",
337#           "orngStat.log2" : "Orange.evaluation.scoring.log2",
338#           "orngStat.math" : "Orange.evaluation.scoring.math",
339#           "orngStat.numpy" : "Orange.evaluation.scoring.numpy",
340#           "orngStat.operator" : "Orange.evaluation.scoring.operator",
341           "orngStat.plotLearningCurve" : "Orange.evaluation.scoring.plotLearningCurve",
342           "orngStat.plotLearningCurveLearners" : "Orange.evaluation.scoring.plotLearningCurveLearners",
343           "orngStat.plotMcNemarCurve" : "Orange.evaluation.scoring.plotMcNemarCurve",
344           "orngStat.plotMcNemarCurveLearners" : "Orange.evaluation.scoring.plotMcNemarCurveLearners",
345           "orngStat.plotROC" : "Orange.evaluation.scoring.plotROC",
346           "orngStat.plotROCLearners" : "Orange.evaluation.scoring.plotROCLearners",
347           "orngStat.precision" : "Orange.evaluation.scoring.precision",
348           "orngStat.printSingleROCCurveCoordinates" : "Orange.evaluation.scoring.printSingleROCCurveCoordinates",
349           "orngStat.rankDifference" : "Orange.evaluation.scoring.rankDifference",
350           "orngStat.recall" : "Orange.evaluation.scoring.recall",
351           "orngStat.regressionError" : "Orange.evaluation.scoring.regressionError",
352           "orngStat.scottsPi" : "Orange.evaluation.scoring.scottsPi",
353           "orngStat.sens" : "Orange.evaluation.scoring.sens",
354           "orngStat.spec" : "Orange.evaluation.scoring.spec",
355           "orngStat.splitByIterations" : "Orange.evaluation.scoring.splitByIterations",
356#           "orngStat.statc" : "Orange.evaluation.scoring.statc",
357           "orngStat.statisticsByFolds" : "Orange.evaluation.scoring.statisticsByFolds",
358#           "orngStat.x" : "Orange.evaluation.scoring.x",
359           
360           # Now use old orngMisc
361           # Orange.selection
362           #"orngMisc.BestOnTheFly":"Orange.misc.selection.BestOnTheFly",
363           #"orngMisc.selectBest":"Orange.misc.selection.selectBest",
364           #"orngMisc.selectBestIndex":"Orange.misc.selection.selectBestIndex",
365           #"orngMisc.compare2_firstBigger":"Orange.misc.selection.compareFirstBigger",
366           #"orngMisc.compare2_firstBigger":"Orange.misc.selection.compareFirstBigger",
367           #"orngMisc.compare2_firstSmaller":"Orange.misc.selection.compareFirstSmaller",
368           #"orngMisc.compare2_lastBigger":"Orange.misc.selection.compareLastBigger",
369           #"orngMisc.compare2_lastSmaller":"Orange.misc.selection.compareLastSmaller",
370           #"orngMisc.compare2_bigger":"Orange.misc.selection.compareBigger",
371           #"orngMisc.compare2_smaller":"Orange.misc.selection.compareSmaller",
372           
373           "orngEnsemble.BaggedLearner":"Orange.ensemble.bagging.BaggedLearner",
374           "orngEnsemble.BaggedClassifier":"Orange.ensemble.bagging.BaggedClassifier",
375           "orngEnsemble.BoostedLearner":"Orange.boosting.BoostedLearner",
376           "orngEnsemble.BoostedClassifier":"Orange.ensemble.boosting.BoostedClassifier",
377           "orngEnsemble.RandomForestClassifier":"Orange.ensemble.forest.RandomForestClassifier",
378           "orngEnsemble.RandomForestLearner":"Orange.ensemble.forest.RandomForestLearner",
379           "orngEnsemble.MeasureAttribute_randomForests":"Orange.ensemble.forest.ScoreFeature",
380           "orngEnsemble.SplitConstructor_AttributeSubset":"Orange.ensemble.forest.SplitConstructor_AttributeSubset",
381
382           "orngTest.proportionTest":"Orange.evaluation.testing.proportionTest",
383           "orngTest.leaveOneOut":"Orange.evaluation.testing.leaveOneOut",
384           "orngTest.crossValidation":"Orange.evaluation.testing.crossValidation",
385           "orngTest.testWithIndices":"Orange.evaluation.testing.testWithIndices",
386           "orngTest.learningCurve":"Orange.evaluation.testing.learningCurve",
387           "orngTest.learningCurveN":"Orange.evaluation.testing.learningCurveN",
388           "orngTest.learningCurveWithTestData":"Orange.evaluation.testing.learningCurveWithTestData",
389           "orngTest.learnAndTestOnTestData":"Orange.evaluation.testing.learnAndTestOnTestData",
390           "orngTest.learnAndTestOnLearnData":"Orange.evaluation.testing.learnAndTestOnLearnData",
391           "orngTest.testOnData":"Orange.evaluation.testing.testOnData",
392           "orngTest.TestedExample":"Orange.evaluation.testing.TestedExample",
393           "orngTest.ExperimentResults":"Orange.evaluation.testing.ExperimentResults",
394
395           "orngLR.printOUT":"Orange.classification.logreg.dump",
396           "orngLR.printOut":"Orange.classification.logreg.dump",
397           "orngLR.hasDiscreteValues":"Orange.classification.logreg.has_discrete_values",
398           "orngLR.LogRegLearner":"Orange.classification.logreg.LogRegLearner",
399           "orngLR.LogRegLearnerClass":"Orange.classification.logreg.LogRegLearner",
400           "orngLR.Univariate_LogRegLearner":"Orange.classification.logreg.UnivariateLogRegLearner",
401           "orngLR.Univariate_LogRegLearner_Class":"Orange.classification.logreg.UnivariateLogRegLearner",
402           "orngLR.Univariate_LogRegClassifier":"Orange.classification.logreg.UnivariateLogRegClassifier",
403           "orngLR.LogRegLearner_getPriors":"Orange.classification.logreg.LogRegLearnerGetPriors",
404           "orngLR.LogRegLearnerClass_getPriors":"Orange.classification.logreg.LogRegLearnerGetPriors",
405           "orngLR.LogRegLearnerClass_getPriors_OneTable":"Orange.classification.logreg.LogRegLearnerGetPriorsOneTable",
406           "orngLR.Pr":"Orange.classification.logreg.pr",
407           "orngLR.lh":"Orange.classification.logreg.lh",
408           "orngLR.diag":"Orange.classification.logreg.diag",
409           "orngLR.simpleFitter":"Orange.classification.logreg.SimpleFitter",
410           "orngLR.Pr_bx":"Orange.classification.logreg.pr_bx",
411           "orngLR.bayesianFitter":"Orange.classification.logreg.BayesianFitter",
412           "orngLR.StepWiseFSS":"Orange.classification.logreg.StepWiseFSS",
413           "orngLR.getLikelihood":"Orange.classification.logreg.get_likelihood",
414           "orngLR.StepWiseFSS_class":"Orange.classification.logreg.StepWiseFSS",
415           "orngLR.StepWiseFSS_Filter":"Orange.classification.logreg.StepWiseFSSFilter",
416           "orngLR.StepWiseFSS_Filter_class":"Orange.classification.logreg.StepWiseFSSFilter",
417           "orngLR.lchisqprob":"Orange.classification.logreg.lchisqprob",
418           "orngLR.zprob":"Orange.classification.logreg.zprob",
419           
420           "orange.Preprocessor": "Orange.preprocess.Preprocessor",
421           "orange.Preprocessor_addCensorWeight": "Orange.preprocess.Preprocessor_addCensorWeight",
422           "orange.Preprocessor_addClassNoise": "Orange.preprocess.Preprocessor_addClassNoise",
423           "orange.Preprocessor_addClassWeight": "Orange.preprocess.Preprocessor_addClassWeight",
424           "orange.Preprocessor_addGaussianClassNoise": "Orange.preprocess.Preprocessor_addGaussianClassNoise",
425           "orange.Preprocessor_addGaussianNoise": "Orange.preprocess.Preprocessor_addGaussianNoise",
426           "orange.Preprocessor_addMissing": "Orange.preprocess.Preprocessor_addMissing",
427           "orange.Preprocessor_addMissingClasses": "Orange.preprocess.Preprocessor_addMissingClasses",
428           "orange.Preprocessor_addNoise": "Orange.preprocess.Preprocessor_addNoise",
429           "orange.Preprocessor_discretize": "Orange.preprocess.Preprocessor_discretize",
430           "orange.Preprocessor_drop": "Orange.preprocess.Preprocessor_drop",
431           "orange.Preprocessor_dropMissing": "Orange.preprocess.Preprocessor_dropMissing",
432           "orange.Preprocessor_dropMissingClasses": "Orange.preprocess.Preprocessor_dropMissingClasses",
433           "orange.Preprocessor_filter": "Orange.preprocess.Preprocessor_filter",
434           "orange.Preprocessor_ignore": "Orange.preprocess.Preprocessor_ignore",
435           "orange.Preprocessor_imputeByLearner": "Orange.preprocess.Preprocessor_imputeByLearner",
436           "orange.Preprocessor_removeDuplicates": "Orange.preprocess.Preprocessor_removeDuplicates",
437           "orange.Preprocessor_select": "Orange.preprocess.Preprocessor_select",
438           "orange.Preprocessor_shuffle": "Orange.preprocess.Preprocessor_shuffle",
439           "orange.Preprocessor_take": "Orange.preprocess.Preprocessor_take",
440           "orange.Preprocessor_takeMissing": "Orange.preprocess.Preprocessor_takeMissing",
441           "orange.Preprocessor_takeMissingClasses": "Orange.preprocess.Preprocessor_takeMissingClasses",
442           
443           "orange.Discretizer": "Orange.feature.discretization.Discretizer",
444           "orange.BiModalDiscretizer": "Orange.feature.discretization.BiModalDiscretizer",
445           "orange.EquiDistDiscretizer": "Orange.feature.discretization.EquiDistDiscretizer",
446           "orange.IntervalDiscretizer": "Orange.feature.discretization.IntervalDiscretizer",
447           "orange.ThresholdDiscretizer": "Orange.feature.discretization.ThresholdDiscretizer",
448           "orange.EntropyDiscretization": "Orange.feature.discretization.EntropyDiscretization",
449           "orange.Discrete2Continuous": "Orange.feature.discretization.Discrete2Continuous",
450           
451           "orange.DomainContinuizer": "Orange.feature.continuization.DomainContinuizer",
452           
453           "orange.MakeRandomIndices": "Orange.data.sample.MakeRandomIndices",
454           "orange.MakeRandomIndicesN": "Orange.data.sample.MakeRandomIndicesN",
455           "orange.MakeRandomIndicesCV": "Orange.data.sample.MakeRandomIndicesCV",
456           "orange.MakeRandomIndicesMultiple": "Orange.data.sample.MakeRandomIndicesMultiple",
457           "orange.MakeRandomIndices2": "Orange.data.sample.MakeRandomIndices2",
458           
459           }
460
461   
462def build_pattern(mapping=MAPPING):
463    PATTERN = """
464    power< head=any+
465         trailer< '.' member=(%s) >
466         tail=any*
467    >
468    """ 
469    return PATTERN % "|".join("'%s'" % key.split(".")[-1] for key in mapping.keys())
470   
471class FixChangedNames(fixer_base.BaseFix):
472    mapping = MAPPING
473   
474    run_order = 1
475   
476    def compile_pattern(self):
477        self.PATTERN = build_pattern(self.mapping)
478        self._modules_to_change = [key.split(".", 1)[0] for key in self.mapping.keys()]
479        super(FixChangedNames, self).compile_pattern()
480       
481    def package_tree(self, package):
482        """ Return pytree tree for accessing the package
483       
484        Example:
485            >>> package_tree("Orange.feature.scoring")
486            [Name('Orange'), trailer('.' 'feature'), trailer('.', 'scoring')]
487        """
488        path = package.split('.')
489        nodes = []
490        nodes.append(Name(path[0]))
491        for name in path[1:]:
492            new = pytree.Node(self.syms.trailer, [Dot(), Name(name)])
493            nodes.append(new)
494        return nodes
495       
496       
497    def transform(self, node, results):
498        member = results.get("member")
499        head = results.get("head")
500        tail = results.get("tail")
501        module = head[0].value
502       
503        if member and module in self._modules_to_change:
504            node = member[0]
505            head = head[0]
506           
507            old_name = module + "." + node.value
508            if old_name not in self.mapping:
509                return
510             
511            new_name = unicode(self.mapping[module + "." + node.value])
512           
513            syms = self.syms
514           
515            if tail:
516                tail = [t.clone() for t in  tail]
517            new = self.package_tree(new_name)
518            new = pytree.Node(syms.power, new + tail, prefix=head.prefix)
519           
520            # Make sure the proper package is imported
521            package = new_name.rsplit(".", 1)[0]
522            touch_import(None, package, node)
523            return new   
524   
Note: See TracBrowser for help on using the repository browser.