本文整理汇总了Java中org.openimaj.util.pair.IntDoublePair类的典型用法代码示例。如果您正苦于以下问题:Java IntDoublePair类的具体用法?Java IntDoublePair怎么用?Java IntDoublePair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntDoublePair类属于org.openimaj.util.pair包,在下文中一共展示了IntDoublePair类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandCluster
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
private void expandCluster(int p, List<IntDoublePair> region, TIntList cluster, State state) {
addToCluster(p,cluster,state);
for (int regionIndex = 0; regionIndex < region.size(); regionIndex++) {
int pprime = region.get(regionIndex).first;
if (!state.visited.contains(pprime)){
state.visited.add(pprime);
List<IntDoublePair> regionPrime = state.regionMode.regionQuery(pprime);
if(state.regionMode.validRegion(regionPrime))
region.addAll(regionPrime);
else
state.noise.add(pprime);
}
addToCluster(pprime, cluster, state);
}
}
示例2: chooseSplit
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
@Override
public IntDoublePair chooseSplit(double[][] pnts, IntArrayView inds, int depth, double[] minBounds, double[] maxBounds) {
if(inds.size() < minpts) return null;
double[][] subarr = new double[inds.size()][ndims];
for (int i = 0; i < subarr.length; i++) {
double[] pnti = pnts[inds.get(i)];
for (int dim = startindex; dim < startindex + ndims; dim++) {
subarr[i][dim-startindex] = pnti[dim];
}
}
Matrix mat = new Matrix(subarr);
Matrix mean = MatrixUtils.sumCols(mat).times(1./inds.size());
Matrix var = MatrixUtils.sumCols(mat.arrayTimes(mat)).times(1./inds.size()).minus(mean.arrayTimes(mean));
if(firstVariances == null){
firstVariances = var;
double[] variances = var.getArray()[0];
if(max.evaluate(variances) == 0){
return null; // special case, if the first variance is null we've been handed ALL the same, screw it
}
}
Matrix propchange = var.arrayRightDivide(firstVariances);
if(max.evaluate(propchange.getArray()[0]) < varprop){
return null;
}
else{
IntDoublePair maxDim = maxDim(MatrixUtils.abs(var).getArray()[0]);
double[] col = mat.getMatrix(0, inds.size()-1, maxDim.first, maxDim.first).transpose().getArray()[0];
double mid = detectionMode.detect(col);
return IntDoublePair.pair(maxDim.first+startindex,mid);
}
}
示例3: maxDim
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
private IntDoublePair maxDim(double[] ds) {
double maxv = -Double.MAX_VALUE;
int maxi = -1;
for (int i = 0; i < ds.length; i++) {
if(maxv < ds[i]){
maxi = i;
maxv = ds[i];
}
}
return IntDoublePair.pair(maxi, maxv);
}
示例4: regionQuery
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
@Override
public List<IntDoublePair> regionQuery(int index) {
List<IntDoublePair> res = nn.searchKNN(data[index], data.length);
List<IntDoublePair> ret = new ArrayList<IntDoublePair>();
for (IntDoublePair intFloatPair : res) {
if(intFloatPair.second<eps)ret.add(intFloatPair);
else break;
}
return ret;
}
示例5: detectInactive
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
/**
* Given the old and new clusters, make a decision as to which rows are now inactive,
* and therefore which clusters are now completed
* @param oldClusters
* @param newClusters
* @param inactiveRows
* @param completedClusters
*/
protected void detectInactive(IndexClusters oldClusters, IndexClusters newClusters, TIntSet inactiveRows, List<int[]> completedClusters) {
Map<Integer, IntDoublePair> stability = calculateStability(oldClusters,newClusters,inactiveRows);
for (Entry<Integer, IntDoublePair> e : stability.entrySet()) {
if(e.getValue().second >= threshold){
int[] completedCluster = oldClusters.clusters()[e.getKey()];
inactiveRows.addAll(completedCluster);
completedClusters.add(completedCluster);
if(threshold == 1){
newClusters.clusters()[e.getValue().first] = new int[0];
}
}
}
}
示例6: calculateStability
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
protected Map<Integer, IntDoublePair> calculateStability(IndexClusters c1, IndexClusters c2, TIntSet inactiveRows) {
Map<Integer, IntDoublePair> stability = new HashMap<Integer, IntDoublePair>();
int[][] clusters1 = c1.clusters();
int[][] clusters2 = c2.clusters();
for (int i = 0; i < clusters1.length; i++) {
if(clusters1[i].length == 0) continue;
double maxnmi = 0;
int maxj = -1;
TIntArrayList cluster = new TIntArrayList(clusters1[i].length);
for (int j = 0; j < clusters1[i].length; j++) {
if(inactiveRows.contains(clusters1[i][j]))
continue;
cluster.add(clusters1[i][j]);
}
int[][] correct = new int[][]{cluster.toArray()};
for (int j = 0; j < clusters2.length; j++) {
int[][] estimated = new int[][]{clusters2[j]};
// NMIAnalysis nmi = new NMIClusterAnalyser().analyse(correct, estimated);
double score = 0;
if(correct[0].length == 1 && estimated[0].length == 1){
// BOTH 1, either they are the same or not!
score = correct[0][0] == estimated[0][0] ? 1 : 0;
}
else{
score = new FScoreClusterAnalyser().analyse(correct, estimated).score();
}
if(!Double.isNaN(score))
{
if(score > maxnmi){
maxnmi = score;
maxj = j;
}
}
}
stability.put(i, IntDoublePair.pair(maxj, maxnmi));
}
logger.debug(String.format("The stability is:\n%s",stability));
return stability;
}
示例7: doClassify
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
private void doClassify(double[] mean) {
if (points.size() > 0) {
final DoubleNearestNeighboursExact nn = new DoubleNearestNeighboursExact(
points.toArray(new double[points.size()][]));
final List<IntDoublePair> neighbours = nn.searchKNN(mean, k);
final int[] counts = new int[CLASSES.length];
for (final IntDoublePair p : neighbours) {
counts[this.classes.get(p.first)]++;
final double[] pt = this.points.get(p.first);
final Point2dImpl pti = projectPoint(pt);
image.drawPoint(pti, RGBColour.MAGENTA, POINT_SIZE);
image.drawShape(new Circle(pti, CIRCLE_SIZE), CIRCLE_THICKNESS, RGBColour.GREEN);
}
imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
final int[] indices = ArrayUtils.range(0, counts.length - 1);
ArrayUtils.parallelQuicksortDescending(counts, indices);
if (counts.length == 1 || counts[0] > counts[1]) {
guess.setText((String) this.classType.getItemAt(indices[0]));
return;
}
}
guess.setText("unknown");
}
示例8: doClassify
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
private Float[] doClassify(double[] mean) {
if (points.size() > 0) {
final DoubleNearestNeighboursExact nn = new DoubleNearestNeighboursExact(
points.toArray(new double[points.size()][]));
final List<IntDoublePair> neighbours = nn.searchKNN(mean, k);
if (neighbours.get(0).second > 0.05) {
guess.setText("unknown");
return RGBColour.MAGENTA;
}
final int[] counts = new int[CLASSES.length];
for (final IntDoublePair p : neighbours) {
counts[this.classes.get(p.first)]++;
final double[] pt = this.points.get(p.first);
final Point2dImpl pti = projectPoint(pt);
image.drawPoint(pti, RGBColour.MAGENTA, POINT_SIZE);
image.drawShape(new Circle(pti, CIRCLE_SIZE), CIRCLE_THICKNESS, RGBColour.GREEN);
}
imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
final int[] indices = ArrayUtils.range(0, counts.length - 1);
ArrayUtils.parallelQuicksortDescending(counts, indices);
if (counts.length == 1 || counts[0] > counts[1]) {
guess.setText(this.classType.getItemAt(indices[0]));
return COLOURS[indices[0]];
}
}
guess.setText("unknown");
return RGBColour.MAGENTA;
}
示例9: doClassify
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
private void doClassify(double[] mean) {
if (points.size() > 0) {
final DoubleNearestNeighboursExact nn = new DoubleNearestNeighboursExact(
points.toArray(new double[points.size()][]));
final List<IntDoublePair> neighbours = nn.searchKNN(mean, k);
final int[] counts = new int[CLASSES.length];
for (final IntDoublePair p : neighbours) {
counts[this.classes.get(p.first)]++;
final double[] pt = this.points.get(p.first);
final Point2dImpl pti = projectPoint(pt);
image.drawPoint(pti, RGBColour.MAGENTA, POINT_SIZE);
image.drawShape(new Circle(pti, CIRCLE_SIZE), CIRCLE_THICKNESS, RGBColour.GREEN);
}
imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
final int[] indices = ArrayUtils.range(0, counts.length - 1);
ArrayUtils.parallelQuicksortDescending(counts, indices);
if (counts.length == 1 || counts[0] > counts[1]) {
guess.setText(this.classType.getItemAt(indices[0]));
return;
}
}
guess.setText("unknown");
}
示例10: assignDistance
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
@Override
public IntDoublePair assignDistance(double[] data) {
throw new UnsupportedOperationException();
}
示例11: State
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
/**
* @param length
* @param regionMode
* @param noiseAsClusters treat noise as isolated clusters
*/
public State(int length, RegionMode<IntDoublePair> regionMode, boolean noiseAsClusters){
this.regionMode = regionMode;
this.length = length;
this.noiseAsClusters = noiseAsClusters;
}
示例12: validRegion
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
@Override
public boolean validRegion(List<IntDoublePair> region) {
return region.size() >= minPts;
}
示例13: defaultHardAssigner
import org.openimaj.util.pair.IntDoublePair; //导入依赖的package包/类
@Override
public HardAssigner<double[], double[], IntDoublePair> defaultHardAssigner() {
return new ExactDoubleAssigner(this, DoubleFVComparison.INNER_PRODUCT);
}