Aan de slagGa gratis aan de slag

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)

Deze oefening maakt deel uit van de cursus

HR Analytics: Predicting Employee Churn in Python

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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, ____)
Code bewerken en uitvoeren