turicreate.decision_tree_classifier.create

turicreate.decision_tree_classifier.create(dataset, target, features=None, validation_set='auto', class_weights=None, max_depth=6, min_loss_reduction=0.0, min_child_weight=0.1, verbose=True, random_seed=None, metric='auto', **kwargs)

Create a (binary or multi-class) classifier model of type DecisionTreeClassifier. This algorithm is a special case of boosted trees classifier with the number of trees set to 1.

Parameters:
dataset : SFrame

A training dataset containing feature columns and a target column.

target : str

Name of the column containing the target variable. The values in this column must be of string or integer type. String target variables are automatically mapped to integers in alphabetical order of the variable values. For example, a target variable with ‘cat’, ‘dog’, and ‘foosa’ as possible values is mapped to 0, 1, and, 2 respectively.

features : list[str], optional

A list of columns names of features used for training the model. Defaults to None, which uses all columns in the SFrame dataset excepting the target column..

validation_set : SFrame, optional

A dataset for monitoring the model’s generalization performance. For each row of the progress table, the chosen metrics are computed for both the provided training dataset and the validation_set. The format of this SFrame must be the same as the training set. By default this argument is set to ‘auto’ and a validation set is automatically sampled and used for progress printing. If validation_set is set to None, then no additional metrics are computed. This is computed once per full iteration. Large differences in model accuracy between the training data and validation data is indicative of overfitting. The default value is ‘auto’.

class_weights : {dict, auto}, optional

Weights the examples in the training data according to the given class weights. If provided, the dictionary must contain a key for each class label. The value can be any positive number greater than 1e-20. Weights are interpreted as relative to each other. So setting the weights to be 2.0 for the positive class and 1.0 for the negative class has the same effect as setting them to be 20.0 and 10.0, respectively. If set to None, all classes are taken to have weight 1.0. The auto mode sets the class weight to be inversely proportional to the number of examples in the training data with the given class.

max_depth : float, optional

Maximum depth of a tree. Must be at least 1.

min_loss_reduction : float, optional (non-negative)

Minimum loss reduction required to make a further partition/split a node during the tree learning phase. Larger (more positive) values can help prevent overfitting by avoiding splits that do not sufficiently reduce the loss function.

min_child_weight : float, optional (non-negative)

Controls the minimum weight of each leaf node. Larger values result in more conservative tree learning and help prevent overfitting. Formally, this is minimum sum of instance weights (hessians) in each node. If the tree learning algorithm results in a leaf node with the sum of instance weights less than min_child_weight, tree building will terminate.

verbose : boolean, optional

Print progress information during training (if set to true).

random_seed : int, optional

Seeds random operations such as column and row subsampling, such that results are reproducible.

metric : str or list[str], optional

Performance metric(s) that are tracked during training. When specified, the progress table will display the tracked metric(s) on training and validation set. Supported metrics are: {‘accuracy’, ‘auc’, ‘log_loss’}

Returns:
out : DecisionTreeClassifier

A trained decision tree model for classifications tasks.

References

Examples

>>> url = 'https://static.turi.com/datasets/xgboost/mushroom.csv'
>>> data = turicreate.SFrame.read_csv(url)

>>> train, test = data.random_split(0.8)
>>> model = turicreate.decision_tree_classifier.create(train, target='label')

>>> predictions = model.classify(test)
>>> results = model.evaluate(test)