• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# cs_unittest.VowpalWabbitExampleValidator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中cs_unittest.VowpalWabbitExampleValidator的典型用法代码示例。如果您正苦于以下问题:C# VowpalWabbitExampleValidator类的具体用法?C# VowpalWabbitExampleValidator怎么用?C# VowpalWabbitExampleValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VowpalWabbitExampleValidator类属于cs_unittest命名空间,在下文中一共展示了VowpalWabbitExampleValidator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestNumericUInt64OverflowArray

 public void TestNumericUInt64OverflowArray()
 {
     using (var vw = new VowpalWabbitExampleValidator<NumericExampleUInt64Array>(string.Empty))
     {
         vw.Validate("| 0:1.844674E+19", new NumericExampleUInt64Array() { Value = new[] { UInt64.MaxValue } });
     }
 }
开发者ID:XkhldY,项目名称:vowpal_wabbit,代码行数:7,代码来源:TestMarshallingOverflow.cs


示例2: TestJsonDirect

        public void TestJsonDirect()
        {
            using (var vw = new VowpalWabbitExampleValidator<JsonContext>(new VowpalWabbitSettings(featureDiscovery:VowpalWabbitFeatureDiscovery.Json)))
            {
                vw.Validate("| Clicks:5 |a Bar:1 Age25_old |b Marker", new JsonContext()
                {
                    Ns1 = new Namespace1
                    {
                        Foo = 1,
                        Age = "25 old",
                        DontConsider = "XXX"
                    },
                    Ns2 = new Namespace2
                    {
                        FeatureA = true
                    },
                    Clicks = 5
                });

                vw.Validate("| Clicks:5 |a Bar:1", new JsonContext() {
                    Ns1 = new Namespace1
                    {
                        Foo = 1,
                        DontConsider = "XXX"
                    },
                    Clicks = 5,
                    IgnoreMe = "true"
                });
            }
        }
开发者ID:jconwell,项目名称:vowpal_wabbit,代码行数:30,代码来源:TestJsonDirect.cs


示例3: TestNumericUInt64Overflow

 public void TestNumericUInt64Overflow()
 {
     using (var vw = new VowpalWabbitExampleValidator<NumericExampleUInt64>(string.Empty))
     {
         vw.Validate("| Value:1.844674E+19", new NumericExampleUInt64() { Value = UInt64.MaxValue});
     }
 }
开发者ID:XkhldY,项目名称:vowpal_wabbit,代码行数:7,代码来源:TestMarshallingOverflow.cs


示例4: Test87

        public void Test87()
        {
            using (var vw = new VowpalWabbit<DataString, DataStringADF>("--cb_adf --rank_all"))
            using (var vwSharedValidation = new VowpalWabbitExampleValidator<DataString>("--cb_adf --rank_all"))
            using (var vwADFValidation = new VowpalWabbitExampleValidator<DataStringADF>("--cb_adf --rank_all"))
            {
                var sampleData = CreateSampleCbAdfData();

                var example = sampleData[0];
                Validate(vwSharedValidation, vwADFValidation, example);

                var result = vw.LearnAndPredict(example, example.ActionDependentFeatures, example.SelectedActionIndex, example.Label);
                ReferenceEquals(example.ActionDependentFeatures[0], result[0]);
                ReferenceEquals(example.ActionDependentFeatures[1], result[1]);
                ReferenceEquals(example.ActionDependentFeatures[2], result[2]);

                example = sampleData[1];
                Validate(vwSharedValidation, vwADFValidation, example);

                result = vw.LearnAndPredict(example, example.ActionDependentFeatures, example.SelectedActionIndex, example.Label);
                ReferenceEquals(example.ActionDependentFeatures[0], result[1]);
                ReferenceEquals(example.ActionDependentFeatures[1], result[0]);

                example = sampleData[2];
                Validate(vwSharedValidation, vwADFValidation, example);

                result = vw.Predict(example, example.ActionDependentFeatures);

                ReferenceEquals(example.ActionDependentFeatures[0], result[1]);
                ReferenceEquals(example.ActionDependentFeatures[1], result[0]);
            }
        }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:32,代码来源:TestCbAdf.cs


示例5: TestStringSplit

 public void TestStringSplit()
 {
     using (var vw = new VowpalWabbitExampleValidator<ExampleStringSplit>(string.Empty))
     {
         vw.Validate("| New York State", new ExampleStringSplit() { Value = "New York State" });
     }
 }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:7,代码来源:TestMarshalling.cs


示例6: TestExpansion

 public void TestExpansion()
 {
     using (var vw = new VowpalWabbitExampleValidator<ExpansionContext>(string.Empty))
     {
         vw.Validate("| 3:.1 4:.2 5:.3", new ExpansionContext() { Features = new[] { .1f, .2f, .3f }, Offset = 3 });
     }
 }
开发者ID:lazy-developer,项目名称:vowpal_wabbit,代码行数:7,代码来源:TestExpansion.cs


示例7: TestStringFeatureGroup

 public void TestStringFeatureGroup()
 {
     using (var vw = new VowpalWabbitExampleValidator<ExampleString2>(string.Empty))
     {
         vw.Validate("|a London", new ExampleString2() { Location = "London" });
     }
 }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:7,代码来源:TestMarshalling.cs


示例8: TestStringEscape

 public void TestStringEscape()
 {
     using (var vw = new VowpalWabbitExampleValidator<ExampleStringEscape>(string.Empty))
     {
         vw.Validate("| New_York_State", new ExampleStringEscape() { Value = "New York State" });
         vw.Validate("| new_York_state", new ExampleStringEscape() { Value = "new York state" });
     }
 }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:8,代码来源:TestMarshalling.cs


示例9: TestNumericInt64OverflowArray

 public void TestNumericInt64OverflowArray()
 {
     using (var vw = new VowpalWabbitExampleValidator<NumericExampleInt64Array>(string.Empty))
     {
         vw.Validate("| 0:9.22337203685477580700E+018", new NumericExampleInt64Array() { Value = new [] { Int64.MaxValue } });
         vw.Validate("| 0:-9.22337203685477580700E+018", new NumericExampleInt64Array() { Value = new[] { Int64.MinValue } });
     }
 }
开发者ID:XkhldY,项目名称:vowpal_wabbit,代码行数:8,代码来源:TestMarshallingOverflow.cs


示例10: TestNumericDoubleOverflowArray

 public void TestNumericDoubleOverflowArray()
 {
     using (var vw = new VowpalWabbitExampleValidator<NumericExampleDoubleArray>(string.Empty))
     {
         vw.Validate("| 0:1.79769313486231570000E+308", new NumericExampleDoubleArray() { Value = new [] { double.MaxValue } });
         vw.Validate("| 0:-1.79769313486231570000E+308", new NumericExampleDoubleArray() { Value = new [] {  double.MinValue } });
     }
 }
开发者ID:XkhldY,项目名称:vowpal_wabbit,代码行数:8,代码来源:TestMarshallingOverflow.cs


示例11: Validate

 private void Validate(VowpalWabbitExampleValidator<DataString> vwSharedValidation, VowpalWabbitExampleValidator<DataStringADF> vwADFValidation, DataString example)
 {
     vwSharedValidation.Validate(example.Line, example, SharedLabel.Instance);
     for (int i = 0; i < example.ActionDependentFeatures.Count; i++)
     {
         var adf = example.ActionDependentFeatures[i];
         vwADFValidation.Validate(adf.Line, adf, i == example.SelectedActionIndex ? example.Label : null);
     }
 }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:9,代码来源:TestCbAdf.cs


示例12: TestString

 public void TestString()
 {
     using (var vw = new VowpalWabbitExampleValidator<ExampleString>(string.Empty))
     {
         vw.Validate("|abc London", new ExampleString() { Location = "London" });
         vw.Validate("", new ExampleString() { });
         vw.Validate("", new ExampleString() { Location = "" });
     }
 }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:9,代码来源:TestMarshalling.cs


示例13: TestEnumerize

 public void TestEnumerize()
 {
     using(var vw = new VowpalWabbitExampleValidator<ExampleEnum>(string.Empty))
     {
         vw.Validate("| AgeEnumerize25", new ExampleEnum() { AgeEnumerize = 25 });
         vw.Validate("| AgeEnumerize0 AgeNumeric:25", new ExampleEnum() { AgeNumeric = 25 });
         vw.Validate("| AgeEnumerize0 AgeNumeric:23 AgeEnumChild", new ExampleEnum() { AgeNumeric = 23, AgeEnum = Age.Child });
     }
 }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:9,代码来源:TestMarshalling.cs


示例14: TestJsonDirectWithLabel

 public void TestJsonDirectWithLabel()
 {
     using (var vw = new VowpalWabbitExampleValidator<JsonContext>(new VowpalWabbitSettings(featureDiscovery: VowpalWabbitFeatureDiscovery.Json)))
     {
         vw.Validate("13 | Clicks:5 MoreClicks:3", new JsonContext()
         {
             Label = new SimpleLabel { Label = 13 },
             Clicks = 5,
             MoreClicks = 3,
             IgnoreMe2 = "YYY"
         });
     }
 }
开发者ID:jconwell,项目名称:vowpal_wabbit,代码行数:13,代码来源:TestJsonDirect.cs


示例15: TestJsonOptIn

 public void TestJsonOptIn()
 {
     using (var vw = new VowpalWabbitExampleValidator<JsonContextOptIn>(new VowpalWabbitSettings(featureDiscovery: VowpalWabbitFeatureDiscovery.Json)))
     {
         vw.Validate("| Clicked |Ns2 Marker", new JsonContextOptIn()
         {
             Clicked = true,
             IgnoredNamespace = new Namespace1 {  Foo = 3 },
             Ns2 = new Namespace2
             {
                 FeatureA = true
             }
         });
     }
 }
开发者ID:jconwell,项目名称:vowpal_wabbit,代码行数:15,代码来源:TestJsonDirect.cs


示例16: TestStringNamespace

        public void TestStringNamespace()
        {
            try
            {
                using (var vw = new VowpalWabbitExampleValidator<ExampleString3>(string.Empty))
                {
                    vw.Validate("|bc London", new ExampleString3() { Location = "London" });
                }

                Assert.Fail("Expected ArgumentException");
            }
            catch (ArgumentException)
            {
            }
        }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:15,代码来源:TestMarshalling.cs


示例17: TestLabels

        public void TestLabels()
        {
            using (var vw = new VowpalWabbitExampleValidator<SimpleContext>(string.Empty))
            {
                vw.Validate("3.2 | Feature:25",
                    new SimpleContext
                    {
                        Feature = 25,
                        Label = new SimpleLabel { Label = 3.2f }
                    });

                vw.Validate("| Feature:25",
                    new SimpleContext
                    {
                        Feature = 25,
                    });
            }
        }
开发者ID:NativoPlatform,项目名称:vowpal_wabbit,代码行数:18,代码来源:TestLabels.cs


示例18: Test1and2

        public void Test1and2()
        {
            var references = File.ReadAllLines(@"pred-sets\ref\0001.predict").Select(l => float.Parse(l, CultureInfo.InvariantCulture)).ToArray();

            var input = new List<Test1>();

            using (var vwStr = new VowpalWabbit(" -k -c test1and2.str --passes 8 -l 20 --power_t 1 --initial_t 128000  --ngram 3 --skips 1 --invariant --holdout_off"))
            using (var vw = new VowpalWabbit<Test1>(new VowpalWabbitSettings(" -k -c test1and2 --passes 8 -l 20 --power_t 1 --initial_t 128000  --ngram 3 --skips 1 --invariant --holdout_off")
                { EnableExampleCaching = false }))
            using (var vwValidate = new VowpalWabbitExampleValidator<Test1>("-l 20 --power_t 1 --initial_t 128000  --ngram 3 --skips 1 --invariant --holdout_off"))
            {
                var lineNr = 0;
                VWTestHelper.ParseInput(
                    File.OpenRead(@"train-sets\0001.dat"),
                    new MyListener(data =>
                    {
                        input.Add(data);

                        vwValidate.Validate(data.Line, data, data.Label);

                        var expected = vwStr.Learn(data.Line, VowpalWabbitPredictionType.Dynamic);
                        Assert.IsInstanceOfType(expected, typeof(float));
                        var actual = vw.Learn(data, data.Label, VowpalWabbitPredictionType.Scalar);

                        Assert.AreEqual((float)expected, actual, 1e-6, "Learn output differs on line: " + lineNr);

                        lineNr++;
                    }));

                vwStr.RunMultiPass();
                vw.Native.RunMultiPass();

                vwStr.SaveModel("models/str0001.model");
                vw.Native.SaveModel("models/0001.model");

                VWTestHelper.AssertEqual(@"train-sets\ref\0001.stderr", vwStr.PerformanceStatistics);
                VWTestHelper.AssertEqual(@"train-sets\ref\0001.stderr", vw.Native.PerformanceStatistics);
            }

            Assert.AreEqual(input.Count, references.Length);

            using (var vwModel = new VowpalWabbitModel(new VowpalWabbitSettings("-k -t --invariant") { ModelStream = File.OpenRead("models/0001.model") }))
            using (var vwInMemoryShared1 = new VowpalWabbit(new VowpalWabbitSettings { Model = vwModel }))
            using (var vwInMemoryShared2 = new VowpalWabbit<Test1>(new VowpalWabbitSettings { Model = vwModel }))
            using (var vwInMemory = new VowpalWabbit(new VowpalWabbitSettings("-k -t --invariant") { ModelStream = File.OpenRead("models/0001.model") }))
            using (var vwStr = new VowpalWabbit("-k -t -i models/str0001.model --invariant"))
            using (var vwNative = new VowpalWabbit("-k -t -i models/0001.model --invariant"))
            using (var vw = new VowpalWabbit<Test1>("-k -t -i models/0001.model --invariant"))
            using (var vwModel2 = new VowpalWabbitModel("-k -t --invariant -i models/0001.model"))
            using (var vwInMemoryShared3 = new VowpalWabbit<Test1>(new VowpalWabbitSettings { Model = vwModel2 }))
            {
                for (var i = 0; i < input.Count; i++)
                {
                    var actualStr = vwStr.Predict(input[i].Line, VowpalWabbitPredictionType.Scalar);
                    var actualNative = vwNative.Predict(input[i].Line, VowpalWabbitPredictionType.Scalar);
                    var actualInMemory = vwInMemory.Predict(input[i].Line, VowpalWabbitPredictionType.Scalar);

                    var actual = vw.Predict(input[i], VowpalWabbitPredictionType.Scalar, input[i].Label);
                    var actualShared1 = vwInMemoryShared1.Predict(input[i].Line, VowpalWabbitPredictionType.Scalar);
                    var actualShared2 = vwInMemoryShared2.Predict(input[i], VowpalWabbitPredictionType.Scalar, input[i].Label);
                    var actualShared3 = vwInMemoryShared3.Predict(input[i], VowpalWabbitPredictionType.Scalar, input[i].Label);

                    Assert.AreEqual(references[i], actualStr, 1e-5);
                    Assert.AreEqual(references[i], actualNative, 1e-5);
                    Assert.AreEqual(references[i], actualInMemory, 1e-5);
                    Assert.AreEqual(references[i], actual, 1e-5);
                    Assert.AreEqual(references[i], actualShared1, 1e-5);
                    Assert.AreEqual(references[i], actualShared2, 1e-5);
                    Assert.AreEqual(references[i], actualShared3, 1e-5);
                }

                // due to shared usage the counters don't match up
                //VWTestHelper.AssertEqual(@"test-sets\ref\0001.stderr", vwInMemoryShared2.Native.PerformanceStatistics);
                //VWTestHelper.AssertEqual(@"test-sets\ref\0001.stderr", vwInMemoryShared1.PerformanceStatistics);

                VWTestHelper.AssertEqual(@"test-sets\ref\0001.stderr", vwInMemory.PerformanceStatistics);
                VWTestHelper.AssertEqual(@"test-sets\ref\0001.stderr", vwStr.PerformanceStatistics);
                VWTestHelper.AssertEqual(@"test-sets\ref\0001.stderr", vw.Native.PerformanceStatistics);
            }
        }
开发者ID:gramhagen,项目名称:vowpal_wabbit,代码行数:80,代码来源:Test1and2.cs


示例19: TestLabelsNoAnnotation

        public void TestLabelsNoAnnotation()
        {
            using (var vw = new VowpalWabbitExampleValidator<SimpleContextNoAnnotation>(
                new VowpalWabbitSettings(featureDiscovery: VowpalWabbitFeatureDiscovery.All)))
            {
                vw.Validate("3.2 | Feature:25",
                    new SimpleContextNoAnnotation
                    {
                        Feature = 25,
                        Label = new SimpleLabel { Label = 3.2f }
                    });

                vw.Validate("| Feature:25",
                    new SimpleContextNoAnnotation
                    {
                        Feature = 25,
                    });
            }
        }
开发者ID:NativoPlatform,项目名称:vowpal_wabbit,代码行数:19,代码来源:TestLabels.cs


示例20: TestNumericUInt64ArrayAnchor

 public void TestNumericUInt64ArrayAnchor()
 {
     using(var vw = new VowpalWabbitExampleValidator<NumericExampleUInt64ArrayAnchor>(string.Empty))
     {
         vw.Validate("| :1 :4 :2 :3", new NumericExampleUInt64ArrayAnchor() { Value = new System.UInt64[] { 4, 2, 3 } });
         vw.Validate("", new NumericExampleUInt64ArrayAnchor());
     }
 }
开发者ID:lmatthieu,项目名称:myvw,代码行数:8,代码来源:TestMarshalNumeric.cs



注:本文中的cs_unittest.VowpalWabbitExampleValidator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# csogg.csBuffer类代码示例发布时间:2022-05-26
下一篇:
C# commonClass.DataSeries类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap