本文整理汇总了C#中VowpalWabbit.EndOfPass方法的典型用法代码示例。如果您正苦于以下问题:C# VowpalWabbit.EndOfPass方法的具体用法?C# VowpalWabbit.EndOfPass怎么用?C# VowpalWabbit.EndOfPass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VowpalWabbit
的用法示例。
在下文中一共展示了VowpalWabbit.EndOfPass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteTest
public static void ExecuteTest(int testCaseNr, string args, string input, string stderr, string predictFile)
{
using (var vw = new VowpalWabbit(args))
{
var multiline = IsMultilineData(input);
using (var streamReader = Open(input))
{
if (multiline)
{
var lines = new List<string>();
string dataLine;
while ((dataLine = streamReader.ReadLine()) != null)
{
if (string.IsNullOrWhiteSpace(dataLine))
{
if (lines.Count > 0)
{
if (args.Contains("-t")) // test only
vw.Predict(lines);
else
vw.Learn(lines);
}
lines.Clear();
continue;
}
lines.Add(dataLine);
}
}
else
{
string dataLine;
while ((dataLine = streamReader.ReadLine()) != null)
{
if (!string.IsNullOrWhiteSpace(predictFile) && File.Exists(predictFile))
{
float actualValue;
if (args.Contains("-t")) // test only
actualValue = vw.Predict(dataLine, VowpalWabbitPredictionType.Scalar);
else
actualValue = vw.Learn(dataLine, VowpalWabbitPredictionType.Scalar);
}
else
vw.Learn(dataLine);
}
}
if (vw.Arguments.NumPasses > 1)
vw.RunMultiPass();
else
vw.EndOfPass();
if (!string.IsNullOrWhiteSpace(stderr) && File.Exists(stderr))
VWTestHelper.AssertEqual(stderr, vw.PerformanceStatistics);
}
}
}
示例2: Ingest
private static void Ingest(VowpalWabbit vw, IEnumerable<List<string>> blocks)
{
foreach (var block in blocks)
{
vw.Learn(block);
}
vw.EndOfPass();
}
示例3: ExecuteTest
public static void ExecuteTest(int testCaseNr, string args, string input, string stderr, string predictFile)
{
using (var vw = new VowpalWabbit(args))
{
var multiline = IsMultilineData(input);
using (var streamReader = Open(input))
{
if (multiline)
{
var lines = new List<string>();
string dataLine;
while ((dataLine = streamReader.ReadLine()) != null)
{
if (string.IsNullOrWhiteSpace(dataLine))
{
if (lines.Count > 0)
{
if (args.Contains("-t")) // test only
vw.Predict(lines);
else
vw.Learn(lines);
}
lines.Clear();
continue;
}
lines.Add(dataLine);
}
}
else
{
int lineNr = 0;
string[] predictions = null;
if (File.Exists(predictFile))
predictions = File.ReadAllLines(predictFile);
string dataLine;
while ((dataLine = streamReader.ReadLine()) != null)
{
if (!string.IsNullOrWhiteSpace(predictFile) && File.Exists(predictFile))
{
object actualValue;
if (args.Contains("-t")) // test only
actualValue = vw.Predict(dataLine, VowpalWabbitPredictionType.Dynamic);
else
actualValue = vw.Learn(dataLine, VowpalWabbitPredictionType.Dynamic);
if (predictions != null)
{
// validate predictions
var actualFloat = actualValue as float?;
if (actualFloat != null)
{
var expectedPrediction = float.Parse(predictions[lineNr].Split(' ').First(), CultureInfo.InvariantCulture);
VWTestHelper.FuzzyEqual(expectedPrediction, (float)actualFloat, 1e-4, "Prediction mismatch");
}
var actualScalar = actualValue as VowpalWabbitScalar?;
if (actualScalar != null)
{
var expectedPredictions = predictions[lineNr]
.Split(' ')
.Select(field => float.Parse(field, CultureInfo.InvariantCulture))
.ToArray();
Assert.AreEqual(2, expectedPredictions.Length);
VWTestHelper.FuzzyEqual(expectedPredictions[0], actualScalar.Value.Value, 1e-4, "Prediction value mismatch");
VWTestHelper.FuzzyEqual(expectedPredictions[1], actualScalar.Value.Confidence, 1e-4, "Prediction confidence mismatch");
}
}
}
else
vw.Learn(dataLine);
lineNr++;
}
}
if (vw.Arguments.NumPasses > 1)
vw.RunMultiPass();
else
vw.EndOfPass();
if (!string.IsNullOrWhiteSpace(stderr) && File.Exists(stderr))
VWTestHelper.AssertEqual(stderr, vw.PerformanceStatistics);
}
}
}