Exemplo n.º 1
0
        /// <summary>
        ///   Learns a model that can map the given inputs to the given outputs.
        /// </summary>
        ///
        /// <param name="x">The model inputs.</param>
        /// <param name="y">The desired outputs associated with each <paramref name="x">inputs</paramref>.</param>
        /// <param name="weights">The weight of importance for each input-output pair (if supported by the learning algorithm).</param>
        ///
        /// <returns>A model that has learned how to produce <paramref name="y"/> given <paramref name="x"/>.</returns>
        ///
        public DecisionTree Learn(double[][] x, int[] y, double[] weights = null)
        {
            if (Model == null)
            {
                init(DecisionTreeHelper.Create(x, y, this.Attributes));
            }

            this.run(x, y, weights);
            return(Model);
        }
Exemplo n.º 2
0
        /// <summary>
        ///   Learns a model that can map the given inputs to the given outputs.
        /// </summary>
        ///
        /// <param name="x">The model inputs.</param>
        /// <param name="y">The desired outputs associated with each <paramref name="x">inputs</paramref>.</param>
        /// <param name="weights">The weight of importance for each input-output pair (if supported by the learning algorithm).</param>
        ///
        /// <returns>A model that has learned how to produce <paramref name="y"/> given <paramref name="x"/>.</returns>
        ///
        public DecisionTree Learn(int?[][] x, int[] y, double[] weights = null)
        {
            if (Model == null)
            {
                init(DecisionTreeHelper.Create(x, y, this.Attributes));
            }

            this.run(x.Apply((xi, i, j) => xi.HasValue ? (double)xi : Double.NaN), y, weights);
            return(Model);
        }
Exemplo n.º 3
0
        /// <summary>
        ///   Learns a model that can map the given inputs to the given outputs.
        /// </summary>
        ///
        /// <param name="x">The model inputs.</param>
        /// <param name="y">The desired outputs associated with each <paramref name="x">inputs</paramref>.</param>
        /// <param name="weights">The weight of importance for each input-output pair (if supported by the learning algorithm).</param>
        ///
        /// <returns>A model that has learned how to produce <paramref name="y"/> given <paramref name="x"/>.</returns>
        ///
        public DecisionTree Learn(int[][] x, int[] y, double[] weights = null)
        {
            if (weights != null)
            {
                throw new ArgumentException(Accord.Properties.Resources.NotSupportedWeights, "weights");
            }

            if (Model == null)
            {
                init(DecisionTreeHelper.Create(x, y, this.Attributes));
            }

            this.run(x.ToDouble(), y, weights);
            return(Model);
        }
Exemplo n.º 4
0
        /// <summary>
        ///   Learns a model that can map the given inputs to the given outputs.
        /// </summary>
        ///
        /// <param name="x">The model inputs.</param>
        /// <param name="y">The desired outputs associated with each <paramref name="x">inputs</paramref>.</param>
        /// <param name="weights">The weight of importance for each input-output pair (if supported by the learning algorithm).</param>
        ///
        /// <returns>A model that has learned how to produce <paramref name="y"/> given <paramref name="x"/>.</returns>
        ///
        public DecisionTree Learn(int?[][] x, int[] y, double[] weights = null)
        {
            if (weights != null)
            {
                throw new ArgumentException(Accord.Properties.Resources.NotSupportedWeights, "weights");
            }

            if (Model == null)
            {
                init(DecisionTreeHelper.Create(x, y, this.Attributes));
            }

            this.run(x.Apply((xi, i, j) => xi.HasValue ? (double)xi : Double.NaN), y);
            return(Model);
        }