BuyOrNot is a machine learning project that predicts whether a customer will make a purchase (it's generic, it could be a product, house, etc.) based on their demographics, using scikit-learn pipelines, preprocessing, and hyperparameter tuning. It is a binary classification problem, and basically the project gives an answer to this question: Based on age, income, gender, education level, marital status, children, job type, credit score, previous purchases and interest in newsletters, will this person make a purchase?
Where the output (purchased column) can be the following:
- 1 = the person purchased (something)
- 0 = the person did not purchase
It's designed for learning, experimentation, and potential real-world adaptation.
The generated purchase data contains almost equal amounts of yes and no values.

Final Model Accuracies:
- RandomForest: Accuracy = 0.7650
- GradientBoosting: Accuracy = 0.7550
- LogisticRegression: Accuracy = 0.8050
- SVC: Accuracy = 0.8150
Best Model: SVC with Accuracy = 0.8150
- Realistic dataset generation (age, income, gender)
- Full data preprocessing (numeric + categorical) to filter missing values
- Training multiple models (i.e. RandomForest, GradientBoosting, LogisticRegression and SVC) using pipelines
- Tuning hyperparameters with GridSearchCV cross-validation
- Evaluation with confusion matrix
- Feature importance visualization
- Saving and reloading the model
- Making predictions on new data
- Python 3.10+
- pandas, numpy, matplotlib
- scikit-learn
- joblib
git clone https://github.com/yourusername/BuyOrNot.git
cd BuyOrNot
pip install -r requirements.txt- Train the model
python src/train_model.py- Make predictions
python src/predict.pynew_person = pd.DataFrame({
'age': [35],
'income': [70000],
'gender': ['Female'],
'education_level': ['PhD'],
'marital_status': ['Single'],
'children': [1],
'job_type': ['Professional'],
'previous_purchase': [0],
'credit_score': [850],
'interested_in_newsletter': [False]
})
prediction = model.predict(new_person)
# Prediction Result
# ========================
# Will the person purchase? → Yes
# ========================MIT License. Feel free to fork and adapt.

