Created
January 31, 2021 06:49
-
-
Save AyishaR/d7700279c1acc765bcab2572582e1472 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, Xval.shape[0] - 1) | |
question = df['Questions'].values[x] | |
print("Question: ", question) | |
cleaned_text = [] | |
sentence = removeURL(question) | |
sentence = removeHTML(sentence) | |
sentence = onlyAlphabets(sentence) | |
sentence = sentence.lower() | |
for word in sentence.split(): | |
#if word not in stop: | |
stemmed = sno.stem(word) | |
cleaned_text.append(stemmed) | |
cleaned_text = [' '.join(cleaned_text)] | |
print("Cleaned text: ", cleaned_text[0]) | |
cleaned_text = tokenizer.texts_to_sequences(cleaned_text) | |
cleaned_text = pad_sequences(cleaned_text, maxlen=mlen) | |
category = df['Category0'].values[x] | |
print("\nTrue category: ", category) | |
output = model.predict(cleaned_text)[0] | |
pred = np.argmax(output) | |
print("\nPredicted category: ", class_names[pred]) | |
print("Probability: ", output[pred]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment