Tutorial — Using BnBInsight
Option A — Install from PyPI (recommended)
The package is published on PyPI and can be installed with pip:
# 1. Create & activate a virtual environment
python -m venv myenv
source myenv/bin/activate # macOS / Linux
# myenv\Scripts\activate # Windows
# 2. Install
pip install bnbinsight
# 3. Verify
python -c "import bnbinsight; print('works')"Option B — Install from source
git clone https://github.com/mbgardin/BnBInsight.git
cd BnBInsight
pip install -e .Step 1 — Load Data
from bnbinsight.data_collection import load_kaggle_data
df = load_kaggle_data("data/raw/kaggle_airbnb.csv")
print(df.shape)
print(df.columns.tolist())Step 2 — Clean Data
from bnbinsight.cleaning import (
clean_price_column,
clean_rating_column,
clean_bedrooms_column,
drop_duplicates_and_nulls,
filter_reasonable_prices,
)
df = clean_price_column(df)
df = clean_rating_column(df)
df = clean_bedrooms_column(df)
df = drop_duplicates_and_nulls(df)
df = filter_reasonable_prices(df)
print(f"Clean rows: {len(df)}")Step 3 — Engineer Features
from bnbinsight.features import parse_amenities_count, create_log_price
df = parse_amenities_count(df)
df = create_log_price(df)
print(df[["price", "log_price", "bedrooms", "rating", "amenities_count"]].head())Step 4 — Run Analysis
from bnbinsight.analysis import run_linear_regression, evaluate_model
from bnbinsight.features import select_model_features
model_df = select_model_features(df)
model = run_linear_regression(model_df)
print(model.summary())
print(evaluate_model(model))Step 5 — Visualize
from bnbinsight.visualization import plot_price_distribution, plot_price_vs_bedrooms
plot_price_distribution(df, save_path="plots/price_dist.png")
plot_price_vs_bedrooms(df, save_path="plots/price_bed.png")Step 6 — Launch Dashboard
You can run the dashboard locally:
pip install bnbinsight[app] # includes streamlit
streamlit run app/streamlit_app.pyOr visit the live deployment at bnbinsight.streamlit.app.
Links
| Resource | URL |
|---|---|
| GitHub Repository | github.com/mbgardin/BnBInsight |
| Live Streamlit Dashboard | bnbinsight.streamlit.app |
| PyPI Package | pypi.org/project/bnbinsight |