本文整理汇总了C#中Tree.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Select方法的具体用法?C# Tree.Select怎么用?C# Tree.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestData
public void TestData()
{
var trainingData = ReadTestData("../../../../Data/train_sensor.txt", "../../../../Data/train_category.txt");
var columnCount = 400;
var cellsPerColumn = 2;
var floatPrecision = 50;
var node = new Tree(
new [] { 32 },
32 * floatPrecision,
columnCount,
cellsPerColumn: cellsPerColumn,
desiredLocalActivity: 50,
minOverlap: 4,
maxSynapsesPerColumn: 20,
newSynapseCount: 4
);
var cl = new AlsingClassifier();
foreach (var frame in trainingData)
node.Feed(BitMapper.Map(frame.Columns, -0.6f, 2.21f, floatPrecision));
using (var log = new StreamWriter("../../../../Data/train_result.txt", false, Encoding.ASCII))
foreach (var frame in trainingData)
{
node.Feed(BitMapper.Map(frame.Columns, -0.6f, 2.21f, floatPrecision));
cl.Train(frame.Category.ToString(), node.ToArray());
log.WriteLine(node.Select(v => v ? '1' : '0').ToArray());
}
node.Learning = false;
var testData = ReadTestData("../../../../Data/test_sensor.txt", "../../../../Data/test_category.txt");
var acurate = 0;
var total = 0;
var accuracy = new Dictionary<string, Accuracy>();
using (var log = new StreamWriter("../../../../Data/test_result.txt", false, Encoding.ASCII))
foreach (var frame in testData)
{
var activeCount = 0;
Func<int, bool> input = BitMapper.Map(frame.Columns, -0.6f, 2.21f, floatPrecision);
node.Feed(input);
foreach (var b in node)
if (b)
activeCount++;
var matches = cl.FindMatches(node.ToArray())
.OrderByDescending(c => c.Strength)
.Take(2)
.ToArray();
log.WriteLine(node.Select(d => d ? '1' : '0').ToArray());
/*for (var i = 0; i < 32 * 50; i++)
Console.Write(input(i) ? "1" : "0");
Console.WriteLine();
Console.WriteLine(String.Join("", outputData.Select(v => v ? "1" : "0")));*/
var cat = frame.Category.ToString();
if (matches[0].Identifier == cat) acurate++;
total++;
Accuracy v;
if (!accuracy.TryGetValue(cat, out v))
accuracy.Add(cat, v = new Accuracy());
if (matches[0].Identifier == frame.Category.ToString()) v.acurate++;
v.total++;
Console.WriteLine("Expected: {0} Matched: {1} ({3:p}) Runner Up: {2} ({4:p}) Activity Count: {5}", frame.Category, matches[0].Identifier, matches[1].Identifier, matches[0].Strength, matches[1].Strength, activeCount);
}
Console.WriteLine("Accuracy: {0:p}", ((float)acurate) / ((float)total));
foreach (var pair in accuracy)
Console.WriteLine("Accuracy {1}: {0:p}", ((float)pair.Value.acurate) / ((float)pair.Value.total), pair.Key);
}
示例2: GetTreeModels
private IEnumerable<RepositoryTreeDetailModel> GetTreeModels(Tree tree, string referenceName)
{
return tree.Select(i => CreateRepositoryDetailModel(i, null, referenceName)).ToList();
}