选择理想的数据集
现在需要去除 ufo 数据集中一些不必要的特征。由于 country 列已编码为 country_enc,您可以保留它,并删除与地理位置相关的其他列:city、country、lat、long 和 state。
您已经构造了 month 和 year 列,因此不再需要 date 或 recorded 列。您还将 seconds 标准化为 seconds_log,所以可以删除 seconds 和 minutes。
您已对 desc 向量化,因此可以删除它。目前先保留 type。
您也可以删除 length_of_time 列,因为在提取出 minutes 之后它已不再需要。
本练习是课程的一部分
Python 中的机器学习预处理
练习说明
- 创建需要删除的所有列名列表
to_drop。 - 从
ufo中删除这些列。 - 使用您之前创建的
words_to_filter()函数;传入vocab、vec.vocabulary_、desc_tfidf,并将最后一个参数设为保留前4个词。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Make a list of features to drop
to_drop = [____]
# Drop those features
ufo_dropped = ufo.____
# Let's also filter some words out of the text vector we created
filtered_words = ____(____, ____, ____, ____)