Turi Create Error : 'module' object not callable

Turi Create Error : 'module' object not callable

我正在尝试在 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)