public static double test(Regressor r, DataFactory d, int n) {
		double err = 0;
		for (int i = 0; i < n; i++) {
			Instance a = d.generateInstance();
			double[] y0 = r.predict(a.x);
			for (int j = 0; j < y0.length; j++) {
				double e = a.y[j] - y0[j];
				err += e * e / y0.length;
			}
		}
		return err / n;
	}