我已经建立了一个.tar.gz
来连接我的Jupyter Notebook
,调用表中的数据,并将来自API的机器学习模型应用于这些数据,这些数据是产品说明,但我不断得到我非常不熟悉的Postgresql database
。
我的笔记本电脑分为3个单元格,但为了清楚起见,我将它们放在一起:
ValueError: dictionary update sequence element #0 has length 1736; 2 is required
这是完整的错误输出:
from watson_developer_cloud import NaturalLanguageClassifierV1
import pandas as pd
import psycopg2
import json
conn_string = 'host={} port={} dbname={} user={} password={}'.format('119.203.10.242', 5432, 'mydb', 'locq', 'Mypass***')
conn_cbedce9523454e8e9fd3fb55d4c1a52e = psycopg2.connect(conn_string)
data_df_1 = pd.read_sql('SELECT description from public."search_product"', con=conn_cbedce9523454e8e9fd3fb55d4c1a52e)
natural_language_classifier = NaturalLanguageClassifierV1(
iam_apikey='F76ugy8hv1s3sr87buhb7564vb7************',
url='https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/7818d2s519-nlc-1311')
classes = natural_language_classifier.classify_collection('7818d2s519-nlc-1311', [{data_df_1.to_json()}]).get_result()
print(json.dumps(classes, indent=2))
如何解决?