/* harmony default export */

/* harmony export (binding) */

/* harmony import */

/*#__PURE__*/

/**
 * Creates an instance of DecisionTree
 *
 * @constructor
 * @param builder - contains training set and
 *                  some configuration parameters
 */

/**
* Building array of decision trees.
*/

/**
* Calculates the mean of a variable.
*
* @param values - array of values
*/

/**
* Calculates the variance of a variable.
*
* @param values - array of values
*/

/**
* Calculating entropy of a variable.
*
* @param values - array of values
*/

/**
* Calculating how many elements have the same
* values
*
* @param values - array of values
*/

/**
* Contains MIT-licensed code:
*
* The MIT License (MIT)
*
* Copyright (c) 2013 Yurii Lahodiuk
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/**
* Creates an instance of RandomForest with specific number of trees.
*
* @constructor
* @param opts - contains configuration parameters for building decision trees
*/

/**
* Creates an instance of a decision tree for classification problems.
*
* @constructor
* @param opts - contains training set and some configuration parameters
*/

/**
* Finding value which is most frequent in an array.
*
* @param values - array of values
*/

/**
* Function for building classification decision tree.
*/

/**
* Returns the majority vote prediction for the chosen item.
*/

/**
* Returns the predicted value for the i-th observation using the decision tree.
*/

/**
* Splitting observations using specific predicate and pivot.
*/

/***/

// Building sub-trees:

// Count number of occurrences of each of value:

// Count number of occurrences of each value:

// Counting number of occurrences:

// Creating training sets for each tree:

// Detect different values of attribute:

// EXPORTS //

// Exports

// FUNCTIONS //

// Let the value of current attribute be the pivot:

// MAIN //

// MODULES //

// Module

// Move to one of the sub-trees:

// Only leafs contains predicted category...

// PROPERTIES //

// Remember pairs 'attribute-predicate-value' which provide gain...

// Restriction by maximal depth of tree or size of training set is to small so we have to terminate process of building tree...

// Splitting training set by given 'attribute-predicate-value':

// Traversing tree from the root to leaf:

// Used as hash-set for avoiding the checking of split by rules with the same 'attribute-predicate-pivot' more than once

// VARIABLES //

// eslint-disable-line eqeqeq

// iterating over all attributes of item

// let the value of current attribute be the pivot

// or size of training set is to small

// restriction by maximal depth of tree

// so we have to terminate process of building tree

// splitting training set by given 'attribute-predicate-value'

// used as hash-set for avoiding the checking of split by rules

// with the same 'attribute-predicate-pivot' more than once
