class_docstr: Graph modality
  
  Parameters
  ----------
  data: List[str], required
      A list encoding an adjacency matrix, of a user or an item graph, in the sparse triplet format,         e.g., data=[('user1', 'user4', 1.0)].
class_docstr_tok: ["Graph","modality","Parameters","--","--","--","--","--","data",":","List","[","str","]",",","required","A","list","encoding","an","adjacency","matrix",",","of","a","user","or","an","item","graph",",","in","the","sparse","triplet","format",",","e.g.",",","data=","[","(","'user1","'",",","'user4","'",",","1.0",")","]","."]
docstr: Instantiate a GraphModality with a KNN graph build using input features.
  
  Parameters
  ----------
  features: 2d Numpy array, shape: [n_objects, n_features], required
      A 2d Numpy array of features, e.g., visual, textual, etc.
  
  k: int, optional, default: 5
      The number of nearest neighbors
  
  ids: array, optional, default: None
      The list of object ids or labels, which align with the rows of features.             For instance if you use textual (bag-of-word) features,             then "ids" should be the same as the input to cornac.data.TextModality.
  
  similarity: string, optional, default: "cosine"
      The similarity measure. At this time only the cosine is supported
  
  symmetric: bool, optional, default: False
      When True the resulting KNN-Graph is made symmetric
  
  verbose: bool, default: False
      The verbosity flag.
  
  Returns
  -------
  graph_modality: :obj:`<cornac.data.GraphModality>`
      GraphModality object.
docstr_tok: ["Instantiate","a","GraphModality","with","a","KNN","graph","build","using","input","features",".","Parameters","--","--","--","--","--","features",":","2d","Numpy","array",",","shape",":","[","n_objects",",","n_features","]",",","required","A","2d","Numpy","array","of","features",",","e.g.",",","visual",",","textual",",","etc",".","k",":","int",",","optional",",","default",":","5","The","number","of","nearest","neighbors","ids",":","array",",","optional",",","default",":","None","The","list","of","object","ids","or","labels",",","which","align","with","the","rows","of","features",".","For","instance","if","you","use","textual","(","bag-of-word",")","features",",","then","``","ids","''","should","be","the","same","as","the","input","to","cornac.data.TextModality",".","similarity",":","string",",","optional",",","default",":","``","cosine","''","The","similarity","measure",".","At","this","time","only","the","cosine","is","supported","symmetric",":","bool",",","optional",",","default",":","False","When","True","the","resulting","KNN-Graph","is","made","symmetric","verbose",":","bool",",","default",":","False","The","verbosity","flag",".","Returns","--","--","--","-","graph_modality",":",":","obj",":","`","<","cornac.data.GraphModality",">","`","GraphModality","object","."]
code: def from_feature(
      cls,
      features,
      k=5,
      ids=None,
      similarity="cosine",
      symmetric=False,
      verbose=True,
  ):
      """Instantiate a GraphModality with a KNN graph build using input features.
  
          Parameters
          ----------
          features: 2d Numpy array, shape: [n_objects, n_features], required
              A 2d Numpy array of features, e.g., visual, textual, etc.
  
          k: int, optional, default: 5
              The number of nearest neighbors
  
          ids: array, optional, default: None
              The list of object ids or labels, which align with the rows of features. \
              For instance if you use textual (bag-of-word) features, \
              then "ids" should be the same as the input to cornac.data.TextModality.
  
          similarity: string, optional, default: "cosine"
              The similarity measure. At this time only the cosine is supported
  
          symmetric: bool, optional, default: False
              When True the resulting KNN-Graph is made symmetric
  
          verbose: bool, default: False
              The verbosity flag.
  
          Returns
          -------
          graph_modality: :obj:`<cornac.data.GraphModality>`
              GraphModality object.
          """
      # build knn graph
      knn_graph_array = GraphModality._build_knn(
          features, k, similarity, verbose=verbose
      )
      knn_graph_triplet = GraphModality._to_triplet(
          mat=knn_graph_array, ids=ids
      )
      if symmetric:
          if verbose:
              print("Symmetrizing the graph")
          knn_graph_triplet = GraphModality._to_symmetric(
              knn_graph_triplet
          )
  
      return cls(data=knn_graph_triplet)
  
file_path: cornac/cornac/data/graph.py
imports: import scipy.sparse
  import numpy
  from tqdm.auto import trange
  from .None import FeatureModality
label_desc: Use image node_id 11 for calling the GraphModality obj's underlying member method code with example usage: obj.from_feature(cls, features, k, ids, similarity, symmetric, verbose) and returns: cls