public Data(DataTable dataSet) { this.OriginalDataSet = dataSet; this.DataSet = ConvertNumericData(dataSet.Copy()); this.Decisions = FindDecisions(); AttributeValuePairs = AttributeValuePair.GetAttributeValuePairs(DataSet); Characteristic = new Characteristic(this); MaximalConsistent = new MaximalConsistent(this); ConditionalProbability = ProbApprox.GetConditionalProbability(this); }
static void Main(string[] args) { //var dataTable = FileOperation.ReadDataFile(@"C:\Users\kumar\OneDrive\Documents\Projects\CharMax\CharMax\Datasets\breast-35.d"); var files = Directory.GetFiles(ConfigurationManager.AppSettings["DataSetFolder"], "*.d", SearchOption.TopDirectoryOnly); ConcurrentBag <Rules> AllRules = new ConcurrentBag <Rules>(); List <List <int> > temp = new List <List <int> >(); temp.Add(new List <int> { 1, 2, 3, 4 }); temp.Add(new List <int> { 3, 4 }); temp.Add(new List <int> { 4, 3, 3, 4 }); var t = temp.IntersectAll().ToList(); //Parallel.ForEach(files, file => //{ // var dataTable = FileOperation.ReadDataFile(file); // Data data = new Data(dataTable); // var alphaValue = 0.0f; // Parallel.For(0, 12, alpha => // { // alphaValue = (float)Math.Round(alphaValue + 0.10f, 1); // RuleInduction ruleInductionCharacteristic = new RuleInduction(); // RuleInduction ruleInductionMCB = new RuleInduction(); // var charTask = Task.Factory.StartNew(() => // { // var charApprox = ProbApprox.GetConceptApprox(data.Characteristic, data.ConditionalProbability.CharacteristicCondProb, alphaValue); // return ruleInductionCharacteristic.ComputeRules(data, data.AttributeValuePairs, charApprox); // }); // var mcBTask = Task.Factory.StartNew(() => // { // var mcbApprox = ProbApprox.GetConceptApprox(data.MaximalConsistent, data.ConditionalProbability.MaximalCondProb, alphaValue); // return ruleInductionMCB.ComputeRules(data, data.AttributeValuePairs, mcbApprox); // }); // Task.WaitAll(charTask, mcBTask); // var charRule = charTask.Result; // var mcbRule = mcBTask.Result; // Rules rules = new Rules(Path.GetFileNameWithoutExtension(file), alphaValue, charRule, mcbRule); // AllRules.Add(rules); // }); //for (float alphaValue = 0.0f; alphaValue <= 1.0f; alphaValue = (float)Math.Round(alphaValue + 0.10f, 1)) //{ // //RuleInduction ruleInductionCharacteristic = new RuleInduction(); // //RuleInduction ruleInductionMCB = new RuleInduction(); // //var charTask = Task.Factory.StartNew(() => // //{ // // var charApprox = ProbApprox.GetConceptApprox(data.Characteristic, data.ConditionalProbability.CharacteristicCondProb, alphaValue); // // return ruleInductionCharacteristic.ComputeRules(data, data.AttributeValuePairs, charApprox); // //}); // //var mcBTask = Task.Factory.StartNew(() => // //{ // // var mcbApprox = ProbApprox.GetConceptApprox(data.MaximalConsistent, data.ConditionalProbability.MaximalCondProb, alphaValue); // // return ruleInductionMCB.ComputeRules(data, data.AttributeValuePairs, mcbApprox); // //}); // //Task.WaitAll(charTask, mcBTask); // //var charRule = charTask.Result; // //var mcbRule = mcBTask.Result; // //Rules rules = new Rules(Path.GetFileNameWithoutExtension(file), alphaValue, charRule, mcbRule); // //AllRules.Add(rules); //} //}); foreach (var file in files) { var dataTable = FileOperation.ReadDataFile(file); Data data = new Data(dataTable); //var alphaValue = 0.0f; for (float alphaValue = 0.01f; alphaValue <= 1.0f; alphaValue = (float)Math.Round(alphaValue + 0.10f, 1)) { RuleInduction ruleInductionCharacteristic = new RuleInduction(); RuleInduction ruleInductionMCB = new RuleInduction(); var charTask = Task.Factory.StartNew(() => { var charApprox = ProbApprox.GetConceptApprox(data.Characteristic, data.ConditionalProbability.CharacteristicCondProb, alphaValue); return(ruleInductionCharacteristic.ComputeRules(data, data.AttributeValuePairs, charApprox)); }); var mcBTask = Task.Factory.StartNew(() => { var mcbApprox = ProbApprox.GetConceptApprox(data.MaximalConsistent, data.ConditionalProbability.MaximalCondProb, alphaValue); return(ruleInductionMCB.ComputeRules(data, data.AttributeValuePairs, mcbApprox)); }); //Task.WaitAll(charTask, mcBTask); var charRule = charTask.Result; var mcbRule = mcBTask.Result; //var charApprox = ProbApprox.GetConceptApprox(data.Characteristic, data.ConditionalProbability.CharacteristicCondProb, alphaValue); //var r = ruleInductionCharacteristic.ComputeRules(data, data.AttributeValuePairs, charApprox); //var mcbApprox = ProbApprox.GetConceptApprox(data.MaximalConsistent, data.ConditionalProbability.MaximalCondProb, alphaValue); //var r1 = ruleInductionMCB.ComputeRules(data, data.AttributeValuePairs, mcbApprox); Rules rules = new Rules(Path.GetFileNameWithoutExtension(file), alphaValue, charRule, mcbRule); //Rules rules = new Rules(Path.GetFileNameWithoutExtension(file), alphaValue, r, r1); AllRules.Add(rules); } } RuleStat ruleStat = new RuleStat(); ruleStat.SaveRuleStat(AllRules.ToList()); //Console.WriteLine("Rules - Characteristic Set"); //PrintRules(charRule); //Console.WriteLine("\n\n\n End of Characteristic Rules \n \n"); //Console.WriteLine("Rules - MCB"); //PrintRules(mcbRule); }