@Test public void testToString() { System.out.println("toString"); Formula formula = Formula.lhs("salary"); assertEquals("salary ~ .", formula.toString()); formula = Formula.rhs($("salary")); assertEquals(" ~ salary", formula.toString()); formula = Formula.of("salary", dot(), cross("a", "b", "c") , delete("d")); assertEquals("salary ~ . + (a x b x c) - d", formula.toString()); }
@Override public String toString() { String r = response == null ? "" : response.toString(); String p = Arrays.stream(predictors).map(predictor -> { String s = predictor.toString(); if (!s.startsWith("- ")) s = "+ " + s; return s; }).collect(Collectors.joining(" ")); if (p.startsWith("+ ")) p = p.substring(2); return String.format("%s ~ %s", r, p); }
Formula implements Serializable { @Override public String toString() { String r = response == null ? "" : response.toString(); String p = Arrays.stream(predictors).map(predictor -> { String s = predictor.toString(); if (!s.startsWith("- ")) s = "+ " + s; return s; }).collect(Collectors.joining(" ")); if (p.startsWith("+ ")) p = p.substring(2); return String.format("%s ~ %s", r, p); } }
Formula implements Serializable { @Override public String toString() { String r = response == null ? "" : response.toString(); String p = Arrays.stream(predictors).map(predictor -> { String s = predictor.toString(); if (!s.startsWith("- ")) s = "+ " + s; return s; }).collect(Collectors.joining(" ")); if (p.startsWith("+ ")) p = p.substring(2); return String.format("%s ~ %s", r, p); } Formula(Term response, Term... predictors); }
Formula implements Serializable { @Override public String toString() { String r = response == null ? "" : response.toString(); String p = Arrays.stream(predictors).map(predictor -> { String s = predictor.toString(); if (!s.startsWith("- ")) s = "+ " + s; return s; }).collect(Collectors.joining(" ")); if (p.startsWith("+ ")) p = p.substring(2); return String.format("%s ~ %s", r, p); } Formula(Term response, Term... predictors); Term[] predictors(); Term response(); @Override String toString(); @Override boolean equals(Object o); static Formula lhs(String lhs); static Formula lhs(Term lhs); static Formula rhs(String... predictors); static Formula rhs(Term... predictors); static Formula of(String response, String... predictors); static Formula of(String response, Term... predictors); static Formula of(Term response, Term... predictors); Formula expand(StructType inputSchema); StructType bind(StructType inputSchema); Tuple apply(Tuple t); Tuple x(Tuple t); DataFrame frame(DataFrame df); DataFrame x(DataFrame df); Matrix matrix(DataFrame df); Matrix matrix(DataFrame df, boolean bias); BaseVector y(DataFrame df); double y(Tuple t); int yint(Tuple t); }
Formula implements Serializable { @Override public String toString() { String r = response == null ? "" : response.toString(); String p = Arrays.stream(predictors).map(predictor -> { String s = predictor.toString(); if (!s.startsWith("- ")) s = "+ " + s; return s; }).collect(Collectors.joining(" ")); if (p.startsWith("+ ")) p = p.substring(2); return String.format("%s ~ %s", r, p); } Formula(Term response, Term... predictors); Term[] predictors(); Term response(); @Override String toString(); @Override boolean equals(Object o); static Formula lhs(String lhs); static Formula lhs(Term lhs); static Formula rhs(String... predictors); static Formula rhs(Term... predictors); static Formula of(String response, String... predictors); static Formula of(String response, Term... predictors); static Formula of(Term response, Term... predictors); Formula expand(StructType inputSchema); StructType bind(StructType inputSchema); Tuple apply(Tuple t); Tuple x(Tuple t); DataFrame frame(DataFrame df); DataFrame x(DataFrame df); Matrix matrix(DataFrame df); Matrix matrix(DataFrame df, boolean bias); BaseVector y(DataFrame df); double y(Tuple t); int yint(Tuple t);  }