I am trying to predict each label of word from review sentences. By far I have trained a classifier before with training data and now I am using on testing data. Basically, what I want to achieve is that from a full sentence the first word is removed, predict the rest of the sentence label, next return the first word and remove the second, predict again so on. This procedure would remove i-th word and predict rest of sentence label in every case.
I ran following code which is capable to remove one word and then return it back, but the problem is that my classifier predicts the whole sentence, because I use stems1 pre-process it list as whole document, thus I thought I could use i loop instead of stems1 at fit_transform but does not work.
vec = TfidfVectorizer(tokenizer=identity_tokenizer,use_idf = True, lowercase = False, max_features = 401)
X_new = vec.fit_transform(stems1).toarray() #stems1 is a pre-processed list that contains inside reviews lists
from typing import List
for i in stems1:
for j in range(0,len(i)):
i.pop(int(j)
new_pred = m.predict_proba(X_new)[:, 0]
i.insert(j, a)