本文整理汇总了C#中DataFrame.GetSubsetByRows方法的典型用法代码示例。如果您正苦于以下问题:C# DataFrame.GetSubsetByRows方法的具体用法?C# DataFrame.GetSubsetByRows怎么用?C# DataFrame.GetSubsetByRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFrame
的用法示例。
在下文中一共展示了DataFrame.GetSubsetByRows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInformationGainCalculator_WithGroupsCountsOnly
public void TestInformationGainCalculator_WithGroupsCountsOnly()
{
// Given
var initialDataTable = new DataFrame(
new DataTable()
{
Columns = { new DataColumn("Col1", typeof(string)) },
Rows =
{
new object[] { "A" },
new object[] { "A" },
new object[] { "A" },
new object[] { "B" },
new object[] { "B" },
}
});
var group1 = initialDataTable.GetSubsetByRows(new[] { 0, 1, 3 });
var splittedDataGroup1 = new SplittedData(null, group1);
var group1UniqueValuesCount =
group1.GetColumnVector("Col1")
.Values.GroupBy(val => val, val => val)
.Select(grp => grp.Count())
.ToList();
var group2 = initialDataTable.GetSubsetByRows(new[] { 2, 4 });
var splittedDataGroup2 = new SplittedData(null, group2);
var group2UniqueValuesCount =
group2.GetColumnVector("Col1")
.Values.GroupBy(val => val, val => val)
.Select(grp => grp.Count())
.ToList();
var groupsCounts = new List<IList<int>> { group1UniqueValuesCount, group2UniqueValuesCount };
// When
var entropyFromGroups = informationGainCalculator.CalculateSplitQuality(
1.0,
5,
new List<ISplittedData> { splittedDataGroup1, splittedDataGroup2 },
"Col1");
var entropyFromGroupCounts = informationGainCalculator.CalculateSplitQuality(1.0, 5, groupsCounts);
// Then
Assert.AreEqual(entropyFromGroupCounts, entropyFromGroups);
}