# Which classifier should I use for a dataset with one feature?

I have a labeled dataset composed of 3000 data. Its single feature is the price of the house and its label is the number of bedrooms.

Which classifier would be a good choice to classify these data?

• A simple correlation coefficient? Apr 12, 2020 at 12:06
• Have you plotted and visualized your data already? A simple linear regresión might do Apr 14, 2020 at 1:23

It is not really a metter of what model, but if it is possible at all to predict what you're trying to predict. Let's take a similar dataset from kaggle: California Housing Prices

This dataset contains house prices and other information among which the number of bedrooms per house. As suggested by Oliver in the comments we can compute the Person coefficient to estimate the correlation between the two variables.

import pandas as pd
from scipy.stats import pearsonr

df = df.apply(lambda row: row[df['total_bedrooms'] <= 20]) # select subset of dataframe for sake of clarity
df.dropna(inplace=True)

x = df['median_house_value'] # our single feature
y = df['total_bedrooms'] # target labels

print('Correlation: \n', pearsonr(x,y))


Out:

>>Correlation:
>>(-0.14015312664251944, 0.12362969210761204)


The correlation is pretty low, which means that the price and number of bedrooms are basically not related. We can also plot the points to check that indeed there is no correlation at all.

df.plot(x='total_bedrooms',y='median_house_value',kind='scatter')


Out: Training a model to predict the number of bedrooms uniquely from the price would mean to find a function that can interpolate all those points, which is an impossible task since we have several different prices for houses with the same amount of bedrooms.

The only way to tackle a problem like this would be to expand the dimensionality of the data, for example by using a Support Vector Machine with a non linear kernel. But even with non linear kernels you can't do miracles, so if you're dataset looks like this one, the only solution would be to expand your dataset to include extra features.

• Thanks for your explanation, I think you're right. Apr 14, 2020 at 7:22

Classification can be performed on structured or unstructured data. Classification is a technique where we categorize data into a given number of classes.

Based on my project in price classification, when i compared into the 5 models, i got a higher score on a Random Forest Classifier compared to Decision Tree, SVM, Naive Bayes, Logistic Regression.

If your data is labeled, but you only have a limited amount, you should use a classifier with high bias (for example, Naive Bayes). I'm guessing this is because a higher-bias classifier will have lower variance, which is good because of the small amount of data

if you use just one feature for dataset, i'm recommend a Algorithm Naive Bayes Classifier because Naive Bayes is a method using probability and statistical methods. And we can also get the total data train and its accuracy value by using.

I think no matter you use one or more feature for dataset. You can compare the classification algorithms regarding the accuracy provided by the algorithm. Like compare naive bayes with svm method, it based on your problem set.