Changeset 49 for trunk/CrossPare/src/de/ugoe/cs/cpdp
- Timestamp:
- 03/03/16 11:41:22 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/MetricMatchingTraining.java
r48 r49 107 107 else if (this.method.equals("kolmogorov")) { 108 108 tmp.kolmogorovSmirnovTest(this.threshold); 109 } 110 else if( this.method.equals("percentile") ) { 111 tmp.percentiles(this.threshold); 109 112 } 110 113 else { … … 403 406 } 404 407 408 /** 409 * Calculates the Percentiles of the source and target metrics. 410 * 411 * @param cutoff 412 */ 413 public void percentiles(double cutoff) { 414 for( int i = 0; i < this.train.numAttributes()-1; i++ ) { 415 for( int j = 0; j < this.test.numAttributes()-1; j++ ) { 416 // class attributes are not relevant 417 if( this.train.classIndex() == i ) { 418 continue; 419 } 420 if( this.test.classIndex() == j ) { 421 continue; 422 } 423 424 425 if( !this.attributes.containsKey(i) ) { 426 // get percentiles 427 double train[] = this.train_values.get(i); 428 double test[] = this.test_values.get(j); 429 430 Arrays.sort(train); 431 Arrays.sort(test); 432 433 // percentiles 434 double train_p; 435 double test_p; 436 double score = 0.0; 437 for( double p=0.1; p < 1; p+=0.1 ) { 438 train_p = train[(int)Math.ceil(train.length * p)]; 439 test_p = test[(int)Math.ceil(test.length * p)]; 440 441 if( train_p > test_p ) { 442 score += test_p / train_p; 443 }else { 444 score += train_p / test_p; 445 } 446 } 447 448 if( score > cutoff ) { 449 this.attributes.put(i, j); 450 } 451 } 452 } 453 } 454 } 405 455 406 456 /**
Note: See TracChangeset
for help on using the changeset viewer.