Skip to content

Commit

Permalink
add example code
Browse files Browse the repository at this point in the history
  • Loading branch information
RLeenings committed Jun 5, 2019
1 parent b1c924c commit ffbad24
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
13 changes: 13 additions & 0 deletions photonai/examples/Investigator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

from photonai.investigator.Investigator import Investigator

# from mongodb
Investigator.load_from_db('mongodb://server:27017/photon_results', 'my_pipe')

# from working memory
my_pipe = Hyperpipe(...)
my_pipe.fit(X, y)
Investigator.show(my_pipe)

# from file
Investigator.load_from_file('my_pipe_name', '/home/usr123/proj45/my_pipe_results2019-08-01/photon_result_file.p')
29 changes: 29 additions & 0 deletions photonai/examples/custom_estimator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from sklearn.base import BaseEstimator


class CustomEstimator(BaseEstimator):

def __init__(self, param1=0, param2=None):
# it is important that you name your params the same in the constructor
# stub as well as in your class variables!
self.param1 = param1
self.param2 = param2

def fit(self, data, targets=None, **kwargs):
"""
Adjust the underlying model or method to the data.
Returns
-------
IMPORTANT: must return self!
"""
return self

def predict(self, data):
"""
Use the learned model to make predictions.
"""
my_predictions = []
return my_predictions


28 changes: 28 additions & 0 deletions photonai/examples/custom_transformer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from sklearn.base import BaseEstimator


class CustomTransformer(BaseEstimator):

def __init__(self, param1=0, param2=None):
# it is important that you name your params the same in the constructor
# stub as well as in your class variables!
self.param1 = param1
self.param2 = param2

def fit(self, data, targets=None, **kwargs):
"""
Adjust the underlying model or method to the data.
Returns
-------
IMPORTANT: must return self!
"""
return self

def transform(self, data, targets=None, **kwargs):
"""
Apply the method's logic to the data.
"""
transformed_data = []
return transformed_data

0 comments on commit ffbad24

Please sign in to comment.