本文整理了Java中Jama.Matrix.read()
方法的一些代码示例,展示了Matrix.read()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.read()
方法的具体详情如下:
包路径:Jama.Matrix
类名称:Matrix
方法名:read
暂无
代码示例来源:origin: marytts/marytts
public void multipleLinearRegression(String fileName, boolean interceptTerm) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
Matrix indVar = data.getMatrix(0, rows, 0, 0); // dataVowels(:,0) -> col 0 is the independent variable
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
multipleLinearRegression(indVar, data, interceptTerm);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
public void multipleLinearRegression(String fileName, boolean interceptTerm) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
Matrix indVar = data.getMatrix(0, rows, 0, 0); // dataVowels(:,0) -> col 0 is the independent variable
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
multipleLinearRegression(indVar, data, interceptTerm);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
代码示例来源:origin: marytts/marytts
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
代码示例来源:origin: marytts/marytts
private int[] checkMeanColumns(String dataFile, int Y[], String[] features) {
try {
BufferedReader reader = new BufferedReader(new FileReader(dataFile));
Matrix data = Matrix.read(reader);
reader.close();
data = data.transpose(); // then I have easy access to the columns
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
int M = data.getRowDimension();
double mn;
for (int i = 0; i < M; i++) {
mn = MathUtils.mean(data.getArray()[i]);
if (mn == 0.0) {
System.out.println("Removing feature: " + features[i] + " from list of features because it has mean=0.0");
Y = MathUtils.removeIndex(Y, i);
}
}
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + dataFile, e);
}
System.out.println();
return Y;
}
代码示例来源:origin: marytts/marytts
private int[] checkMeanColumns(String dataFile, int Y[], String[] features) {
try {
BufferedReader reader = new BufferedReader(new FileReader(dataFile));
Matrix data = Matrix.read(reader);
reader.close();
data = data.transpose(); // then I have easy access to the columns
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
int M = data.getRowDimension();
double mn;
for (int i = 0; i < M; i++) {
mn = MathUtils.mean(data.getArray()[i]);
if (mn == 0.0) {
System.out.println("Removing feature: " + features[i] + " from list of features because it has mean=0.0");
Y = MathUtils.removeIndex(Y, i);
}
}
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + dataFile, e);
}
System.out.println();
return Y;
}
代码示例来源:origin: marytts/marytts
/***
* PCA
*
* @param fileName
* data one column per dimension or linguistic factor
* @param eigen
* if true use eigenvalues, if false use svd (recomended)
* @param scale
* if true use z-normalisation (recomended), if false substract off the mean for ecah dimension
*/
public void principalComponentAnalysis(String fileName, boolean eigen, boolean scale) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
if (eigen)
eigenPCA(data.transpose(), scale, false);
else
svdPCA(data.transpose(), scale, false);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
/***
* PCA
*
* @param fileName
* data one column per dimension or linguistic factor
* @param eigen
* if true use eigenvalues, if false use svd (recomended)
* @param scale
* if true use z-normalisation (recomended), if false substract off the mean for ecah dimension
*/
public void principalComponentAnalysis(String fileName, boolean eigen, boolean scale) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
if (eigen)
eigenPCA(data.transpose(), scale, false);
else
svdPCA(data.transpose(), scale, false);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
public void predictValues(String fileName, int indVariable, int[] c, boolean interceptTerm, int rowIni, int rowEnd) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
代码示例来源:origin: marytts/marytts
public void predictValues(String fileName, int indVariable, int[] c, boolean interceptTerm, int rowIni, int rowEnd) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
代码示例来源:origin: marytts/marytts
Matrix dataVowels = Matrix.read(reader);
int rows = dataVowels.getRowDimension() - 1;
int cols = dataVowels.getColumnDimension() - 1;
代码示例来源:origin: marytts/marytts
Matrix dataVowels = Matrix.read(reader);
int rows = dataVowels.getRowDimension() - 1;
int cols = dataVowels.getColumnDimension() - 1;
代码示例来源:origin: bcdev/beam
int weighted = Integer.valueOf(stok.nextToken());
int dimension = Integer.valueOf(stok.nextToken());
double[][] df = Matrix.read(in).getArray();
this.npoints = df.length;
this.np = this.npoints;
代码示例来源:origin: bcdev/beam
@Override
protected void setUp() throws Exception {
endmembers = Matrix.read(getResourceReader("endmember-spectra.csv"));
spectra = Matrix.read(getResourceReader("pixel-spectra.csv"));
}
}
代码示例来源:origin: de.dfki.mary/marytts-runtime
private int[] checkMeanColumns(String dataFile, int Y[], String[] features) {
try {
BufferedReader reader = new BufferedReader(new FileReader(dataFile));
Matrix data = Matrix.read(reader);
reader.close();
data = data.transpose(); // then I have easy access to the columns
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
int M = data.getRowDimension();
double mn;
for (int i = 0; i < M; i++) {
mn = MathUtils.mean(data.getArray()[i]);
if (mn == 0.0) {
System.out.println("Removing feature: " + features[i] + " from list of features because it has mean=0.0");
Y = MathUtils.removeIndex(Y, i);
}
}
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + dataFile, e);
}
System.out.println();
return Y;
}
代码示例来源:origin: bcdev/beam
public void testUnconstrainedUnmixing() throws IOException {
SpectralUnmixing mlm = new UnconstrainedLSU(endmembers.getArray());
Matrix abundUnconstrBeam = new Matrix(mlm.unmix(spectra.getArray()));
Matrix abundUnconstrEnvi = Matrix.read(getResourceReader("abundances-unconstr-envi.csv"));
Matrix abundUnconstrExpected = Matrix.read(getResourceReader("abundances-unconstr-expected.csv"));
assertEquals("Difference of abundances (BEAM minus ENVI, unconstrained)",
0.0,
maxAbs(abundUnconstrBeam.minus(abundUnconstrEnvi)),
1e-4);
assertEquals("Difference of abundances (BEAM minus EXPECTED, unconstrained)",
0.0,
maxAbs(abundUnconstrBeam.minus(abundUnconstrExpected)),
1e-7);
}
代码示例来源:origin: bcdev/beam
public void testConstrainedUnmixing() throws IOException {
SpectralUnmixing mlmC = new ConstrainedLSU(endmembers.getArray());
Matrix abundConstrBeam = new Matrix(mlmC.unmix(spectra.getArray()));
Matrix abundConstrEnvi = Matrix.read(getResourceReader("abundances-constr-envi.csv"));
Matrix abundConstrExpected = Matrix.read(getResourceReader("abundances-constr-expected.csv"));
assertEquals("Difference of abundances (BEAM minus ENVI, constrained)",
0.0,
maxAbs(abundConstrBeam.minus(abundConstrEnvi)),
1e-2);
assertEquals("Difference of abundances (BEAM minus EXPECTED, constrained)",
0.0,
maxAbs(abundConstrBeam.minus(abundConstrExpected)),
1e-7);
assertEquals("Sum of abundances must be 1 (constrained)",
0.0,
maxAbsDeltaRowSumFromOne(abundConstrBeam),
1e-15);
}
代码示例来源:origin: gov.nist.math/jama
A.print(FILE,fmt,10);
FILE.close();
R = Matrix.read(new BufferedReader(new FileReader("JamaTestMatrix.out")));
if (A.minus(R).norm1() < .001 ) {
try_success("print()/read()...","");
A.print(FILE,fmt,10);
FILE.close();
R = Matrix.read(new BufferedReader(new FileReader("JamaTestMatrix.out")));
if (A.minus(R).norm1() < .001 ) {
try_success("print()/read()...","");
内容来源于网络,如有侵权,请联系作者删除!