类 PaceMatrix
java.lang.Object
weka.core.matrix.Matrix
weka.classifiers.functions.pace.PaceMatrix
- 所有已实现的接口:
Serializable
,Cloneable
,RevisionHandler
Class for matrix manipulation used for pace regression.
REFERENCES
Wang, Y. (2000). "A new approach to fitting linear models in high dimensional spaces." PhD Thesis. Department of Computer Science, University of Waikato, New Zealand.
Wang, Y. and Witten, I. H. (2002). "Modeling for optimal probability prediction." Proceedings of ICML'2002. Sydney.
- 版本:
- $Revision: 1.6 $
- 作者:
- Yong Wang (yongwang@cs.waikato.ac.nz)
- 另请参阅:
-
构造器概要
构造器构造器说明PaceMatrix
(double[][] A) Construct a PACE matrix from a 2-D array.PaceMatrix
(double[][] A, int m, int n) Construct a PACE matrix quickly without checking arguments.PaceMatrix
(double[] vals, int m) Construct a PaceMatrix from a one-dimensional packed arrayPaceMatrix
(int m, int n) Construct an m-by-n PACE matrix of zeros.PaceMatrix
(int m, int n, double s) Construct an m-by-n constant PACE matrix.Construct a PaceMatrix with a single column from a DoubleVectorPaceMatrix
(Matrix X) Construct a PaceMatrix from a Matrix -
方法概要
修饰符和类型方法说明void
backward
(PaceMatrix b, IntVector pvt, int ks, int k0) Backward ordering of columns in terms of response explanation.cbind
(PaceMatrix b) Returns a new matrix which binds two matrices with columns.clone()
Clone the PaceMatrix object.double
columnResponseExplanation
(PaceMatrix b, IntVector pvt, int j, int ks) Returns the squared ks-th response value if the j-th column becomes the ks-th after orthogonal transformation.void
forward
(PaceMatrix b, IntVector pvt, int k0) Forward ordering of columns in terms of response explanation.double[]
g1
(double a, double b) Constructs the Givens rotationvoid
g2
(double[] cs, int i0, int i1, int j) Performs the Givens rotationgetColumn
(int j) Return a DoubleVector that stores a column of the matrixgetColumn
(int i0, int i1, int j) Return a DoubleVector that stores some elements of a column of the matrixReturns the revision string.double[]
h1
(int j, int k) Constructs single Householder transformation for a columnvoid
h2
(int j, int k, double q, PaceMatrix b, int l) Performs single Householder transformation on one column of a matrixboolean
isEmpty()
Check if the matrix is emptyint
leastExplainingColumn
(PaceMatrix b, IntVector pvt, int ks, int k0) Returns the index of the column that has the smallest (squared) response, when the column is moved to become the (ks-1)-th column.void
lsqr
(PaceMatrix b, IntVector pvt, int k0) QR transformation for a least squares problem
A x = b
implicitly both A and b are transformed.void
lsqrSelection
(PaceMatrix b, IntVector pvt, int k0) QR transformation for a least squares problem
A x = b
implicitly both A and b are transformed.static void
for testing onlydouble
maxAbs()
Returns the maximum absolute value of all elementsdouble
maxAbs
(int i0, int i1, int j) Returns the maximum absolute value of some elements of a column, that is, the elements of A[i0:i1][j].double
minAbs
(int i0, int i1, int column) Returns the minimum absolute value of some elements of a column, that is, the elements of A[i0:i1][j].int
mostExplainingColumn
(PaceMatrix b, IntVector pvt, int ks) Returns the index of the column that has the largest (squared) response, when each of columns pvt[ks:] is moved to become the ks-th column.nnls
(PaceMatrix b, IntVector pvt) Solves the nonnegative linear squares problem.nnlse
(PaceMatrix b, PaceMatrix c, PaceMatrix d, IntVector pvt) Solves the nonnegative least squares problem with equality constraint.nnlse1
(PaceMatrix b, IntVector pvt) Solves the nonnegative least squares problem with equality constraint.void
positiveDiagonal
(PaceMatrix Y, IntVector pvt) Sets all diagonal elements to be positive (or nonnegative) without changing the least squares solutionstatic Matrix
randomNormal
(int m, int n) Generate matrix with standard-normally distributed random elementsrbind
(PaceMatrix b) Returns a new matrix which binds two matrices together with rows.void
rsolve
(PaceMatrix b, IntVector pvt, int kp) Solves upper-triangular equation
R x = b
On output, the solution is stored in bvoid
setColumnDimension
(int columnDimension) Set the column dimenion of the matrixvoid
setMatrix
(double[] v, boolean columnFirst) Set the whole matrix from a 1-D arrayvoid
setMatrix
(int i0, int i1, int j0, int j1, double s) Set the submatrix A[i0:i1][j0:j1] with a same valuevoid
setMatrix
(int i0, int i1, int j, DoubleVector v) Set the submatrix A[i0:i1][j] with the values stored in a DoubleVectorvoid
setPlus
(int i, int j, double s) Add a value to an element and reset the elementvoid
setRowDimension
(int rowDimension) Set the row dimenion of the matrixvoid
setTimes
(int i, int j, double s) Multiply a value with an element and reset the elementvoid
steplsqr
(PaceMatrix b, IntVector pvt, int ks, int j, boolean adjoin) Stepwise least squares QR-decomposition of the problem A x = bdouble[]
sum2
(boolean col) Squared sum of columns or rows of a matrixdouble
sum2
(int j, int i0, int i1, boolean col) Squared sum of a column or row in a matrixdouble
times
(int i, int j0, int j1, PaceMatrix B, int l) Multiplication between a row (or part of a row) of the first matrix and a column (or part or a column) of the second matrix.toString()
Converts matrix to stringtoString
(int digits, boolean trailing) Converts matrix to string从类继承的方法 weka.core.matrix.Matrix
arrayLeftDivide, arrayLeftDivideEquals, arrayRightDivide, arrayRightDivideEquals, arrayTimes, arrayTimesEquals, chol, cond, constructWithCopy, copy, det, eig, get, getArray, getArrayCopy, getColumnDimension, getColumnPackedCopy, getMatrix, getMatrix, getMatrix, getMatrix, getRowDimension, getRowPackedCopy, identity, inverse, isSquare, isSymmetric, lu, minus, minusEquals, norm1, norm2, normF, normInf, parseMatlab, plus, plusEquals, print, print, print, print, qr, random, rank, read, regression, regression, set, setMatrix, setMatrix, setMatrix, setMatrix, solve, solveTranspose, sqrt, svd, times, times, timesEquals, toMatlab, trace, transpose, uminus, write
-
构造器详细资料
-
PaceMatrix
public PaceMatrix(int m, int n) Construct an m-by-n PACE matrix of zeros.- 参数:
m
- Number of rows.n
- Number of colums.
-
PaceMatrix
public PaceMatrix(int m, int n, double s) Construct an m-by-n constant PACE matrix.- 参数:
m
- Number of rows.n
- Number of colums.s
- Fill the matrix with this scalar value.
-
PaceMatrix
public PaceMatrix(double[][] A) Construct a PACE matrix from a 2-D array.- 参数:
A
- Two-dimensional array of doubles.- 抛出:
IllegalArgumentException
- All rows must have the same length
-
PaceMatrix
public PaceMatrix(double[][] A, int m, int n) Construct a PACE matrix quickly without checking arguments.- 参数:
A
- Two-dimensional array of doubles.m
- Number of rows.n
- Number of colums.
-
PaceMatrix
public PaceMatrix(double[] vals, int m) Construct a PaceMatrix from a one-dimensional packed array- 参数:
vals
- One-dimensional array of doubles, packed by columns (ala Fortran).m
- Number of rows.- 抛出:
IllegalArgumentException
- Array length must be a multiple of m.
-
PaceMatrix
Construct a PaceMatrix with a single column from a DoubleVector- 参数:
v
- DoubleVector
-
PaceMatrix
Construct a PaceMatrix from a Matrix- 参数:
X
- Matrix
-
-
方法详细资料
-
setRowDimension
public void setRowDimension(int rowDimension) Set the row dimenion of the matrix- 参数:
rowDimension
- the row dimension
-
setColumnDimension
public void setColumnDimension(int columnDimension) Set the column dimenion of the matrix- 参数:
columnDimension
- the column dimension
-
clone
Clone the PaceMatrix object. -
setPlus
public void setPlus(int i, int j, double s) Add a value to an element and reset the element- 参数:
i
- the row number of the elementj
- the column number of the elements
- the double value to be added with
-
setTimes
public void setTimes(int i, int j, double s) Multiply a value with an element and reset the element- 参数:
i
- the row number of the elementj
- the column number of the elements
- the double value to be multiplied with
-
setMatrix
public void setMatrix(int i0, int i1, int j0, int j1, double s) Set the submatrix A[i0:i1][j0:j1] with a same value- 参数:
i0
- the index of the first element of the columni1
- the index of the last element of the columnj0
- the index of the first columnj1
- the index of the last columns
- the value to be set to
-
setMatrix
Set the submatrix A[i0:i1][j] with the values stored in a DoubleVector- 参数:
i0
- the index of the first element of the columni1
- the index of the last element of the columnj
- the index of the columnv
- the vector that stores the values
-
setMatrix
public void setMatrix(double[] v, boolean columnFirst) Set the whole matrix from a 1-D array- 参数:
v
- 1-D array of doublescolumnFirst
- Whether to fill the column first or the row.- 抛出:
ArrayIndexOutOfBoundsException
- Submatrix indices
-
maxAbs
public double maxAbs()Returns the maximum absolute value of all elements- 返回:
- the maximum value
-
maxAbs
public double maxAbs(int i0, int i1, int j) Returns the maximum absolute value of some elements of a column, that is, the elements of A[i0:i1][j].- 参数:
i0
- the index of the first element of the columni1
- the index of the last element of the columnj
- the index of the column- 返回:
- the maximum value
-
minAbs
public double minAbs(int i0, int i1, int column) Returns the minimum absolute value of some elements of a column, that is, the elements of A[i0:i1][j].- 参数:
i0
- the index of the first element of the columni1
- the index of the last element of the columncolumn
- the index of the column- 返回:
- the minimum value
-
isEmpty
public boolean isEmpty()Check if the matrix is empty- 返回:
- true if the matrix is empty
-
getColumn
Return a DoubleVector that stores a column of the matrix- 参数:
j
- the index of the column- 返回:
- the column
-
getColumn
Return a DoubleVector that stores some elements of a column of the matrix- 参数:
i0
- the index of the first element of the columni1
- the index of the last element of the columnj
- the index of the column- 返回:
- the DoubleVector
-
times
Multiplication between a row (or part of a row) of the first matrix and a column (or part or a column) of the second matrix.- 参数:
i
- the index of the row in the first matrixj0
- the index of the first column in the first matrixj1
- the index of the last column in the first matrixB
- the second matrixl
- the index of the column in the second matrix- 返回:
- the result of the multiplication
-
toString
Converts matrix to string -
toString
Converts matrix to string- 参数:
digits
- number of digits after decimal pointtrailing
- true if trailing zeros are padded- 返回:
- the matrix as string
-
sum2
public double sum2(int j, int i0, int i1, boolean col) Squared sum of a column or row in a matrix- 参数:
j
- the index of the column or rowi0
- the index of the first elementi1
- the index of the last elementcol
- if true, sum over a column; otherwise, over a row- 返回:
- the squared sum
-
sum2
public double[] sum2(boolean col) Squared sum of columns or rows of a matrix- 参数:
col
- if true, sum over columns; otherwise, over rows- 返回:
- the squared sum
-
h1
public double[] h1(int j, int k) Constructs single Householder transformation for a column- 参数:
j
- the index of the columnk
- the index of the row- 返回:
- d and q
-
h2
Performs single Householder transformation on one column of a matrix- 参数:
j
- the index of the columnk
- the index of the rowq
- q = - u'u/2; must be negativeb
- the matrix to be transformedl
- the column of the matrix b
-
g1
public double[] g1(double a, double b) Constructs the Givens rotation- 参数:
a
-b
-- 返回:
- a double array that stores the cosine and sine values
-
g2
public void g2(double[] cs, int i0, int i1, int j) Performs the Givens rotation- 参数:
cs
- a array storing the cosine and sine valuesi0
- the index of the row of the first elementi1
- the index of the row of the second elementj
- the index of the column
-
forward
Forward ordering of columns in terms of response explanation. On input, matrices A and b are already QR-transformed. The indices of transformed columns are stored in the pivoting vector.- 参数:
b
- the PaceMatrix bpvt
- the pivoting vectork0
- the first k0 columns (in pvt) of A are not to be changed
-
mostExplainingColumn
Returns the index of the column that has the largest (squared) response, when each of columns pvt[ks:] is moved to become the ks-th column. On input, A and b are both QR-transformed.- 参数:
b
- responsepvt
- pivoting index of Aks
- columns pvt[ks:] of A are to be tested- 返回:
- the index of the column
-
backward
Backward ordering of columns in terms of response explanation. On input, matrices A and b are already QR-transformed. The indices of transformed columns are stored in the pivoting vector. A and b must have the same number of rows, being the (pseudo-)rank.- 参数:
b
- PaceMatrix bpvt
- pivoting vectorks
- number of QR-transformed columns; psuedo-rank of Ak0
- first k0 columns in pvt[] are not to be ordered.
-
leastExplainingColumn
Returns the index of the column that has the smallest (squared) response, when the column is moved to become the (ks-1)-th column. On input, A and b are both QR-transformed.- 参数:
b
- responsepvt
- pivoting index of Aks
- psudo-rank of Ak0
- A[][pvt[0:(k0-1)]] are excluded from the testing.- 返回:
- the index of the column
-
columnResponseExplanation
Returns the squared ks-th response value if the j-th column becomes the ks-th after orthogonal transformation. A[][pvt[ks:j]] (or A[][pvt[j:ks]], if ks > j) and b[] are already QR-transformed on input and will remain unchanged on output. More generally, it returns the inner product of the corresponding row vector of the response PaceMatrix. (To be implemented.)- 参数:
b
- PaceMatrix bpvt
- pivoting vectorj
- the column A[pvt[j]][] is to be movedks
- the target column A[pvt[ks]][]- 返回:
- the squared response value
-
lsqr
QR transformation for a least squares problem
A x = b
implicitly both A and b are transformed. pvt.size() is the psuedo-rank of A.- 参数:
b
- PaceMatrix bpvt
- pivoting vectork0
- the first k0 columns of A (indexed by pvt) are pre-chosen. (But subject to rank examination.) For example, the constant term may be reserved, in which case k0 = 1.
-
lsqrSelection
QR transformation for a least squares problem
A x = b
implicitly both A and b are transformed. pvt.size() is the psuedo-rank of A.- 参数:
b
- PaceMatrix bpvt
- pivoting vectork0
- the first k0 columns of A (indexed by pvt) are pre-chosen. (But subject to rank examination.) For example, the constant term may be reserved, in which case k0 = 1.
-
positiveDiagonal
Sets all diagonal elements to be positive (or nonnegative) without changing the least squares solution- 参数:
Y
- the responsepvt
- the pivoted column index
-
steplsqr
Stepwise least squares QR-decomposition of the problem A x = b- 参数:
b
- PaceMatrix bpvt
- pivoting vectorks
- number of transformed columnsj
- pvt[j], the column to adjoin or deleteadjoin
- to adjoin if true; otherwise, to delete
-
rsolve
Solves upper-triangular equation
R x = b
On output, the solution is stored in b- 参数:
b
- the responsepvt
- the pivoting vectorkp
- the number of the first columns involved
-
rbind
Returns a new matrix which binds two matrices together with rows.- 参数:
b
- the second matrix- 返回:
- the combined matrix
-
cbind
Returns a new matrix which binds two matrices with columns.- 参数:
b
- the second matrix- 返回:
- the combined matrix
-
nnls
Solves the nonnegative linear squares problem. That is,min || A x - b||, subject to x >= 0. For algorithm, refer to P161, Chapter 23 of C. L. Lawson and R. J. Hanson (1974). "Solving Least Squares Problems". Prentice-Hall.
- 参数:
b
- the responsepvt
- vector storing pivoting column indices- 返回:
- solution
-
nnlse
Solves the nonnegative least squares problem with equality constraint. That is,min ||A x - b||, subject to x >= 0 and c x = d. - 参数:
b
- the responsec
- coeficients of equality constraintsd
- constants of equality constraintspvt
- vector storing pivoting column indices- 返回:
- the solution
-
nnlse1
Solves the nonnegative least squares problem with equality constraint. That is,min ||A x - b||, subject to x >= 0 and || x || = 1. - 参数:
b
- the responsepvt
- vector storing pivoting column indices- 返回:
- the solution
-
randomNormal
Generate matrix with standard-normally distributed random elements- 参数:
m
- Number of rows.n
- Number of colums.- 返回:
- An m-by-n matrix with random elements.
-
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 覆盖:
getRevision
在类中Matrix
- 返回:
- the revision
-
main
for testing only- 参数:
args
- the commandline arguments - ignored
-