haifengl / smile

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

Method in interface BaseArray can never return an int[] #760

Closed hewitta closed 7 months ago

hewitta commented 7 months ago

Describe the bug Method toIntArray(int[]a) on line 109 in the BaseVector interface only has code to return an exception and can never return an int[]

Expected behavior The method should return an int[]

Actual behavior My stacktrace: Exception in thread "main" java.lang.UnsupportedOperationException at smile.data.vector.BaseVector.toIntArray(BaseVector.java:110) at smile.data.vector.BaseVector.toIntArray(BaseVector.java:101) at smile.classification.ClassLabels.fit(ClassLabels.java:120) at smile.feature.selection.SignalNoiseRatio.fit(SignalNoiseRatio.java:80) at MLPTest2.calculateS2R(MLPTest2.java:112) at MLPTest2.main(MLPTest2.java:46)

Code snippet The code to reproduce the behavior.

Input data The sample data

Additional context

haifengl commented 7 months ago

I think that your class label column is probably StringVector. You should call

df2 = df.factorize("class", ...)

to factorize string columns to categorical first. Replace class to your column name.

hewitta commented 7 months ago

That worked, thank you