class_docstr: Node embedding application.
  
  Given a graph, it embeds each node into a continuous vector representation.
  The learned embeddings can be used for many downstream tasks.
  e.g. **node classification**, **link prediction**, **node analogy**.
  The similarity between node embeddings can be measured by cosine distance.
  
  Supported Models:
      - DeepWalk (`DeepWalk: Online Learning of Social Representations`_)
      - LINE (`LINE: Large-scale Information Network Embedding`_)
      - node2vec (`node2vec: Scalable Feature Learning for Networks`_)
  
  .. _DeepWalk\: Online Learning of Social Representations:
      https://arxiv.org/pdf/1403.6652.pdf
  .. _LINE\: Large-scale Information Network Embedding:
      https://arxiv.org/pdf/1503.03578.pdf
  .. _node2vec\: Scalable Feature Learning for Networks:
      https://www.kdd.org/kdd2016/papers/files/rfp0218-groverA.pdf
  
  Parameters:
      dim (int): dimension of embeddings
      gpus (list of int, optional): GPU ids, default is all GPUs
      cpu_per_gpu (int, optional): number of CPU threads per GPU, default is all CPUs
      float_type (dtype, optional): type of parameters
      index_type (dtype, optional): type of graph indexes
  
  See also:
      :class:`Graph <graphvite.graph.Graph>`,
      :class:`GraphSolver <graphvite.solver.GraphSolver>`
class_docstr_tok: ["Node","embedding","application",".","Given","a","graph",",","it","embeds","each","node","into","a","continuous","vector","representation",".","The","learned","embeddings","can","be","used","for","many","downstream","tasks",".","e.g",".","*","*","node","classification","*","*",",","*","*","link","prediction","*","*",",","*","*","node","analogy","*","*",".","The","similarity","between","node","embeddings","can","be","measured","by","cosine","distance",".","Supported","Models",":","-","DeepWalk","(","`","DeepWalk",":","Online","Learning","of","Social","Representations","`","_",")","-","LINE","(","`","LINE",":","Large-scale","Information","Network","Embedding","`","_",")","-","node2vec","(","`","node2vec",":","Scalable","Feature","Learning","for","Networks","`","_",")","..","_DeepWalk\\",":","Online","Learning","of","Social","Representations",":","https",":","\/\/arxiv.org\/pdf\/1403.6652.pdf","..","_LINE\\",":","Large-scale","Information","Network","Embedding",":","https",":","\/\/arxiv.org\/pdf\/1503.03578.pdf","..","_node2vec\\",":","Scalable","Feature","Learning","for","Networks",":","https",":","\/\/www.kdd.org\/kdd2016\/papers\/files\/rfp0218-groverA.pdf","Parameters",":","dim","(","int",")",":","dimension","of","embeddings","gpus","(","list","of","int",",","optional",")",":","GPU","ids",",","default","is","all","GPUs","cpu_per_gpu","(","int",",","optional",")",":","number","of","CPU","threads","per","GPU",",","default","is","all","CPUs","float_type","(","dtype",",","optional",")",":","type","of","parameters","index_type","(","dtype",",","optional",")",":","type","of","graph","indexes","See","also",":",":","class",":","`","Graph","<","graphvite.graph.Graph",">","`",",",":","class",":","`","GraphSolver","<","graphvite.solver.GraphSolver",">","`"]
docstr: Evaluate node embeddings on node classification task.
  
  Parameters:
      X (list of str, optional): names of nodes
      Y (list, optional): labels of nodes
      file_name (str, optional): file of nodes & labels
      portions (tuple of float, optional): how much data for training
      normalization (bool, optional): normalize the embeddings or not
      times (int, optional): number of trials
      patience (int, optional): patience on loss convergence
  
  Returns:
      dict: macro-F1 & micro-F1 averaged over all trials
docstr_tok: ["Evaluate","node","embeddings","on","node","classification","task",".","Parameters",":","X","(","list","of","str",",","optional",")",":","names","of","nodes","Y","(","list",",","optional",")",":","labels","of","nodes","file_name","(","str",",","optional",")",":","file","of","nodes","&","labels","portions","(","tuple","of","float",",","optional",")",":","how","much","data","for","training","normalization","(","bool",",","optional",")",":","normalize","the","embeddings","or","not","times","(","int",",","optional",")",":","number","of","trials","patience","(","int",",","optional",")",":","patience","on","loss","convergence","Returns",":","dict",":","macro-F1","&","micro-F1","averaged","over","all","trials"]
code: def node_classification(
      self,
      X=None,
      Y=None,
      file_name=None,
      portions=(0.02,),
      normalization=False,
      times=1,
      patience=100,
  ):
      """
      Evaluate node embeddings on node classification task.
  
      Parameters:
          X (list of str, optional): names of nodes
          Y (list, optional): labels of nodes
          file_name (str, optional): file of nodes & labels
          portions (tuple of float, optional): how much data for training
          normalization (bool, optional): normalize the embeddings or not
          times (int, optional): number of trials
          patience (int, optional): patience on loss convergence
  
      Returns:
          dict: macro-F1 & micro-F1 averaged over all trials
      """
      import scipy.sparse as sp
  
      self.solver.clear()
  
      if file_name:
          if not (X is None and Y is None):
              raise ValueError(
                  "Evaluation data and file should not be provided at the same time"
              )
          X = []
          Y = []
          with open(file_name, "r") as fin:
              for line in fin:
                  tokens = self.tokenize(line)
                  if len(tokens) == 0:
                      continue
                  x, y = tokens
                  X.append(x)
                  Y.append(y)
      if X is None or Y is None:
          raise ValueError(
              "Either evaluataion data (X, Y) or a file name should be provided"
          )
  
      name2id = self.graph.name2id
      class2id = {c: i for i, c in enumerate(np.unique(Y))}
      new_X, new_Y = self.name_map((name2id, class2id), (X, Y))
      logger.info("effective labels: %d / %d" % (len(new_X), len(X)))
      X = np.asarray(new_X)
      Y = np.asarray(new_Y)
  
      labels = sp.coo_matrix(
          (np.ones_like(X), (X, Y)), dtype=np.int32
      ).todense()
      indexes, _ = np.where(np.sum(labels, axis=1) > 0)
      # discard non-labeled nodes
      labels = labels[indexes]
      vertex_embeddings = SharedNDArray(
          self.solver.vertex_embeddings[indexes]
      )
  
      settings = []
      for portion in portions:
          settings.append(
              (
                  vertex_embeddings,
                  labels,
                  portion,
                  normalization,
                  times,
                  patience,
              )
          )
      results = self.gpu_map(linear_classification, settings)
  
      metrics = {}
      for result in results:
          metrics.update(result)
      return metrics
  
imports: from __future__ import print_function, absolute_import, unicode_literals, division
  import os
  import re
  import pickle
  import logging
  import multiprocessing
  from collections import defaultdict
  from future.builtins import str, map, range
  from easydict import EasyDict
  import numpy
  from ..None import lib, cfg, auto
  from ..None import graph, solver
  from ..util import assert_in, monitor, SharedNDArray
label_desc: Use image node_id 4 for calling the GraphApplication obj's underlying member method code with example usage: obj.node_classification(X, Y, file_name, portions, normalization, times, patience) and returns: metrics