Pricing a short-term rental property is a complex task influenced by many factors such as location, property type, capacity, host characteristics, and available amenities. Hosts often struggle to determine an optimal price that is competitive in the market while still maximizing revenue. Manual pricing can be inconsistent, subjective, and may not adapt well to market patterns.
The objective of this project is to predict the nightly price of a rental listing based on its attributes. This is a regression problem, where the target variable is a continuous numeric value (price), and the input consists of structured data (numerical and categorical features) as well as unstructured text data (amenities description).
A machine learning regression model can learn patterns from historical rental listings and their prices to make accurate predictions for new or existing listings.
- Feature Representation
Each listing is transformed into a numerical feature vector using:
- Numerical features such as number of bedrooms, bathrooms, location coordinates, and minimum nights
- Categorical features such as neighbourhood, property type, and room type, encoded using one-hot encoding
- Text features derived from the amenities list, converted into numerical form using TF-IDF vectorization
- This preprocessing allows the model to handle heterogeneous data sources in a unified format.
- Model Training
A regression model (e.g., Decision Tree Regressor, Random Forest Regressor, or Gradient Boosting model) is trained on historical data where the true price is known.
During training, the model learns:
- How different features influence price
- Interactions between variables (e.g., location + room type)
- Non-linear relationships between listing attributes and price
- Prediction
Once trained, the model can:
- Predict the expected price for a new listing
- Suggest price adjustments for existing listings
- Support hosts in making data-driven pricing decisions
- Given a listing’s attributes, the model outputs a predicted nightly price.
- Evaluation
Model performance is evaluated using Root Mean Squared Error (RMSE), which measures the average difference between predicted and actual prices. A lower RMSE indicates better predictive accuracy.
Practical Applications
- Helping hosts price listings competitively
- Identifying under-priced or over-priced properties
- Supporting automated pricing tools for rental platforms
- Improving market transparency and consistency
Simply install uv using the following command and sync dependencies.
pip install uv
uv syncTo run Jupyter Notebook run:
uv run jupyter labTo run FastAPI server and access interactive API doc run:
uv run fastapi run predict.pyUsing Dockerfile we can create an image with our trained model, run FastAPI server and expose a port to the api:
docker build -t pricy .
docker run -p 8000:8000 -it --rm pricy
Interactive API can then be found here.
Exploratory Data Analysis is present in notebook.ipynb.
Model training is done post EDA in notebook.ipynb.
Model training lives in its own module train.py and can be reproduced using the command
uv run python train.pyPrediction and API in its own module predict.py and can be run using
uv run fastapi run predict.pyInteractive API should be visible here.
Notebook, model training and prediction api can be easily reproduced as explain in the steps above.
Model is deployed using FastAPI defined in predict.py.
Dependency and Virtual Environment is maintained by uv, via pyproject.toml and uv.lock as defined in Local Setup.
Dockerfile handles creating image that can be used to run API container as defined in Docker Setup.
Public deployment can be accessed here - https://pricy-production.up.railway.app/docs#/default/predict_price_predict_price_post.