所有代码都在python中。我有一个名为“语料库”的python列表,其中包含总计2000的评论(+ ve和-ve评论两者)。 mycode的主要/重要部分是:
PR1 = (10 .* log10(PR)) + 30;
现在我想将一个句子预测为+ ve或-ve('1'或'0')。这句话是
clc();
close all;
clear all;
f = 2100000000;
wl = ((3 * 10^8) / f) ^ 2;
PT = 50.12;
d = 1:0.1:20;
PR = (wl ./ ((4 .* pi() .* d) .^ 2)) .* PT;
d1 = d .* 1000;
PR1 = (10 .* log10(PR)) + 30;
subplot(2,1,1);
plot(d,PR);
xlabel('x --> D (Distance in Km)');
ylabel('y --> PR (Received Power in Watts)');
title('Distance of separation between the TX/RX and the receive signal strength');
grid on;
subplot(2,1,2);
plot(d1,PR1);
xlabel('x --> D (Distance in Meter)');
ylabel('y --> PR (Received Power in dBm)');
title('Distance of separation between the TX/RX and the receive signal strength');
grid on;
我应该如何预测上述情况。(我知道CountVectorizer和TdfidfTransformer的作用是什么,但它让我对TdfidfVectorizer感到困惑)
答案 0 :(得分:1)
CountVectorizer
和TfidfTranformer
所取得的成就只能由TfidfVecorizer
来实现。
回答你的问题:
sample = ["you are a nice person and have a good life"]
这是您要预测的样本数据。我在vectorizer上使用了transform方法(CountVectorizer)
Count_sample = vectorizer.transform(sample)
转换CountVectorizer后,我们必须在变换器上使用transform方法(TfidfTranformer)
Tfidf_sample = transformer.transform(Count_sample)
完成所有数据转换后,使用预测LogisticRegression
predicted = logistic_reg.predict(Tfidf_sample)