May 13, 2023

Mobile Price Classification

Mobile phones are the best selling electronic devices as people keep updating their cell phones whenever they find new features in a new device. Thousands of mobiles are sold daily, and it is difficult for someone who is considering changing his or her mobile to decide how much to invest in a new mobile.

Here, we present a machine learning project on a mobile price classification model where we train a model to classify the price range of mobiles using Python. This task is based on classifying the price range of cell phones and not predicting the actual prices, so we will train a classification model to classify the price range of cell phones as: 0 (low cost), 1 (medium cost), 2 (high cost), 3 (very high cost).

1- We start by importing the necessary Python libraries and the dataset:

2- Let's explore our dataset:

So the dataset contains 21 columns and luckily this dataset has no missing values, so we can just start by training the model, but before that let’s take a look at the correlation between the features in the dataset:

3- Let's prepare our data:

This dataset has no categorical features, so we can just use this data without any transformation because all the features of the dataset are numeric. But to train a model, it is very important to standardize or normalize the data and break it up into training and testing sets. So let’s standardize the dataset and divide the data into 80% training and 30% testing:

4- Mobile Price Classification Model:

As it is a classification problem, we will use the logistic regression algorithm provided by Scikit-learn and we will then calculate the accuracy of the model:

The model gives an accuracy of about 95.83% which is great. Now let’s have a look at the predictions made by the model:

Now let's look at the number of cell phones ranked for each price range:

We notice that the most purchased mobiles are respectively classified as very high, medium, low and finally high.