Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 17 00:58
    saudet commented #722
  • Jul 15 08:32
    ZeliangSu commented #693
  • Jun 28 01:15
    haifengl closed #722
  • Jun 26 19:01
    s2h22 edited #724
  • Jun 26 19:00
    s2h22 opened #724
  • Jun 21 21:37
    nyenggyang commented #723
  • Jun 21 21:25
    nyenggyang edited #723
  • Jun 21 21:25
    nyenggyang edited #723
  • Jun 21 21:25
    nyenggyang edited #723
  • Jun 21 20:08
    nyenggyang opened #723
  • May 20 16:21

    haifengl on master

    fix javadoc (compare)

  • May 19 16:02

    haifengl on master

    move ica package to smile.ica i… (compare)

  • May 19 15:45

    haifengl on master

    refactor KPCA remove Projection rename LinearProjection to Proj… (compare)

  • May 18 01:11

    haifengl on master

    extend DataFrame.toArray(column… refactor LinearProjection fix arpack and 2 more (compare)

  • May 17 13:29
    haifengl commented #722
  • May 16 14:08

    haifengl on master

    add KMedoidsImputer and remove … (compare)

  • May 16 01:31

    haifengl on master

    fix missing value detection bug (compare)

  • May 15 01:49

    haifengl on master

    refactor SVDImputer refactor LLSImputer refactor imputation test and 1 more (compare)

  • May 14 03:33
    dongdongunique commented #722
  • May 13 21:34

    haifengl on master

    move names()/type()/measures() … add KNNImputer (compare)

Haifeng Li
@haifengl
BTW, why do you call BLAS.getInstance().gemm(...) directly? It is better to use Matrix class.
Kamil Kloch
@kamilkloch
You miss classifier "" for arpack-ng
It did not help, same error
java.lang.NoClassDefFoundError: org/bytedeco/openblas/global/openblas

BTW, why do you call BLAS.getInstance().gemm(...) directly? It is better to use Matrix class.

Many changes have changed from 2.2.x to 2.5.x, to be honest I am struggling a lot to update the code. If there is any sample/doc/changelog, let me know, that would be very helpful.

Kamil Kloch
@kamilkloch
For example, smile.plot.swing.ScatterPlot.plot is gone and ScatterPlot.of does not accept and array of colors.
Haifeng Li
@haifengl
What SBT version are you using?
ScatterPlot.of automatically choose color if you pass an array y.
Javadoc is always updated. check it out
Kamil Kloch
@kamilkloch
@haifengl I just found a pretty nasty behaviour in sbt... sbt/sbt#5775
Kamil Kloch
@kamilkloch

@haifengl perhaps you could give a quick glance how to migrate the following piece of smile 2.2.x code into 2.5.x...

val canvas: PlotCanvas = smile.plot.swing.plot(data: Array[Array[Double]], label: Array[Int], legend: Array[Char], palette: Array[Color])

canvas.setAxisLabels(...)
canvas.setTitle(...)
PlotWindow.show("Clusters", canvas)

In 2.5.1

  • there is no corresponding signature of plot
  • the return value changed from PlotCanvasto Canvaswhich is no longer a JPanel
    Thanks!
Haifeng Li
@haifengl
@kamilkloch Have you checked the project website? All examples were updated with 2.5. For example
    val iris = read.arff("data/weka/iris.arff")
    val canvas = plot(iris, "sepallength", "sepalwidth", "class", '*')
    canvas.setAxisLabels("sepallength", "sepalwidth")
    show(canvas)
Kamil Kloch
@kamilkloch
@haifengl Thanks for the example. I still cannot solve my problem, though... I do now want to use smile.plot.show but rather assemble the swing components myself. In 2.2.x it was possible with PlotCanvas, in 2.5.x panel.add(canvas) no longer works. How do I make it work? Thanks!
Haifeng Li
@haifengl
new PlotCanvas(canvas)
Kamil Kloch
@kamilkloch

new PlotCanvas(canvas)

I cannot find PlotCanvas 2.5.1

*in 2.5.1
Haifeng Li
@haifengl
sorry, it is PlotPanel
and PlotGrid for a grid of canvas
Kamil Kloch
@kamilkloch

sorry, it is PlotPanel

Thanks, it works!
Back to the 'old ' vs 'new' plot: smile.plot.swing.plot supported an array of markers and an array of colors (we used a custom palette). Both options seem to be gone in 2.5.1?

Haifeng Li
@haifengl
color and markers are determined by y
Mzazvor
@Mzazvor
Hi. I have tried to move to smile 2.5 but I do get following error. sys::Err: java.lang.NoClassDefFoundError: org/bytedeco/openblas/global/openblas
smile.math.blas.openblas.OpenBLAS.gesdd (OpenBLAS.java:689) Does anyone have any idea how to fix that ?
Kamil Kloch
@kamilkloch

color and markers are determined by y

Does it mean that custom palette is no longer supported?

Haifeng Li
@haifengl
@Mzazvor you need add javacpp's openblas jar. See Readme for details
@kamilkloch no more custom palette. If you have to use your color choice, try to create multiple Point objects, each with its own color. you can add many Points into a plot.
implisci
@implisci
@haifengl any plans or possibilities for using GPUs using some unsafe libs? I think some java libs do that (deep learning for Java?), correct? Might be relevant for Neural Networks.
Haifeng Li
@haifengl
@implisci yes
implisci
@implisci
@haifengl The smile.math.matrix has a constructor which takes a 2D array of doubles and creates a smile.math.matrix.Matrix object which has inverse() and other linear algebra functions. The smile.cas.Matrix is a trait that extends Tensor. Given a smile.math.matrix.Matrix how does one use the smile.cas Matrix capabilities? I assume the main purpose of smile.cas is evaluating expressions from strings and returning various objects.
Haifeng Li
@haifengl
@implisci your understanding is correct. matrix.Matrix is for numeric computation. cas.Matrix is for symbolic computation.
implisci
@implisci
Thanks @haifengl. In matrix.Matrix is there a way to supress very small values (1E-15 or less) to display as 0.0? These values for off diagonal elements happens due to floating point precision in matrix multiplication, for example, when a matrix is multiplied with its inverse. Also is it possible to use numerical matrices as input to cas.Matrix ?
implisci
@implisci
The package.scala in cas says "substitution of symbols or numeric values for certain expressions". Could you clarify? How does this substitution work? Regarding my earlier question regarding small non-zero values (that are actually zero but non-zero due to precision limitations) I wonder if those can be recognized as (for example) an identity matrix using some library function without writing a transform for that.
Haifeng Li
@haifengl
@implisci what do you try to do?
Tatsuaki KOBAYASHI
@tatsunidas
Hi, everyone,
I would like to use GradientTreeBoost for feature selection purpose.
Could show me how to with simple sample code ?
Tatsuaki KOBAYASHI
@tatsunidas

SVM

Hi,
I want to use SVM(linear) with OneVsOne strategy for binary classification.
I tried it with reading reference page(https://haifengl.github.io/classification.html), but I got errors from fit() methods.
T[] is a generic type object array, but I prepared DataFrame, what shold I do ?
public void trainSVM(DataFrame data, DataFrame label, String[] headerArrayThatSortedByImportance, int numOfSelection) {
        String[] selectedFeatures = new String[numOfSelection];
        for(int i=0;i<numOfSelection;i++) {
            selectedFeatures[i] = headerArrayThatSortedByImportance[i];
        }
        double[][] x = data.select(selectedFeatures).toArray();
        double[] y = label.toArray()[0];
        double min = Arrays.stream(y).min().getAsDouble(); 
        if(min==0) {
            for(int i=0;i<y.length;i++) {
                if(y[i]==0) {
                    y[i] = -1;
                }
            }
        }
        LinearKernel kernel = new LinearKernel();//GaussianKernel(8.0);
        // I can not run here...
        SVM model = OneVersusOne.fit(x, y, (x, y) -> SVM.fit( x, y,kernel, 1, 1E-3));
    }
2 replies
Tatsuaki KOBAYASHI
@tatsunidas

@haifengl,
and user/developers

Hello,
SMILE is great product.

If you do not mind,please tell me how to do Group KFolds CrossValidation.
I found "GroupKFold" in API:http://haifengl.github.io/api/java/smile/validation/GroupKFold.html.
Then, I tried it, but I do not know following procedures,
1.I want to use SVM, what should I do/set parameters ?
int[] pred = new GropuKFold(1000,10,groups).classification(df, (??, ??) -> SVM.fit(????));
2.If I want visualize ROC curve, and calculate auc of each k, how to do that? When I use scikit-learn's GroupedkFold, I can load each folds dataset and can visualize all folds ROC with auc. By SMILE, how to perform?

Best regards,

13 replies
Tatsuaki KOBAYASHI
@tatsunidas

Sensitivity and Specificity

@haifengl

Hi, I have one question,

  1. Why SMILE Sensitivity.of() is return PPV ?
  2. Why SMILE Specificity.of() is return NPV ?

Or, my code is wrong ? (If so, so sory...)

Validation code is following,

        int[] truth = new int[] {0,0,0,0,0,1,1,1,1,1};
        int[] pred = new int[] {1,0,0,1,0,1,1,1,1,0};
        ConfusionMatrix mtx = ConfusionMatrix.of(truth, pred);
        System.out.println(mtx.toString());
        int[][] mat = mtx.matrix;
        double tn = mat[0][0];//tn
        double fn = mat[0][1];//fn
        double fp = mat[1][0];//fp
        double tp = mat[1][1];//tp
        double ppv = tp/(tp+fp);
        double tpr = tp/(tp+fn);
        double npv = tn/(tn+fn);
        double spc = tn/(fp+tn);
        System.out.println("TPR is "+tpr);//0.66
        System.out.println("PPV is "+ppv);//0.8
        System.out.println("SPC is "+spc);//0.75
        System.out.println("NPV is "+npv);//0.6
        System.out.println("Sensitivity is "+Sensitivity.of(truth, pred));//0.8
        System.out.println("Specificity is "+Specificity.of(truth, pred));//0.6
1 reply
Lukas Braach
@lukasbraach
Hey @haifengl , thank you for open-sourcing smile. I have a question regarding Random Forest classification training and inference: How am I supposed to represent missing values inside the input vector, using the DataFrame and Tuple classes?
Haifeng Li
@haifengl
@lukasbraach missing values should be null. Note that the column type should be to DoubleObjectType (instead of DoubleType). And we don't handle missing values in random forest. So you should impute the missing values first.
2 replies
Tatsuaki KOBAYASHI
@tatsunidas
Hello,
I'd like to compare SMILE GradientTreeBoost and scikit-learn GradientBoostingClassifier.
Do you think how set parameters to GradientTreeBoost ?
I think, I can not get same results, but I do not understand why that be not same. maybe, maxNode settings ...?
Haifeng Li
@haifengl
There are many implementation difference. You won't get exact results among any GBM packages.
1 reply
PedroSena
@PedroSena

HI Everyone, sorry for the newbie question but I'm kinda stuck here and didn't find a good way to work around the problem.
Basically I'm just trying to create a DataFrame from a SQL query but I keep getting an error:

       val url = "jdbc:postgresql://localhost/test"
        val props = Properties()
        props.setProperty("user", "test")
        props.setProperty("password", "test")
        val conn: Connection = DriverManager.getConnection(url, props)
        val rs = conn.createStatement().executeQuery("select 1 from homes")
        val df = DataFrame.of(rs)
        println(df)

and the error:

Exception in thread "main" java.lang.IllegalArgumentException: No enum constant java.sql.JDBCType.int4
    at java.base/java.lang.Enum.valueOf(Enum.java:240)
    at java.sql/java.sql.JDBCType.valueOf(JDBCType.java:34)
    at smile.data.type.DataTypes.struct(DataTypes.java:168)
    at smile.data.type.DataTypes.struct(DataTypes.java:158)
    at smile.data.DataFrame.of(DataFrame.java:1261)

I'm using org.postgresql:postgresql:42.2.12

10 replies
Jingwei-THU
@Jingwei-THU

Hi hifeng, I tried to use MultivariateGaussianMixture but have the following exception:
Warning: Could not load Loader: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopenblas_nolapack in java.library.path

I import the dependency in maven like this:

<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>2.5.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bytedeco/javacpp -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.5.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bytedeco/openblas -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>openblas</artifactId>
<version>0.3.9-1.5.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bytedeco/arpack-ng -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>arpack-ng</artifactId>
<version>3.7.0-1.5.3</version>
</dependency>

Haifeng Li
@haifengl
@Jingwei-THU can you try javacpp 1.5.4 (and accordingly openblas and arpack-ng)?
Tatsuaki KOBAYASHI
@tatsunidas
@haifengl
Hi,
Can I run my code with SMILE on GPU ?
Haifeng Li
@haifengl
no
ynjacobs
@ynjacobs
Hi @haifengl thanks again for this library! I'm wondering how I can go about reading lines from a dataframe, doing some computations and then making that into a new column of a dataframe. In python I could do something like:
new_col = lambda each_row: math.sqrt((3*each_row.first_column)**4 + (3*each_row.second_column)**4+ (3*each_row.third_column)**4) my_dataframe.apply(new_col)
Haifeng Li
@haifengl
Use smile.data.formula.Formula
import smile.data.formula.Formula;
import static smile.data.formula.Terms.*;
in scala, we have a DSL to write formula close to math form.
In Java, you have to assemble the formula by methods provided in Terms
ynjacobs
@ynjacobs
Thank you! And how would I get each row of the dataframe to make the computation on? Is that included in Formula? I'm using Java.