# Predicting whether house is sold: regression or classification

I am new to machine learning (I am currently following the Udemy course machine learning from A-Z). Basically, I would like to reproduce the following analysis (https://www.datasciencecentral.com/profiles/blogs/predicting-house-sales)

My aim is to predict if a house to going to be sold in the coming year. I have an apartment database with the following info:

• size
• owner name
• sex
• a few socio-demographic features
• When the apartment was last sold (date, target prediction variable)

I am not sure how to take into account this time component of the variable I am trying to predict:

• should I consider this as a regression model trying to compute the predicted sales date?
• should I consider this more of a classification problem with the y value being 1 if the apartment is predicted to be sold in the coming year. If so, how do I have to modify my dataset structure in order to train the model (should I represent I represent 1 apartment for each year and the outcome?).

What model would you recommend considering I am trying to model rare events? (sale likelyhood is 5% per year on average).

People seem to be using different models to achieve this: Cox (survival analysis), Random forest...

• Do I understand correctly that you are trying to predict the sale of $houses$ based on $apartment$ data? – StatsStudent Jan 15 at 16:52

My aim is to predict if a house to going to be sold in the coming year.

So your aim is classification. For such problem you can use logistic regression to predict the probability that it is going to be sold, or other classification algorithm (e.g. random forest, XGBoost, kNN etc). For hints what to use with imbalanced classes, check questions tagged as , but logistic regression doesn't have problems with imbalanced classes.

This would be a regression problem if you were going to predict things like the price for the house, or other numeric value.

If you were going to predict the time that you are going to wait until it gets sold, you would be possibly using survival analysis.

• – kjetil b halvorsen Jan 15 at 20:12
• @kjetilbhalvorsen honestly, who cares? This is a terminology used everywhere in machine learning. I don't think that it is something worth discussing for a beginner. Moreover, the second sentence says that it predicts probabilities. – Tim Jan 15 at 20:37
• Thanks a lot for your answer this is really helpful. I am checking out the un-balanced classes topics. How would you take into account the time component in the model? (let's say instead of predicting the house expected to by sold in the coming year, you want the houses expected to be sold in the next 6 months) Thanks a lot for your help – Chris Jan 16 at 8:07
• @Chris then simply train on subset of the data in the 6-month window time. – Tim Jan 16 at 8:12
• Thanks a lot I managed to run the algorithm on the 6 months subset but I feel that model training is not benefiting from all the historical data. I ran the model as of today, so I used all the houses sold between august 2018 and dec 2019 and marked them as 1 in my y vector Now If I am placing myself in August 2018, I would like to use the houses sold bewteen Jan 2018 and July 2018 And do this over all the historical data – Chris Jan 17 at 9:11