1

我已经使用 spacytextblob 库进行了一些情感分析,获取了文本的极性,但我想将增量学习应用于模型。我一直在寻找 creme 或 riverml.xyz 来开发这个增量模型,但我意识到 textblob 不使用 ml 模型进行分析。它使用它来代替https://github.com/sloria/TextBlob/blob/dev/textblob/en/en-sentiment.xml。如何应用增量学习来准确描述情绪?

(空间 2.3.0)

Spacy 代码:(来自https://spacy.io/universe/project/spacy-textblob

import spacy
from spacytextblob.spacytextblob import SpacyTextBlob

nlp = spacy.load('en_core_web_sm')
spacy_text_blob = SpacyTextBlob()
nlp.add_pipe(spacy_text_blob)
text = 'But every now and then I have a really good day that makes me happy.'
doc = nlp(text)
print(f'Polarity: {doc._.sentiment.polarity}')
print(f'Subjectivity: {doc._.sentiment.subjectivity}')

creme而言,这是一个非常简单的应用程序:(来自https://gokhang1327.medium.com/how-to-create-a-text-classifier-online-incremental-learning-with-creme-ml-6aac9d869e5c

import pandas as pd
from creme import compose
from creme import feature_extraction
from creme import naive_bayes
# Read dataset
df = pd.read_csv("7allV03.csv")
# Convert dataframe to list of tuples
docs = df.to_records(index=False)
# Creating the pipeline
# 1st function is creating the bag of words
# 2nd function is the naive bayes predictor
model = compose.Pipeline(
    ('tokenize', feature_extraction.BagOfWords(lowercase=False)),
    ('nb', naive_bayes.MultinomialNB(alpha=1))
)
# Training the model row by row
for sentence, label in docs:
    model = model.fit_one(sentence, label)

#Make predictions
model.predict_one("text to predict category")

#Increment Model
model = model.fit_one("new text to increment model", "label for new text")

让我知道如何解决这个问题。

4

0 回答 0