本文整理汇总了C#中DataFrame.GetNumericRowVector方法的典型用法代码示例。如果您正苦于以下问题:C# DataFrame.GetNumericRowVector方法的具体用法?C# DataFrame.GetNumericRowVector怎么用?C# DataFrame.GetNumericRowVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFrame
的用法示例。
在下文中一共展示了DataFrame.GetNumericRowVector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_RegressionWith_SimpleKnnModel
public void Test_RegressionWith_SimpleKnnModel()
{
// Given
var randomizer = new Random(55);
var baseDataFrame = TestDataBuilder.BuildRandomAbstractNumericDataFrameWithRedundantAttrs(randomizer: randomizer);
var queryDataFrame = new DataFrame(new DataTable("some data")
{
Columns =
{
new DataColumn("F1", typeof(double)),
new DataColumn("F2", typeof(double)),
new DataColumn("F3", typeof(double)),
new DataColumn("F4", typeof(double)),
new DataColumn("F5", typeof(double))
},
Rows =
{
new object[] { 10, 1, 1, 4, 5 },
new object[] { 4, 2, 1, 9, 10},
new object[] { 2, 1, 1, 3, 7},
}
});
var expectedValues = Enumerable.Range(0, queryDataFrame.RowCount)
.Select(
rowIdx =>
TestDataBuilder.CalcualteLinearlyDependentFeatureValue(queryDataFrame.GetNumericRowVector(rowIdx))).ToList();
var modelBuilder = new SimpleKnnModelBuilder<double>();
var modelParams = new KnnAdditionalParams(4, true);
var weightingFunction = new GaussianFunction(0.3);
var predictor = new SimpleKnnRegressor(new EuclideanDistanceMeasure(), new MinMaxNormalizer(), weightingFunction.GetValue, normalizeNumericValues: true);
var errorMeasure = new MeanSquareError();
// When
var model = modelBuilder.BuildModel(baseDataFrame, "F6", modelParams);
var results = predictor.Predict(queryDataFrame, model, "F6");
// Then
var mse = errorMeasure.CalculateError(Vector<double>.Build.DenseOfEnumerable(expectedValues), Vector<double>.Build.DenseOfEnumerable(results));
Assert.IsTrue(mse < 0.55);
}