Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 21 19:30
    haifengl closed #723
  • Aug 21 19:30
    haifengl closed #724
  • Aug 21 19:29
    haifengl closed #725
  • Aug 15 19:55
    Mikhail42 commented #725
  • Aug 15 19:54
    haifengl commented #725
  • Aug 15 19:51
    Mikhail42 commented #725
  • Aug 15 19:49
    Mikhail42 opened #725
  • 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)

Christopher Small
@metasoarous
@haifengl I did some more digging on the PCA performance issues and was able to rule out something upstream of smile causing the slowdown. Looking at the implementation, it seems as if the only thing upstream of the SVD itself is the recentering step (and copying of data into a matrix):
        double[] mu = MathEx.colMeans(data);
        Matrix x = new Matrix(data);
        for (int j = 0; j < n; j++) {
            for (int i = 0; i < m; i++) {
                x.sub(i, j, mu[j]);
            }
        }
Please let me know if anything comes to mind about why this might be so slow. Thanks!
Haifeng Li
@haifengl
@implisci scala has a DSL for matrix computation in smile.math.matrix. check out online document for usage.
Kamil Kloch
@kamilkloch
Hello all, what happened to smile-netlib? Last release is 2.4.0, smile-core 2.5.0 no longer depends on it.
Haifeng Li
@haifengl
@kamilkloch we don't need smile-netlib any more. OpenBLAS/MKL is in use from 2.5.0
jansiroky
@jansiroky
Hello, we do face a problem with OLS and SVD convergence. We call OLS.fit(Formula.lhs("y"), data, "svd", false, false) and for some data sets it ends up with error "no convergence in 30 iterations". We are using SMIL 2.4.0. Is there a way how to avoid this convergence problem?
Haifeng Li
@haifengl
@jansiroky stack trace?
Kamil Kloch
@kamilkloch

@kamilkloch we don't need smile-netlib any more. OpenBLAS/MKL is in use from 2.5.0

@haifengl Thanks, how do I now check if native BLAS/LAPACK/ARPACK libraries are loaded? With 2.2.xI would do [BLAS/LAPACK/ARPACK].getInstance().getClass.getName contains "NativeSystem". In 2.5.0 [BLAS/LAPACK].getInstance().getClass.getName returns smile.math.blas.openblas.OpenBLAS and ARPACK.getInstance() does not exist...

Haifeng Li
@haifengl
The native library is built in. you don't need to check it
Kamil Kloch
@kamilkloch

The native library is built in. you don't need to check it

Hm, I am trying to run

BLAS.getInstance().gemm(...)

and get

java.lang.NoClassDefFoundError: org/bytedeco/openblas/global/openblas
project dependencies:
```
libraryDependencies ++= Seq(
"com.github.haifengl" %% "smile-scala" % "2.5.1",
"org.bytedeco" % "javacpp" % "1.5.3" classifier "windows-x86_64" classifier "linux-x86_64",
"org.bytedeco" % "openblas" % "0.3.9-1.5.3" classifier "windows-x86_64" classifier "linux-x86_64",
"org.bytedeco" % "arpack-ng" % "3.7.0-1.5.3" classifier "windows-x86_64" classifier "linux-x86_64"
)
Kamil Kloch
@kamilkloch
Also, adding smile-mkl dependency end up with
[error] (update) sbt.librarymanagement.ResolveException: download failed: org.bytedeco#mkl;2020.1-1.5.3!mkl.jar
*ends up
Haifeng Li
@haifengl
You miss classifier "" for arpack-ng
"org.bytedeco" % "arpack-ng" % "3.7.0-1.5.3" classifier "windows-x86_64" classifier "linux-x86_64" classifier ""
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