利用tf-idf词向量和卷积神经网络做文本多分类

本文介绍如何结合tf-idf词向量和卷积神经网络(CNN)进行文本多分类任务,通过代码展示了tf-idf的计算过程,并提及了模型参数的设置。
摘要由CSDN通过智能技术生成

首先了解一下tf-idf,通过一段小代码

import pandas as pd
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer

corpus = [
    'This is the first document.',
    'This document is the second document.',
    'And this is the third one.',
    'Is this the first document?',
]
vectorizer = TfidfVectorizer()
x= vectorizer.fit_transform(corpus)

a=x.toarray()
print(type(x))
print(type(a))

输出结果: 

<class 'scipy.sparse.csr.csr_matrix'>
<class 'numpy.ndarray'>
import numpy as np
import pandas as pd
import jieba
import re
np.random.seed(1337)  # for reproducibility
from keras.datasets import mnist
from keras.utils import np_utils
from keras.utils import to_categorical
from kera
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值