【发布时间】:2014-07-10 19:29:36
【问题描述】:
我正在尝试在包含 58 个属性的 promoters data 上构建 ID3 算法。我怎样才能不初始化每个单个属性,而是使用循环(例如 for 或 foreach)来初始化所有属性?
基本上,我不想做下面的事情,而是想用一个循环来做,但我不能在卷发内使用一个循环
var splits = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var name = splits[1];
var data = splits[2].Trim();
string[] array = null;
for (int i = 0; i < data.Length; i++)
{
array[i]= data.ToCharArray().GetValue(i).ToString();
}
return new Instance
{
Output = new Output(splits[0], "Result"),
Features = new List<Feature>
{
new Feature(array[0], "1"),
new Feature(array[1], "2"),
new Feature(array[2], "3"),
new Feature(array[3], "4"),
//and so on for all atributes
}
};
【问题讨论】:
标签: c# algorithm decision-tree id3