How onsrajhi/laptop-price-prediction works
Project type and purpose
• This is a self-contained, monolithic ML web application built with Streamlit.
• Purpose: allow end-users to input laptop specs via a web UI and receive a predicted price based on a pre-trained scikit-learn pipeline.
File structure
• Top-level files:
• app.py – the Streamlit app (UI + request handler)
• laptop-prediction.ipynb – exploratory notebook (data cleaning, EDA, model training)
• pipe.pkl – serialized ML pipeline (preprocessing + regression model)
• df.pkl – serialized processed DataFrame (encoders, feature references)
• laptop.csv – original raw dataset
• requirements.txt – Python dependencies
• .devcontainer folder – defines local dev container for consistent environment
README for additional insights
• Data flow: CSV → cleaning/feature-engineering → train/test → pipeline → pickle
• Streamlit app loads pipe.pkl + df.pkl to serve predictions
• Deployment target: Streamlit Cloud
Main components
a. User & Browser (External Actor)
b. Streamlit Web UI (app.py)
c. Business Logic Layer
– Input validation & form handling
– Pipeline loader
d. ML Pipeline (pipe.pkl)
– Feature encoders (from df.pkl)
– Preprocessing transformers
– Regression model
e. Data Artifacts (Data Stores)
– df.pkl: encodings & metadata
– pipe.pkl: trained pipeline
– laptop.csv: raw dataset (used offline)
f. Development Container (.devcontainer) – optional for local dev
Relationships and interactions
1. User opens browser → HTTP request to Streamlit server
2. app.py renders input form → user submits specs
3. app.py loads pipe.pkl & df.pkl from disk (once at startup)
4. Input passed through pipeline → model returns prediction
5. app.py displays result in browser
6. For local dev, .devcontainer ensures consistent environment
Architectural patterns & design principles
• Monolithic, layered architecture (UI + Logic + Model + Data)
• Separation of concerns: UI code in Streamlit calls into a distinct ML pipeline
• Artifacts versioned and immutable (pickle files)
• Dev environment codified via devcontainer
Detail level
• Initialization: Streamlit App loads pipeline at startup
• Request flow for each prediction
• Configuration (e.g., devcontainer for local Dockerized dev)