text_plain_output_1.png
from sklearn.feature_extraction.text import TfidfVectorizer

from sklearn.linear_model import LogisticRegression

from sklearn.metrics import f1_score

from sklearn.model_selection import train_test_split, GridSearchCV

from sklearn.multiclass import OneVsRestClassifier

import pandas as pd

try:
    df_train = pd.read_csv('data/train.csv')
    df_test = pd.read_csv('data/test.csv')
except:
    df_train = pd.read_csv('/kaggle/input/tweet-sentiment-extraction/train.csv')
    df_test = pd.read_csv('/kaggle/input/tweet-sentiment-extraction/test.csv')

df_train.fillna('', inplace=True)
df_test.fillna('', inplace=True)

tf = TfidfVectorizer(ngram_range=(1, 1))
X_train, X_val, y_train, y_val = train_test_split(tf.fit_transform(df_train['text']), df_train['target'])
df_train['is_training'] = [1 if x in y_train.index else 0 for x in df_train.index]

parameters = {}
clf = OneVsRestClassifier(LogisticRegression(solver='lbfgs'))
clf.fit(X_train, y_train)

y_val_predict_sentiment = clf.predict(X_val)

f1_score(y_val, y_val_predict_sentiment, average='weighted')