BaşlayınÜcretsiz Başlayın

Creating a flag

This time you are going to create an actual flag variable that gives a 1 when the emails get a hit on the search terms of interest, and 0 otherwise. This is the last step you need to make in order to actually use the text data content as a feature in a machine learning model, or as an actual flag on top of model results. You can continue working with the dataframe df containing the emails, and the searchfor list is the one defined in the last exercise.

Bu egzersiz

Fraud Detection in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use a numpy where condition to flag '1' where the cleaned email contains words on the searchfor list and 0 otherwise.
  • Join the words on the searchfor list with an "or" indicator.
  • Count the values of the newly created flag variable.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create flag variable where the emails match the searchfor terms
df['flag'] = ____.____((df['clean_content'].___.____('____'.____(____)) == True), 1, 0)

# Count the values of the flag variable
count = df['flag'].____()
print(count)
Kodu Düzenle ve Çalıştır