3
$\begingroup$

I want to build a classification algorithm that will predict multiple values for a set of features. For instance, lets say I have a customer demographic data like Income, age, sex, city and I want to predict 5 top products they will buy: like if a customer is male, has income less than 30k, lives in Tier1 city and has age 20-35 years--then the output is: 1. Mobile 2. Car 3. Furniture i.e., there are three outputs which means they would most probably buy Mobile, Car and Furniture with decreasing value of probability. Which algorithm will be best suited for this problem?

$\endgroup$
1
  • $\begingroup$ This is either multiclass, and you're interested in retrieving probabilities, or multilabel. What would your training data look like? $\endgroup$ Feb 28 '20 at 13:10
1
$\begingroup$

Your problem can be considered as multiclass classification problem. So, you have a dataset of features X and the predictor y. Where X contain Income, age, sex,etc. and y is an item that one customer will buy with higher probability.

To achieve your goal and predict the probability of a customer you can use any classifier from scikit-learn Library (if you use python) and call the method predict_proba after you fit the classifier, as shown in the following example:

from sklearn.datasets import make_classification
from sklearn.ensemble import RandomForestClassifier

# Make a random multiclass classification problem
X, y = make_classification(n_samples=1000,
                           n_features=10,
                           n_informative=10,
                           n_redundant=0,
                           n_repeated=0,
                           n_classes=5,
                           random_state=0,
                           shuffle=False)

# Fit any classifier
rfc = RandomForestClassifier(n_jobs=-1,max_features= 'sqrt' ,n_estimators=50, oob_score = True) 
rfc.fit(X,y)

# Prediction for one example
one_example = X[10,:].reshape(1,-1)
outcome     = rfc.predict_proba(one_example)

The outcome of this problem with 5 classes is

array([[0.76, 0.12, 0.02, 0.06, 0.04]])

Which represent the probability of each class for this example (or customer in your case)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.