Generate \( (\omega,\varepsilon) \\\)-Reducts Over Universe of Weighted Objects
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//load benchmark data
var data = Data.Benchmark.Factory.Zoo();
//set object weights using r(u) weighting scheme
data.SetWeights(new WeightGeneratorRelative(data).Weights);
//split data into training and testing sets
DecisionTable train, test;
var splitter = new DataSplitterRatio(data, 0.8);
splitter.Split(out train, out test);
//set parameters for reduct factory
var parm = new Args();
parm.SetParameter(ReductFactoryOptions.DecisionTable, train);
parm.SetParameter(ReductFactoryOptions.ReductType,
ReductTypes.ApproximateDecisionReduct);
parm.SetParameter(ReductFactoryOptions.FMeasure,
(FMeasure)FMeasures.MajorityWeighted);
parm.SetParameter(ReductFactoryOptions.Epsilon, 0.05);
//compute reducts
var reductGenerator = ReductFactory.GetReductGenerator(parm);
var reducts = reductGenerator.GetReducts();
//select 10 reducts with least number of attributes
var bestReduct = reducts.OrderBy(r => r.Attributes.Count).Take(10);
//create decision rules based on reducts
var decisionRules = new ReductDecisionRules(bestReducts);
//when test instance is not recognized
//set output as unclassified
decisionRules.DefaultOutput = null;
//classify test data
var result = Classifier.DefaultClassifer.Classify(
decisionRules, test);
//output accuracy and coverage
Console.WriteLine("Accuracy: {0}", result.Accuracy);
Written on June 28, 2017