本文整理了Java中org.ujmp.core.Matrix.getAsInt()
方法的一些代码示例,展示了Matrix.getAsInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.getAsInt()
方法的具体详情如下:
包路径:org.ujmp.core.Matrix
类名称:Matrix
方法名:getAsInt
暂无
代码示例来源:origin: ujmp/universal-java-matrix-package
public int getInt(long... coordinates) {
return discretized.getAsInt(coordinates);
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public int getInt(long... coordinates) {
int col = getSource().getAsInt(coordinates[ROW], 0);
if (col == coordinates[COLUMN]) {
return 1;
} else {
return 0;
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public double getDouble(long... coordinates) {
final int value = getSource().getAsInt(coordinates);
switch (colorChannel) {
case Red:
return ((value >> 16) & 0xFF) / 255.0;
case Green:
return ((value >> 8) & 0xFF) / 255.0;
default:
return (value & 0xFF) / 255.0;
}
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public int getInt(long... coordinates) {
return getSource().getAsInt(coordinates);
}
代码示例来源:origin: kompics/kompics
@Override
public int bestActionAt(int state) {
Matrix stateRow = m.getRowList().get(state);
if (stateRow == null) {
stateRow = SparseMatrix.Factory.zeros(1, actions.length);
}
Matrix maxIndex = stateRow.indexOfMax(Calculation.Ret.NEW, Calculation.COLUMN);
//LOG.trace("Max is: {}", maxIndex);
return maxIndex.getAsInt(0, 0);
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public ValueToColumn(Matrix matrix) {
super(matrix);
if (matrix.getColumnCount() != 1) {
throw new RuntimeException("matrix must have one column");
}
for (long[] c : getSource().availableCoordinates()) {
max = Math.max(max, getSource().getAsInt(c));
}
this.size = new long[] { getSource().getRowCount(), max + 1 };
}
代码示例来源:origin: ujmp/universal-java-matrix-package
int aij = A.getAsInt(i, j);
M[i][j] = aij;
M[i][j + p] = aij + 2 * p * p;
代码示例来源:origin: jdmp/java-data-mining-package
public Map<String, Object> calculateObjects(Map<String, Object> input) {
Map<String, Object> result = new HashMap<String, Object>();
Matrix source = MathUtil.getMatrix(input.get(SOURCE));
Matrix target = Matrix.Factory.zeros(source.getRowCount(), 1);
long cols = source.getColumnCount();
long rows = source.getRowCount();
for (int k = 0; k < rows; k++) {
int tp = 0;
int fn = 0;
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
int count = source.getAsInt(r, c);
boolean expected = r == k;
boolean predicted = c == k;
if (expected && predicted) {
tp += count;
} else if (expected && (!predicted)) {
fn += count;
}
}
}
target.setAsDouble(MathUtil.sensitivity(tp, fn), k, 0);
}
result.put(TARGET, target);
return result;
}
代码示例来源:origin: jdmp/java-data-mining-package
public Map<String, Object> calculateObjects(Map<String, Object> input) {
Map<String, Object> result = new HashMap<String, Object>();
Matrix source = MathUtil.getMatrix(input.get(SOURCE));
Matrix target = Matrix.Factory.zeros(source.getRowCount(), 1);
long cols = source.getColumnCount();
long rows = source.getRowCount();
for (int k = 0; k < rows; k++) {
int tp = 0;
int fn = 0;
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
int count = source.getAsInt(r, c);
boolean expected = r == k;
boolean predicted = c == k;
if (expected && predicted) {
tp += count;
} else if (expected && (!predicted)) {
fn += count;
}
}
}
target.setAsDouble(MathUtil.recall(tp, fn), k, 0);
}
result.put(TARGET, target);
return result;
}
代码示例来源:origin: jdmp/java-data-mining-package
public Map<String, Object> calculateObjects(Map<String, Object> input) {
Map<String, Object> result = new HashMap<String, Object>();
Matrix source = MathUtil.getMatrix(input.get(SOURCE));
Matrix target = Matrix.Factory.zeros(source.getRowCount(), 1);
long cols = source.getColumnCount();
long rows = source.getRowCount();
for (int k = 0; k < rows; k++) {
int tp = 0;
int fp = 0;
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
int count = source.getAsInt(r, c);
boolean expected = r == k;
boolean predicted = c == k;
if (expected && predicted) {
tp += count;
} else if ((!expected) && predicted) {
fp += count;
}
}
}
target.setAsDouble(MathUtil.precision(tp, fp), k, 0);
}
result.put(TARGET, target);
return result;
}
代码示例来源:origin: jdmp/java-data-mining-package
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
int count = source.getAsInt(r, c);
boolean expected = r == k;
boolean predicted = c == k;
代码示例来源:origin: jdmp/java-data-mining-package
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
int count = source.getAsInt(r, c);
boolean expected = r == k;
boolean predicted = c == k;
代码示例来源:origin: jdmp/java-data-mining-package
public void trainAll(ListDataSet dataSet) {
Matrix dataSetInput = dataSet.getInputMatrix();
Matrix max = dataSetInput.max(Ret.NEW, Matrix.ROW);
cumSum = new ArrayList<Integer>((int) max.getColumnCount());
int sum = 0;
cumSum.add(sum);
for (int i = (int) max.getColumnCount() - 1; i != -1; i--) {
sum += max.getAsInt(0, i) + 1;
cumSum.add(sum);
}
LabelAlphabet inputAlphabet = new LabelAlphabet();
int featureCount = getFeatureCount(dataSet);
for (int i = 0; i < featureCount; i++) {
// iterate from 1 to max (inclusive!)
for (int fv = 1; fv < max.getAsDouble(0, i) + 1; fv++) {
inputAlphabet.lookupIndex("Feature" + i + "=" + fv, true);
}
}
LabelAlphabet targetAlphabet = new LabelAlphabet();
for (int i = 0; i < dataSet.getTargetMatrix().getColumnCount(); i++) {
targetAlphabet.lookupIndex("Class" + i, true);
}
InstanceList trainingSet = new DataSet2InstanceList(dataSet, inputAlphabet, targetAlphabet, cumSum);
classifier = trainer.train(trainingSet);
}
代码示例来源:origin: ujmp/universal-java-matrix-package
int count = result.getAsInt(row, i);
result.setAsInt(++count, row, i);
代码示例来源:origin: ujmp/universal-java-matrix-package
case INT:
for (long r = 0; r < rowCount; r++) {
Integer c = m.getAsInt(r, column);
rows.add(new Sortable<Integer, Long>(c, r, true));
内容来源于网络,如有侵权,请联系作者删除!