Registrations Closing Soon for DevOps Certification Training by CloudxLab | Batch Starts on 18th April

  Enroll Now

Spam Classifier - Split the Dataset

Before we start learning about the data, let's split it into a training set and a test set.

  • First, let's import Numpy:

    import << your code goes here >> as np
  • Then, import train_test_split from sklearn:

    from sklearn.model_selection import << your code goes here >>
  • Now let's collate the data in X and y variables:

    X = np.array(ham_emails + spam_emails)
    y = np.array([0] * len(ham_emails) + [1] * len(spam_emails))
  • Finally, let's split the dataset into a 80/20 ratio:

    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=<< your code goes here >>, random_state=42)

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...