DecisionTree
Bases: Classifier
Decision tree classification.
Source code in src/safeds/ml/classical/classification/_decision_tree.py
__init__()
¶
fit(training_set)
¶
Create a copy of this classifier and fit it with the given training data.
This classifier is not modified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
training_set |
TaggedTable
|
The training data containing the feature and target vectors. |
required |
Returns:
Name | Type | Description |
---|---|---|
fitted_classifier |
DecisionTree
|
The fitted classifier. |
Raises:
Type | Description |
---|---|
LearningError
|
If the training data contains invalid values or if the training failed. |
UntaggedTableError
|
If the table is untagged. |
NonNumericColumnError
|
If the training data contains non-numerical values. |
MissingValuesColumnError
|
If the training data contains missing values. |
DatasetMissesDataError
|
If the training data contains no rows. |
Source code in src/safeds/ml/classical/classification/_decision_tree.py
is_fitted()
¶
Check if the classifier is fitted.
Returns:
Name | Type | Description |
---|---|---|
is_fitted |
bool
|
Whether the classifier is fitted. |
predict(dataset)
¶
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
Table
|
The dataset containing the feature vectors. |
required |
Returns:
Name | Type | Description |
---|---|---|
table |
TaggedTable
|
A dataset containing the given feature vectors and the predicted target vector. |
Raises:
Type | Description |
---|---|
ModelNotFittedError
|
If the model has not been fitted yet. |
DatasetContainsTargetError
|
If the dataset contains the target column already. |
DatasetMissesFeaturesError
|
If the dataset misses feature columns. |
PredictionError
|
If predicting with the given dataset failed. |
NonNumericColumnError
|
If the dataset contains non-numerical values. |
MissingValuesColumnError
|
If the dataset contains missing values. |
DatasetMissesDataError
|
If the dataset contains no rows. |