本文整理汇总了Python中eden.graph.Vectorizer._transform方法的典型用法代码示例。如果您正苦于以下问题:Python Vectorizer._transform方法的具体用法?Python Vectorizer._transform怎么用?Python Vectorizer._transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eden.graph.Vectorizer
的用法示例。
在下文中一共展示了Vectorizer._transform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ListVectorizer
# 需要导入模块: from eden.graph import Vectorizer [as 别名]
# 或者: from eden.graph.Vectorizer import _transform [as 别名]
class ListVectorizer(Vectorizer):
"""Transform vector labeled, weighted, nested graphs in sparse vectors.
A list of iterators over graphs and a list of weights are taken in input.
The returned vector is the linear combination of sparse vectors obtained on each
corresponding graph.
"""
def __init__(self,
complexity=3,
r=None,
d=None,
min_r=0,
min_d=0,
nbits=20,
normalization=True,
inner_normalization=True,
n=1,
min_n=2):
"""
Arguments:
complexity : int
The complexity of the features extracted.
r : int
The maximal radius size.
d : int
The maximal distance size.
min_r : int
The minimal radius size.
min_d : int
The minimal distance size.
nbits : int
The number of bits that defines the feature space size: |feature space|=2^nbits.
normalization : bool
If set the resulting feature vector will have unit euclidean norm.
inner_normalization : bool
If set the feature vector for a specific combination of the radius and
distance size will have unit euclidean norm.
When used together with the 'normalization' flag it will be applied first and
then the resulting feature vector will be normalized.
n : int
The maximal number of clusters used to discretized label vectors.
min:n : int
The minimal number of clusters used to discretized label vectors.
"""
self.vectorizer = Vectorizer(complexity=complexity,
r=r,
d=d,
min_r=min_r,
min_d=min_d,
nbits=nbits,
normalization=normalization,
inner_normalization=inner_normalization,
n=n,
min_n=min_n)
self.vectorizers = list()
def fit(self, graphs_iterators_list):
"""
Constructs an approximate explicit mapping of a kernel function on the data
stored in the nodes of the graphs.
Arguments:
graphs_iterators_list : list of iterators over networkx graphs.
The data.
"""
for i, graphs in enumerate(graphs_iterators_list):
self.vectorizers.append(copy.copy(self.vectorizer))
self.vectorizers[i].fit(graphs)
def fit_transform(self, graphs_iterators_list, weights=list()):
"""
Arguments:
graphs_iterators_list : list of iterators over networkx graphs.
The data.
weights : list of positive real values.
Weights for the linear combination of sparse vectors obtained on each iterated tuple of graphs.
"""
graphs_iterators_list_fit, graphs_iterators_list_transf = itertools.tee(graphs_iterators_list)
self.fit(graphs_iterators_list_fit)
return self.transform(graphs_iterators_list_transf)
def transform(self, graphs_iterators_list, weights=list()):
"""
Transforms a list of networkx graphs into a Numpy csr sparse matrix
( Compressed Sparse Row matrix ).
#.........这里部分代码省略.........