haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
5.99k stars 1.12k forks source link

A Typo in the Javadoc documentation of Class smile.clustering.CentroidClustering<T,U> and a Possible Bug in class smile.data.formula.Formula #723

Closed nyenggyang closed 1 year ago

nyenggyang commented 2 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

nyenggyang commented 2 years ago

(1.) The Typo in class smile.clustering.CentroidClustering<T,U>

The centroids field or variable member of class smile.clustering.CentroidClustering<T,U> is documented here as being a 1D array (of type T), as follows: public final T[] centroids. However, this variable data member of this class is actually a 2D array (not a 1D array).

(2.) The Possible Bug in class smile.data.formula.Formula

My invocation of the following factory method of class smile.data.formula.Formula (shown in the point number 2A below) results in my getting the following exception report (shown in the point number 2B below, for Java code that is stored in a file named LinearRegression.java) when I ran the following lines of code in this file (shown in the point number 2C below):

(A) This is the method:

of(java.lang.String response, java.lang.String... predictors)

(B) This is the exception report:

Exception in thread "main" java.lang.UnsupportedOperationException: The data has no response variable. at smile.data.formula.Formula.y(Formula.java:438) at smile.regression.OLS.fit(OLS.java:122) at smile.regression.OLS.fit(OLS.java:105) at smile.regression.OLS.fit(OLS.java:85) at LinearRegression.main(LinearRegression.java:72)

(C) These are the lines of code:

65 DataFrame dataFrame = DataFrame.of(trainSetArray, columnNames); 68 Formula formula = Formula.of("SalesPrice", columnNames); 72 LinearModel linearModel = OLS.fit(formula, dataFrame);

Note the following about the lines of code shown in the foregoing point number 2C above:

Since I have provided a response variable in the second of the three lines of code above, I guess that there might be a bug in either the code of the of(java.lang.String response, java.lang.String... predictors) method of class smile.data.formula.Formula or some other code that the code of this method relies upon (in any case, after I checked the code implemented for this method in this class, I didn't see any reason why I should get the exception report shown in the foregoing point number 2B above).

I will be much obliged if someone can assist with an explanation for why I obtained the exception report shown in the foregoing point number 2B above.

Thanks in advance.