【问题标题】:AttributeError: module 'utils' has no attribute 'make_labels' in featuretools in PythonAttributeError:模块'utils'在Python的featuretools中没有属性'make_labels'
【发布时间】:2019-07-10 23:18:24
【问题描述】:

我正在尝试遵循名为:使用自动化特征工程预测客户的下一次购买的 Featuretools 教程

有关 Featuretools 的更多信息,请看这里:https://docs.featuretools.com/index.html

数据可以在这里获取:https://www.instacart.com/datasets/grocery-shopping-2017

当我尝试运行教程(jupyter notebook)中包含的命令时,我遇到了这个异常:

import featuretools as ft
from dask import bag
from dask.diagnostics import ProgressBar
import pandas as pd

import utils

from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import cross_val_score
import os
ft.__version__

label_times = utils.make_labels(es=es,
                                product_name = "Banana",
                                cutoff_time = pd.Timestamp('March 15, 2015'),
                                prediction_window = ft.Timedelta("4 weeks"),
                                training_window = ft.Timedelta("60 days"))

AttributeError: module 'utils' has no attribute 'make_labels'

es 对象是 featuretools 中的一个 'EntitySet' 类对象。

我使用以下命令创建了es:

es = es.entity_from_dataframe(entity_id = 'orders',
                             dataframe = orders,
                             index = 'order_id',
                             variable_types = {

                                 'user_id' : ft.variable_types.Categorical,

                                 'eval_set' : ft.variable_types.Categorical,

                                 'order_number' : ft.variable_types.Numeric,

                                 'order_dow' : ft.variable_types.Numeric,

                                 'order_hour_of_day' : ft.variable_types.Numeric,

                                 'days_since_prior_order' : ft.variable_types.Numeric
                             })

es = es.entity_from_dataframe(entity_id = 'products',
                             dataframe = products,
                             index = 'product_id',
                             variable_types = {

                                 'product_name' : ft.variable_types.Categorical,

                                 'aisle_id' : ft.variable_types.Categorical,

                                 'department_id' : ft.variable_types.Categorical
                             })

es = es.entity_from_dataframe(entity_id = 'departments',
                             dataframe = departments,
                             index = 'department_id',
                             variable_types = {

                                 'department' : ft.variable_types.Categorical
                             })

es = es.entity_from_dataframe(entity_id = 'aisles',
                             dataframe = aisles,
                             index = 'aisle_id',
                             variable_types = {

                                 'aisle' : ft.variable_types.Categorical
                             })

【问题讨论】:

    标签: python-3.x featuretools


    【解决方案1】:

    您似乎缺少 util.py 文件。确保在 GitHub 上克隆存储库并在存储库中运行代码。您可以使用以下命令克隆它

    git clone https://github.com/Featuretools/predict-next-purchase.git
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-28
      • 2023-04-06
      • 2018-06-16
      • 2015-03-09
      • 2020-10-18
      相关资源
      最近更新 更多