text_plain_output_5.png application_vnd.jupyter.stderr_output_7.png text_plain_output_4.png text_plain_output_6.png text_plain_output_8.png text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from simpletransformers.classification import ClassificationModel

import pandas as pd

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

from simpletransformers.classification import ClassificationModel
model = ClassificationModel('bert', 'bert-base-cased', num_labels=3, args={'reprocess_input_data': True, 'overwrite_output_dir': True}, use_cuda=False)

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:]})

model.train_model(train_df)

result, model_outputs, wrong_predictions = model.eval_model(eval_df)