python - 图里创建错误: 'module' object not callable

标签 python python-3.x machine-learning graphlab

我正在尝试在 Turi Create 中实现最近邻分类器,但是我不确定我收到的这个错误。当我创建实际模型时会出现此错误。我正在使用 python 3.6 如果有帮助的话。

错误:

Traceback (most recent call last):
  File "/Users/PycharmProjects/turi/turi.py", line 51, in <module>
    iris_cross()
  File "/Users/PycharmProjects/turi/turi.py", line 37, in iris_cross
    clf = tc.nearest_neighbor_classifier(train_data, target='4', features=features)
TypeError: 'module' object is not callable

代码:

import turicreate as tc
import pandas as pd

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn import datasets

import time
import numpy as np

#Iris Classification Cross Validation
def iris_cross():
    iris = datasets.load_iris()
    features = ['0','1','2','3']
    target = iris.target_names
    x = iris.data
    y = iris.target.astype(int)

    undata = np.column_stack((x,y))
    data = tc.SFrame(pd.DataFrame(undata))
    print(data)

    train_data, test_data = data.random_split(.8)

    clf = tc.nearest_neighbor_classifier(train_data, target='4', features=features)

    print('done')

iris_cross()

最佳答案

您必须实际调用nearest_neighbor_classifier的create()方法。请参阅library API .

改为运行以下代码行:

clf = tc.nearest_neighbor_classifier.create(train_data, target='4', features=features)

关于python - 图里创建错误: 'module' object not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50166146/

相关文章:

python - 有没有办法找到带有标准库的应用程序的路径?

python - 使用 Python 和 OpenCV 的通用填充形状

python - PySerial 非阻塞读取循环

Python 'Logger' 模块双重记录

二进制数据的随机森林

python - 文本分割 : Algorithm to match input with the longest words from the dictionary

python - pylint bad-format-string的解释

python - 如何重新安装损坏的 pip?

python - 使用 TF-IDF 分数进行文本分类的 KNN

machine-learning - 如何使用tensorflow获取inception模型中分类图片的热图或x y坐标(边界框)