%reload_ext autoreload
%autoreload 2
%matplotlib inline
from fastai.tabular import *
import pandas as pd
bs = 64
# Reading the tweets into the pandas dataframes
path = ('drive/My Drive/Colab Notebooks/twitter_airline_sentiment')
data_panda = pd.read_csv(path+'/tweets.csv')
conversion = {
"object": "TEXT",
"float64": "NUMERIC",
"int64": "INTEGER"
}
# Initializing variables that can be used
dep_var = 'airline_sentiment'
cat_names = ['airline', 'negativereason', 'tweet_location', 'user_timezone']
cont_names = ['tweet_id', 'airline_sentiment_confidence', 'negativereason_confidence', 'retweet_count']
procs = [FillMissing, Categorify, Normalize]
# Making a test dataset that can be used for validation
path
test = TabularList.from_df(data_panda.iloc[400:700].copy(), path=path, cat_names=cat_names, cont_names=cont_names)
# Creating the tabularlist that can be used to do training and testing
data = (TabularList.from_df(data_panda, path=path, cat_names=cat_names, cont_names=cont_names, procs=procs)
.split_by_idx(list(range(800,1000)))
.label_from_df(cols=dep_var)
.add_test(test)
.databunch())
len(data_panda)
data.show_batch(rows=10)
# The tabular learner making the predictions based on neural networks
learn = tabular_learner(data, layers=[53,10], metrics=accuracy)
learn.lr_find()
learn.recorder.plot()
learn.fit(4, 1e-1)
row = data_panda.iloc[51]
row
learn.predict(row)