# Deep Learning-Based Sentimental Analysis for Large-Scale Imbalanced Twitter Data
## 4 Results and Discussions  
We take the kaggle dataset, which contains 1,600,000 emotions tweets collected using twitter API. The dataset contains user identification (id) number, date of tweet posted, username (name of user account), and tweet text columns. The target variable is set to 0 = negative, 2 = neutral and 4 = positive. The negative, neutral, and positive mean negative, neutral, and positive impressions in tweets, respectively. Tweets contain raw text which needs to be refined before being used for prediction purposes. The preprocessing steps are used to convert these tweets into useful features without noisy data. A chunk of tweets is shown in Figure 3, as it is difficult to visualize the whole dataset. There is a total of 2100 tweets shown in positive and negative emotions are 50.90% and 49.10% respectively. Tweets are mostly not an equal number of words, and there is no proper rule that restricts users to a limited number of words and no grammar rule while posting tweets. We faced two problems in the training phase. First, the class imbalance problem among minority classes and secondly high correlation among weighing features [37]. These two problems must be solved in order to get better classification accuracy. The correlation values are shown in Figure 4. The tweets emotions and classes show the dataset variables and the lower diagonal shows the visual representation of the correlation. The upper diagonal shows the correlation in numbers. Figure 3: Percentage ratio of positive and negative emotions tweets for training features. Figure 2: TensorFlow dataflow graph for training tweets data. We used the class balancer technique to balance classes and zoom the minority classes. It calculates and adds the weight value of each minor class and then sums up the total to balance all features contain in a dataset. Figure 5 shows the balanced features after applying class balancer technique. The class balancer converts the dataset into 12 number of features set, as shown in the diagonal. The first is the weight variable, which is used to balance each class according to the corresponding values. We have balanced the classes, but the correlation problem is still there. The correlation among text features significantly affects the classification to accuracy. Further, we applied PCA to convert high correlated data into normalized uncorrelated scores, as shown in Figure 6.  
Figure 4: Correlation among emotion tweets in a dataset. Figure 5: The balanced weighting features after applying class balancer technique. PCA removes the high correlation among values and transforms the 'emotions' dataset into uncorrelated variables. There are 12 PCs extracted from the class balancer feature's set, as shown in the diagonal. We used 8 PCs for further input to deep learning as it covers the maximum variances [38]. Mostly, the correlation values are zero shown in upper diagonal, which is a good indication for better classification accuracy. We designed a densely connected deep learning model from the TensorFlow framework. There is a total of 11 layers configured in which five are densely connected and four are dropout layers, as shown in Table 2. The first dense layers take input with Relu activation function. Each successive dense layer receives input from the previous layer. The four successive dense layers configured with 100, 80, 60, and 40 neurons respectively. Dropout layer is configured with each dense layer to solve the problem of overfitting. The 5 th dense layer is configured to target the output variable with the softmax activation function. All these dense layers are densely connected with each other to train the required data [39; 40]. It receives tensor as input then focuses tensor with same output shape. The Adam optimizer uses stochastic descent gradients to compile and optimize the designed deep learning model [34; 35]. The proposed deep learning model is fine-tuned with activation and loss functions, dropout layer, optimizer, and learning error rate.