-
Notifications
You must be signed in to change notification settings - Fork 10
Home
toncho11 edited this page Sep 19, 2022
·
6 revisions
Here is an example code:
metric = {
'mean': "convex",
'distance': "convex"
}
`distance_methods["convex"] = lambda A, B: np.linalg.norm(A - B, ord='fro')`
`clf = make_pipeline(XdawnCovariances(), MDM(metric=metric))`
`skf = StratifiedKFold(n_splits=5)`
`n_matrices, n_channels, n_classes = 100, 3, 2`
`covset = get_covmats(n_matrices, n_channels)`
`labels = get_labels(n_matrices, n_classes)`
`score = cross_val_score(clf, covset, labels, cv=skf, scoring='roc_auc')`
We provide a convex model for the first situation based on frobenius distance (method fro_mean_convex
), as well as a wrapper around QAOA optimizer (class NaiveQAOAOptimizer
) that rounds covariance matrices to a certain precision and convert each resulting integer to binary. The implementation is based on Qiskit's IntegerToBinary
, a bounded-coefficient encoding method.
Therefore, complexity of the optimizer raises as a function of the matrix size and the coefficients, and hence it best adapt to covariance matrices having a limited number of channels, with naturally bounded and "differentiable" values. "