You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by to...@apache.org on 2013/03/23 07:48:22 UTC

svn commit: r1460104 - in /labs/yay/trunk/api/src/main/java/org/apache/yay: CostFunction.java ErrorFunction.java Hypothesis.java HypothesisFactory.java

Author: tommaso
Date: Sat Mar 23 06:48:22 2013
New Revision: 1460104

URL: http://svn.apache.org/r1460104
Log:
continuing refactoring api

Added:
    labs/yay/trunk/api/src/main/java/org/apache/yay/ErrorFunction.java   (with props)
    labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java   (with props)
    labs/yay/trunk/api/src/main/java/org/apache/yay/HypothesisFactory.java   (with props)
Modified:
    labs/yay/trunk/api/src/main/java/org/apache/yay/CostFunction.java

Modified: labs/yay/trunk/api/src/main/java/org/apache/yay/CostFunction.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/api/src/main/java/org/apache/yay/CostFunction.java?rev=1460104&r1=1460103&r2=1460104&view=diff
==============================================================================
--- labs/yay/trunk/api/src/main/java/org/apache/yay/CostFunction.java (original)
+++ labs/yay/trunk/api/src/main/java/org/apache/yay/CostFunction.java Sat Mar 23 06:48:22 2013
@@ -26,10 +26,12 @@ import java.util.Collection;
  * of {@link TrainingExample}s).
  *
  */
-public interface CostFunction<T, S> {
+public interface CostFunction<T, I, O> {
 
-  public Double calculateCost(Collection<TrainingExample<S, S>> trainingExamples,
-                              ActivationFunction<S> activationFunction,
-                              T... parameters) throws Exception;
+  public Double calculateAggregatedCost(Collection<TrainingExample<I, O>> trainingExamples,
+                              Hypothesis<T, I, O> hypothesis) throws Exception;
+
+  public Double calculateCost(TrainingExample<I, O> trainingExample,
+                              Hypothesis<T, I, O> hypothesis) throws Exception;
 
 }

Added: labs/yay/trunk/api/src/main/java/org/apache/yay/ErrorFunction.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/api/src/main/java/org/apache/yay/ErrorFunction.java?rev=1460104&view=auto
==============================================================================
--- labs/yay/trunk/api/src/main/java/org/apache/yay/ErrorFunction.java (added)
+++ labs/yay/trunk/api/src/main/java/org/apache/yay/ErrorFunction.java Sat Mar 23 06:48:22 2013
@@ -0,0 +1,38 @@
+/*
+ * 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.yay;
+
+import java.util.Collection;
+
+/**
+ * An error function calculates the error for a given ({@link Collection} of)
+ * {@link TrainingExample}, output and {@link CostFunction}.
+ */
+public interface ErrorFunction<T, I, O> {
+
+
+    public Double calculateSingleError(O output, TrainingExample<I, O> trainingExample,
+                                       CostFunction<T, I, O> costFunction,
+                                       Hypothesis<T, I, O> hypothesis);
+
+    public Double calculateAggregateError(O output, TrainingSet<I, O> trainingSet,
+                                          CostFunction<T, I, O> costFunction,
+                                          Hypothesis<T, I, O> hypothesis);
+
+}

Propchange: labs/yay/trunk/api/src/main/java/org/apache/yay/ErrorFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java?rev=1460104&view=auto
==============================================================================
--- labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java (added)
+++ labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java Sat Mar 23 06:48:22 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.yay;
+
+/**
+ * In machine learning an hypothesis is the output of the applying a learning
+ * algorithm to a training set, an hypothesis maps new inputs to possible outputs.
+ */
+public interface Hypothesis<T, I, O> {
+
+    public void setParameters(T... parameters);
+
+    public O predict(Input<I> input) throws PredictionException;
+
+}

Propchange: labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/yay/trunk/api/src/main/java/org/apache/yay/HypothesisFactory.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/api/src/main/java/org/apache/yay/HypothesisFactory.java?rev=1460104&view=auto
==============================================================================
--- labs/yay/trunk/api/src/main/java/org/apache/yay/HypothesisFactory.java (added)
+++ labs/yay/trunk/api/src/main/java/org/apache/yay/HypothesisFactory.java Sat Mar 23 06:48:22 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.yay;
+
+import java.util.Collection;
+
+/**
+ * Add javadoc here
+ */
+public interface HypothesisFactory {
+
+  <T, I, O> Hypothesis<T, I, O> createHypothesis(TrainingSet<I, O> trainingSet,
+                                                 LearningStrategy<I, O> learningStrategy,
+                                                 T... parameters);
+}

Propchange: labs/yay/trunk/api/src/main/java/org/apache/yay/HypothesisFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org