I am new to machine learning and I am trying to solve a problem where I have to predict if a customer will buy a home insurance product or not.

  1. I have got a dataset which tells me that which of the bank's customer bought a mortgage from the bank.
  2. I have got another data of the customers who bought the mortgage first, then the bank ran a campaign to provide them with home insurance randomly and this dataset tells me that which of the mortgage customers actually bought home insurance from the bank.

Now my job is to predict which customers should I pick for the bank that will have the highest possibility to subscribe to the home insurance product.

I do not have a separate train/test/validation dataset, but just one dataset. How do I approach this problem? Should I create the validation and test data from my original dataset that I have been given? how should I approach this problem to predict correctly?

  • $\begingroup$ How do you believe other train/test/validation data sets are created? $\endgroup$ May 18, 2021 at 19:23
  • $\begingroup$ Maybe I am getting confused here, the train/test/validation datasets are all created from the original dataset itslef? Am I right here? Maybe something like a split of 60%/20%/20% ? and then I can use my training data to build a model and then test it on the valdiation data? $\endgroup$
    – Django0602
    May 18, 2021 at 19:25

1 Answer 1


Usually, with a predictive model, you generate a train and test sample from the original dataset, e.g. by using sklearn.

import numpy as np
from sklearn.model_selection import train_test_split
X, y = np.arange(10).reshape((5, 2)), range(5)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)


Train some model on one set and test on the other by comparing predictions to actual (true) outcomes.

You could also use cross validation, in which case a model is trained on one part of the data (e.g. 4/5 of the data with 5-fold cv) and tested on the remaining 1/5 of the data. This is done for all of the „folds“. See Ch. 5.1. of „Introduction to Statistical Learning“ for more details on that. https://www.statlearning.com/

Simply make sure you obtain a test score based on data not used for training.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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