Exemplo n.º 1
0
        public void Compute(decimal[] vectror, int lag)
        {
            if (vectror == null)
            {
                throw new ArgumentNullException("vector");
            }

            if (lag >= vectror.Length)
            {
                throw new IndexOutOfRangeException("lag can't be more or equal x.Length");
            }

            decimal[] x = new decimal[vectror.Length - lag];

            for (int i = 0; i < vectror.Length - lag; i++)
            {
                x[i] = vectror[i];
            }

            decimal[] y = new decimal[vectror.Length - lag];

            for (int i = lag; i < vectror.Length; i++)
            {
                y[i - lag] = vectror[i];
            }

            RegressionMethod.Compute(y, x);
        }
Exemplo n.º 2
0
        public PredictionEngine <ModelInput, ModelOutput> CreatePredictionEngine(RegressionMethod method)
        {
            if (Transformers.ContainsKey(method))
            {
                var modelData = Transformers[method];
                return(modelData.Context.Model.CreatePredictionEngine <ModelInput, ModelOutput>(modelData.Model, inputSchema: modelData.Schema));
            }
            else
            {
                var path = $"{_path}\\ML\\Models\\{method.ToString()}.zip";
                if (File.Exists(path))
                {
                    MLContext context = new MLContext();
                    var       model   = context.Model.Load(path, out var schema);
                    Transformers[method] = new ModelData()
                    {
                        Context = context,
                        Schema  = schema,
                        Model   = model
                    };
                    var predictEngine = context.Model.CreatePredictionEngine <ModelInput, ModelOutput>(model, inputSchema: schema);
                    return(predictEngine);
                }
            }

            throw new InvalidOperationException($"Regression Model ({method} couldn't be found.");
        }
 public RegressionWithRanking(RegressionMethod regressionMethod, RegressionFeatureRankingMethod ranker, int nfeatures,
                              Parameters regressionParam, Parameters rankerParam)
 {
     this.regressionMethod = regressionMethod;
     this.ranker           = ranker;
     this.nfeatures        = nfeatures;
     this.regressionParam  = regressionParam;
     this.rankerParam      = rankerParam;
 }
 public RegressionWithRankingMultiSizes(RegressionMethod classifier, RegressionFeatureRankingMethod ranker,
                                        double reductionFactor, int maxFeatures, Parameters classifierParam, Parameters rankerParam)
 {
     this.classifier      = classifier;
     this.ranker          = ranker;
     this.reductionFactor = reductionFactor;
     this.maxFeatures     = maxFeatures;
     this.classifierParam = classifierParam;
     this.rankerParam     = rankerParam;
 }
Exemplo n.º 5
0
        public void Compute(decimal[] y, decimal[] x)
        {
            if (y == null)
            {
                throw new ArgumentNullException("y");
            }
            if (x == null)
            {
                throw new ArgumentNullException("x");
            }
            if (x.Length != y.Length)
            {
                throw new DifferentLengthException();
            }

            RegressionMethod.Compute(y, x);
        }
 public void Compute(decimal[] y, params decimal[][] xn)
 {
     RegressionMethod.Compute(y, xn);
 }
Exemplo n.º 7
0
 public void Compute(bool[] y, params decimal[][] xn)
 {
     RegressionMethod.Compute(y.Select(i => Convert.ToDecimal(i)).ToArray(), xn);
 }