How themrityunjaypathak/autoiq works
Purpose and Entry Points
AutoIQ is a used-car price-estimation system trained on Cars24 listings. Runtime entry is the FastAPI app at api/main.py, configured through api/config.py; it loads serialized prediction assets from models/pipe.pkl and models/model_freq.pkl. A separate static browser frontend begins at index.html and submits prediction requests through script.js.
Serving API Boundary
The API accepts structured vehicle attributes—brand, model, year, odometer, engine capacity, fuel, transmission, and owner—and returns a formatted price range. api/main.py is the HTTP/control boundary, including health and prediction endpoints; api/config.py supplies environment-driven model locations, allowed CORS origins, and prediction-error metadata. Model deserialization and inference remain server-side.
Browser Client
The frontend is independently deployable static content, suitable for GitHub Pages rather than being hosted by the FastAPI process. index.html captures vehicle inputs, script.js serializes them into a POST /predict request and renders the response, and style.css provides presentation. CORS configuration in api/config.py bridges this client/API deployment boundary.
Prediction Assets and Inference
models/pipe.pkl represents the fitted Scikit-learn preprocessing-plus-regression pipeline, preserving training-time transformations during inference. The pipeline uses categorical encoding, ordinal owner handling, robust numerical scaling, and a tuned stacking regressor composed of Random Forest, XGBoost, Gradient Boosting, and ElasticNet meta-model. models/model_freq.pkl is an auxiliary serialized model-frequency artifact used by serving logic. The API must keep request field names/types aligned with the pipeline’s expected feature schema.
Data Acquisition
Source listings originate from Cars24. The scraping implementation and exploration are centered in scrape_code/scrape_code.ipynb, supported by reusable scraping functions in utils/web_scraping.py. Selenium renders dynamically loaded listing pages; BeautifulSoup parses listing fields; individual detail pages are queried for engine capacity. Raw collected output is stored at scrape_data/scrape_data.csv. Cars24 is an external, schema-fragile dependency outside the serving path.
Data Refinement and Feature Construction
The offline dataset pipeline turns raw listings into progressively cleaned Parquet datasets: clean_data/clean_data.parquet, clean_data/clean_data_with_no_outlier.parquet, and clean_data/clean_data_after_eda.parquet. Cleaning, outlier handling, EDA, and feature preparation are documented as sequential notebook stages in notebooks/step_1_data_preprocessing.ipynb, notebooks/step_2_outlier_detection.ipynb, and notebooks/step_3_exploratory_data_analysis.ipynb. Utilities such as utils/read_data.py and utils/export_data.py define the reusable storage boundary.
Training and Model Promotion
notebooks/step_4_model_building.ipynb trains and evaluates candidate regressors using train/test splitting, cross-validation, and leakage-safe Scikit-learn pipelines. The selected tuned stacking pipeline is serialized into models/pipe.pkl for API use. This is an offline promotion boundary: notebooks/data artifacts produce versioned model files; the API only consumes those files and does not retrain.
Runtime and Deployment
The Python service depends on FastAPI, Pandas, Scikit-learn, and XGBoost; scraping additionally uses Selenium, BeautifulSoup, Requests, and ChromeDriver tooling. Dockerfile packages the service and model artifacts into a container, with runtime environment variables supplied externally. The documented deployment model is Docker locally or via Docker Hub, with the API hosted on Render and the static frontend hosted on GitHub Pages.
Main entry points: main.py FastAPI application · step_4_model_building.ipynb Model training and promotion · scrape_code.ipynb Listing scraper · pipe.pkl Prediction pipeline
Components 17
Browser client
Independently deployed static frontend.
- User browser
- Static prediction UI · Collects vehicle attributes and renders price ranges.
index.html - Request client · Posts form data to /predict.
script.js
Prediction serving
FastAPI inference boundary.
- FastAPI application · Owns health and prediction HTTP endpoints.
api/main.py - Runtime configuration · Provides model locations, CORS origins, and error metadata.
api/config.py - Prediction pipeline · Fitted preprocessing and tuned stacking regressor.
models/pipe.pkl - Model-frequency artifact · Auxiliary serving artifact.
models/model_freq.pkl - Service container · Packages API and prediction assets.
Dockerfile
Offline data pipeline
Acquisition, refinement, and training flow.
- Cars24 listings · Schema-fragile source of used-car listings.
- Listing scraper · Uses browser rendering, parsing, and detail-page lookups.
scrape_code/scrape_code.ipynb - Scraping utilities · Reusable Selenium and BeautifulSoup scraping functions.
utils/web_scraping.py - Raw listings
scrape_data/scrape_data.csv - Preprocessing stage · Cleans raw listings into Parquet datasets.
notebooks/step_1_data_preprocessing.ipynb - Outlier stage · Produces the no-outlier dataset.
notebooks/step_2_outlier_detection.ipynb - EDA and feature preparation · Produces the training-ready dataset.
notebooks/step_3_exploratory_data_analysis.ipynb - Training-ready data
clean_data/clean_data_after_eda.parquet - Model training and promotion · Evaluates candidates and serializes the selected pipeline.
notebooks/step_4_model_building.ipynb
Connections 18
- User browser → Static prediction UI: loads
- Static prediction UI → Request client: uses
- Request client → FastAPI application: POST /predict · Sends structured vehicle attributes.
- Runtime configuration → FastAPI application: configures · Supplies CORS and model paths.
- FastAPI application → Prediction pipeline: loads and infers with
- FastAPI application → Model-frequency artifact: loads
- Service container → FastAPI application: packages
- Service container → Prediction pipeline: includes
- Cars24 listings → Listing scraper: listing pages
- Scraping utilities → Listing scraper: supports
- Listing scraper → Raw listings: writes
- Raw listings → Preprocessing stage: input
- Preprocessing stage → Outlier stage: cleaned Parquet
- Outlier stage → EDA and feature preparation: no-outlier Parquet
- EDA and feature preparation → Training-ready data: writes
- Training-ready data → Model training and promotion: training input
- Model training and promotion → Prediction pipeline: promotes serialized model
- Model training and promotion → Model-frequency artifact: serializes auxiliary artifact