yall.initializations module

class yall.initializations.CentralityMeasure(X, k)[source]

Bases: object

\(score(x)= \frac{1}{k-1} \sum_{x_j \in NN(x_i)} \omega(x_i, x_j)\)

\(NN(x)\): The k nearest neighbors of \(x\).

\(\omega\): A weight method.

centrality()[source]
find_centers(n=50)[source]
weight(i, j)[source]

Computes the weight between nodes i and j according to the graph matrix.

class yall.initializations.ClosenessCentrality(X, k=30)[source]

Bases: yall.initializations.CentralityMeasure

\(\omega(x_i, x_j) = \frac{1}{dist(x_i, x_j)}\)

weight(i, j)[source]

Computes the weight between nodes i and j according to the graph matrix.

class yall.initializations.DegreeCentrality(X, k=30)[source]

Bases: yall.initializations.CentralityMeasure

\(\omega(x_i, x_j) = \delta_{ij}\)

weight(i, j)[source]

Computes the weight between nodes i and j according to the graph matrix.

class yall.initializations.EigenvectorCentrality(X, k=30, n='auto')[source]

Bases: yall.initializations.CentralityMeasure

We solve for the eigenvalues \(\lambda\) of the adjecency matrix \(A\)

\(Ax = \lambda x\)

The nodes with the highest eigenvalues \(\lambda\) are the most central.

centrality()[source]
class yall.initializations.FacilityLocation(X, k=30, solver='GUROBI')[source]

Bases: yall.initializations.SetCover

This is a simplified version of the uncapacitated facility location problem in which there is no cost to open a facility. Customers are data points and facilities are centers. The cost to ship from a facility to a customer is computed as the distance between them in a k nearest neighbor graph.

\(I\) : Set of candidate center locations.

\(J\) : Set of data points.

N.B. In this case \(I = J\) as each data point is a potential center.

\(M\) : Maximum number of centers.

\[ \begin{align}\begin{aligned}y_{ij} = \begin{cases} 1 & \text{if center} ~i~ \text{covers data point} ~j\\ 0 & \text{otherwise} \end{cases}\end{aligned}\end{align} \]

\(D_{ij} =\) distance between center \(i\) and data point \(j\)

\(\epsilon =\) number of permissable outliers

minimize \(\sum_{i \in I} \sum_{j \in J} D_{ij} y_{ij}\)

subject to

\(\sum_i max_j ~y_{ij} \leq M\)

\(\sum_{ij} y_{ij} = ~|J| - ~\epsilon\)

\(y_{ij} \in \{0,1\} ~~\forall i \in I, j \in J\)

find_centers(n=50, epsilon='auto')[source]
class yall.initializations.GreedySetCover(X, k=30)[source]

Bases: yall.initializations.SetCover

Given a set of partial covers \(S\) of \(X\), greedily search for a subset of them, indexed by \(I\) such that \(\bigcup_{i \in I} S_i~ = X\)

find_centers(n=50)[source]
class yall.initializations.LDSCentrality(X, k=30)[source]

Bases: yall.initializations.CentralityMeasure

\(\omega(x_i, x_j) = ~\mid NN(x_i) \cap NN(x_j) \mid\)

weight(i, j)[source]

Computes the weight between nodes i and j according to the graph matrix.

class yall.initializations.SetCover(X, k=30)[source]

Bases: object

find_centers(n=50)[source]