Student data analysis

BeginnerRegression

Problem description

Exploring the factors related to a student's final grade (study hours, attendance, previous grade, sleep) and building a regression model that predicts it. The data is synthetic.

Objectives

  • Computing and reading correlations
  • Handling missing values
  • Building and evaluating a regression model

Problem type

Regression

Dataset

Tools used

Algorithms

Implementation steps

  1. In KNIME: File → Import KNIME Workflow… and choose student-performance.knwf, then Execute all.
  2. Open student-performance.ows in Orange.
  3. Review Column Statistics to find the missing values (24 values).
  4. Use Correlations to rank the features by their correlation with final_score.
  5. Impute, then Test and Score with Linear Regression and Random Forest.
  6. Avoid using the result column as a feature, because it is derived from the target (data leakage).

Workflow diagram

Orange

DataVisualizeEvaluateModel

File FileData Table Data TableColumn Statistics Column StatisticsScatter Plot Scatter PlotCorrelations CorrelationsDistributions DistributionsImpute ImputeTest and Score Test and ScoreLinear Regression Linear RegressionRandom Forest Random ForestDataDataDataDataDataDataDataLearnerLearner
Drawn from the OWS workflow file attached to the project: the widgets, their icons, their category colours and the channel names on the links, as they appear when opened in Orange.

↔ Drag the diagram sideways to see all of it.

Connections as text (9)
  • File → Data Table (Data)
  • File → Column Statistics (Data)
  • File → Scatter Plot (Data)
  • File → Correlations (Data)
  • File → Distributions (Data)
  • File → Impute (Data)
  • Impute → Test and Score (Data)
  • Linear Regression → Test and Score (Learner)
  • Random Forest → Test and Score (Learner)

KNIME

SourceManipulatorLearnerPredictorOtherData portModel port

CSV Reader — SourceCSV ReaderNode 1Column Filter — ManipulatorColumn FilterNode 2Missing Value — ManipulatorMissing ValueNode 3Partitioning — ManipulatorPartitioningNode 4Linear Regression Learner — LearnerLinear RegressionLearnerNode 5Regression Predictor — PredictorRegression PredictorNode 6Numeric Scorer — OtherNumeric ScorerNode 7Linear Correlation — OtherLinear CorrelationNode 8
KNIME nodes with their names in the node repository, their original icons, type colour, shape and ports (a triangle for data, a square for a model) and the status light, so you can build it in the same order. The ready KNWF workflow file is attached under "Project files", and it ran successfully in the KNIME 5.12 engine.

↔ Drag the diagram sideways to see all of it.

Connections as text (8)
  • CSV Reader → Column Filter
  • Column Filter → Missing Value
  • Missing Value → Partitioning
  • Partitioning → Linear Regression Learner
  • Linear Regression Learner → Regression Predictor
  • Regression Predictor → Numeric Scorer
  • Partitioning → Regression Predictor
  • Missing Value → Linear Correlation

Project files

The KNIME file (.knwf) was built on KNIME 5.12 and all its nodes ran successfully in the KNIME engine without opening the interface; open it from File → Import KNIME Workflow.

Results

Actual results computed on the attached files

Pearson correlation with the final grade: study_hours_week 0.739, attendance_pct 0.328, previous_score 0.212, sleep_hours 0.118
scikit-learn 1.9.1 reference, 10-fold CV, shuffle, random_state=42:
• Linear Regression: MAE 4.86 points, RMSE 6.05 points, R² 0.735
• Random Forest: MAE 5.52 points, RMSE 6.88 points, R² 0.657

Evaluation metrics

  • Pearson correlation
  • MAE, RMSE and R²

Interpreting the results

Study hours are the most strongly related to the grade. Linear regression beat the random forest here because the generated relationship is mostly linear; the more complex model is not always the best.

Discussion questions

  • What is the difference between correlation and causation in this data?
  • Why is using the result column data leakage?
  • How do the results change if we remove the incomplete rows instead of imputing them?

Try it in the Regression Lab

Similar projects