A machine learning project that predicts laptop prices based on various hardware specifications using advanced regression models and a user-friendly web interface.
This project leverages machine learning to predict laptop prices from technical specifications including brand, processor, RAM, GPU, display features, and more. The system uses a Gradient Boosting Regressor model with an R² score of 88.04% and provides an interactive Streamlit web application for real-time predictions.
- High Accuracy: Gradient Boosting Regressor with 88.04% R² score
- Interactive Web App: User-friendly Streamlit interface
- Comprehensive Feature Set: 10+ technical specifications considered
- Real-time Predictions: Instant price estimates
- Data-driven Insights: EDA and feature engineering included
- Model Comparison: Evaluation of 9 different ML algorithms
- Python 3.8 or higher
- pip package manager
-
Clone the repository
git clone https://github.com/yourusername/Laptop-Price-Prediction.git cd Laptop-Price-Prediction -
Install dependencies
pip install streamlit pandas numpy scikit-learn xgboost matplotlib seaborn
-
Run the application
streamlit run app.py
-
Open your browser Navigate to
http://localhost:8501to access the web application.
- Data Collection: Laptop specifications dataset (1,303 samples)
- Preprocessing: Feature engineering, encoding, and scaling
- Feature Engineering: PPI calculation, binary indicators for touchscreen/IPS
- Model Training: 9 ML algorithms compared
- Deployment: Pickle serialization with Streamlit frontend
| Feature | Type | Description |
|---|---|---|
| Company | Categorical | Laptop brand (Dell, HP, Lenovo, etc.) |
| TypeName | Categorical | Laptop type (Notebook, Gaming, Ultrabook, etc.) |
| CPU | Categorical | Processor type and generation |
| RAM | Numerical | Memory in GB (2-128GB) |
| GPU | Categorical | Graphics card manufacturer |
| OS | Categorical | Operating system |
| Weight | Numerical | Weight in kg |
| Touchscreen | Binary | Touchscreen capability |
| IPS | Binary | IPS display panel |
| PPI | Numerical | Pixels per inch |
| Model | R² Score | MAE | MSE |
|---|---|---|---|
| Gradient Boosting | 0.8804 | 0.1443 | 0.0378 |
| XGBoost | 0.8775 | 0.1459 | 0.0387 |
| Random Forest | 0.8668 | 0.1565 | 0.0420 |
| Decision Tree | 0.8175 | 0.1828 | 0.0576 |
| SVR | 0.8144 | 0.1811 | 0.0586 |
| AdaBoost | 0.8049 | 0.1967 | 0.0616 |
| Lasso | 0.7925 | 0.1951 | 0.0655 |
| Ridge | 0.7903 | 0.1967 | 0.0662 |
| Linear Regression | 0.7850 | 0.2001 | 0.0679 |
- Best Model: Gradient Boosting Regressor (300 estimators)
- Training/Test Split: 85%/15%
- Target Variable: Log-transformed price (for better distribution)
- Feature Encoding: OneHotEncoder for categorical variables
- Pipeline: ColumnTransformer + GradientBoostingRegressor
- RAM has the strongest correlation with price (r = 0.73)
- PPI (Pixels Per Inch) shows significant impact on pricing
- Gaming laptops and workstations command premium prices
- Apple laptops tend to be priced higher than competitors
- Touchscreen and IPS display features add value
- Removed duplicates and low-frequency brands
- Engineered PPI feature from screen resolution and size
- Created binary features for touchscreen and IPS displays
- Simplified CPU categorization (Intel Core i3/i5/i7 vs others)
- Grouped operating systems into major categories
- Applied log transformation to price for normality
- Brand Selection: Choose from major laptop manufacturers
- Type Selection: Notebook, Gaming, Ultrabook, 2-in-1, etc.
- Hardware Specs: CPU, RAM, GPU configuration
- Display Options: Touchscreen, IPS panel, PPI settings
- System Info: Operating system and weight
- Instant Results: Real-time price prediction
- Frontend: Streamlit
- Backend: Python/Scikit-learn
- Model Serialization: Pickle
- Data Processing: Pandas, NumPy
Laptop-Price-Prediction/
├── README.md # Project documentation
├── LICENSE # MIT License
├── app.py # Streamlit web application
├── Laptop_Price_Prediction.ipynb # Jupyter notebook with full analysis
├── laptop_price.csv # Raw dataset
├── df.pkl # Processed dataframe
├── pipe.pkl # Trained model pipeline
└── requirements.txt # Python dependencies (create if needed)
import pickle
import numpy as np
# Load model and data
df = pickle.load(open('df.pkl', 'rb'))
pipe = pickle.load(open('pipe.pkl', 'rb'))
# Make prediction
input_data = np.array([['Dell', 'Notebook', 'Intel Core i5', 8, 'Intel', 'Windows 10', 1.5, 0, 1, 141]])
prediction = pipe.predict(input_data)
price = np.exp(prediction[0]) # Reverse log transform
print(f"Predicted price: ${price:.2f}")- Select laptop brand from dropdown
- Choose laptop type (Gaming, Ultrabook, etc.)
- Configure hardware specifications
- Set display preferences
- Click "Predict" for instant price estimate
- Source: Laptop price dataset with 1,303 samples
- Features: 13 original features, engineered to 10 final features
- Target: Price in Euros (converted to local currency)
- Time Period: Contemporary laptop models
- Price Range: ~$200 - $25,000
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Add more laptop brands and models
- Implement deep learning models
- Add price trend analysis over time
- Include user reviews and ratings
- Deploy as cloud-based API
- Add mobile-responsive design
- Implement batch prediction feature
This project is licensed under the MIT License - see the LICENSE file for details.
- Dataset providers for comprehensive laptop specifications
- Scikit-learn team for excellent ML tools
- Streamlit team for the web framework
- Open-source community for inspiration and tools
If you have any questions or suggestions, feel free to reach out:
- Create an issue in this repository
- Connect on LinkedIn
- Email: surajgrao0203@gmail.com
⭐ If this project helped you, please give it a star!