處理少見的類別
有些特徵的類別很多,但各類別出現的次數分布非常不平均。以資料科學常用的程式語言為例,常見的有 Python、R、Julia,但也可能有人使用較客製的選擇,如 FORTRAN、C 等。這種情況下,你可能不想為每個值都建立一個特徵,而只保留比較常見的那些。
本練習屬於課程
Feature Engineering for Machine Learning in Python
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a series out of the Country column
countries = so_survey_df.____
# Get the counts of each category
country_counts = countries.____
# Print the count values for each category
print(country_counts)