Created
January 22, 2021 17:01
-
-
Save AyishaR/128e54959bd677549e8504180c905b7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = np.random.randint(0, Xtest.shape[0] - 1) | |
sentence = test_df['Message'].values[x] | |
print("Sentence: ", sentence) | |
cleaned_sentence = [] | |
sentence = removeURL(sentence) | |
sentence = removeHTML(sentence) | |
sentence = onlyAlphabets(sentence) | |
sentence = sentence.lower() | |
sentence = removeRecurring(sentence) | |
for word in sentence.split(): | |
#if word not in stop: | |
stemmed = sno.stem(word) | |
cleaned_sentence.append(stemmed) | |
sentence = [' '.join(cleaned_sentence)] | |
print("\nCleaned sentence: ", sentence[0]) | |
sentence = cv.transform(sentence) | |
sentence = tfidf.transform(sentence) | |
print("\nTrue value: ", columns[test_df['Category'].values[x]]) | |
pred = model.predict(sentence.toarray())[0][0] | |
print("\nPredicted value: ", columns[int(pred>0.5)], "(", pred, "-->", (pred>0.5).astype('int'), ")") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment