apple / turicreate

Turi Create simplifies the development of custom machine learning models.
BSD 3-Clause "New" or "Revised" License
11.2k stars 1.14k forks source link

Invalid type conversion when creating sentence_classifier model #198

Closed emannuelOC closed 6 years ago

emannuelOC commented 6 years ago

I'm getting the following error when I try to create a sentence classifier model:

[ERROR] turicreate.toolkits._main: Toolkit error: Invalid type conversion

I've built the project locally as described in BUILD.md and I tried creating the model using different csv files in order to create the SFrame.

My code is as follows:

>>> import turicreate as tc
>>> data = tc.SFrame('sent_train.csv')
Finished parsing file /Users/emannuelcarvalho/Developer/sent_train.csv
Parsing completed. Parsed 100 lines in 0.057555 secs.
------------------------------------------------------
Inferred types from first 100 line(s) of file as 
column_type_hints=[int,str]
If parsing fails due to incorrect types, you can correct
the inferred type list above and pass it to read_csv in
the column_type_hints argument
------------------------------------------------------
Finished parsing file /Users/emannuelcarvalho/Developer/sent_train.csv
Parsing completed. Parsed 7086 lines in 0.020674 secs.
>>> model = tc.sentence_classifier.create(data, 'sentiment', features=['text'])

The error happens after all the iterations, as you can see in the log below:

PROGRESS: Creating a validation set from 5 percent of training data. This may take a while.
          You can set ``validation_set=None`` to disable validation tracking.

Logistic regression:
--------------------------------------------------------
Number of examples          : 6733
Number of classes           : 2
Number of feature columns   : 1
Number of unpacked features : 2951
Number of coefficients    : 2952
Starting L-BFGS
--------------------------------------------------------
+-----------+----------+-----------+--------------+-------------------+---------------------+
| Iteration | Passes   | Step size | Elapsed Time | Training-accuracy | Validation-accuracy |
+-----------+----------+-----------+--------------+-------------------+---------------------+
| 1         | 3        | 0.000149  | 1.275833     | 0.987524          | 0.966006            |
| 2         | 5        | 1.000000  | 1.541272     | 0.995990          | 0.974504            |
| 3         | 6        | 1.000000  | 1.721297     | 0.997475          | 0.980170            |
| 4         | 7        | 1.000000  | 1.904854     | 0.999257          | 0.971671            |
| 5         | 8        | 1.000000  | 2.082908     | 0.999554          | 0.971671            |
| 6         | 9        | 1.000000  | 2.267777     | 0.999554          | 0.971671            |
| 10        | 19       | 1.860520  | 3.499873     | 0.999703          | 0.977337            |
+-----------+----------+-----------+--------------+-------------------+---------------------+
TERMINATED: Iteration limit reached.
This model may not be optimal. To improve it, consider increasing `max_iterations`.
[ERROR] turicreate.toolkits._main: Toolkit error: Invalid type conversion
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/emannuelcarvalho/Developer/turicreate/debug/src/unity/python/turicreate/toolkits/sentence_classifier/_sentence_classifier.py", line 104, in create
    l2_penalty=.2)
  File "/Users/emannuelcarvalho/Developer/turicreate/debug/src/unity/python/turicreate/toolkits/classifier/logistic_classifier.py", line 312, in create
    seed=seed)
  File "/Users/emannuelcarvalho/Developer/turicreate/debug/src/unity/python/turicreate/toolkits/_supervised_learning.py", line 398, in create
    options, verbose)
  File "/Users/emannuelcarvalho/Developer/turicreate/debug/src/unity/python/turicreate/toolkits/_main.py", line 84, in run
    raise ToolkitError(str(message))
turicreate.toolkits._main.ToolkitError: Invalid type conversion
znation commented 6 years ago

@emannuelOC Can you try again with latest master? I suspect this may be fixed with #197.

emannuelOC commented 6 years ago

@znation It did work now! I was able to create the model and export it to the .mlmodel format. Now I'm back at the problem in #174.

znation commented 6 years ago

Thanks @emannuelOC! I'll close this as fixed with #197.