public override IPredictor CreatePredictor() { Contracts.Assert(WeightArraySize == 1); Contracts.Assert(Utils.Size(Weights) == 1); Contracts.Assert(Utils.Size(Bias) == 1); Host.Check(Weights[0].Length > 0); VBuffer <Float> maybeSparseWeights = VBufferUtils.CreateEmpty <Float>(Weights[0].Length); VBufferUtils.CreateMaybeSparseCopy(ref Weights[0], ref maybeSparseWeights, Conversions.Instance.GetIsDefaultPredicate <Float>(NumberType.Float)); return(new LinearRegressionPredictor(Host, ref maybeSparseWeights, Bias[0])); }
private TPredictor CreatePredictor(VBuffer <Float> weights, Float bias) { Host.CheckParam(weights.Length > 0, nameof(weights)); VBuffer <Float> maybeSparseWeights = default; VBufferUtils.CreateMaybeSparseCopy(ref weights, ref maybeSparseWeights, Conversions.Instance.GetIsDefaultPredicate <Float>(NumberType.Float)); var predictor = new LinearBinaryPredictor(Host, ref maybeSparseWeights, bias); return(new ParameterMixingCalibratedPredictor(Host, predictor, new PlattCalibrator(Host, -1, 0))); }
protected override LinearRegressionPredictor CreatePredictor(VBuffer <Float>[] weights, Float[] bias) { Host.CheckParam(Utils.Size(weights) == 1, nameof(weights)); Host.CheckParam(Utils.Size(bias) == 1, nameof(bias)); Host.CheckParam(weights[0].Length > 0, nameof(weights)); VBuffer <Float> maybeSparseWeights = default; VBufferUtils.CreateMaybeSparseCopy(ref weights[0], ref maybeSparseWeights, Conversions.Instance.GetIsDefaultPredicate <Float>(NumberType.Float)); return(new LinearRegressionPredictor(Host, ref maybeSparseWeights, bias[0])); }
protected override LinearRegressionPredictor CreatePredictor(VBuffer <Float>[] weights, Float[] bias) { Host.CheckParam(Utils.Size(weights) == 1, nameof(weights)); Host.CheckParam(Utils.Size(bias) == 1, nameof(bias)); Host.CheckParam(weights[0].Length > 0, nameof(weights)); VBuffer <Float> maybeSparseWeights = default; // below should be `in weights[0]`, but can't because of https://github.com/dotnet/roslyn/issues/29371 VBufferUtils.CreateMaybeSparseCopy(weights[0], ref maybeSparseWeights, Conversions.Instance.GetIsDefaultPredicate <Float>(NumberType.Float)); return(new LinearRegressionPredictor(Host, in maybeSparseWeights, bias[0]));