Skip to content

Commit

Permalink
version 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
haifengl committed Dec 19, 2015
1 parent 9e10829 commit 90381ca
Show file tree
Hide file tree
Showing 17 changed files with 1,318,029 additions and 24 deletions.
71 changes: 71 additions & 0 deletions benchmark/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.haifengl</groupId>
<artifactId>smile-benchmark</artifactId>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Benchmark</name>
<description>Statistical Machine Intelligence and Learning Engine -- Benchmark</description>
<url>http://github.com/haifengl/smile</url>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<name>Haifeng Li</name>
<email>[email protected]</email>
<url>http://haifengl.wordpress.com</url>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>America/New_York</timezone>
<properties>
<twitter>@haifengl</twitter>
</properties>
</developer>
</developers>

<scm>
<connection>scm:git:[email protected]:haifengl/smile.git</connection>
<developerConnection>scm:git:[email protected]:haifengl/smile.git</developerConnection>
<url>[email protected]:haifengl/smile.git</url>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
69 changes: 69 additions & 0 deletions benchmark/src/main/java/smile/bench/Benchmark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2010 Haifeng Li
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package smile.classification;

import smile.sort.QuickSort;
import smile.data.Attribute;
import smile.math.Math;
import smile.validation.LOOCV;
import smile.data.parser.ArffParser;
import smile.data.AttributeDataset;
import smile.data.NominalAttribute;
import smile.data.parser.DelimitedTextParser;

/**
*
* @author Haifeng Li
*/
public class Benchmark {

public Benchmark() {
}

public static void main(String[] args) {
System.out.println("Random Forest benchmark");
DelimitedTextParser parser = new DelimitedTextParser();
parser.setDelimiter(",");
parser.setColumnNames(true);
parser.setResponseIndex(new NominalAttribute("class"), 8);
try {
AttributeDataset train = parser.parse("Benchmark Train", this.getClass().getResourceAsStream("/smile/data/benchm-ml/train-1m.csv"));
AttributeDataset test = parser.parse("Benchmark Test", this.getClass().getResourceAsStream("/smile/data/benchm-ml/test.csv"));

double[][] x = train.toArray(new double[train.size()][]);
int[] y = train.toArray(new int[train.size()]);
double[][] testx = test.toArray(new double[test.size()][]);
int[] testy = test.toArray(new int[test.size()]);

long start = System.currentTimeMillis();
RandomForest forest = new RandomForest(x, y, 100);
long end = System.currentTimeMillis();
System.out.format("Random forest 100 trees training time: %.2f%% s\n", (end-start)/1000.0);

int error = 0;
for (int i = 0; i < testx.length; i++) {
if (forest.predict(testx[i]) != testy[i]) {
error++;
}
}

System.out.format("Benchmark OOB error rate = %.2f%%\n", 100.0 * forest.error());
System.out.format("Benchmark error rate = %.2f%%\n", 100.0 * error / testx.length);
} catch (Exception ex) {
System.err.println(ex);
}
}
}
10 changes: 5 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Core</name>
Expand Down Expand Up @@ -51,22 +51,22 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-math</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-data</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-graph</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-test-data</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
35 changes: 35 additions & 0 deletions core/src/test/java/smile/classification/RandomForestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,39 @@ public void testUSPSNominal() {
System.err.println(ex);
}
}

@Test
public void testBenchmark() {
System.out.println("Random Forest benchmark");
DelimitedTextParser parser = new DelimitedTextParser();
parser.setDelimiter(",");
parser.setColumnNames(true);
parser.setResponseIndex(new NominalAttribute("class"), 8);
try {
AttributeDataset train = parser.parse("Benchmark Train", this.getClass().getResourceAsStream("/smile/data/benchm-ml/train-1m.csv"));
AttributeDataset test = parser.parse("Benchmark Test", this.getClass().getResourceAsStream("/smile/data/benchm-ml/test.csv"));

double[][] x = train.toArray(new double[train.size()][]);
int[] y = train.toArray(new int[train.size()]);
double[][] testx = test.toArray(new double[test.size()][]);
int[] testy = test.toArray(new int[test.size()]);

long start = System.currentTimeMillis();
RandomForest forest = new RandomForest(x, y, 100);
long end = System.currentTimeMillis();
System.out.format("Random forest 100 trees training time: %.2f%% s\n", (end-start)/1000.0);

int error = 0;
for (int i = 0; i < testx.length; i++) {
if (forest.predict(testx[i]) != testy[i]) {
error++;
}
}

System.out.format("Benchmark OOB error rate = %.2f%%\n", 100.0 * forest.error());
System.out.format("Benchmark error rate = %.2f%%\n", 100.0 * error / testx.length);
} catch (Exception ex) {
System.err.println(ex);
}
}
}
6 changes: 3 additions & 3 deletions data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-data</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Data</name>
Expand Down Expand Up @@ -51,12 +51,12 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-math</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-test-data</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-demo</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Demo</name>
Expand Down Expand Up @@ -51,12 +51,12 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-plot</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions graph/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-graph</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Graph</name>
Expand Down Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-math</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions interpolation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-interpolation</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Interpolation</name>
Expand Down Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-math</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
2 changes: 1 addition & 1 deletion math/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-math</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Math</name>
Expand Down
6 changes: 3 additions & 3 deletions nlp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-math</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-test-data</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions plot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-plot</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Plot</name>
Expand Down Expand Up @@ -51,12 +51,12 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-math</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.swinglabs.swingx</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-all</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>pom</packaging>

<name>Smile Aggregate POM</name>
Expand Down
2 changes: 1 addition & 1 deletion test-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.haifengl</groupId>
<artifactId>smile-test-data</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>

<name>Smile Test Data</name>
Expand Down
Loading

0 comments on commit 90381ca

Please sign in to comment.