A collection of filters to use with QGraphs.
A QGraph is a partially ordered infinite list of graphs with some constraints on the actual structure of the graphs.
One way to tune these constraints is to filter the QGraph with one or more filters from this package.
# Consider only graphs that are two deep and involve the "x" register.
> qgraph = qgraph.filter(feyn.filters.Depth(2))
> qgraph = qgraph.filter(feyn.filters.Contains("x"))
> qgraph.fit(data)
Notice that QGraph filters can be chained, and will be and'ed together.
This module has a useful collection of filters. It's also possible to define custom filters by deriving from the QGraphFilter baseclass
Use this class to obtain a QGraph that only contain graphs involving certain registers.
# Consider only graphs that are two deep and involve the "x" register
> qgraph = qgraph.filter(feyn.filters.Depth(2))
> qgrpah = qgraph.filter(feyn.filters.Contains("x"))
> qgraph.fit(data)
Notice that this example demonstrates searching for all graphs that involve 'x' plus zero or one of the other input features.
Using this chained filter approach it's possible to guide the search for non-linear and dynamic correlations in your dataset with the output variable.
method Contains.key
def key(
self
)
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.
class Depth
def__init__(
depth
) -> Depth
Use this class obtain a QGraph that only contain graphs of a certain depth.
# Consider only graphs with depth 2
> qgraph = qgraph.filter(feyn.filters.Depth(2))
> qgraph.fit(data)
method Depth.key
def key(
self
)
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.
class Edges
def__init__(
edges
) -> Edges
Use this class obtain a QGraph that only contain graphs with a certain number of edges.
# Consider only graphs with 3 edges
> qgraph = qgraph.filter(feyn.filters.Edges(3))
> qgraph.fit(data)
method Edges.key
def key(
self
)
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.
Use this class to obtain a QGraph that does not use certain named functions.
# Consider only graphs that do not use the "gaussian" and "tanh" function
> qgraph = qgraph.filter(feyn.filters.ExcludeFunctions(["gaussian", "tanh"]))
> qgraph.fit(data)
method ExcludeFunctions.key
def key(
self
)
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.
Use this class to obtain a QGraph that only uses certain named functions.
# Consider only graphs made of "add" and "multiply"
> qgraph = qgraph.filter(feyn.filters.Functions(["add","multiply"]))
> qgraph.fit(data)
method Functions.key
def key(
self
)
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.
class MaxDepth
def__init__(
depth
) -> MaxDepth
Use this class obtain a QGraph that only contain graphs up to a certain depth.
# Consider only graphs with depth smaller or equal to 2
> qgraph = qgraph.filter(feyn.filters.MaxDepth(2))
> qgraph.fit(data)
method MaxDepth.key
def key(
self
)
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.
class MaxEdges
def__init__(
edges
) -> MaxEdges
Use this class to obtain a QGraph that only contain graphs with a up to a certain number of edges.
# Consider only graphs with up to 3 edges
> qgraph = qgraph.filter(feyn.filters.MaxEdges(3))
> qgraph.fit(data)
method MaxEdges.key
def key(
self
)
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.
class QGraphFilter
def__init__(
/,
*args,
**kwargs
) -> QGraphFilter
The abstract base class for QGraph Filters
method QGraphFilter.key
defkey(
self
) -> str
Return a unique key for this filter. A QGraph can only have one filter with a given key, so filters can be made mutually exlusive using this method.
When defining a filter that derives from this class, be sure to override this method and return a custom key.