Since Google announced that they are shutting down the code hosting service 'Google code' in which our two projects RCaller and Fuzuli Programming Language are hosted.
We migrated our projects into the popular code hosting site GitHub.
Source code of these projects will no longer be committed in Google code site. Please check the new repositories.
GitHub pages are listed below:
RCaller:
https://github.com/jbytecode/rcaller
Fuzuli Project:
https://github.com/jbytecode/fuzuli
Friday, March 13, 2015
Thursday, March 12, 2015
Android Device Information Tool Application
Hello! I would like to share an Android application that can be used as a tool.
The application provides information about software of your Android device. You can find out:
-Device name
-Device ID
-Android version
-Device product
-Device manufacturer
-Device brand
-Device version
-Device host
-Device model
-Device user
-Device hardware
-Device radio version
-Device serial number
-Device finger print
If you need informations given above, you can download it from this URL.
The application provides information about software of your Android device. You can find out:
-Device name
-Device ID
-Android version
-Device product
-Device manufacturer
-Device brand
-Device version
-Device host
-Device model
-Device user
-Device hardware
-Device radio version
-Device serial number
-Device finger print
If you need informations given above, you can download it from this URL.
Android Device Info App! |
Labels
android,
application,
device,
info,
information,
tool
Monday, March 9, 2015
Nearest-Neighbor Clustering using RCaller - A library for Calling R from Java
RCaller is a software for calling R from Java. A blog post includes the latest version of downloadable jar and documentation here. The latest news can always be traced using the RCaller label in Practical Code Solutions blog.
A blog post on performing a k-means clustering analysis using RCaller is also available at this link.
In the code below, two double arrays, x and y, are created in Java side. These variables are then passed to R. In R side, distance matrix d is calculated. The R function hclust performs the main calculations. Finally, calculated heights of clustering tree and a dendrogram plot are returned to Java. The source code, output text and the returned plot are presented here:
package kmeansrcaller;
import java.io.File;
import rcaller.RCaller;
import rcaller.RCode;
public class SingleLinkageClustering {
public static void main(String[] args) {
RCaller caller = new RCaller();
RCode code = new RCode();
File dendrogram = null;
double[] x = new double[]{1, 2, 3, 4, 5, 10, 20, 30, 40, 50};
double[] y = new double[]{2, 4, 6, 8, 10, 20, 40, 60, 80, 100};
code.addDoubleArray("x", x);
code.addDoubleArray("y", y);
code.addRCode("d <- dist(cbind(x,y))");
code.addRCode("h&<- hclust(d, method=\"single\")");
try {
dendrogram = code.startPlot();
code.addRCode("plot(h)");
code.endPlot();
} catch (Exception e) {
System.out.println("Plot Error: " + e.toString());
}
caller.setRCode(code);
caller.setRscriptExecutable("/usr/bin/Rscript");
caller.runAndReturnResult("h");
System.out.println(caller.getParser().getNames());
if (dendrogram != null) {
code.showPlot(dendrogram);
}
double[] heights = caller.getParser().getAsDoubleArray("height");
for (int i = 0; i < heights.length; i++) {
System.out.println("Height " + i + " = " + heights[i]);
}
}
}
The output is
[merge, height, order, method, call, dist_method]
Height 0 = 2.23606797749979
Height 1 = 2.23606797749979
Height 2 = 2.23606797749979
Height 3 = 2.23606797749979
Height 4 = 11.1803398874989
Height 5 = 22.3606797749979
Height 6 = 22.3606797749979
Height 7 = 22.3606797749979
Height 8 = 22.3606797749979
The screen shot of the plotted graphics is here:
Have a nice read!
Saturday, March 7, 2015
K-means clustering with RCaller - A library for calling R from Java
Here is an example of RCaller, a library for calling R from Java.
In the code below, we create two variables x and y. K-means clustering function kmeans is applied on the data matrix that consists of x and y. The result is then reported in Java.
The output is
[cluster, centers, totss, withinss, tot_withinss, betweenss, size, iter, ifault]
Observation 0 is in cluster 2
Observation 1 is in cluster 2
Observation 2 is in cluster 2
Observation 3 is in cluster 2
Observation 4 is in cluster 2
Observation 5 is in cluster 2
Observation 6 is in cluster 2
Observation 7 is in cluster 1
Observation 8 is in cluster 1
Observation 9 is in cluster 1
Cluster Centers:
40.0 6.42857142857143
80.0 12.8571428571429
Total Within Sum of Squares: 2328.57142857143
Total Between Sum of Squares: 11833.9285714286
Total Sum of Squares: 14162.5
Have a nice read!
In the code below, we create two variables x and y. K-means clustering function kmeans is applied on the data matrix that consists of x and y. The result is then reported in Java.
package kmeansrcaller;
import rcaller.RCaller;
import rcaller.RCode;
public class KMeansRCaller {
public static void main(String[] args) {
RCaller caller = new RCaller();
RCode code = new RCode();
double[] x = new double[]{1, 2, 3, 4, 5, 10, 20, 30, 40, 50};
double[] y = new double[]{2, 4, 6, 8, 10, 20, 40, 60, 80, 100};
code.addDoubleArray("x", x);
code.addDoubleArray("y", y);
code.addRCode("result <- kmeans(cbind(x,y), 2)");
caller.setRCode(code);
caller.setRscriptExecutable("/usr/bin/Rscript");
caller.runAndReturnResult("result");
System.out.println(caller.getParser().getNames());
int[] clusters = caller.getParser().getAsIntArray("cluster");
double[][] centers = caller.getParser().getAsDoubleMatrix("centers");
double[] totalSumOfSquares = caller.getParser().getAsDoubleArray("totss");
// RCaller automatically replaces dots with underlines in variable names
// So the parameter tot.withinss is accessible as tot_withinss
double[] totalWithinSumOfSquares = caller.getParser().getAsDoubleArray("tot_withinss");
double[] totalBetweenSumOfSquares = caller.getParser().getAsDoubleArray("betweenss");
for (int i = 0; i < clusters.length; i++) {
System.out.println("Observation " + i + " is in cluster " + clusters[i]);
}
System.out.println("Cluster Centers:");
for (int i = 0; i < centers.length; i++) {
for (int j = 0; j < centers[0].length; j++) {
System.out.print(centers[i][j] + " ");
}
System.out.println();
}
System.out.println("Total Within Sum of Squares: " + totalWithinSumOfSquares[0]);
System.out.println("Total Between Sum of Squares: " + totalBetweenSumOfSquares[0]);
System.out.println("Total Sum of Squares: " + totalSumOfSquares[0]);
}
}
import rcaller.RCaller;
import rcaller.RCode;
public class KMeansRCaller {
public static void main(String[] args) {
RCaller caller = new RCaller();
RCode code = new RCode();
double[] x = new double[]{1, 2, 3, 4, 5, 10, 20, 30, 40, 50};
double[] y = new double[]{2, 4, 6, 8, 10, 20, 40, 60, 80, 100};
code.addDoubleArray("x", x);
code.addDoubleArray("y", y);
code.addRCode("result <- kmeans(cbind(x,y), 2)");
caller.setRCode(code);
caller.setRscriptExecutable("/usr/bin/Rscript");
caller.runAndReturnResult("result");
System.out.println(caller.getParser().getNames());
int[] clusters = caller.getParser().getAsIntArray("cluster");
double[][] centers = caller.getParser().getAsDoubleMatrix("centers");
double[] totalSumOfSquares = caller.getParser().getAsDoubleArray("totss");
// RCaller automatically replaces dots with underlines in variable names
// So the parameter tot.withinss is accessible as tot_withinss
double[] totalWithinSumOfSquares = caller.getParser().getAsDoubleArray("tot_withinss");
double[] totalBetweenSumOfSquares = caller.getParser().getAsDoubleArray("betweenss");
for (int i = 0; i < clusters.length; i++) {
System.out.println("Observation " + i + " is in cluster " + clusters[i]);
}
System.out.println("Cluster Centers:");
for (int i = 0; i < centers.length; i++) {
for (int j = 0; j < centers[0].length; j++) {
System.out.print(centers[i][j] + " ");
}
System.out.println();
}
System.out.println("Total Within Sum of Squares: " + totalWithinSumOfSquares[0]);
System.out.println("Total Between Sum of Squares: " + totalBetweenSumOfSquares[0]);
System.out.println("Total Sum of Squares: " + totalSumOfSquares[0]);
}
}
The output is
Observation 0 is in cluster 2
Observation 1 is in cluster 2
Observation 2 is in cluster 2
Observation 3 is in cluster 2
Observation 4 is in cluster 2
Observation 5 is in cluster 2
Observation 6 is in cluster 2
Observation 7 is in cluster 1
Observation 8 is in cluster 1
Observation 9 is in cluster 1
Cluster Centers:
40.0 6.42857142857143
80.0 12.8571428571429
Total Within Sum of Squares: 2328.57142857143
Total Between Sum of Squares: 11833.9285714286
Total Sum of Squares: 14162.5
Have a nice read!
Saturday, February 28, 2015
Levenshtein Distance in R
Edit distance and Levenshtein distance are nonparametric distance measures that not like well known metric distance measures such as Euclidean or Mahalanobis distances in some persfectives.
Levenshtein distance is a measure of how many characters should be replaced or moved to get two strings same.
In the example below, a string text is asked from the user in console mode. Then the input string is compared to colour names defined in R. Similar colour names are then reported:
user.string <- readline("Enter a word: ")
wordlist <- colours()
dists <- adist(user.string, wordlist)
mindist <- min(dists)
best.ones <- which(dists == mindist)
for (index in best.ones){
cat("Did you mean: ", wordlist[index],"\n")
}
Here is the results:
Enter a word: turtoise
Did you mean: turquoise
Enter a word: turtle
Did you mean: purple
Enter a word: night blue
Did you mean: lightblue
Enter a word: parliament
Did you mean: darkmagenta
Enter a word: marooon
Did you mean: maroon
Have a nice read
Levenshtein distance is a measure of how many characters should be replaced or moved to get two strings same.
In the example below, a string text is asked from the user in console mode. Then the input string is compared to colour names defined in R. Similar colour names are then reported:
user.string <- readline("Enter a word: ")
wordlist <- colours()
dists <- adist(user.string, wordlist)
mindist <- min(dists)
best.ones <- which(dists == mindist)
for (index in best.ones){
cat("Did you mean: ", wordlist[index],"\n")
}
Here is the results:
Enter a word: turtoise
Did you mean: turquoise
Enter a word: turtle
Did you mean: purple
Enter a word: night blue
Did you mean: lightblue
Enter a word: parliament
Did you mean: darkmagenta
Enter a word: marooon
Did you mean: maroon
Have a nice read
Labels
r
Subscribe to:
Posts (Atom)