diff pylearn/algorithms/kernel_regression.py @ 1505:723e2d761985

auto white space fix.
author Frederic Bastien <nouiz@nouiz.org>
date Mon, 12 Sep 2011 10:49:15 -0400
parents bf5c0f797161
children
line wrap: on
line diff
--- a/pylearn/algorithms/kernel_regression.py	Mon Sep 12 10:48:33 2011 -0400
+++ b/pylearn/algorithms/kernel_regression.py	Mon Sep 12 10:49:15 2011 -0400
@@ -37,11 +37,11 @@
   small datasets.
 * the linear system is
       (M + lambda I_n) theta = (1, y)'
-  where theta = (b, alpha), I_n is the (n+1)x(n+1) matrix that is the identity 
-  except with a 0 at (0,0), M is the matrix with G in the sub-matrix starting 
-  at (1,1), 1's in column 0, except for a value of n at (0,0), and sum_i G_{i,j} 
+  where theta = (b, alpha), I_n is the (n+1)x(n+1) matrix that is the identity
+  except with a 0 at (0,0), M is the matrix with G in the sub-matrix starting
+  at (1,1), 1's in column 0, except for a value of n at (0,0), and sum_i G_{i,j}
   in the rest of row 0.
-  
+
 Note that this is gives an estimate of E[y|x,training_set] that is the
 same as obtained with a Gaussian process regression. The GP
 regression would also provide a Bayesian Var[y|x,training_set].
@@ -60,8 +60,8 @@
        outputs, errors = kernel_predictor.compute_outputs_and_errors(inputs,targets)
        errors = kernel_predictor.compute_errors(inputs,targets)
        mse = kernel_predictor.compute_mse(inputs,targets)
-       
-       
+
+
 
     The training_set must have fields "input" and "target".
     The test_set must have field "input", and needs "target" if
@@ -147,7 +147,7 @@
 
     def __init__(self):
         self.compile()
-        
+
 class KernelRegressionEquations(KernelPredictorEquations):
     #M = T.matrix() # (n_examples+1) x (n_examples+1)
     inputs = T.matrix() # n_examples x n_inputs
@@ -158,9 +158,9 @@
     #new_G = T.gemm(G,1.,inputs,inputs.T,1.)
     G = T.exp(-(row_vector(inputs_square)-2*T.dot(inputs,inputs.T)+col_vector(inputs_square))*inv_gamma2)
     sumG = T.sum(G,axis=0)
-    
+
     __compiled = False
-    
+
     @classmethod
     def compile(cls,linker='c|py'):
         if cls.__compiled:
@@ -200,7 +200,7 @@
     def compute_mse(self,inputs,targets):
         errors = self.compute_errors(inputs,targets)
         return numpy.sum(errors)/errors.size
-    
+
     def __call__(self,dataset,output_fieldnames=None,cached_output_dataset=False):
         assert dataset.hasFields(["input"])
         if output_fieldnames is None:
@@ -217,15 +217,14 @@
             f = self.compute_outputs_and_errors
         else:
             raise ValueError("unknown field(s) in output_fieldnames: "+str(output_fieldnames))
-        
+
         ds=ApplyFunctionDataSet(dataset,f,output_fieldnames)
         if cached_output_dataset:
             return CachedDataSet(ds)
         else:
             return ds
-        
+
 
 def kernel_predictor(inputs,params,*otherargs):
-  p = KernelPredictor(params,*otherargs[0])
-  return p.compute_outputs(inputs)
-  
+    p = KernelPredictor(params,*otherargs[0])
+    return p.compute_outputs(inputs)