πLab 2
Sekilas Ekstraksi Fitur TF-IDF
Pengantar
Langkah 0 - Siapkan Corpus
corpus = [
'the house had a tiny little mouse',
'the cat saw the mouse',
'the mouse ran away from the house',
'the cat finally ate the mouse',
'the end of the mouse story'
]Langkah 1 - Buat Model TF-IDF
from sklearn.feature_extraction.text import TfidfVectorizer
# Inisiasi obyek TFidfVectorizer
vect = TfidfVectorizer(stop_words='english')
# Pembobotan TF-IDF
resp = vect.fit_transform(corpus)
# Cetak hasil
print(resp)Langkah 2 - Cek Kata yang Digunakan
Last updated