With my budget, what part of Dar es Salaam can I actually afford?

With my budget, what part of Dar es Salaam can I actually afford?

TanzaniaDataMachine LearningHousing

TL;DR: I used old-school supervised ML on scraped Instagram rental listings to build a Dar es Salaam rent calculator. Lesson: cleaning beat the model, location + bedrooms explain ~70% of rent, and the real barrier is the 6-months-upfront advance, not the monthly rent. You can access the write-up here.

Recently a number of friends have been trying to rent new places around Dar. New job, rent going up, having a baby, getting married; the usual reasons. And the question they all land on is some version of the same one: “with what I can pay, where in Dar can I actually live?” or “I want to move to Msasani, how much should I budget for?”

I realised I was sitting on something that could help. A while back, as part of a project looking at the dalalis who quietly run Dar es Salaam’s housing market on Instagram, we scraped thousands of their listings (that earlier piece is here). Every listing came with signals: an asking price, a ward, the number of bedrooms, amenities, and so on. Exactly the kind of structured, tabular data that, honestly, made me a little nostalgic.

Because somewhere in the noise of the last two years, “AI” quietly came to mean “a large language model.” I wanted to go back to the other kind. The supervised machine learning I learned first, where you have features and a target and you actually have to think about your data. So, I gave myself an excuse to dust it off.

Two questions, two very different tools

My friends were really asking two questions.

The first: “given my budget, which areas can I afford?” That one is easy, and it does not need a model at all. You can read it straight from the data. Take the real asking prices in each ward, look at the spread, and see where a given budget lands. Pure statistics.

The second is harder: “I like this particular ward, what should I expect to pay there for the kind of place I want?” That is a prediction. To answer it well, you have to build a model that learns how price responds to location, size, and the rest.

I built one. Properly, like the old days.

The ladder

I first started with a dumb baseline that just guesses the typical rent for the area. Then linear regression. Then a random forest. Then XGBoost at the top. Each one had to earn its place by beating the one below it on data it had never seen.

I had to do the data cleaning first, as when looked closely, almost half of the listings were the same property posted again and again. Dalalis repost an apartment for reach, or as a reminder that it is still available. If you ignore that, the same home ends up in both your training and your testing data, and your model looks brilliant while actually having memorised the answer.

What the model actually learned

Once it was working, I asked it the question I find most interesting: what are you really paying attention to? To crack it open I reached for SHAP, a method that shows exactly how each feature pushed a given prediction up or down. Sitting there reading those plots took me straight back to my junior year studying AI and ML at college, the version of this craft that was all features, residuals, and trying to genuinely understand a model rather than just prompt one. I had forgotten how much I enjoyed it.

The answer it gave was clean.

The number of bedrooms and the location together drive the large majority of the rent. Everything else combined, the amenities, the furnishing, the property type, made up a much smaller slice.

SHAP figures from the model: importance bars, a beeswarm, and the bedroom partial-dependence curve

And some signals I thought might matter turned out to be almost noise. The number of likes on a post, for example, told the model close to nothing about price. Popularity is not value.

There is a humbling footnote here. These are asking prices, from one scrape in time, posted on one platform. The model is useful, not magic, and a chunk of its error is simply the messiness of the data rather than a failing of the method.

The useful part

A model sitting in a notebook does not help anyone pack a box. I turned both questions into a small tool.

Tell it your budget and it shows which wards are within reach, ranked by the best areas your money can actually cover, along with the real broker accounts that post there. Or pick a ward and it tells you the ballpark you should be ready for, and which nearby areas cost less for a similar place.

It also surfaces the thing my friends kept running into that no monthly figure captures. The rent is not what stops you. The advance is.

A callout in the calculator: the real barrier isn't the monthly rent, it's the cash you need up front

It is an informal starting point, not financial advice, and definitely not a substitute for official figures.

Try the calculator or read the full write-up, which walks through the model ladder, the SHAP figures and the scoreboard in detail.

This first appeared on LinkedIn.

Share

← All posts

Contact

Let’s talk.

Love to chat about ideas, innovations, or just geek out over tech?

or press ⌘K anywhere
GitHub ↗LinkedIn ↗Email ↗