<jupyter_start><jupyter_text><jupyter_code>import pandas as pd 
import matplotlib.pyplot as plt
import numpy as np
dataset=pd.read_csv('Data.csv',emcoding='ISO-8859-1')
dataset.head()
y=dataset['Label']
print(y)
dataset=dataset.drop(['Date','Label'],axis=1)
dataset.head()
dataset.replace('[^a-zA-Z]',' ',regex=True,inplace=True)
print(len(dataset))
' '.join(x for x in dataset.iloc[0,0:25].values)
headlines_perDay=[]
for i in range(0,len(dataset)):
  headlines_perDay.append(' '.join(str(x) for x in dataset.iloc[i,0:25].values))
headlines_perDay
import nltk
from nltk.corpus import stopwords

nltk.download('stopwords')
all_stopwords = stopwords.words('english')
all_stopwords.remove('not')
from sklearn.feature_extraction.text import CountVectorizer
cv = CountVectorizer(stop_words=all_stopwords,ngram_range=(2, 2))
x=cv.fit_transform(headlines_perDay).toarray()
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.20, random_state = 0)
from sklearn.naive_bayes import GaussianNB
classifier = GaussianNB()
classifier.fit(x_train, y_train)
y_pred = classifier.predict(x_test)
print(y_pred)
from sklearn.metrics import confusion_matrix, accuracy_score
cm = confusion_matrix(y_test, y_pred)
print(cm)
accuracy_score(y_test, y_pred)<jupyter_output>[[194 194]
 [233 200]]
{'fraction_non_alphanumeric': 0.1370067014147431, 'fraction_numerical': 0.023827252419955324, 'mean_word_length': 8.53191489361702, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '538644', 'license': 'Apache-2.0', 'n_tokens_mistral': 523, 'n_tokens_neox': 495, 'n_words': 95, 'path': 'StockPrediction.ipynb', 'repo_name': 'satyaki-sen/Stock-Sentiment-Analysis', 'size': '1343'}