Hello, I use java language to write elastic network regression, when building the model, error display null pointer. After I debug the idea display and formula binding is empty. After reading the source code and documentation, I still have not solved it. I hope to get your help, thank you
double[][] data = {
{1.2,2.3,3.5,4.3},
{2.2,3.3,4.5,5.3},
{3.2,4.3,5.5,6.3},
{4.2,5.3,6.5,7.3},
{5.2,6.3,7.5,8.3},
{6.2,7.3,8.5,9.3},
{7.2,8.3,9.5,10.3}
};
String[] columns = {"Feature1","Feature2","Feature3", "Target"};
DataFrame df = DataFrame.of(data, columns);
System.out.println("DataFrame:");
System.out.println(df);
Formula formula = Formula.of("Target", "Feature1", "Feature2", "Feature3"});
Properties prop = new Properties();
prop.setProperty("lambda1", "0.1");
prop.setProperty("lambda2", "0.2");
prop.setProperty("max.iterations", "100");
prop.setProperty("tol", "1e-6");
LinearModel elasticNet = ElasticNet.fit(formula, df,prop);
以下是我的报错:
Exception in thread "main" java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at java.lang.Double.valueOf(Double.java:502)
at smile.regression.ElasticNet.fit(ElasticNet.java:58)
at com.smile.ElasticNR.main(ElasticNR.java:70)
Hello, I use java language to write elastic network regression, when building the model, error display null pointer. After I debug the idea display and formula binding is empty. After reading the source code and documentation, I still have not solved it. I hope to get your help, thank you double[][] data = { {1.2,2.3,3.5,4.3}, {2.2,3.3,4.5,5.3}, {3.2,4.3,5.5,6.3}, {4.2,5.3,6.5,7.3}, {5.2,6.3,7.5,8.3}, {6.2,7.3,8.5,9.3}, {7.2,8.3,9.5,10.3} }; String[] columns = {"Feature1","Feature2","Feature3", "Target"}; DataFrame df = DataFrame.of(data, columns); System.out.println("DataFrame:"); System.out.println(df); Formula formula = Formula.of("Target", "Feature1", "Feature2", "Feature3"}); Properties prop = new Properties(); prop.setProperty("lambda1", "0.1"); prop.setProperty("lambda2", "0.2"); prop.setProperty("max.iterations", "100"); prop.setProperty("tol", "1e-6");
LinearModel elasticNet = ElasticNet.fit(formula, df,prop); 以下是我的报错: Exception in thread "main" java.lang.NullPointerException at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838) at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110) at java.lang.Double.parseDouble(Double.java:538) at java.lang.Double.valueOf(Double.java:502) at smile.regression.ElasticNet.fit(ElasticNet.java:58) at com.smile.ElasticNR.main(ElasticNR.java:70)