NYC House Types Classifier

A scikit-learn classification project that predicts the type of accommodation listed in New York City Airbnb data.

The model classifies each listing into one of these room_type categories:

  • Entire home/apt
  • Private room
  • Shared room

This project is intended as an educational baseline for exploring tabular data, feature preprocessing, model comparison, and hyperparameter tuning.

Model Details

  • Task: Multiclass tabular classification
  • Target variable: room_type
  • Framework: scikit-learn
  • Saved format: .pkl via joblib
  • Saved model: House_Types_Classifier.pkl

The workflow compares Logistic Regression, Decision Tree, Random Forest, and Gradient Boosting classifiers. Random Forest is also evaluated with Grid Search and Randomized Search hyperparameter tuning.

Dataset

The dataset contains NYC Airbnb listing records with information about listing location, price, minimum stay, reviews, host listings, and availability.

Raw columns

  • id
  • name
  • host_id
  • host_name
  • neighbourhood_group
  • neighbourhood
  • latitude
  • longitude
  • room_type
  • price
  • minimum_nights
  • number_of_reviews
  • last_review
  • reviews_per_month
  • calculated_host_listings_count
  • availability_365

The target column is room_type.

Preprocessing

The notebook applies the following preparation steps:

  • Removes identifier, name, host, and date fields that are not used as model features.
  • Fills missing reviews_per_month values with zero.
  • Caps price and minimum_nights at their 99th percentiles to reduce the effect of extreme values.
  • Uses median imputation and standard scaling for numeric features.
  • Uses most-frequent imputation and one-hot encoding for categorical features.
  • Splits the data into training and test sets using an 80/20 stratified split.

The preprocessing steps are included in the saved scikit-learn pipeline.

Training and Evaluation

Models are compared using cross-validated accuracy and macro F1 score on the training data, followed by accuracy and macro F1 evaluation on the held-out test set.

The notebook also evaluates tuned Random Forest pipelines using:

  • Grid Search CV
  • Randomized Search CV

Run the notebook to reproduce the model comparison and generate the evaluation results for the current dataset.

How to Use

import joblib
import pandas as pd

model = joblib.load("House_Types_Classifier.pkl")

sample = pd.DataFrame([{
    "neighbourhood_group": "Manhattan",
    "latitude": 40.7536,
    "longitude": -73.9838,
    "price": 225,
    "minimum_nights": 1,
    "number_of_reviews": 45,
    "reviews_per_month": 0.38,
    "calculated_host_listings_count": 2,
    "availability_365": 355
}])

prediction = model.predict(sample)
print(f"Predicted room type: {prediction[0]}")

The model expects the feature columns used by the preprocessing pipeline. The pipeline handles imputation, scaling, and categorical encoding during prediction.

Limitations

  • The model reflects patterns in this dataset and may not generalize to other cities or time periods.
  • Listing prices, availability, and review behavior can change over time.
  • The dataset may contain sampling, reporting, and geographic bias.
  • Predictions should be treated as estimates for learning and experimentation, not as authoritative property classifications.

Files

  • notebook.ipynb - Full workflow covering data loading, EDA, cleaning, preprocessing, training, tuning, and evaluation.
  • data.csv - NYC Airbnb listing dataset.
  • House_Types_Classifier.pkl - Saved scikit-learn classification pipeline.
  • pyproject.toml - Project metadata and Python dependencies.

License

Released under the MIT License. Use freely for learning and experimentation.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support