@Override
	public GAM build(Instances instances) {
		GAM gam = null;
		if (maxNumIters < 0) {
			maxNumIters = 20;
		}
		if (metric == null) {
			metric = task.getDefaultMetric();
		}
		switch (task) {
			case REGRESSION:
				if (validSet != null) {
					gam = buildRegressor(instances, validSet, maxNumIters, maxNumLeaves);
				} else {
					gam = buildRegressor(instances, maxNumIters, maxNumLeaves);
				}
				break;
			case CLASSIFICATION:
				if (validSet != null) {
					gam = buildClassifier(instances, validSet, maxNumIters, maxNumLeaves);
				} else {
					gam = buildClassifier(instances, maxNumIters, maxNumLeaves);
				}
				break;
			default:
				break;
		}
		return gam;
	}