惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
C
Check Point Blog
博客园_首页
B
Blog
D
Docker
U
Unit 42
量子位
I
InfoQ
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
GbyAI
GbyAI
L
LangChain Blog
云风的 BLOG
云风的 BLOG
博客园 - Franky
美团技术团队
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
Vercel News
Vercel News
Recent Announcements
Recent Announcements
雷峰网
雷峰网
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Google DeepMind News
Google DeepMind News

Keep the gradient flowing

Policy Gradients Part 1: The REINFORCE Estimator On the Link Between Optimization and Polynomials, Part 6. Optimization Nuggets: Stochastic Polyak Step-size, Part 2 Optimization Nuggets: Stochastic Polyak Step-size On the Convergence of the Unadjusted Langevin Algorithm The Russian Roulette: An Unbiased Estimator of the Limit Notes on the Frank-Wolfe Algorithm, Part III: backtracking line-search On the Link Between Optimization and Polynomials, Part 5 Optimization Nuggets: Implicit Bias of Gradient-based Methods Optimization Nuggets: Exponential Convergence of SGD On the Link Between Optimization and Polynomials, Part 4 On the Link Between Optimization and Polynomials, Part 3 On the Link Between Optimization and Polynomials, Part 2 On the Link Between Polynomials and Optimization, Part 1 How to Evaluate the Logistic Loss and not NaN trying Notes on the Frank-Wolfe Algorithm, Part II: A Primal-dual Analysis Three Operator Splitting Notes on the Frank-Wolfe Algorithm, Part I Optimization inequalities cheatsheet A fully asynchronous variant of the SAGA algorithm Hyperparameter optimization with approximate gradient Lightning v0.1 scikit-learn-contrib, an umbrella for scikit-learn related projects. SAGA algorithm in the lightning library On the consistency of ordinal regression methods Holdout cross-validation generator IPython/Jupyter notebook gallery PyData Paris - April 2015 Data-driven hemodynamic response function estimation Plot memory usage as a function of time
Support for sparse matrices in scikits.learn
Fabian Pedregosa · 2010-08-23 · via Keep the gradient flowing

I recently added support for sparse matrices (as defined in scipy.sparse) in some classifiers of scikits.learn. In those classes, the fit method will perform the algorithm without converting to a dense representation and will also store parameters in an efficient format. Right now, the only classese that implements this is SVC and LinearSVC in scikits.learn.svm.sparse, although the plan is to add more classes in the future. These are capable of taking sparse matrices in the fit() method and will also store support vectors as sparse matrices. Here is an example. We first create a toy dataset and import relevant modules:

[cc lang="python"] In [1]: import scipy.sparse In [2]: from scikits.learn. import svm In [3]: X, Y = scipy.sparse.csr_matrix([[0,0], [0, 1]]), [0, 1] In [4]: clf = svm.sparse.SVC(kernel='linear') [/cc]

now we will fit the model and query some of its parameters: [cc lang="python"] In [5]: clf.fit(X, Y) Out[5]: SVC(kernel='linear', C=1.0, probability=0, shrinking=1, eps=0.001, cache_size=100.0, coef0=0.0, gamma=0.0) In [6]: clf.support_ Out[6]: <2x2 sparse matrix of type '' with 1 stored elements in Compressed Sparse Row format> In [7]: clf.coef_ Out[7]: <1x2 sparse matrix of type '' with 1 stored elements in Compressed Sparse Row format> [/cc] For a more complete example, you can look at Classification of text documents using sparse features, contributed by Olivier Grisel.