Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def fit(self, graph, X):
"""
Fitting a MUSAE model.
Arg types:
* **graph** *(NetworkX graph)* - The graph to be embedded.
* **X** *(Scipy COO array)* - The binary matrix of node features.
"""
self._set_seed()
self._check_graph(graph)
self.graph = graph
self._walker = RandomWalker(self.walk_length, self.walk_number)
self._walker.do_walks(graph)
self.features = self._feature_transform(graph, X)
self._base_docs = self._create_base_docs()
self.embeddings = [self._create_single_embedding(self._base_docs)]
self._learn_musae_embedding()
def fit(self, graph):
"""
Fitting a Walklets model.
Arg types:
* **graph** *(NetworkX graph)* - The graph to be embedded.
"""
self._set_seed()
self._check_graph(graph)
walker = RandomWalker(self.walk_length, self.walk_number)
walker.do_walks(graph)
num_of_nodes = graph.number_of_nodes()
self._embedding = []
for power in range(1, self.window_size+1):
walklets = self._select_walklets(walker.walks, power)
model = Word2Vec(walklets,
hs=0,
alpha=self.learning_rate,
iter=self.epochs,
size=self.dimensions,
window=1,
min_count=self.min_count,
workers=self.workers,
seed=self.seed)
def fit(self, graph, X):
"""
Fitting a SINE model.
Arg types:
* **graph** *(NetworkX graph)* - The graph to be embedded.
* **X** *(Scipy COO array)* - The matrix of node features.
"""
self._set_seed()
self._check_graph(graph)
self._walker = RandomWalker(self.walk_length, self.walk_number)
self._walker.do_walks(graph)
self._features = self._feature_transform(graph, X)
self._select_walklets()
model = Word2Vec(self._walklets,
hs=0,
alpha=self.learning_rate,
iter=self.epochs,
size=self.dimensions,
window=1,
min_count=self.min_count,
workers=self.workers,
seed=self.seed)
self.embedding = np.array([model[str(n)] for n in range(graph.number_of_nodes())])
def fit(self, graph):
"""
Fitting a Role2vec model.
Arg types:
* **graph** *(NetworkX graph)* - The graph to be embedded.
"""
self._set_seed()
self._check_graph(graph)
walker = RandomWalker(self.walk_length, self.walk_number)
walker.do_walks(graph)
hasher = WeisfeilerLehmanHashing(graph=graph, wl_iterations=self.wl_iterations, attributed=False)
node_features = hasher.get_node_features()
documents = self._create_documents(walker.walks, node_features)
model = Doc2Vec(documents,
vector_size=self.dimensions,
window=0,
min_count=self.min_count,
dm=0,
workers=self.workers,
sample=self.down_sampling,
epochs=self.epochs,
alpha=self.learning_rate,
def fit(self, graph):
"""
Fitting a GEMSEC model.
Arg types:
* **graph** *(NetworkX graph)* - The graph to be embedded.
"""
self._set_seed()
self._check_graph(graph)
self._setup_sampling_weights(graph)
self._walker = RandomWalker(self.walk_length, self.walk_number)
self._walker.do_walks(graph)
self._initialize_node_embeddings(graph)
self._initialize_cluster_centers(graph)
self._do_gradient_descent()
def fit(self, graph):
"""
Fitting a DeepWalk model.
Arg types:
* **graph** *(NetworkX graph)* - The graph to be embedded.
"""
self._set_seed()
self._check_graph(graph)
walker = RandomWalker(self.walk_length, self.walk_number)
walker.do_walks(graph)
model = Word2Vec(walker.walks,
hs=1,
alpha=self.learning_rate,
iter=self.epochs,
size=self.dimensions,
window=self.window_size,
min_count=self.min_count,
workers=self.workers,
seed=self.seed)
num_of_nodes = graph.number_of_nodes()
self._embedding = [model[str(n)] for n in range(num_of_nodes)]