private void AppendFeatureValueFromGridView( DataGridViewCell cell, C45FeatureSet featureSet) { if (cell.ColumnIndex < this.schema.Properties.Count) { String cellValue = String.Empty; if (cell.IsInEditMode) { cellValue = cell.EditedFormattedValue.ToString(); } else { cellValue = cell.FormattedValue.ToString(); } C45SchemaProperty col = (C45SchemaProperty)this.dataGridView.Columns[cell.ColumnIndex].Tag; if (cellValue == "?".ToString() || cellValue == "".ToString()) { featureSet.AddUnknownFeature(); } else { if (col.IsDiscrete) { // Just one attribute with 100 % probability supported, yet. // Multiple attribute has to be implemented in future. C45DiscreteFeature discreteFeature = new C45DiscreteFeature(); C45DiscreteFeatureAttribute discreteFeatureAttribute = new C45DiscreteFeatureAttribute(); discreteFeatureAttribute.AttributeName = (String)cellValue; discreteFeatureAttribute.Probability = 100; discreteFeature.Add(discreteFeatureAttribute); featureSet.AddDiscreteFeature(discreteFeature); } else { // Just a fix continous value or ignore-value supported, yet. // Lower and upper bound has to be implemented in future. C45ContinuousFeature continuousFeature = new C45ContinuousFeature(); continuousFeature.LowerBound = Convert.ToInt32(cellValue); continuousFeature.UpperBound = Convert.ToInt32(cellValue); featureSet.AddContinousFeature(continuousFeature); } } } }
internal static C45FeatureSet GetFSFromLine(String line, C45Schema schema) { C45FeatureSet featureSet = new C45FeatureSet(); int currentFeature = 0; String[] features = line.Split(",".ToCharArray()); for (int i = 0; i < features.Length; i++) { features[i] = features[i].Trim(); } foreach (C45SchemaProperty column in schema.Properties) { if (features[currentFeature] == "" || features[currentFeature] == "?") { featureSet.AddUnknownFeature(); } else { if (column.IsDiscrete) { C45DiscreteFeature discreteFeature = new C45DiscreteFeature(); C45DiscreteFeatureAttribute discreteFeatureAttribute = new C45DiscreteFeatureAttribute(); discreteFeatureAttribute.AttributeName = features[currentFeature]; discreteFeatureAttribute.Probability = 100; discreteFeature.Add(discreteFeatureAttribute); featureSet.AddDiscreteFeature(discreteFeature); } else { C45ContinuousFeature continuousFeature = new C45ContinuousFeature(); continuousFeature.LowerBound = Convert.ToInt32(features[currentFeature]); continuousFeature.UpperBound = Convert.ToInt32(features[currentFeature]); featureSet.AddContinousFeature(continuousFeature); } } currentFeature++; } featureSet.UserResult.ClassName = features[currentFeature]; return(featureSet); }