public void calc_gain() { setLengthOfDS(); setNumberofFeatures(); calc_feature_list(); calc_unique_feature_values(); calcclassCounts(); calc_class_list(); setMajorityClass(); getPureClass(); calc_entropy(); if (Len_dataset > 0) { if (Info_gain_features_map == null) { Info_gain_features_map = new Dictionary <string, double>(); } foreach (string feature_name in Features_list) { if (Featurestoexclude == null) { Featurestoexclude = new List <string>(); } if (!Featurestoexclude.Contains(feature_name) && feature_name != (Number_of_features - 1).ToString()) { Info_gain_features_map[feature_name] = set_gains(feature_name); } } } }//info gain <-- dont consider max if it is in the excluded features list
public void removeFeatures(List <string> features_to_remove) { if (Featurestoexclude == null) { Featurestoexclude = new List <string>(); } if (features_to_remove != null) { foreach (string fe in features_to_remove) { if (!Featurestoexclude.Contains(fe)) { Featurestoexclude.Add(fe); } } } }
public void calc_unique_feature_values() { if (Len_dataset > 0) { foreach (string feat in Features_list) { List <string> u_list = new List <string>(); bool goAhead = false; if (Featurestoexclude == null) { goAhead = true; } else if (!Featurestoexclude.Contains(feat)) { goAhead = true; } if (goAhead) { foreach (DataRow datarow in Dataset.Rows) { string val = Convert.ToString(datarow.ItemArray[int.Parse(feat)]); if (!u_list.Contains(val)) { u_list.Add(val); } } } if (Feature_uniqueValues == null) { Feature_uniqueValues = new Dictionary <string, List <string> >(); } Feature_uniqueValues[feat] = u_list; } } }