Turi创建错误:'module'对象不可调用

时间:2018-05-04 02:07:27

标签: 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()

1 个答案:

答案 0 :(得分:1)

您必须实际调用nearest_neighbor_classifier的value方法。请参阅library API

改为运行以下代码行:

create()