赞
踩
Python中支持Convex Optimization(凸规划)的模块为CVXOPT,能够解决线性规划和二次型规划问题,其应用场景如SVM中的Hard Margin SVM。
CVXOPT has separate dense and sparse matrix objects.
A dense matrix is created using the matrix() function; it can be created from a list (or iterator):
- >>>from cvxopt import matrix
- >>>A = matrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], (2,3))
- >>>print(A)
- [ 1.00e+00 3.00e+00 5.00e+00]
- [ 2.00e+00 4.00e+00 6.00e+00]
- >>>A.size
- (2, 3)
or from a list of lists, where each inner list represents a column of the matrix:
- >>>B = matrix([ [1.0, 2.0], [3.0, 4.0] ])
- >>>print(B)
- [ 1.00e+00 3.00e+00]
- [ 2.00e+00 4.00e+00]
More generally, the inner lists can represent block-columns.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。