The above referenced project predicts the price range of mobile phones based on hardware specifications using machine learning.
This project takes input features like RAM, battery life, camera specs, screen, and connectivity attributes to build models that classify mobiles into one of four price categories:
- 0 – low cost
- 1 – medium cost
- 2 – high cost
- 3 – very high cost
- Supports multiple ML algorithms: Logistic Regression, KNN, SVM, Decision Trees, Random Forest
- Includes EDA, preprocessing, and feature engineering
- Generates model evaluation reports: accuracy, confusion matrix, classification report
- Saves the best-performing model for reuse/prediction
- Python 3.x
- pandas, NumPy
- scikit-learn
- Jupyter Notebook
- matplotlib / seaborn
- Python 3.8+
- Git
- pip
git clone https://github.com/Ogutu01/Mobile-Price-Classifier.git
cd Mobile-Price-Classifier
# (Optional) create & activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtIf requirements.txt is missing, manually install:
pip install pandas numpy scikit-learn matplotlib seaborn jupyterjupyter notebookOpen notebooks/Mobile_Price_Classifier.ipynb to explore EDA, preprocessing steps, model training, and evaluation.
Inside the notebook:
- Preprocess dataset (handle missing values, scale features)
- Split into train/test
- Train multiple classifiers
- Evaluate using metrics & select the best model
- Save the winning model as
model.pkl
from src.predict import load_model, predict_price
model = load_model("model.pkl")
features = {
"battery_power": 1500,
"ram": 2048,
"pc": 12,
"fc": 5,
# Add all required features...
}
print("Predicted price range:", predict_price(model, features))Mobile-Price-Classifier/
├── data/
│ └── images
└──test_data_with_oredictions.csv
└──test.csv
└──train.csv
├── notebooks/
│ └── index.ipynb
├── model.pkl
├── requirements.txt
└── GEN_AI(Updated)_README.md
- Jupyter won't run: Ensure
jupyteris installed and you're in the project root. - Module import errors: Activate your virtual environment before running scripts/notebooks.
- Error loading model: Make sure
model.pklexists and paths inapp.pyare correct. - Poor model accuracy: Tune hyperparameters, try different test/train splits, or add more features.
Contributions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/YourFeature) - Make changes and add tests
- Commit with clear messages (
git commit -m "Add XYZ") - Push to your branch and open a PR
Please follow existing code style and document new features.
This project is open-source and distributed under the MIT License. See the LICENSE file for more details.
If you've got any questions or found a bug, please open an issue or contact via email.
