Ejemplo n.º 1
0
 def test_pickle(self):
     # TODO this just makes sure the object can be pickled. It doesn't
     # verify that the unpickled object is correct
     uo = UObject(UObjectPhase.Write)
     np_array = np.array([[0]])
     uo.from_np(np_array)
     self.__pickle('upsg.export.csv.CSVWrite', path_of_data('_out.csv'))
     self.__pickle('upsg.fetch.csv.CSVRead', path_of_data('mixed_csv.csv'))
     self.__pickle('upsg.fetch.np.NumpyRead', np.array([[0]]))
     self.__pickle('upsg.transform.split.SplitTrainTest')
     self.__pickle('upsg.transform.split.SplitY', 0)
     self.__pickle('upsg.transform.rename_cols.RenameCols',
                   {'name': 'rename'})
     self.__pickle(wrap('sklearn.preprocessing.Imputer'), strategy='mean',
                   missing_values='NaN')
     self.__pickle(wrap('sklearn.svm.SVC'), gamma=0.1)
     self.__pickle(wrap('sklearn.metrics.roc_curve'))
Ejemplo n.º 2
0
    def run(self, outputs_requested, **kwargs):
        in_data = kwargs['input'].to_np()
        cols = []
        dtype = []
        
        for name, sub_dtype in in_data.dtype.descr:
            col = in_data[name]
            if 'S' in sub_dtype:
                try:
                    col = col.astype('M8')
                    sub_dtype = col.dtype
                except ValueError: # not a time
                    pass
            cols.append(col)
            dtype.append((name, sub_dtype))

        uo_out = UObject(UObjectPhase.Write)
        uo_out.from_np(np.fromiter(it.izip(*cols), dtype=dtype))
        return {'output': uo_out}
Ejemplo n.º 3
0
    def run(self, outputs_requested, **kwargs):
        in_data = kwargs['input'].to_np()
        cols = []
        dtype = []

        for name, sub_dtype in in_data.dtype.descr:
            col = in_data[name]
            if 'S' in sub_dtype:
                try:
                    col = col.astype('M8')
                    sub_dtype = col.dtype
                except ValueError:  # not a time
                    pass
            cols.append(col)
            dtype.append((name, sub_dtype))

        uo_out = UObject(UObjectPhase.Write)
        uo_out.from_np(np.fromiter(it.izip(*cols), dtype=dtype))
        return {'output': uo_out}
Ejemplo n.º 4
0
 def run(self, outputs_requested, **kwargs):
     fxs = self.__lam(**{key: kwargs[key].to_np()[0][0] for key in kwargs})
     if self.__fout:
         self.__fout.write(str(fxs))
         return {}
     if self.__n_results <= 1:
         fxs = [fxs]
     fxs_np = map(lambda fx: np.core.records.fromrecords([(fx, )]), fxs)
     ret = {key: UObject(UObjectPhase.Write) for key in self.__output_keys}
     [
         ret[key].from_np(fxs_np[i])
         for i, key in enumerate(self.__output_keys)
     ]
     return ret