示例#1
0
 def transform(self, X):
     
     result = []
     for x in X:
         event = array2json(x)
         result.append(self.stream.transform(event))
     return result
示例#2
0
    def fit(self, X, y=None, headers=None, verbose=False):

        X = array2d(X)

        if (X.ndim != 2):
            raise ValueError('X must have dimension 2, ndim='+X.ndim)        

#        n_samples, self.n_features_ = X.shape
        y = np.atleast_1d(y)
#        y = y.astype(DOUBLE)

        if self.target is not None:
            if y is None:
                y = [None]*len(X)
            if (len(y) != len(X)):
                raise ValueError('y must be same shape as X, len(X)='+str(len(X))+', len(y)='+str(len(y)))

        if headers is not None:
            if (len(headers) != len(X)):
                raise ValueError('headers must be same shape as X, len(X)='+str(len(X))+', len(headers)='+str(len(headers)))


        for x,t in zip(X,y):
            if verbose: print x,t
            event = array2json(x,headers)
            if self.target is not None:
                event[self.target] = t
            self.stream.train(event)
示例#3
0
    def predict(self, X):
        
        result = []
        for x in X:
            event = array2json(x)
	    # should this be a numpy type?
            result.append(float(self.stream.predict(event)['prediction']))
        return result