text_plain_output_1.png
import numpy as np

import pandas as pd

import sklearn

df = pd.read_csv('../input/sentiment-analysis-for-financial-news/all-data.csv', encoding='ISO-8859-1')

def making_label(st):
    if st == 'positive':
        return 0
    elif st == 'neutral':
        return 2
    else:
        return 1
train['label'] = train['sentiment'].apply(making_label)
eva['label'] = eva['sentiment'].apply(making_label)

train_df = pd.DataFrame({'text': train['statement'][:1500].replace('\\n', ' ', regex=True), 'label': train['label'][:1500]})
eval_df = pd.DataFrame({'text': eva['statement'][-400:].replace('\\n', ' ', regex=True), 'label': eva['label'][-400:]})

lst = []
for arr in model_outputs:
    lst.append(np.argmax(arr))

true = eval_df['label'].tolist()
predicted = lst

import sklearn
mat = sklearn.metrics.confusion_matrix(true, predicted)
mat

sklearn.metrics.classification_report(true, predicted, target_names=['positive', 'neutral', 'negative'])

sklearn.metrics.accuracy_score(true, predicted)