Compute Generalized Majority \( (m^{\varepsilon},\cap) \\\)-Reducts with Exceptions
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
41
42
43
//load training and test data sets
var train = Data.Benchmark.Factory.Dna();
var test = Data.Benchmark.Factory.DnaTest();
//setup reduct factory parameters
Args parms = new Args();
parms.SetParameter(ReductFactoryOptions.DecisionTable, train);
parms.SetParameter(ReductFactoryOptions.ReductType,
ReductTypes.GeneralizedMajorityDecision);
parms.SetParameter(ReductFactoryOptions.WeightGenerator,
new WeightGeneratorMajority(train));
parms.SetParameter(ReductFactoryOptions.Epsilon, 0.05);
parms.SetParameter(ReductFactoryOptions.PermutationCollection,
new PermutationCollection(10,
train.SelectAttributeIds(a => a.IsStandard)
.ToArray()));
parms.SetParameter(ReductFactoryOptions.UseExceptionRules, true);
//generate reducts with exceptions
var reductGenerator = ReductFactory.GetReductGenerator(parms);
var reducts = reductGenerator.GetReducts();
foreach (var reduct in reducts) {
var r = reduct as ReductWithExceptions;
foreach (var exception in r.Exceptions) {
Console.WriteLine(exception.Attributes
.ToArray().ToStr());
Console.WriteLine(exception.SupportedObjects
.ToArray().ToStr());
}
}
var rules = new ReductDecisionRules(reducts);
rules.DecisionIdentificationMethod
= RuleQualityMethods.Confidence;
rules.RuleVotingMethod = RuleQualityMethods.SingleVote;
rules.Learn(train, null);
//classify test data set
var result = Classifier.Default.Classify(rules, test);
//show results
Console.WriteLine(result);
Written on June 28, 2017