Tambahkan regularisasi terbaik dan dropout terbaik pada kode analisis sentimen LSTM-CNN berikut untuk mengurangi overfitting
import pickle
import pandas as pd
import numpy as np
from keras.preprocessing.text import Tokenizer
from keras.utils import pad_sequences
from keras.models import Sequential
from keras.layers import Embedding, LSTM, Dense, Dropout, Conv1D, MaxPooling1D
from keras.layers import Flatten
from keras.utils import to_categorical
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report
import gensim

# Membaca dataset
data_list = pickle.load(open('pre_processed_beritaFIX_joined.pkl', 'rb'))
data = pd.DataFrame(data_list, columns=['judul', 'isi', 'pre_processed', 'Label'])
data['Isi Berita'] = data['pre_processed']

# Tokenisasi dan Padding
max_words = 10000  # mengurangi jumlah kata maksimum
max_len =  500     # mengurangi panjang input
tokenizer = Tokenizer(num_words=max_words)
tokenizer.fit_on_texts(data['Isi Berita'])
sequences = tokenizer.texts_to_sequences(data['Isi Berita'])
X = pad_sequences(sequences, maxlen=max_len)
y = to_categorical(data['Label'].astype('category').cat.codes)

# Membagi data menjadi data latih dan data uji
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# Menggunakan pre-trained word2vec Bahasa Indonesia
path = 'idwiki_word2vec_300.model'
id_w2v = gensim.models.word2vec.Word2Vec.load(path)
wv = id_w2v.wv

# Membuat matriks embedding
embedding_dim = 300
embedding_matrix = np.zeros((max_words, embedding_dim))
for word, i in tokenizer.word_index.items():
    if i < max_words:
        try:
            embedding_vector = wv[word]
            embedding_matrix[i] = embedding_vector
        except KeyError:
            pass

# Membuat model LSTM-CNN dengan jumlah unit yang lebih kecil
model = Sequential()
model.add(Embedding(max_words, embedding_dim, weights=[embedding_matrix], input_length=max_len, trainable=False))
model.add(LSTM(64, return_sequences=True, dropout=0.2))
model.add(Conv1D(64, 5, activation='relu'))
model.add(MaxPooling1D(pool_size=4))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(32, activation='relu'))
model.add(Dense(3, activation='softmax'))

# Menyusun model
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])

# Melatih model dengan jumlah epoch yang lebih kecil
history = model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=50, batch_size=128)

# Mengevaluasi model
y_pred = model.predict(X_test)
y_pred = np.argmax(y_pred, axis=1)
y_true = np.argmax(y_test, axis=1)

# Menghitung akurasi
accuracy = accuracy_score(y_true, y_pred)
print(f"Akurasi: {accuracy}")

# Menampilkan classification report
report = classification_report(y_true, y_pred, target_names=['Negatif', 'Netral', 'Positif'])
print("Classification Report:")
print(report)