0Pricing
NLP Academy · Lekcja

Łączenie wielu typów cech

Połącz cechy tekstowe i liczbowe

Łączenie wielu typów cech to bezpłatna lekcja NLP Academy na CoddyKit. To lekcja 3 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.

One Type Is Rarely Enough

TF-IDF captures words, your hand-built numbers capture style. The best models often combine several feature types into one input.

Text and Numbers Together

Imagine a review's TF-IDF vector plus its length and star rating. Stacking these gives the model both word and numeric signal at once.

The Shape Problem

TF-IDF outputs a sparse matrix, while your custom features are a small dense array. You must join them along the same rows.

Side by Side, Not Stacked

We glue features as new columns for the same documents, not new rows. This horizontal join is called concatenation.

Stacking Sparse Matrices

SciPy offers hstack to place matrices side by side efficiently. It keeps everything sparse, so memory stays under control.

from scipy.sparse import hstack
combined = hstack([tfidf_matrix, numeric_features])

ColumnTransformer to the Rescue

scikit-learn's ColumnTransformer applies different steps to different columns. It is the clean way to route text and numbers through one pipeline.

Wiring It Up

You give ColumnTransformer a list of named transformers and the columns each one handles. It builds a single feature matrix for you.

from sklearn.compose import ColumnTransformer
ct = ColumnTransformer([("text", TfidfVectorizer(), "review"), ("num", "passthrough", ["length"])])

FeatureUnion for Parallel Steps

When several transformers read the same input, FeatureUnion runs them in parallel and joins the outputs. It is built for combining feature extractors.

Mind the Scales

Raw word counts and a 0-to-1000 length live on very different ranges. Mixing them often calls for scaling so no feature dominates.

Let Data Decide

Adding feature types should be a measured experiment. Compare a validation score before and after to confirm the combo actually helps.

More Is Not Always Better

Throwing in every feature can add noise and slow training. Aim for a small, well-chosen mix over a giant kitchen sink. 🧹

Quick Check

How should TF-IDF and numeric features be merged?

Recap

Strong models combine text and numeric features by concatenating columns. Use hstack, ColumnTransformer, or FeatureUnion, and scale before mixing. ✅

Często zadawane pytania

Czy lekcja „Łączenie wielu typów cech” jest bezpłatna?

Tak — pełny tekst „Łączenie wielu typów cech” 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 „Łączenie wielu typów cech”?

Połącz cechy tekstowe i liczbowe Ć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 3 z 4.

Ile czasu zajmuje lekcja „Łączenie wielu typów cech”?

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

  1. Poza bag-of-words
  2. N-gramy znakowe dla większej odporności
  3. Łączenie wielu typów cech
  4. Skalowanie i wybieranie cech
← Powrót do NLP Academy