Ejemplo n.º 1
0
        public static Vector <double> GenerateToyData(int seed, Vector <double> x_train)
        {
            var           generater = RndGenerater.Build(seed);
            Func <double> noise     = () => generater.NextNormal(NoiseNormalMean, NoiseNormalStddev);

            return(ToyDataGenerater.Generate2D(Fig_1_2_func, noise, x_train));
        }
Ejemplo n.º 2
0
        private static (int, LinearRegressionResult.CalibratedData) Predict(LinearRegressionResult.GivenData data, int polynomialDegree)
        {
            IFeature        feature         = new PolynomialFeature(polynomialDegree);
            Matrix <double> designMatrix    = ToyDataGenerater.DesignMatrix(data.X_train, feature);
            Matrix <double> invDesignMatrix = designMatrix.PseudoInverse();
            Vector <double> weights         = invDesignMatrix * data.T_train;
            Vector <double> t_test          = Predicts(data.X_test, weights, feature);

            return(polynomialDegree, new LinearRegressionResult.CalibratedData(t_test, weights));
        }