House price prediction

IntermediateRegression

Problem description

Estimating the price of a house from its area, number of rooms, age and distance from the centre. The data is synthetic.

Objectives

  • Building and comparing regression models
  • Reading MAE, RMSE and R²
  • Understanding when a linear model is enough

Problem type

Regression

Dataset

Tools used

Algorithms

Implementation steps

  1. In KNIME: File → Import KNIME Workflow… and choose house-prices.knwf, then Execute all.
  2. Open house-prices.ows in Orange.
  3. Compare Linear Regression, Tree and Random Forest in Test and Score.
  4. In WEKA: open houses-synthetic.arff → Classify → LinearRegression, then M5P and RandomForest.
  5. Plot the errors against the true values to look for a pattern.

Workflow diagram

Orange

DataEvaluateVisualizeModel

File FileData Table Data TableTest and Score Test and ScoreScatter Plot Scatter PlotLinear Regression Linear RegressionTree TreeRandom Forest Random ForestDataDataDataLearnerLearnerLearner
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 (6)
  • File → Data Table (Data)
  • File → Test and Score (Data)
  • File → Scatter Plot (Data)
  • Linear Regression → Test and Score (Learner)
  • Tree → Test and Score (Learner)
  • Random Forest → Test and Score (Learner)

KNIME

SourceManipulatorLearnerPredictorOtherData portModel port

CSV Reader — SourceCSV ReaderNode 1Missing Value — ManipulatorMissing ValueNode 2Partitioning — ManipulatorPartitioningNode 3Linear Regression Learner — LearnerLinear RegressionLearnerNode 4Regression Predictor — PredictorRegression PredictorNode 5Numeric Scorer — OtherNumeric ScorerNode 6Random Forest Learner (Regression) — LearnerRandom Forest Learner(Regression)Node 7Random Forest Predictor (Regression) — PredictorRandom ForestPredictor (Regression)Node 8Numeric Scorer — OtherNumeric ScorerNode 9
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 (10)
  • CSV Reader → Missing Value
  • Missing Value → Partitioning
  • Partitioning → Linear Regression Learner
  • Linear Regression Learner → Regression Predictor
  • Regression Predictor → Numeric Scorer
  • Partitioning → Regression Predictor
  • Partitioning → Random Forest Learner (Regression)
  • Random Forest Learner (Regression) → Random Forest Predictor (Regression)
  • Random Forest Predictor (Regression) → Numeric Scorer
  • Partitioning → Random Forest Predictor (Regression)

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

scikit-learn 1.9.1 reference, 10-fold CV, shuffle, random_state=42:
• Linear Regression: MAE 20,712.90, RMSE 26,147.25, R² 0.965
• Decision Tree: MAE 32,930.40, RMSE 41,151.69, R² 0.912
• Random Forest: MAE 23,659.11, RMSE 29,576.34, R² 0.955
And the results of the Orange 3.41.0 library (10-fold, like the default Test and Score settings):
• Linear Regression: MAE 20,761.72, RMSE 26,272.15, R² 0.964
• Tree: MAE 33,034.60, RMSE 40,929.65, R² 0.913
• Random Forest: MAE 25,072.82, RMSE 31,113.13, R² 0.950

Evaluation metrics

  • MAE
  • RMSE
  • R²

Interpreting the results

Linear regression explains about 96% of the variance because the prices were generated with a roughly linear relationship plus noise; in real markets the relationships are more complex and need location and quality features.

Discussion questions

  • Why is RMSE always greater than or equal to MAE?
  • What does R² = 0.96 mean in practice?
  • How do you handle a house outside the range of the training data?

Try it in the Regression Lab

Similar projects