haifengl on master
fix javadoc (compare)
haifengl on master
move ica package to smile.ica i… (compare)
haifengl on master
refactor KPCA remove Projection rename LinearProjection to Proj… (compare)
haifengl on master
extend DataFrame.toArray(column… refactor LinearProjection fix arpack and 2 more (compare)
haifengl on master
add KMedoidsImputer and remove … (compare)
ScatterPlot.of
automatically choose color if you pass an array y
.
@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
plot
PlotCanvas
to Canvas
which is no longer a JPanel
val iris = read.arff("data/weka/iris.arff")
val canvas = plot(iris, "sepallength", "sepalwidth", "class", '*')
canvas.setAxisLabels("sepallength", "sepalwidth")
show(canvas)
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!
2.5.1
PlotGrid
for a grid of canvas
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));
}
@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,
@haifengl
Hi, I have one question,
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
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
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>
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)
import smile.data.formula.Formula;
import static smile.data.formula.Terms.*;
df.stream().map(row -> {
or something?