## 3 Proposed Method
The sampling data for X_train_seq and T_train were stored in X_train_samp and T_train_samp, respectively. from imblearn.under_sampling import RandomUnderSampler sampler = RandomUnderSampler(random_state = 0) X_train_samp, T_train_samp = sampler.fit_resample(X_train_seq, T_train)  
To perform oversampling, RandomOverSampler, SMOTE, Borderline-SMOTE, and ADASYN were used. The following shows the code to apply RandomOverSampler to the training data. The class was imported from the imblearn.over_sampling package. The code to use other algorithms is also similar; only the class name is changed to SMOTE, BorderlineSMOTE, or ADASYN, and the rest of the code, except the class name, is the same. \begin{table}
\begin{tabular}{l c c c c c c} \hline \hline  & **Nampu** & **Dongu** & **Bukgu** & **Ulju** & **Joonggu** & **Average** \\ \hline No. of tokens & 56,077 & 61,179 & 56,264 & 77,209 & 54,535 & 61,053 \\ No. of unique tokens & 1465 & 1569 & 1560 & 2159 & 1643 & 1679 \\ Maximum no. of tokens in a sentence & 38 & 36 & 36 & 37 & 38 & 37 \\ Average no. of tokens in a sentence & 18.6 & 18.5 & 17.6 & 18.8 & 18.6 & 18.4 \\ Ratio of top-5 frequent words & 7.5\% & 9.4\% & 7.8\% & 7.2\% & 8.5\% & 8.1\% \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Statistics for the reviews of tourist attractions for each district in Ulsan. from imblearn.over_sampling import RandomOverSampler sampler = RandomOverSampler (random_state = 0) X_train_samp, T_train_samp = sampler.fit_resample(X_train_seq, T_train) ```
The oversampled data are then fed into a model to detect irrelevant reviews. As mentioned earlier, various machine learning algorithms, such as RNN, LSTM, GRU, and BERT, whose algorithms are known to provide high accuracy in text processing, were used in the proposed method. The RNN, LSTM, and GRU models can be implemented using Keras. For example, the LSTM model can be built as follows:
``` model = keras.Sequential([ keras.layers.Embedding(2000, 50, input_length = 40), keras.layers.LSTM(32), keras.layers.Dense(128, activation ='relu'), keras.layers.Dense(1, activation ='sigmoid') ]) model.fit(X_train_samp, T_train_samp, epochs = 30) ```  
The Embedding layer contains corpus, a set of unique words appearing in the training data. Each word in the corpus is represented as a multi-dimensional vector to keep information about the relationship to other words in the reviews. The layer receives three parameters, including the corpus size, the dimension of the word vector, and the maximum length of a sentence. In the above code, 2000, 50, and 40 were given for the parameters that were sufficient to store the training data. In this case, each word is represented as a 50-dimensional vector, and a 40 \(\times\) 50 matrix representing a given review is output to the next layer. The LSTM layer receives the matrix and performs training to remember the sequence of the words in the review. The parameter 32 denotes the number of hidden nodes used to maintain the learning information, which can be adjusted to a larger value if more information needs to be trained. The remaining two Dense layers are used for the classification, i.e., to determine whether the review from the LSTM layer is noisy. The Dense layer has two parameters to denote the number of hidden nodes and the activation function. As an activation function, relu is commonly used in the middle layers to prevent the vanishing gradient problem, and sigmoid is used in the last layer to determine the class to which a given output belongs. The fit function executes the configured model with a given training data. The learning was set to be performed up to 30 epochs. The RNN and GRU models can be implemented in the same manner. To implement the RNN models, the keras.layers.SimpleRNN class can be used, instead of the keras.layers.LSTM in the above code. Similarly, the GRU model can be implemented using the keras.layers.GRU class. The rest of the code, except the class name, is the same. The three algorithms mentioned above use only given input data for learning.