cs224u sst_02_hand_built_features Wrapper for LogisticRegression
上一篇博客(https://duanzhihua.blog.csdn.net/article/details/105981617)我们讲解了BasicSGDClassifier ,它在SST上做得很好!但我们可能不想依赖BasicSGDClassifier ,相反,我们希望依靠sklearn。下面是一个简单的sklearn.linear.model.LogisticRegression封装器,使用了build-dataset加载数据。
def fit_softmax_classifier(X, y):
"""Wrapper for `sklearn.linear.model.LogisticRegression`. This is
also called a Maximum Entropy (MaxEnt) Classifier, which is more
fitting for the multiclass case.
Parameters
----------
X : 2d np.array
The matrix of features, one example per row.
y : list
The list of labels for rows in `X`.
Returns
-------
sklearn.linear.model.LogisticRegression
A trained `LogisticRegression` instance.
"""
mod = L