2
こんにちは私はこれで使用したテキスト分類器を私に返していますが、jsonresponseあなたは簡単に使用して行うことができますlist
オブジェクトにnumpy array
を変換する必要が私にエラーを与えてコードの最後の行「の配列([」サイクリング「]、DTYPE =オブジェクト)、シリアライズJSONではありません」TypeError:配列(['cycling']、dtype = object)はJSONのシリアライズ可能ではありません
def classify_text(request):
if request.method == 'POST' and request.POST.get('text'):
test = []
text = request.POST.get('text')
text = re.sub('[^a-zA-Z]', ' ', text)
text = text.lower()
text = text.split()
ps = PorterStemmer()
text = [ps.stem(word) for word in text if not word in set(stopwords.words('english'))]
text = ' '.join(text)
test.append(text)
pred = cv.transform(test).toarray()
pred = svm_model_linear.predict(pred)
return JsonResponse(pred, safe=False)
代わりに捧げる私はpred' 'の種類は何 –
にお答え提供してください? –
"'' pred = ['cycling']」という分類子の予測を保持しています –