cs224u sst_02_hand_built_features Wrapper for LogisticRegression

≡放荡痞女 提交于 2020-08-06 06:05:31

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 = LogisticRegression(
        fit_intercept=True, 
        solver='libline
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!