Exemplo n.º 1
0
    def __init__(self, n_trees=10, max_depth=2, min_size=2, cost='mse'):
        """
		Constructor for random forest regressor. This mainly just initialize
		the attributes of the class by calling the base class constructor. 
		However, here is where it is the cost function string is checked
		to make sure it is using 'mse', otherwise an error is thrown.

		Args:
			cost (str) : The name of the cost function to use for evaluating
						 the split.

			n_trees (int): The number of trees to use.

			max_depth (int): The maximum depth of tree.

			min_size (int): The minimum number of datapoints in terminal nodes.
	
		"""
        if cost != 'mse':
            raise NameError('Not valid cost function')
        else:
            RandomForest.__init__(self,
                                  cost,
                                  n_trees=10,
                                  max_depth=2,
                                  min_size=2)
Exemplo n.º 2
0
 def __init__(self, num_trees, num_features, impurity_criterion, prune=False):
     """
        num_trees:  number of trees to create in the forest:
     num_features:  the number of features to consider when choosing the
                        best split for each node of the decision trees
     """
     RandomForest.__init__(self, num_trees, num_features, impurity_criterion)
     self.prune = prune
Exemplo n.º 3
0
 def __init__(self,
              num_trees,
              num_features,
              impurity_criterion,
              prune=False):
     '''
        num_trees:  number of trees to create in the forest:
     num_features:  the number of features to consider when choosing the
                        best split for each node of the decision trees
     '''
     RandomForest.__init__(self, num_trees, num_features,
                           impurity_criterion)
     self.prune = prune
Exemplo n.º 4
0
	def __init__(self, n_trees=10, max_depth=2, min_size=2, cost='mse'):
		if cost != 'mse':
			raise NameError('Not valid cost function')
		else:
			RandomForest.__init__(self, cost, n_trees=10, max_depth=2, min_size=2)