コード例 #1
0
        public void EhCrossPRESS(int[] group, IMatrix XX, IMatrix YY, IMatrix XU, IMatrix YU)
        {
            IVector meanX, scaleX, meanY, scaleY;

            if (_predictedY == null || _predictedY.Rows != YU.Rows || _predictedY.Columns != YU.Columns)
            {
                _predictedY = new MatrixMath.BEMatrix(YU.Rows, YU.Columns);
            }

            MultivariateRegression.PreprocessForAnalysis(_preprocessOptions, _spectralRegions, XX, YY, out meanX, out scaleX, out meanY, out scaleY);
            _analysis.AnalyzeFromPreprocessed(XX, YY, _numFactors);
            _numFactors = Math.Min(_numFactors, _analysis.NumberOfFactors);

            MultivariateRegression.PreprocessSpectraForPrediction(_preprocessOptions, XU, meanX, scaleX);


            // allocate the crossPRESS vector here, since now we know about the number of factors a bit more
            if (null == _crossPRESS)
            {
                _crossPRESS = new double[_numFactors + 1]; // one more since we want to have the value at factors=0 (i.e. the variance of the y-matrix)
            }
            // for all factors do now a prediction of the remaining spectra
            _crossPRESS[0] += MatrixMath.SumOfSquares(YU);
            for (int nFactor = 1; nFactor <= _numFactors; nFactor++)
            {
                _analysis.PredictYFromPreprocessed(XU, nFactor, _predictedY);
                MultivariateRegression.PostprocessY(_predictedY, meanY, scaleY);
                _crossPRESS[nFactor] += MatrixMath.SumOfSquaredDifferences(YU, _predictedY);
            }
        }
コード例 #2
0
        public void EhCrossValidationWorker(int[] group, IMatrix XX, IMatrix YY, IMatrix XU, IMatrix YU)
        {
            IVector meanX, scaleX, meanY, scaleY;

            MultivariateRegression.PreprocessForAnalysis(_preprocessOptions, _spectralRegions, XX, YY,
                                                         out meanX, out scaleX, out meanY, out scaleY);

            _analysis.AnalyzeFromPreprocessed(XX, YY, _numFactors);
            _numFactors = Math.Min(_numFactors, _analysis.NumberOfFactors);

            MultivariateRegression.PreprocessSpectraForPrediction(_preprocessOptions, XU, meanX, scaleX);
            IROMatrix xResidual = _analysis.SpectralResidualsFromPreprocessed(XU, _numFactors);



            if (this._XCrossResiduals == null)
            {
                this._XCrossResiduals = new MatrixMath.BEMatrix(_numberOfPoints, xResidual.Columns);
            }

            for (int i = 0; i < group.Length; i++)
            {
                MatrixMath.SetRow(xResidual, i, this._XCrossResiduals, group[i]);
            }
        }
コード例 #3
0
        public void EhCrossValidationWorker(int[] group, IMatrix XX, IMatrix YY, IMatrix XU, IMatrix YU)
        {
            IVector meanX, scaleX, meanY, scaleY;

            MultivariateRegression.PreprocessForAnalysis(_preprocessOptions, _spectralRegions, XX, YY,
                                                         out meanX, out scaleX, out meanY, out scaleY);

            _analysis.AnalyzeFromPreprocessed(XX, YY, _numFactors);
            _numFactors = Math.Min(_numFactors, _analysis.NumberOfFactors);

            MultivariateRegression.PreprocessSpectraForPrediction(_preprocessOptions, XU, meanX, scaleX);

            if (_predictedY == null || _predictedY.Rows != YU.Rows || _predictedY.Columns != YU.Columns)
            {
                _predictedY = new MatrixMath.BEMatrix(YU.Rows, YU.Columns);
            }
            if (_spectralResidual == null || _spectralResidual.Rows != XU.Rows || _spectralResidual.Columns != _analysis.NumberOfSpectralResiduals)
            {
                _spectralResidual = new MatrixMath.BEMatrix(XU.Rows, _analysis.NumberOfSpectralResiduals);
            }



            for (int nFactor = 0; nFactor <= _numFactors; nFactor++)
            {
                _analysis.PredictedYAndSpectralResidualsFromPreprocessed(XU, nFactor, _predictedY, _spectralResidual);
                MultivariateRegression.PostprocessY(_predictedY, meanY, scaleY);

                for (int i = 0; i < group.Length; i++)
                {
                    MatrixMath.SetRow(_predictedY, i, _result.GetPredictedYW(NumberOfFactors), group[i]);
                    MatrixMath.SetRow(_spectralResidual, i, _result.GetSpectralResidualW(NumberOfFactors), group[i]);
                }
            }
        }
コード例 #4
0
 public CrossPRESSEvaluator(
     int[] spectralRegions,
     int numFactors,
     ICrossValidationGroupingStrategy groupingStrategy,
     SpectralPreprocessingOptions preprocessOptions,
     MultivariateRegression analysis
     )
     : base(spectralRegions, numFactors, groupingStrategy, preprocessOptions, analysis)
 {
 }
コード例 #5
0
 public CrossPredictedXResidualsEvaluator(
     int numberOfPoints,
     int[] spectralRegions,
     int numFactors,
     ICrossValidationGroupingStrategy groupingStrategy,
     SpectralPreprocessingOptions preprocessOptions,
     MultivariateRegression analysis
     )
     : base(spectralRegions, numFactors, groupingStrategy, preprocessOptions, analysis)
 {
     _numberOfPoints = numberOfPoints;
 }
コード例 #6
0
 public CrossPredictedYEvaluator(
     int[] spectralRegions,
     int numFactors,
     ICrossValidationGroupingStrategy groupingStrategy,
     SpectralPreprocessingOptions preprocessOptions,
     MultivariateRegression analysis,
     IMatrix YCrossValidationPrediction
     )
     : base(spectralRegions, numFactors, groupingStrategy, preprocessOptions, analysis)
 {
     _YCrossValidationPrediction = YCrossValidationPrediction;
 }
コード例 #7
0
 public CrossValidationWorker(
     int[] spectralRegions,
     int numFactors,
     ICrossValidationGroupingStrategy groupingStrategy,
     SpectralPreprocessingOptions preprocessOptions,
     MultivariateRegression analysis
     )
 {
     _spectralRegions   = spectralRegions;
     _numFactors        = numFactors;
     _groupingStrategy  = groupingStrategy;
     _preprocessOptions = preprocessOptions;
     _analysis          = analysis;
 }
コード例 #8
0
        public void EhCrossValidationWorker(int[] group, IMatrix <double> XX, IMatrix <double> YY, IMatrix <double> XU, IMatrix <double> YU)
        {
            MultivariateRegression.PreprocessForAnalysis(_preprocessOptions, _spectralRegions, XX, YY,
                                                         out var meanX, out var scaleX, out var meanY, out var scaleY);

            _analysis.AnalyzeFromPreprocessed(XX, YY, _numFactors);
            _numFactors = Math.Min(_numFactors, _analysis.NumberOfFactors);

            MultivariateRegression.PreprocessSpectraForPrediction(_preprocessOptions, XU, meanX, scaleX);
            IROMatrix <double> xResidual = _analysis.SpectralResidualsFromPreprocessed(XU, _numFactors);

            if (_XCrossResiduals == null)
            {
                _XCrossResiduals = new MatrixMath.LeftSpineJaggedArrayMatrix <double>(_numberOfPoints, xResidual.ColumnCount);
            }

            for (int i = 0; i < group.Length; i++)
            {
                MatrixMath.SetRow(xResidual, i, _XCrossResiduals, group[i]);
            }
        }
コード例 #9
0
        public void EhYCrossPredicted(int[] group, IMatrix <double> XX, IMatrix <double> YY, IMatrix <double> XU, IMatrix <double> YU)
        {
            if (_predictedY == null || _predictedY.RowCount != YU.RowCount || _predictedY.ColumnCount != YU.ColumnCount)
            {
                _predictedY = new MatrixMath.LeftSpineJaggedArrayMatrix <double>(YU.RowCount, YU.ColumnCount);
            }

            MultivariateRegression.PreprocessForAnalysis(_preprocessOptions, _spectralRegions, XX, YY,
                                                         out var meanX, out var scaleX, out var meanY, out var scaleY);

            _analysis.AnalyzeFromPreprocessed(XX, YY, _numFactors);
            _numFactors = Math.Min(_numFactors, _analysis.NumberOfFactors);

            MultivariateRegression.PreprocessSpectraForPrediction(_preprocessOptions, XU, meanX, scaleX);
            _analysis.PredictYFromPreprocessed(XU, _numFactors, _predictedY);
            MultivariateRegression.PostprocessY(_predictedY, meanY, scaleY);

            for (int i = 0; i < group.Length; i++)
            {
                MatrixMath.SetRow(_predictedY, i, _YCrossValidationPrediction, group[i]);
            }
        }
コード例 #10
0
        public void EhYCrossPredicted(int[] group, IMatrix XX, IMatrix YY, IMatrix XU, IMatrix YU)
        {
            IVector meanX, scaleX, meanY, scaleY;

            if (_predictedY == null || _predictedY.Rows != YU.Rows || _predictedY.Columns != YU.Columns)
            {
                _predictedY = new MatrixMath.BEMatrix(YU.Rows, YU.Columns);
            }

            MultivariateRegression.PreprocessForAnalysis(_preprocessOptions, _spectralRegions, XX, YY,
                                                         out meanX, out scaleX, out meanY, out scaleY);

            _analysis.AnalyzeFromPreprocessed(XX, YY, _numFactors);
            _numFactors = Math.Min(_numFactors, _analysis.NumberOfFactors);

            MultivariateRegression.PreprocessSpectraForPrediction(_preprocessOptions, XU, meanX, scaleX);
            _analysis.PredictYFromPreprocessed(XU, _numFactors, _predictedY);
            MultivariateRegression.PostprocessY(_predictedY, meanY, scaleY);

            for (int i = 0; i < group.Length; i++)
            {
                MatrixMath.SetRow(_predictedY, i, _YCrossValidationPrediction, group[i]);
            }
        }