0Pricing
NLP Academy · บทเรียน

ปรับขนาดและเลือกคุณลักษณะ

เก็บเฉพาะคุณลักษณะที่ช่วยได้จริง

ปรับขนาดและเลือกคุณลักษณะ เป็นบทเรียน NLP Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน NLP Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Too Many Features Hurt

Text models can explode to tens of thousands of features. Many add only noise, so trimming the list often improves both speed and accuracy.

Why Scale at All

Some models compare feature magnitudes directly. If one feature ranges 0 to 1000, it can drown out the rest unless you scale them first.

Standardizing Numbers

StandardScaler shifts each feature to zero mean and unit variance. Now every numeric feature speaks on the same scale.

from sklearn.preprocessing import StandardScaler
scaled = StandardScaler().fit_transform(numeric_features)

Careful With Sparse Data

Centering a sparse TF-IDF matrix fills it with nonzeros and wastes memory. Use MaxAbsScaler, which scales without destroying sparsity.

from sklearn.preprocessing import MaxAbsScaler
scaled = MaxAbsScaler().fit_transform(tfidf_matrix)

Drop the Dead Weight

Features that barely vary tell the model nothing. A VarianceThreshold filter removes near-constant columns in one quick pass.

Pick the Most Useful

SelectKBest keeps the top features by a scoring test like chi-squared. You ask for the best k and it drops the rest.

from sklearn.feature_selection import SelectKBest, chi2
best = SelectKBest(chi2, k=2000).fit_transform(X, y)

Let the Model Choose

An L1-penalized model pushes useless weights to zero on its own. This built-in selection is often called embedded feature selection.

Fit on Train Only

Always fit scalers and selectors on training data alone, then apply them to test data. Mixing them causes leakage and rosy fake scores.

Keep It in a Pipeline

Putting scaling and selection inside a Pipeline runs them in the right order every time. It also blocks accidental leakage during validation.

from sklearn.pipeline import Pipeline
pipe = Pipeline([("select", SelectKBest(chi2, k=2000)), ("clf", model)])

Fewer Features, Faster Model

A leaner feature set trains faster, needs less memory, and is easier to explain. Smaller is often better once noise is gone. ⚡

Measure, Do Not Guess

Try a few values of k and compare validation scores. Let the numbers, not a hunch, decide how many features to keep.

Quick Check

Which scaler keeps a sparse matrix sparse?

Recap

Scale numeric features and select the useful ones with SelectKBest or L1. Use MaxAbsScaler for sparse data, and fit everything inside a pipeline. ✅

คำถามที่พบบ่อย

บทเรียน “ปรับขนาดและเลือกคุณลักษณะ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ปรับขนาดและเลือกคุณลักษณะ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NLP Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ปรับขนาดและเลือกคุณลักษณะ”

เก็บเฉพาะคุณลักษณะที่ช่วยได้จริง คุณปฏิบัติ NLP Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NLP Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน NLP Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “ปรับขนาดและเลือกคุณลักษณะ” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน NLP Academy นี้ได้ไหม

ได้ บทเรียน NLP Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ก้าวข้ามถุงคำ
  2. N-Gram ของอักขระเพื่อความทนทาน
  3. ผสานคุณลักษณะหลายประเภท
  4. ปรับขนาดและเลือกคุณลักษณะ
← กลับไปที่ NLP Academy