Exemple #1
0
 def test_4_4(self):  # X not a subset of ground set for marginalGain()
     M = np.array([[1, 2], [3, 4]])
     obj = FacilityLocationFunction(n=2, sijs=M)
     X = {0, 2}
     try:
         obj.marginalGain(X, 1)
     except Exception as e:
         assert str(e) == "ERROR: X is not a subset of ground set"
Exemple #2
0
#dryrun of create_kernel
n_, K_dense = create_kernel(data, 'dense', 'euclidean')
print(K_dense)
n_, K_sparse = create_kernel(data, 'sparse', 'euclidean', num_neigh=2)
print(K_sparse)

#dryrun of C++ FL and Python FL when user provides similarity matrix
#1) with dense matrix
obj = FacilityLocationFunction(n=3, sijs=K_dense)
X = {1}
print(obj.evaluate(X))
X = {1, 2}
print(obj.evaluate(X))
X = {1}
print(obj.marginalGain(X, 2))

#2) with sparse matrix
obj = FacilityLocationFunction(n=3, sijs=K_sparse, num_neigh=2)

#dryrun of C++ FL and Python FL when user provides data
#1) with dense mode
obj = FacilityLocationFunction(n=3,
                               data=data,
                               mode="dense",
                               metric="euclidean")
X = {1}
print(obj.evaluate(X))
X = {1, 2}
print(obj.evaluate(X))
X = {1}