# Regression in Predicting Tenancy Lengths

I'm currently working on a project involving the prediction of tenancy lengths. I've so far managed to get to a point where I've processed the data and pruned my Random Forest model (via sklearn in Python) to the following accuracy levels (in days):

Train MAE: 131
Train R^2: 0.906
Test MAE: 259 (using cross-validation)
Test R^2: 0.651


While the model is decent for the industry, there's more performance to squeeze out of it. It currently overestimates results and has poor accuracy on the test data imo.

I'd like to further develop a Neural Network approach, as my initial implementation of an MLP Regressor seems promising:

Train MAE: 301
Train R^2: 0.582
Test MAE: 338 (using cross-validation)
Test R^2: 0.522


My question is how can I improve my results for the prediction (using Python) other than using GridSearch to play around with the MLPRegression function in sklearn? Are there any other models that could be useful in this situation? (I have tried also decision trees, gradient boosting)

In case it is relevant, my dataset contains ~5000 entries since 2008 onwards of individual tenancies, containing: tenancy dates, rent, repair costs, property information and replacements, client information, etc., currently at 41 variables.

## 1 Answer

You may have done this already, but if your target values are positive integers, it could be worth transforming your output layer in such a way that constrains it to take an appropriate range of values.

Tenancy length values presumably have some recognisable distribution that might fruitfully be modelled by a known statistical process (Poisson process, survival analysis, etc.), and so instead of using your NN to predict the tenancy length directly, you could use the NN to parametrise a relevant probability distribution, and make a point estimate of that distribution in your output layer.

• Hm, that's a pretty good idea, thanks! I have indeed conducted survival analysis on tenancy length previously, so I have some idea on how the distributions look like. The problem is I'd have no idea where to even start to transform my output layer in sklearn's NN. Would I have to create a custom NN or is there something I'm overlooking? – Silviu Tofan Oct 12 '16 at 8:10
• Having a look at the scikit-learn docs for MLPRegressor, it looks like it takes a parameter out_activation_, which is the name of a function to apply at the output layer. – R Hill Oct 12 '16 at 8:56
• Not sure if I understand how that works unfortunately.. Sorry, I'm quite inexperienced with this. – Silviu Tofan Oct 12 '16 at 9:30
• Looking at it a bit more, out_activation_ is an attribute of the model, not a parameter, so you can't set it yourself. It looks like MLPRegressor won't support this, so you probably will have to create a custom NN to achieve this. – R Hill Oct 12 '16 at 9:58
• Just what I was afraid of. Thank you very much. I guess my current predictions have to be enough for the time being until I get the chance to look into how this would be achieved. – Silviu Tofan Oct 12 '16 at 10:04