Kaggle competition: Natural Language Processing with Disaster Tweets
<SOS> metric: meanfscore Kaggle data source: natural-language-processing-with-disaster-tweets<load_from_csv>
import numpy as np
import pandas as pd
from pathlib import Path
from fastai.text.all import *
df = pd.read_csv('/kaggle/input/costa-rican-household-poverty-prediction/train.csv')
 test = pd.read_csv('/kaggle/input/costa-rican-household-poverty-prediction/test.csv')
 df.shape, test.shape<concatenate>
datadir = Path.cwd().parent / 'input' / 'nlp-getting-started'
df_all = df.append(test)
 df_all.shape<count_values>
df_train = pd.read_csv(datadir/'train.csv')
 df_test = pd.read_csv(datadir/'test.csv')
 df_submission = pd.read_csv(datadir/'sample_submission.csv' )
df_all['dependency'].value_counts()<count_values>
dls = TextDataLoaders.from_df(df_train, text_col='text', label_col='target' )
df_all['edjefa'].value_counts()<count_values>
dls.show_batch(max_n=2 )
df_all['edjefe'].value_counts()<data_type_conversions>
learn = text_classifier_learner(dls, AWD_LSTM, drop_mult=0.5, metrics=accuracy )
mapeamento = {'yes': 1, 'no': 0}
df_all['edjefa'] = df_all['edjefa'].replace(mapeamento ).astype(int)
 df_all['edjefe'] = df_all['edjefe'].replace(mapeamento ).astype(int )<count_values>
learn.fine_tune(4, 1e-2 )
df_all['dependency'].value_counts()<data_type_conversions>
text_list = list(df_test['text'].values )
df_all['dependency'] = df_all['dependency'].replace(mapeamento ).astype(float )<count_missing_values>
%%capture
prediction = [learn.predict(i)[0] for i in text_list]
df_all.isnull().sum()<count_missing_values>
df_submission['target'] = prediction
df_submission['target'] = df_submission['target'].astype(int )
df_all[df_all['parentesco1'] == 1]['v2a1'].isnull().sum()<count_values>
df_submission.to_csv('submission.csv', index=False )