This article highlights graphs, properties of its representations and its application in Machine learning to perform Spectral clustering.

Introduction

A graph is a data structure with nodes connected to each other through directed or undirected edges. The edges can have weights to represent for eg. the distance between 2 cities for a graph representing an urban road network with cities as nodes.

Contents

  • Loading data
  • Constructing a graph from features
  • Deriving its Laplacian representation
  • Explore properties of Graph Laplacian
  • Applications in machine learning — Spectral clustering

Loading data

We will begin with a toy make_moons data set from python library scikit-learn.

import numpy as np
from scipy import sparse

from sklearn.datasets import make_moons
from sklearn.neighbors import kneighbors_graph
from sklearn.cluster import KMeans
from sklearn.metrics import homogeneity_score, completeness_score,v_measure_score
import networkx as nx
import matplotlib.pyplot as plt
random_state = 213
np.random.seed(random_state)
data_size = 150
features,y = make_moons(n_samples=data_size, noise=0.07, random_state=213)

#graph-laplacian #linear-algebra #machine-learning #graph-analytics #spectral-clustering

Graph Laplacian and its application in Machine learning
2.05 GEEK