scikit_nodes

Module: missions.nodes.scikit_nodes

Wrap the algorithms defined in scikit.learn in pySPACE nodes

For details on parameter usage look at the scikit documentation or the wrapped documentation of pySPACE: Scikit Nodes. The parameters given in the node specification are filtered, to check if they are available, and then directly forwarded to the scikit algorithm.

This module is based heavily on the scikit.learn wrapper for the “Modular toolkit for Data Processing” (MDP, version 3.3, http://mdp-toolkit.sourceforge.net/). All credit goes to the MDP authors.

MDP (version 3.3) is distributed under the following BSD license:

This file is part of Modular toolkit for Data Processing (MDP).
All the code in this package is distributed under the following conditions:

Copyright (c) 2003-2012, MDP Developers <mdp-toolkit-devel@lists.sourceforge.net>

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the Modular toolkit for Data Processing (MDP)
      nor the names of its contributors may be used to endorse or promote
      products derived from this software without specific prior written
      permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Inheritance diagram for pySPACE.missions.nodes.scikit_nodes:

Inheritance diagram of pySPACE.missions.nodes.scikit_nodes

Class Summary

ScikitException Base class for exceptions in nodes wrapping scikit algorithms.

Function Summary

apply_to_scikit_algorithms(current_module, ...) Function that traverses a module to find scikit algorithms.
wrap_scikit_classifier(scikit_class) Wrap a sklearn classifier as a BaseNode subclass.
wrap_scikit_transformer(scikit_class) Wrap a sklearn transformer as a pySPACE BaseNode subclass
wrap_scikit_predictor(scikit_class) Wrap a sklearn predictor as an pySPACE BaseNode subclass
print_public_members(class_) Print methods of sklearn algorithm
wrap_scikit_algorithms(scikit_class, nodes_list) Check scikit_class and append new wrapped class to nodes_list

Class

ScikitException

class pySPACE.missions.nodes.scikit_nodes.ScikitException[source]

Bases: exceptions.Exception

Base class for exceptions in nodes wrapping scikit algorithms.

__weakref__

list of weak references to the object (if defined)

Functions

apply_to_scikit_algorithms()

pySPACE.missions.nodes.scikit_nodes.apply_to_scikit_algorithms(current_module, action, processed_modules=None, processed_classes=None)[source]

Function that traverses a module to find scikit algorithms.

‘sklearn’ algorithms are identified by the ‘fit’ ‘predict’, or ‘transform’ methods. The ‘action’ function is applied to each found algorithm.

action – a function that is called with as action(class_), where
class_ is a class that defines the ‘fit’ or ‘predict’ method

wrap_scikit_classifier()

pySPACE.missions.nodes.scikit_nodes.wrap_scikit_classifier(scikit_class)[source]

Wrap a sklearn classifier as a BaseNode subclass.

The wrapper maps these node methods to their sklearn equivalents:

  • _stop_training -> fit
  • _execute -> predict

wrap_scikit_transformer()

pySPACE.missions.nodes.scikit_nodes.wrap_scikit_transformer(scikit_class)[source]

Wrap a sklearn transformer as a pySPACE BaseNode subclass

The wrapper maps these pySPACE methods to their sklearn equivalents:

  • _stop_training -> fit
  • _execute -> transform

wrap_scikit_predictor()

pySPACE.missions.nodes.scikit_nodes.wrap_scikit_predictor(scikit_class)[source]

Wrap a sklearn predictor as an pySPACE BaseNode subclass

The wrapper maps these pySPACE methods to their sklearn equivalents:

  • _stop_training -> fit
  • _execute -> predict

wrap_scikit_algorithms()

pySPACE.missions.nodes.scikit_nodes.wrap_scikit_algorithms(scikit_class, nodes_list)[source]

Check scikit_class and append new wrapped class to nodes_list

Currently only classifiers subclassing sklearn.base.ClassifierMixin and having a fit method were integrated and tested. Algorithms with the transform function are also available. predict nodes will be available soon but require more testing especially of regression in pySPACE.