src/machinelearning/Dataset.java
protected Pair<Dataset,Dataset> split(HashSet<Pair<Boolean,Integer>> predicate) {
		assert(predicate.size() > 0);
		for (Pair<Boolean,Integer> atom : predicate)
			assert(atom.second() >= 0 && atom.second() < attributes.size());
		assert(attributes.size() == positions.size());

		Dataset unsat = new Dataset(this, predicate);
		Dataset sat = new Dataset(this, predicate);

		for (int i=0; i<instances.size(); i++) {
			boolean satisfies = false;
			for (Pair<Boolean,Integer> atom : predicate)
				if (atom.first().equals(instances.get(i).attValues.get(atom.second()))) {
					satisfies = true;
					break;
				}

			if (!satisfies) {
				unsat.instances.add(new Instance(instances.get(i), predicate));
				if (instances.get(i).classValue)
					unsat.numYES++;
				else
					unsat.numNO++;
			} else {
				sat.instances.add(new Instance(instances.get(i), predicate));
				if (instances.get(i).classValue)
					sat.numYES++;
				else
					sat.numNO++;
			}
		}

		unsat.instances.trimToSize();
		sat.instances.trimToSize();

		return new Pair<Dataset,Dataset>(unsat, sat);
	}
/** Splits the dataset based on the values of the chosen attribute
	 * @param  predicate Disjunction (or a single atom) used to split the dataset
	 * @return Two datasets, first doesn't satisfy the predicate, second does
	 * */
Splits the dataset based on the values of the chosen attribute
@param  predicate Disjunction (or a single atom) used to split the dataset
@return Two datasets, first doesn't satisfy the predicate, second does
Splits the dataset based on the values of the chosen attribute @param predicate Disjunction ( or a single atom ) used to split the dataset @return Two datasets first doesn ' t satisfy the predicate second does
protected Pair<Dataset,Dataset> split(HashSet<Pair<Boolean,Integer>> predicate) {
		assert(predicate.size() > 0);
		for (Pair<Boolean,Integer> atom : predicate)
			assert(atom.second() >= 0 && atom.second() < attributes.size());
		assert(attributes.size() == positions.size());
		Dataset unsat = new Dataset(this, predicate);
		Dataset sat = new Dataset(this, predicate);
		for (int i=0; i<instances.size(); i++) {
			boolean satisfies = false;
			for (Pair<Boolean,Integer> atom : predicate)
				if (atom.first().equals(instances.get(i).attValues.get(atom.second()))) {
					satisfies = true;
					break;
				}
			if (!satisfies) {
				unsat.instances.add(new Instance(instances.get(i), predicate));
				if (instances.get(i).classValue)
					unsat.numYES++;
				else
					unsat.numNO++;
			} else {
				sat.instances.add(new Instance(instances.get(i), predicate));
				if (instances.get(i).classValue)
					sat.numYES++;
				else
					sat.numNO++;
			}
		}
		unsat.instances.trimToSize();
		sat.instances.trimToSize();
		return new Pair<Dataset,Dataset>(unsat, sat);
	}
protected Pair < Dataset , Dataset > split ( HashSet < Pair < Boolean , Integer > > predicate ) { assert ( predicate . size ( ) > 0 ) ; for ( Pair < Boolean , Integer > atom : predicate ) assert ( atom . second ( ) >= 0 && atom . second ( ) < attributes . size ( ) ) ; assert ( attributes . size ( ) == positions . size ( ) ) ; Dataset unsat = new Dataset ( this , predicate ) ; Dataset sat = new Dataset ( this , predicate ) ; for ( int i = 0 ; i < instances . size ( ) ; i ++ ) { boolean satisfies = false ; for ( Pair < Boolean , Integer > atom : predicate ) if ( atom . first ( ) . equals ( instances . get ( i ) . attValues . get ( atom . second ( ) ) ) ) { satisfies = true ; break ; } if ( ! satisfies ) { unsat . instances . add ( new Instance ( instances . get ( i ) , predicate ) ) ; if ( instances . get ( i ) . classValue ) unsat . numYES ++ ; else unsat . numNO ++ ; } else { sat . instances . add ( new Instance ( instances . get ( i ) , predicate ) ) ; if ( instances . get ( i ) . classValue ) sat . numYES ++ ; else sat . numNO ++ ; } } unsat . instances . trimToSize ( ) ; sat . instances . trimToSize ( ) ; return new Pair < Dataset , Dataset > ( unsat , sat ) ; }
Splits the dataset based on the values of the chosen attribute
 @param  predicate Disjunction (or a single atom) used to split the dataset
 @return Two datasets, first doesn't satisfy the predicate, second does
Splits the dataset based on the values of the chosen attribute @param predicate Disjunction ( or a single atom ) used to split the dataset @return Two datasets first doesn ' t satisfy the predicate second does