Turicreate: [ERROR] turicreate.toolkits._main: Toolkit error: Column type of target 'rating' must be int or str.

Created on 12 Mar 2018  路  3Comments  路  Source: apple/turicreate

Hi, I am getting this error.

[ERROR] turicreate.toolkits._main: Toolkit error: Column type of target 'rating' must be int or str.
Traceback (most recent call last):
  File "imdb_sent_turi.py", line 45, in <module>
    model = tc.sentence_classifier.create(dataset, 'rating', features=['text'])
  File "/Users/airphoenix/Desktop/aclImdb/sent_turi/lib/python3.6/site-packages/turicreate/toolkits/sentence_classifier/_sentence_classifier.py", line 110, in create
    validation_set=validation_set)
  File "/Users/airphoenix/Desktop/aclImdb/sent_turi/lib/python3.6/site-packages/turicreate/toolkits/classifier/logistic_classifier.py", line 312, in create
    seed=seed)
  File "/Users/airphoenix/Desktop/aclImdb/sent_turi/lib/python3.6/site-packages/turicreate/toolkits/_supervised_learning.py", line 398, in create
    options, verbose)
  File "/Users/airphoenix/Desktop/aclImdb/sent_turi/lib/python3.6/site-packages/turicreate/toolkits/_main.py", line 84, in run
    raise ToolkitError(str(message))
turicreate.toolkits._main.ToolkitError: Column type of target 'rating' must be int or str.

My ratings vector is derived from
```or pf in positiveFiles:
with open(pf, "r") as f:
indexCounter = 0
review = f.read()
split_title = pf.split('_')
split_title2 = split_title[1].split('.')
rating = int(split_title2[0])

    ratings_vector.append(rating)
    reviews_vector.append(review)`
and is, when printed, an array of ints.
My code for the model is:

dataset = {'rating': ratings_vector, 'text': reviews_vector}
model = tc.sentence_classifier.create(dataset, 'rating', features=['text'])
```

bug

All 3 comments

@jchuter - Sorry for the unhelpful error message. You need to create a SFrame and then pass that to tc.sentence_classifier.create(...).

So instead of
dataset = {'rating': ratings_vector, 'text': reviews_vector}
do
dataset = tc.SFrame({'rating': ratings_vector, 'text': reviews_vector})

Let's keep this issue open to track putting a better error message here when the input is not an SFrame.

My mistake, and thanks for the response!

Was this page helpful?
0 / 5 - 0 ratings