Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Evaluating Model Performance | Predictive People Analytics
Python for People Analytics

bookEvaluating Model Performance

Pyyhkäise näyttääksesi valikon

Predictive models play a crucial role in People Analytics by helping you anticipate important outcomes such as employee attrition, promotion, or engagement. To trust and effectively use these models, you need to understand how well they perform. The most common metrics for evaluating classification models in HR contexts are accuracy, precision, and recall.

Accuracy measures the proportion of correct predictions out of all predictions made. In HR, this might tell you how often your attrition model correctly predicts whether an employee will stay or leave. Precision focuses on the correctness of positive predictions—how many employees predicted to leave actually do leave. This is vital if the cost of a false alarm (predicting someone will leave when they do not) is high. Recall measures how many actual cases of attrition your model successfully identifies. High recall is important when missing a true case (such as not identifying an at-risk employee) could have serious consequences.

Selecting the right metric depends on your business priorities. For example, in attrition prediction, you might prioritize recall to ensure you identify as many potential leavers as possible, even if it means a few false positives.

12345678910111213
from sklearn.metrics import accuracy_score, precision_score, recall_score # Simulated predictions from an attrition model y_true = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0] # 1 = left, 0 = stayed y_pred = [0, 1, 0, 0, 0, 1, 1, 0, 1, 1] # model predictions accuracy = accuracy_score(y_true, y_pred) precision = precision_score(y_true, y_pred) recall = recall_score(y_true, y_pred) print("Accuracy:", round(accuracy, 2)) print("Precision:", round(precision, 2)) print("Recall:", round(recall, 2))
copy

To gain deeper insights into your model's predictions, you can use a confusion matrix. This tool breaks down the results into four categories: true positives, true negatives, false positives, and false negatives. For HR decisions, the confusion matrix helps you see not only how many predictions were correct, but also what types of mistakes your model is making. For instance, if your attrition model has many false negatives, you are missing employees who are actually at risk of leaving—which could lead to costly surprises. On the other hand, too many false positives might mean unnecessary interventions for employees who were never planning to leave.

Interpreting the confusion matrix allows you to adjust your strategy, such as changing the threshold for flagging at-risk employees or focusing on improving recall or precision, depending on your organization's goals.

123456789101112
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay import matplotlib.pyplot as plt # Simulated predictions y_true = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0] y_pred = [0, 1, 0, 0, 0, 1, 1, 0, 1, 1] cm = confusion_matrix(y_true, y_pred) disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=["Stayed", "Left"]) disp.plot(cmap=plt.cm.Blues) plt.title("Attrition Model Confusion Matrix") plt.show()
copy

1. What does precision measure in a classification model?

2. Fill in the blank: The confusion matrix shows the number of ____ and ____ predictions.

3. Why is recall important in attrition prediction?

question mark

What does precision measure in a classification model?

Select the correct answer

question-icon

Fill in the blank: The confusion matrix shows the number of ____ and ____ predictions.

;  predictions.
The confusion matrix shows the number of true and false predictions.
question mark

Why is recall important in attrition prediction?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 3

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Osio 3. Luku 3
some-alt