code: def test_from_feature(self):
      # build a toy feature matrix
      F = np.zeros((4, 3))
      F[0] = np.asarray([1, 0, 0])
      F[1] = np.asarray([1, 1, 0])
      F[2] = np.asarray([0, 0, 1])
      F[3] = np.asarray([1, 1, 1])
  
      # the expected output graph, if using cosine similarity
      s = set()
      s.update(
          [
              (0, 1, 1.0),
              (0, 3, 1.0),
              (1, 0, 1.0),
              (1, 3, 1.0),
              (2, 0, 1.0),  # sim = 0
              (2, 1, 1.0),  # sim = 0
              (2, 3, 1.0),
              (3, 0, 1.0),  # sim ~ 0.57
              (3, 1, 1.0),
              (3, 2, 1.0),  # sim ~ 0.57
          ]
      )
  
      # build graph modality from features
      gm = GraphModality.from_feature(
          features=F, k=2, similarity="cosine", verbose=False
      )
  
      self.assertTrue(isinstance(gm, GraphModality))
      self.assertTrue(not bool(gm.raw_data.difference(s)))
  
file_path: cornac/tests/cornac/data/test_graph.py
imports: import unittest
  import numpy
  from cornac.data import GraphModality
  from cornac.data import Reader
  from collections import OrderedDict
label_desc: Use image node_id 4 for calling the TestGraphModality obj's underlying member method code with example usage: obj.test_from_feature() without return types