Cluster, Decision Tree and Logistic Regression for HR Analysis using KNIME
Overwhelmed with data but can’t seem to find clear, actionable conclusions? You’re not the only one. Data science is extremely powerful, but it’s too often mired behind a fence of complex coding languages like Python or R.
Imagine you could build sophisticated predictive models and discover hidden segments within your data with a simple-to-use visual, drag-and-drop interface?
Step in KNIME (the Konstanz Information Miner). This free, open-source software is a game-changer for analysts, marketers, researchers, and anyone who wants to tap into their data without being swamped by code.
In this blog, we’re bypassing the technical mumbo-jumbo. We’re going to explore three of the most important techniques in any analyst’s toolkit
Cluster Analysis: Unsupervised learning’s hidden gem. We’ll use it to find natural clusters in your data. (Ask yourself: Which of my employees behave similarly?)
Decision Trees: The intuitive classification algorithm. We’ll build a graphical flowchart that makes a prediction. (Ask yourself: What characteristics lead a employees to leave or stay?)
Logistic Regression: The statistical behemoth for prediction. We will use it to predict a mere “yes/no” probability. (Ask yourself: How probable is this employee to quit?)
This isn’t theory. We’re going to build these models from scratch in one KNIME workflow. You’ll have a solid understanding of what these methods are and how you can use them yourself, taking raw data and making rich, data-driven decisions, at the end of this post.
Cluster Analysis:
Cluster Analysis is an exploratory technique used to find natural groupings in your data. It doesn’t predict an outcome; instead, it looks at all your employee data (like performance scores, tenure, satisfaction surveys, and engagement levels) and segments your workforce into distinct groups, or “clusters,” based on their shared characteristics. It’s an “unsupervised” method, meaning you don’t define the groups beforehand — the algorithm finds the hidden patterns for you.
Loading the Data
To do cluster analysis in KNIME, the first step in cluster analysis (or for any from of analysis) will be to gather data. For the sake of this blog, I’ll be using a random data that I found online. Once we have decided the data we have we’ll need to load the data into KNIME for this we will use Excel Reader node (CSV reader if you have a CSV file) shown below:
Right click on the node and then go to the configure option, from there, you can browse through the files and load the data that you have in your local storage in your computer.
You might have noticed that there are some missing values as well. In that case we will use the Missing Value node which will help us clear out rows that have incomplete data.
Now that are data has been cleared, we have the liberty to use various forms on nodes provided by KNIME that will make our lives super easy for various forms of analysis. For cluster analysis, with the data I have got, we can do the following steps:
Data Preparation and Filtering
This is where we select the specific data we want to analyze.
- Column Filter (legacy): We have a lot of employee data, but for this analysis, we’re only interested in two factors: “Number of hours employees are absent” and “No. of children.” This node filters out all other columns to focus our analysis.
- Row Filter (Labs): Now that we have the right columns, we filter the rows. The note “Only those employees who are absent more than 10 hours” tells us we are specifically isolating a subgroup of employees with high absenteeism.
- Rule Engine (x2): These are feature engineering nodes.
- The first Rule Engine (labeled "Low, Medium or High Absenteeism") likely takes the numerical "hours absent" and converts it into a category (e.g., 10-20 hours = "Medium", 21+ = "High").
- The second Rule Engine (labeled "No of children") takes the output from the first and probably does the same for the "No of children" column (e.g., 0 = "None", 1-2 = "Some", 3+ = "Many"). This makes the data easier to interpret.
Of course, for Rule Engine, you will need to use formulas while you are configuring it as shown below:
Clustering and Visualization
- Color Manager & Shape Manager: These nodes prepare our data for visualization. They assign specific colors and shapes based on the categories we just created (e.g., “High Absenteeism” is colored red, “Many Children” is a triangle). This helps us see our known segments before we cluster.
- k-Means: This is the hero node. It performs the cluster analysis. It takes our filtered and prepped data (absenteeism and children) and mathematically groups all the employees into a pre-defined number of clusters (the ‘k’). Employees within the same cluster are more similar to each other (in terms of these two variables) than they are to employees in other clusters.
- Scatter Plot (legacy) & Scatter Plot (JavaScript) (legacy): These are our final output. They generate a visual scatter plot that lets us see the clusters. This plot would likely have “Absenteeism” on one axis and “No. of Children” on the other. The k-Means node will color-code each employee on the plot according to the cluster it was assigned, allowing us to instantly identify the groups it found
All and all, your workflow will look something like this:
Remember to use Shape and Color manager as it gives loads of insights on how different clusters behave. After using the scatter plot node, the output will be something like this:
Logistic Regression:
Logistic Regression is another powerful predictive model used when you want to forecast a binary outcome (a “Yes” or “No” answer). It analyzes a set of employee variables (like age, salary, distance from home, last promotion, etc.) and calculates the probability that a specific event will happen. While a decision tree gives you rigid rules, logistic regression gives you a precise probability score (e.g., 75% chance).
Get RohitKar04’s stories in your inbox
Join Medium for free to get updates from this writer.
Just like Cluster Analysis, in KNIME, you have to do the basics like Excel Reader, Missing Values to clean the data etc. In this case, our initial goals will be to as many Rule Engine nodes as possible.
Those Rule Engine nodes are for feature engineering, most likely to convert categorical (text) data into numbers. A logistic regression algorithm is a powerful statistical tool, but it’s fundamentally mathematical. It cannot understand text values like “Sales,” “HR,” “Male,” “Female,” or “High.” All inputs must be numeric. This long chain of Rule Engine nodes is a manual way to create "dummy variables" (or "one-hot encoding"). Each node likely takes a single categorical column and converts its values into 0s and 1s.
After doing the required. We will use the following shown in the image:
What nodes are these you may wonder, well…..
X- Partitioner: This node is used for k-fold cross-validation, splitting the data into a specified number of “folds” (e.g., 10). It’s designed to be used in a loop to train and test a model multiple times on different subsets of the data for a more robust accuracy score.
Table Partitioner: This node performs a simple train/test split on your data. It divides your dataset into two portions, one for training the model (e.g., 80% of the rows) and a separate one for testing it (e.g., the remaining 20%).
Normalizer: This node rescales numeric columns to a standard range, such as 0 to 1. This is a crucial pre-processing step, as it prevents features with large scales (like Salary) from unfairly dominating features with small scales (like Age) during the model's training.
Logistic Regression Learner: This is the node that builds the actual model. It takes the “training set” of data and “learns” the mathematical formula (the logistic regression equation) that best predicts your target variable (e.g., who will leave vs. who will stay).
Logistic Regression Predictor: This node applies the trained model to new data (the “test set”). It uses the formula created by the Learner to generate a prediction (e.g., "Yes" or "No") and a probability score for each row in the test data.
Scorer: This is the report card for your model. It compares the Predictor's guesses against the actual, true answers from the test set and generates a confusion matrix to show you how many it got right and wrong, along with accuracy statistics as shown below.
Decision Tree:
It is a predictive model that is easy to understand because it looks just like a flowchart. It works by splitting your data into smaller and smaller branches based on a series of “if/then” questions to arrive at a final prediction. It’s a “supervised” model, meaning you train it on historical data where you already know the outcome (e.g., employees who “Left” vs. employees who “Stayed”).
Doing after doing the typical, basic operations such as loading the data, cleaning the data you can do the following:
Column Filter (legacy): This node serves to get rid of irrelevant columns that you do not wish the model to use, e.g., `EmployeeID` or `EmployeeName`.
Column Filter (legacy) (Second one): This is an important step. Here, you’re choosing the exact columns (features) that you wish the model to use for its analysis. In my case it’s: Department, Job Role, Monthly Income, Performance Rating, Attrition (which is my target variable, the one I’m trying to predict) to a fixed 0–1 range. Although Decision Trees aren’t as particular about varying scales as some other models (such as logistic regression), this is a standard step in most machine learning pipelines.
2. Model Training and Testing
Table Partitioner: This node divides the data in half like cutting a pack of cards
Training Set (e.g., 80% of data): This is the bigger set used to train the model. It’s passed to the `Decision Tree Learner`.
Test Set (e.g., 20% of data): This reduced set is kept secret from the model while it’s trained. It’s passed through to the `Decision Tree Predictor` to be utilized for a balanced, unbiased test.
Decision Tree Learner: This is the “thinking cap” of the process. It accepts the training set and constructs the decision tree model. It works through all the features to discover the most optimal “if/then” questions (e.g., “Is `Monthly Income` < 5000?”) that best divide up the data into the “Attrition: Yes” and “Attrition: No” categories. The result is the trained model.
Decision Tree Predictor: This node accepts the trained model from the `Learner` and the test set from the `Partitioner`. It applies the unseen test data to the model’s flowchart in order to provide a prediction for every employee.
Decision Tree Predictor: This node accepts the trained model from the Learner and the test set from the Partitioner. It applies the unseen test data to the model’s flowchart in order to provide a prediction for every employee.
3. Model Visualization
This is the final output, illustrating to what the model constructed.
Decision Tree View (JavaScript) (legacy): The most critical output for this model. It renders the trained model from the `Learner` into an interactive, graphical flowchart. This enables you to view the precise rules the model learned, like “IF `Performance Rating` = ‘Low’ AND `Job Role` = ‘Sales Rep’ THEN Attrition = ‘Yes’ (90% probability).” This renders the model’s logic extremely simple to comprehend and communicate to others.




