protected GAM getGAM(int[] attrs, double[][] knots, double[][] w, double intercept) {
		GAM gam = new GAM();
		for (int j = 0; j < attrs.length; j++) {
			int attIndex = attrs[j];
			double[] beta = w[j];
			boolean isLinear = beta.length == 1 || ArrayUtils.isConstant(beta, 1, beta.length, 0);
			if (isLinear) {
				if (beta[0] != 0) {
					// To rule out a feature, it has to be "linear" and 0 slope.
					gam.add(new int[] { attIndex }, new LinearFunction(attIndex, beta[0]));
				}
			} else {
				double[] coef = Arrays.copyOf(beta, beta.length);
				CubicSpline spline = new CubicSpline(attIndex, 0, knots[j], coef);
				gam.add(new int[] { attIndex }, spline);
			}
		}
		gam.setIntercept(intercept);
		return gam;
	}