Natural Language Processing · 免费预览

用逻辑回归进行文本分类

监督分类设置、手工构造的特征、sigmoid函数与logit,以及对多篇文档同时进行向量化打分。

1. Text Classification with Logistic Regression

Text Classification with Logistic Regression

2. The sigmoid turns a score into a probability

The sigmoid turns a score into a probability

3. Scoring three reviews in NumPy

Scoring three reviews in NumPy

4. The sigmoid of a logit

Compute σ(−1)\sigma(-1) and round to three decimal places.

5. Scoring a document by weighted sum

A binary sentiment classifier has weights w=[−1,1,0.5]\mathbf{w} = [-1, 1, 0.5] applied to the feature vector x=[3,1,2]\mathbf{x} = [3, 1, 2] and bias b=−0.5b = -0.5. Compute the logit z=w⋅x+bz = \mathbf{w} \cdot \mathbf{x} + b.

6. Reading the decision boundary

A binary classifier outputs y^=0.71\hat{y} = 0.71 as P(y=1∣x)P(y{=}1 \mid x). With the standard threshold, which class does the classifier predict, and which condition explains it?

7. The logit as log odds

Compute the logit of p=0.8p = 0.8, that is ln⁡p1−p\ln \frac{p}{1-p}, and round to three decimal places.

8. Shapes in vectorized scoring

A test set stacks m=6m = 6 documents as rows of X\mathbf{X}, each with n=6n = 6 features. With a weight vector w\mathbf{w} and bias vector b\mathbf{b} (one entry per document), the vectorized form is y^=σ(Xw+b)\hat{\mathbf{y}} = \sigma(\mathbf{X}\mathbf{w} + \mathbf{b}). How many probability values does y^\hat{\mathbf{y}} contain? Answer with the number.

进入交互式练习

免费注册 · 即时批改 · 自动安排间隔复习。

免费开始这门课