You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2009/10/26 04:19:20 UTC
svn commit: r829695 - in
/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd:
Attribute.java DataSet.java FileInfoParser.java NominalAttr.java
NumericalAttr.java
Author: srowen
Date: Mon Oct 26 03:19:20 2009
New Revision: 829695
URL: http://svn.apache.org/viewvc?rev=829695&view=rev
Log:
Add another no-arg constructor for xstream, and pull some classes up to the top level for clarity
Added:
lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/Attribute.java
lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java
lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NumericalAttr.java
Modified:
lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java
lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/Attribute.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/Attribute.java?rev=829695&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/Attribute.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/Attribute.java Mon Oct 26 03:19:20 2009
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.mahout.ga.watchmaker.cd;
+
+/**
+ * An attribute for use with {@link DataSet}
+ */
+interface Attribute {
+
+ boolean isNumerical();
+
+}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java?rev=829695&r1=829694&r2=829695&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java Mon Oct 26 03:19:20 2009
@@ -19,75 +19,13 @@
import java.util.List;
-
/**
- * Contains informations about the dataset and its attributes. The label is a
+ * Contains information about the dataset and its attributes. The label is a
* nominal attribute with a known position. Ignored attributes are not taken
* into account when calculating attribute's position.
*/
public class DataSet {
- public interface Attribute {
- boolean isNumerical();
- }
-
- public static class NominalAttr implements Attribute {
- private final String[] values;
-
- public NominalAttr(String[] values) {
- assert values.length > 0 : "values is empty";
- this.values = values;
- }
-
- public int getNbvalues() {
- return values.length;
- }
-
- @Override
- public boolean isNumerical() {
- return false;
- }
-
- /**
- * Converts a string value of a nominal attribute to an <code>int</code>.
- *
- * @param value
- * @return an <code>int</code> representing the value
- * @throws RuntimeException if the value is not found.
- */
- public int valueIndex(String value) {
- for (int index = 0; index < values.length; index++) {
- if (values[index].equals(value))
- return index;
- }
-
- throw new IllegalArgumentException("Value (" + value + ") not found");
- }
- }
-
- public static class NumericalAttr implements Attribute {
- private final double min;
- private final double max;
-
- public NumericalAttr(double min, double max) {
- this.min = min;
- this.max = max;
- }
-
- public double getMin() {
- return min;
- }
-
- public double getMax() {
- return max;
- }
-
- @Override
- public boolean isNumerical() {
- return true;
- }
- }
-
/** Singleton */
private static DataSet dataset;
@@ -97,6 +35,12 @@
private final List<Attribute> attributes;
+ // This constructor just exists to satisfy xstream
+
+ DataSet() {
+ this(null, null, 0);
+ }
+
DataSet(List<Attribute> attributes, List<Integer> ignored, int labelIndex) {
this.attributes = attributes;
ignoredAttributes = ignored;
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java?rev=829695&r1=829694&r2=829695&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java Mon Oct 26 03:19:20 2009
@@ -20,9 +20,6 @@
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.mahout.ga.watchmaker.cd.DataSet.Attribute;
-import org.apache.mahout.ga.watchmaker.cd.DataSet.NominalAttr;
-import org.apache.mahout.ga.watchmaker.cd.DataSet.NumericalAttr;
import java.io.IOException;
import java.util.ArrayList;
Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java?rev=829695&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java Mon Oct 26 03:19:20 2009
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.mahout.ga.watchmaker.cd;
+
+class NominalAttr implements Attribute {
+
+ private final String[] values;
+
+ NominalAttr(String[] values) {
+ assert values.length > 0 : "values is empty";
+ this.values = values;
+ }
+
+ public int getNbvalues() {
+ return values.length;
+ }
+
+ @Override
+ public boolean isNumerical() {
+ return false;
+ }
+
+ /**
+ * Converts a string value of a nominal attribute to an <code>int</code>.
+ *
+ * @param value
+ * @return an <code>int</code> representing the value
+ * @throws IllegalArgumentException if the value is not found.
+ */
+ public int valueIndex(String value) {
+ for (int index = 0; index < values.length; index++) {
+ if (values[index].equals(value))
+ return index;
+ }
+ throw new IllegalArgumentException("Value (" + value + ") not found");
+ }
+
+}
Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NumericalAttr.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NumericalAttr.java?rev=829695&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NumericalAttr.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NumericalAttr.java Mon Oct 26 03:19:20 2009
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.mahout.ga.watchmaker.cd;
+
+class NumericalAttr implements Attribute {
+
+ private final double min;
+ private final double max;
+
+ NumericalAttr(double min, double max) {
+ this.min = min;
+ this.max = max;
+ }
+
+ public double getMin() {
+ return min;
+ }
+
+ public double getMax() {
+ return max;
+ }
+
+ @Override
+ public boolean isNumerical() {
+ return true;
+ }
+
+}