Creates a matrix from the data set, where each row represent a data point, and each column is one of the numeric example from the data set. This matrix can be altered and will not effect any of the values in the data set. @return a matrix of the data points.
()
| 707 | * @return a matrix of the data points. |
| 708 | */ |
| 709 | public Matrix getDataMatrix() |
| 710 | { |
| 711 | if(this.getSampleSize() > 0 && this.getDataPoint(0).getNumericalValues().isSparse()) |
| 712 | { |
| 713 | SparseVector[] vecs = new SparseVector[this.getSampleSize()]; |
| 714 | for(int i = 0; i < getSampleSize(); i++) |
| 715 | { |
| 716 | Vec row = getDataPoint(i).getNumericalValues(); |
| 717 | vecs[i] = new SparseVector(row); |
| 718 | } |
| 719 | |
| 720 | return new SparseMatrix(vecs); |
| 721 | } |
| 722 | else |
| 723 | { |
| 724 | DenseMatrix matrix = new DenseMatrix(this.getSampleSize(), this.getNumNumericalVars()); |
| 725 | |
| 726 | for(int i = 0; i < getSampleSize(); i++) |
| 727 | { |
| 728 | Vec row = getDataPoint(i).getNumericalValues(); |
| 729 | for(int j = 0; j < row.length(); j++) |
| 730 | matrix.set(i, j, row.get(j)); |
| 731 | } |
| 732 | |
| 733 | return matrix; |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * Creates a matrix backed by the data set, where each row is a data point |
no test coverage detected