Developer documentation¶
Adding a feature processing toolbox¶
We suggest to use the wrapping we did around the PyRadiomics toolbox as an example.
Check if config type is in
fastr.types
: else, make your own. See the WORC datatypes for examples.Make a fastr tool, which basically is a XML wrapper around your tool telling fastr what the inputs and outputs are. You can take our wrappers around pyradiomics as example: see the command line wrapper for when your toolbox is command line executable, or the Python wrapper for when your toolbox needs an interpreter such as Python. In the latter case, you will also need to include an actual script using the interpreter, which is by default placed in the bin folder together with the wrapper. The script will need to parse the arguments defined in the XML, see here for the one using PyRadiomics.
For more information, visit the fastr documentation.
In WORC, go to the
WORC.WORC.WORC.add_feature_calculator
function and change the following:
Add a converter for your config file if you do not use the .ini format WORC by default uses.
If you followed a, also add a config safe function to
WORC.WORC.WORC.save_config
.Make sure you add both the sources and sinks for your tools.
Link these sources and sinks to the fastr network in the
WORC.WORCWORC.set
function.Add part to feature converter
To convert the feature files from your toolbox to WORC compatible format, add the neccesary functionality to the
WORC.featureprocessing.FeatureConverter
function.Tell WORC to use your feature calculator by changing the relevant config field:
config['General']['FeatureCalculators]
.Optionally, add the parameters specifically for your toolbox to the WORC configuration in
WORC.WORC.WORC.defaultconfig
.
Testing and example data¶
WIP
Adding methods to hyperoptimization¶
Add the parameters to the relevant parts of the WORC configuration in
WORC.WORC.WORC.defaultconfig
.Please add a description of these parameters and their potential values to the documentation, see https://github.com/MStarmans91/WORC/blob/master/WORC/doc/generate_config.py.
Make sure these fields are adequately parsed by adding parsing to
WORC.IOparser.config_io_classifier.load_config
.Define how the parameters you just added are added to the search space in
WORC.classification.trainclassifier.trainclassifier
, orWORC.classification.construct_classifier
both theconstruct_classifier
andcreate_param_grid
functions for machine learning estimators (e.g. classifiers). For example, your parameters may define the actual options, or the min-max of a distribution (e.g. uniform, log-uniform). See the referred function for some examples. Make sure that the object is iterable.These parameters will end up in the function fitting the workflow:
WORC.classification.fitandscore.fit_and_score
. Hence, add a part to that function to embed your method in the workflow. We advice you to embed your method in a sklearn compatible class, having init, fit and transform functions. See for exampleWORC.featureprocessing.Preprocessor.Preprocessor
.In
WORC.classification.fitandscore.fit_and_score
, make sure that after fitting your object, the parameters used are deleted from the config, as is done for the other methods as well.Lastly, in
WORC.classification.fitandscore.fit_and_score
, make sure the fitted object is returned. We recommend looking at theimputer
object and similarly including your object.This is given to various objects in the
WORC.classification.SearchCV
module. Therefore, add the returned object to all the parts were fitted objects are used: we recommend looking everywhere theimputer
is stated inWORC.classification.SearchCV
, copying those five statements and replaceimputer
with however you called your methods. You can see that this is also similar to e.g. thescaler
,pca
, andgroupsel
objects.If you want your new method to be used by the
SimpleWORC
or a child facade, checkWORC.facade.SimpleWORC
to see if you need to add it, e.g. whitelist a classifier.