haifengl / smile

Statistical Machine Intelligence & Learning Engine

Home Page:https://haifengl.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method in interface BaseArray can never return an int[]

hewitta opened this issue · comments

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

  • What Java (OpenJDK, Orack JDK, etc.) are you using and which Java version
  • Which Smile version 3.0.2
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian )
  • Add any other context about the problem here.

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.

That worked, thank you