# Prediction model for marketing to prospective customers (using pandas)

I'm currently working on a part-time project which involves predicting the likelihood of customers going to buy a product using data analytics. The company I'm interning with has given me a customer CSV file with all current customers and their attributes and needs to make a prediction model to classify whether prospects are feasible to pursue or not.

However since they have given me a list of all their successful customers or leads, in marketing terms, is it possible to train a model like K-means with PCA (and k-fold cross validation?) and get results? I have to train my model to fit a value, say 10, which I will add to the CSV, and further test it.

I am using pandas. Another issue is that there is a lot of demographical data, but I managed to overcome it using get_dummies(). The number of columns escalated from about 10 to 47, though.

I'm just entering into the world of data analysis, hence I'm a bit clueless as to what path to take or whether what I'm doing is right.

The exact analysis is called Predictive Lead Scoring/Analysis, in marketing terminology.

EDIT 1

I followed what @HonzaB did and, hence did get a decision tree. However, since I had 40 columns, it looks like this

I had to take a screenshot of it, as it was over 2 MB.

Obviously it's really big, and I have to prune the tree somehow, but I not sure how to do so on pandas. Also, is there any way that I can just generate the best characteristics as a text file or something that can be understood without the help of a data scientist?

EDIT 2

I've read up on a question that is quite similar to what I need to do. Predictive modeling based on RFM scoring indicators. In it there is a link to a paper([Data Mining using RFM Analysis][3]) that talks about rule-based classification. Ideally this is what I need to do, and what is most suitable to the company's need.

I want to know if it's possible to do this on Python/pandas. Or is it possible to traverse the decision tree and generate the rules?

EDIT 3

I found another website Decision trees in python again, cross-validation that uses cross validation and hyperparameter optimisation to get a better solution. Also they have included Python code to get readable code. It's a feasible solution, however it's quite complicated and I can't understand how it works. Will it work?

PS I solved the "really big decision-tree" problem from Edit 1, by reducing max-depth. I didn't know at all.

• Do you know how the model will be used? some examples: Will they call the top 20% of people that are most likely to buy? Will they send letters or emails to all people the model predicts will buy? – TBSRounder Apr 26 '16 at 13:11
• They just want to know how their best customers have been acquired, ie. thru web, tradeshows, free trials; so they can target them later. I need to get this data from the tree/model. I've set bool values for each kind of acquisition, as they were all in one column(hence, used get_dummies(). That's why there are so many columns. If there is a way to remove the ones with less correlation, I would do so, but I don't know how! – TdBm Apr 26 '16 at 19:48
• Hey TdBm, can you help me how did you solve it? – DeshDeep Singh Aug 6 '18 at 14:44
• Well, it's been a really long time since I had done that. In the end, I realized that the data wasn't helping me out (Good data is necessary for good analysis, at least of you are a beginner, like I was at the time). I found out that the number of positive cases was hardly 2-5% of the data, and in hindsight, should have done anomaly analysis instead. I resorted to artificially making positive samples, adding it to the dataset, and trying to make a model with that dataset. – TdBm Aug 7 '18 at 10:26