ComenzarEmpieza gratis

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 ejercicio forma parte del curso

HR Analytics: Predicting Employee Churn in Python

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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 y ejecutar código