public KMeansPartition run(IDoubleMatrix input){
  mProblemInput=input;
  if (mNumClusters == -1) {
    mNumClusters=(int)Math.round(Math.sqrt(input.getRowNum()));
  }
  mRunSummary=new ArrayList<RunSummary>();
  KMeansPartition minPartition=null;
  double minScore=Double.MAX_VALUE;
  for (int i=0; i < mNumRuns; i++) {
    final long localSeed=mGlobalRandom.nextLong();
    mRandom=new Random(localSeed);
    mPartition=new KMeansPartition();
    final long startTime=System.currentTimeMillis();
    int j=0;
    while (!mPartition.iterateOnce() && j < mMaxIterations) {
      j++;
    }
    final long stopTime=System.currentTimeMillis();
    final long duration=stopTime - startTime;
    mRunSummary.add(new RunSummary(costFunction(),j,duration,localSeed));
    if (minScore > costFunction()) {
      minPartition=mPartition;
      minScore=costFunction();
    }
  }
  return minPartition;
}

public KMeansPartition run ( IDoubleMatrix input ) { mProblemInput = input ; if ( mNumClusters == - 1 ) { mNumClusters = ( int ) Math . round ( Math . sqrt ( input . getRowNum ( ) ) ) ; } mRunSummary = new ArrayList < RunSummary > ( ) ; KMeansPartition minPartition = null ; double minScore = Double . MAX_VALUE ; for ( int i = 0 ; i < mNumRuns ; i ++ ) { final long localSeed = mGlobalRandom . nextLong ( ) ; mRandom = new Random ( localSeed ) ; mPartition = new KMeansPartition ( ) ; final long startTime = System . currentTimeMillis ( ) ; int j = 0 ; while ( ! mPartition . iterateOnce ( ) && j < mMaxIterations ) { j ++ ; } final long stopTime = System . currentTimeMillis ( ) ; final long duration = stopTime - startTime ; mRunSummary . add ( new RunSummary ( costFunction ( ) , j , duration , localSeed ) ) ; if ( minScore > costFunction ( ) ) { minPartition = mPartition ; minScore = costFunction ( ) ; } } return minPartition ; }
run on given matrix . each row represents a point to be clustered
