Częstość terminu i odwrotna częstość dokumentu
Dwie części wyniku
Częstość terminu i odwrotna częstość dokumentu to bezpłatna lekcja NLP Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej NLP Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs NLP Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Two Halves of One Score
TF-IDF is built from two pieces that multiply together: term frequency and inverse document frequency. Each half fixes a different weakness of raw counts.
Term Frequency, Plainly
Term frequency measures how often a word appears inside one document. More mentions of a word suggest that document leans toward that topic.
Normalizing TF
We often divide a word's count by the document length. This normalization stops long documents from looking important just because they have more words.
count = 3
doc_length = 50
tf = count / doc_length
print(round(tf, 3))TF Alone Isn't Enough
By itself, term frequency still rewards filler words that appear a lot. We need a second factor to punish words that show up everywhere.
Document Frequency
Document frequency counts how many documents contain a word at all. A high document frequency means the word is common across your whole collection.
Flip It: Inverse
We want rare words to score high, so we invert that count. Inverse document frequency rises when a word appears in few documents and falls when it is everywhere.
The Log Tames It
IDF uses a logarithm so the values do not explode for very rare words. The log keeps the scale smooth and comparable across terms.
import math
total_docs = 1000
docs_with_word = 10
idf = math.log(total_docs / docs_with_word)
print(round(idf, 3))Multiply Them Together
The final score is simply TF times IDF. A word wins only if it is frequent here and rare elsewhere, which is exactly the combination we wanted.
tf = 0.06
idf = 4.6
tfidf = tf * idf
print(round(tfidf, 3))What Scores High
A topic word like neuroscience in one article gets a high score. A word like the gets crushed because its IDF is nearly zero.
What Scores Low
Words appearing in almost every document earn tiny weights. TF-IDF automatically demotes this background noise without any manual stopword list.
Why It Works So Well
TF-IDF balances local importance against global rarity in one clean formula. That balance is why this weighting stayed a search and text staple for decades. ⭐
Quick Check
What does the inverse document frequency part actually reward?
Recap
TF measures local frequency, IDF rewards global rarity, and their product is TF-IDF. Together they spotlight words that truly define a document. ✅
Często zadawane pytania
Czy lekcja „Częstość terminu i odwrotna częstość dokumentu” jest bezpłatna?
Tak — pełny tekst „Częstość terminu i odwrotna częstość dokumentu” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu NLP Academy, przejdź na CoddyKit PRO. Kurs NLP Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Częstość terminu i odwrotna częstość dokumentu”?
Dwie części wyniku Ćwiczysz NLP Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć NLP Academy?
Nie wymagamy żadnego doświadczenia. NLP Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.
Ile czasu zajmuje lekcja „Częstość terminu i odwrotna częstość dokumentu”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji NLP Academy?
Tak. Każda lekcja NLP Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Problem z surowymi zliczeniami
- Częstość terminu i odwrotna częstość dokumentu
- TF-IDF za pomocą scikit-learn
- Wyszukiwanie najważniejszych słów