πͺ¨ Sonar Rock vs Mine Prediction using Logistic Regression This project uses a Logistic Regression model to classify sonar signals as either rock or mine based on the sonar dataset from the UCI Machine Learning Repository. The dataset contains 60 numerical features representing sonar signal strengths bounced off surfaces.
π Problem Statement Sonar signals are used to detect objects under the sea. The goal is to predict whether the object is a rock or a mine (metal cylinder) based on the sonar return signal data.
π Dataset Source: UCI Sonar Dataset
Features: 60 numeric attributes (energy values in different frequency bands)
Target:
R: Rock
M: Mine
βοΈ Technologies Used Python π
NumPy
Pandas
Matplotlib / Seaborn
Scikit-learn
π Model Used Logistic Regression
Suitable for binary classification
Outputs probability and class label (0 or 1)
Used with scaling and train-test split
π How to Run
- Clone the Repository bash Copy Edit git clone https://github.com/Divyanshu-spec -code/sonar-rock-vs-mine.git cd sonar-rock-vs-mine
- Install Dependencies bash Copy Edit pip install -r requirements.txt
- Run the Code bash Copy Edit python sonar_logistic_regression.py π§ͺ Project Workflow Importing Libraries
Loading the Dataset
Data Exploration and Visualization
Data Preprocessing
Label encoding (R β 0, M β 1)
Train-test split
Feature scaling
Model Training
Logistic Regression with sklearn
Model Evaluation
Accuracy score
Confusion matrix
Classification report
Making Predictions
π Results Accuracy: ~85%β90% (varies slightly due to train-test split randomness)
Model is able to distinguish between rock and mine objects effectively.