twitter爬虫到人工神经网络的数据处理

2024-06-01 05:56:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习python中的情绪分析,使用深度学习(人工神经网络),有困难,如果我的问题很难理解,请原谅

所以,我有一个用于情绪分析的后端和一个Twitter爬虫,但是我很难处理来自Twitter的大量数据

我已经成功地把它分类了,但是只有一个句子被分类为肯定/否定。输出如屏幕截图链接所示

https://imgur.com/krh4pfY

这是我的密码:

def testFromTrained(x):
    model = Sequential()
    # load json and create model
    json_file = open('model/model.json', 'r')
    loaded_model_json = json_file.read()
    json_file.close()
    model = model_from_json(loaded_model_json)

    # load weights into new self.model
    model.load_weights("model/model.h5")
    print("Loaded model from disk")

    sgd = SGD(lr=0.01)

    model.compile(loss='binary_crossentropy', optimizer=sgd)
    return getBinaryResult(model.predict_proba(np.array(x)))
Preproses()
td = TFIDF([xdata, ydata])
# TESTING
test = "he loves me"
print(test)
print (testFromTrained([td.transform(test)]))

来自爬虫:

qry='trump'
maxTweets = 1000 # up to you
tweetsPerQry = 100  # No more than 100 

我需要的是在抓取(1000个原始数据)数据后,立即直接处理,得到神经网络上的情感极性分析(百分比)

有人能帮忙吗


Tags: 数据fromtestjsonmodel分类loadtwitter