ComeçarComece de graça

Fitting the tree to employee data

A train/test split provides the opportunity to develop the classifier on the training component and test it on the rest of the dataset. In this exercise, you will start developing an employee turnover prediction model using the decision tree classification algorithm. The algorithm provides a .fit() method, which can be used to fit the features to the model in the training set.

Reminder: both target and features are already split into train and test components (Train: features_train, target_train, Test: features_test, target_test)

Este exercício faz parte do curso

HR Analytics: Predicting Employee Churn in Python

Ver curso

Instruções do exercício

  • Import the classification algorithm called DecisionTreeClassifier.
  • Initialize it as model and set the random state to 42.
  • Apply the decision tree model by fitting the training set features to the model.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Import the classification algorithm
from sklearn.tree import ____

# Initialize it and call model by specifying the random_state parameter
model = ____(random_state=42)

# Apply a decision tree model to fit features to the target
model.____(features_train, ____)
Editar e executar o código