-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
525de68
commit 9392281
Showing
4 changed files
with
149 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import seldon.fileutil as fu | ||
|
||
class Feature_transform(object): | ||
|
||
def upload(self,fromPath,fromPath): | ||
fu.save(fromPath,toPath) | ||
|
||
def download(self,fromPath,toPath): | ||
fu.download(fromPath,toPath) | ||
|
||
def save(self,folder): | ||
print "no model to save" | ||
|
||
def load(self,folder): | ||
print "no model to load" | ||
|
||
|
||
class Pipeline(object): | ||
|
||
def __init__(self,models_folder="./models"): | ||
self.pipeline = [] | ||
self.models_folder = models_folder | ||
self.objs = [] | ||
|
||
def add(self,feature_transform): | ||
self.pipeline.append(feature_transform) | ||
|
||
def process(self,line): | ||
j = json.loads(line) | ||
self.objs.append(j) | ||
|
||
def getFeatures(self,location): | ||
fu.stream(location,self.process) | ||
|
||
def transform(self,featureLocation): | ||
self.getFeatures(featuresLocation) | ||
for ft in pipeline: | ||
ft.load(self.models_folder) | ||
objs = ft.transform(objs) | ||
|
||
def fit_transform(self): | ||
self.getFeatures(featuresLocation) | ||
for ft in pipeline: | ||
ft.fit(objs) | ||
objs = ft.transform(objs) | ||
ft.save(self.models_folder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters