示例#1
0
        public void TestNull3()
        {
            using (var vw = new VowpalWabbit<Context, ADF>("--cb_adf --rank_all --interact ac"))
            {
                var ctx = new Context()
                {
                    ID = 25,
                    Vector = new float[] { 3 },
                    VectorC = new float[] { 2, 2, 3 },
                    ActionDependentFeatures = new[] {
                        new ADF {
                            ADFID = "23",
                        }
                    }.ToList()
                };

                var label = new ContextualBanditLabel() {
                                Action = 1,
                                Cost= 1,
                                Probability = 0.2f
                            };

                vw.Learn(ctx, ctx.ActionDependentFeatures, 0, label);

                ctx.Vector = null;
                vw.Learn(ctx, ctx.ActionDependentFeatures, 0, label);

                ctx.Vector = new float[] { 2 };
                ctx.VectorC = null;
                vw.Learn(ctx, ctx.ActionDependentFeatures, 0, label);

                ctx.Vector = null;
                vw.Learn(ctx, ctx.ActionDependentFeatures, 0, label);
            }
        }
示例#2
0
        public void TestNull1()
        {
            using (var vw = new VowpalWabbit<Context, ADF>("--cb_adf --rank_all --interact ab"))
            {
                var ctx = new Context()
                {
                    ID = 25,
                    Vector = null,
                    ActionDependentFeatures = new[] {
                        new ADF {
                            ADFID = "23"
                        }
                    }.ToList()
                };

                vw.Learn(ctx, ctx.ActionDependentFeatures, 0, new ContextualBanditLabel()
                {
                    Action = 1,
                    Cost = 1,
                    Probability = 0.2f
                });
                var result = vw.Predict(ctx, ctx.ActionDependentFeatures);
                Assert.AreEqual(1, result.Length);
            }
        }