Commit
·
21d0ed5
1
Parent(s):
e3974a6
Update app.py
Browse files
app.py
CHANGED
@@ -76,12 +76,16 @@ def load_file(kamus_path, kamus_sendiri_path):
|
|
76 |
stop_words = set(stopwords.words("indonesian"))
|
77 |
|
78 |
tfidf_vectorizer = joblib.load(tfidf_model_path)
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
|
81 |
kamus_path = '_json_colloquial-indonesian-lexicon (1).txt'
|
82 |
kamus_sendiri_path = 'kamus_gaul_custom.txt'
|
83 |
tfidf_model_path = 'X_tfidf_model.joblib'
|
84 |
-
lookp_dict, stop_words, tfidf_vectorizer = load_file(kamus_path, kamus_sendiri_path)
|
85 |
|
86 |
# Fungsi untuk normalisasi kata gaul
|
87 |
@st.cache_data
|
@@ -112,12 +116,9 @@ def remove_stopwords(text, stop_words):
|
|
112 |
#---------------------------------------------------Milih Model----------------------------------------------------------------------
|
113 |
|
114 |
# Fungsi untuk memilih model berdasarkan pilihan pengguna
|
115 |
-
|
116 |
-
def select_sentiment_model(selected_model):
|
117 |
-
|
118 |
-
#model_rf
|
119 |
-
model_nb = joblib.load('naive_bayes_model_smote.joblib')
|
120 |
-
model_lr = joblib.load('logreg_model_smote.joblib')
|
121 |
if selected_model == "Ensemble":
|
122 |
model = model_ensemble
|
123 |
elif selected_model == "Random Forest":
|
@@ -225,7 +226,7 @@ def buat_chart(df, target_year):
|
|
225 |
color=[warna_label[label] for label in unique_label]
|
226 |
)
|
227 |
|
228 |
-
|
229 |
def all_data_process(texts, df, _sentiment_model, _tfidf_vectorizer, lookp_dict, stop_words, _predict_sentiment, _get_emoticon, _clean_text, _normalize_slang, _remove_stopwords):
|
230 |
results = []
|
231 |
analisis = False
|
|
|
76 |
stop_words = set(stopwords.words("indonesian"))
|
77 |
|
78 |
tfidf_vectorizer = joblib.load(tfidf_model_path)
|
79 |
+
model_ensemble = joblib.load('ensemble_clf_soft_smote.joblib')
|
80 |
+
#model_rf
|
81 |
+
model_nb = joblib.load('naive_bayes_model_smote.joblib')
|
82 |
+
model_lr = joblib.load('logreg_model_smote.joblib')
|
83 |
+
return lookp_dict, stop_words, tfidf_vectorizer, model_ensemble, model_nb, model_lr
|
84 |
|
85 |
kamus_path = '_json_colloquial-indonesian-lexicon (1).txt'
|
86 |
kamus_sendiri_path = 'kamus_gaul_custom.txt'
|
87 |
tfidf_model_path = 'X_tfidf_model.joblib'
|
88 |
+
lookp_dict, stop_words, tfidf_vectorizer, model_ensemble, model_nb, model_lr = load_file(kamus_path, kamus_sendiri_path)
|
89 |
|
90 |
# Fungsi untuk normalisasi kata gaul
|
91 |
@st.cache_data
|
|
|
116 |
#---------------------------------------------------Milih Model----------------------------------------------------------------------
|
117 |
|
118 |
# Fungsi untuk memilih model berdasarkan pilihan pengguna
|
119 |
+
|
120 |
+
def select_sentiment_model(selected_model, model_enesmble, model_nb, model_lr):
|
121 |
+
|
|
|
|
|
|
|
122 |
if selected_model == "Ensemble":
|
123 |
model = model_ensemble
|
124 |
elif selected_model == "Random Forest":
|
|
|
226 |
color=[warna_label[label] for label in unique_label]
|
227 |
)
|
228 |
|
229 |
+
@st.cache_data
|
230 |
def all_data_process(texts, df, _sentiment_model, _tfidf_vectorizer, lookp_dict, stop_words, _predict_sentiment, _get_emoticon, _clean_text, _normalize_slang, _remove_stopwords):
|
231 |
results = []
|
232 |
analisis = False
|