コード例 #1
0
    public float Predict(List <float> values, List <float> predictions, float?desiredValue = null)
    {
        float basePrediction = BasePredictor.Predict(values, predictions, desiredValue);

        if (values == null || values.Count < 2)
        {
            return(basePrediction);
        }

        var firstDerivative = AdditiveFirstDerivativePredictor.Differentiate(values);

        float derivativePrediction = DerivativePredictor.Predict(firstDerivative, new List <float>(), desiredValue);

        if (firstDerivative.Count < 2)
        {
            return(basePrediction + derivativePrediction);
        }

        var secondDerivative = AdditiveFirstDerivativePredictor.Differentiate(values);

        float secondDerivativePrediction =
            SecondDerivativePredictor.Predict(secondDerivative, new List <float>(), desiredValue);

        return(basePrediction + derivativePrediction + secondDerivativePrediction);
    }
コード例 #2
0
    public float Predict(List <float> values, List <float> predictions, float?desiredValue = null)
    {
        if (values == null || values.Count == 0)
        {
            return(.5f);
        }

        if (values.Count < 2)
        {
            return(values[0]);
        }

        List <float> firstDerivative = AdditiveFirstDerivativePredictor.Differentiate(values);

        float derivativePrediction = DerivativePredictor.Predict(firstDerivative, new List <float>(), desiredValue);

        return(values[values.Count - 1] + derivativePrediction);
    }