-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of NCH (Nearest Convex Hull) classifier #253
Conversation
It gives an error: AttributeError: Pipeline has none of the following attributes: decision_function.
Added an example that runs on a small number of test samples, so that we can get results quicker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest a simpler implementation for NCH, and directly multiclass.
- limite size of training set - change to slsqp optimizer
Merge branch 'main' of https://github.com/toncho11/pyRiemann-qiskit-rep
Added second parameter that specifies the number of hulls.
Added support for transform(). Added a new pipeline [NCH+LDA]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @toncho11!
I see you introduced the n_hulls and n_samples_per_hull parameters.
We could do some hyperparmetrization in a follow-up PR.
I see that the signature of the distance function differs a little bit from pyRiemann, and this is why you could not reuse the whole suggestion from @qbarthelemy in the _predict_distances
method, but you introduced the transform
.
Some minor comments. Questions:
- Do we keep the classifly_P300_nch.py? (I think it could be handfull for the next iterations)
- Do we want to do a short test with quantum=True before merging?
Improvements requested by GC.
I think the PR is ready for merge. |
Set of SPD matrices. Co-authored-by: Quentin Barthélemy <[email protected]>
Added new lines to before Parameters Co-authored-by: Quentin Barthélemy <[email protected]>
[y == c, :, :] => [y == c] Co-authored-by: Quentin Barthélemy <[email protected]>
NearestConvexHull text change Co-authored-by: Quentin Barthélemy <[email protected]>
Changes about the global optimizer so, that it is more evident that a global one is used.
Added support for both "min-hull" and "random-hull" using the constructor parameter "hull-type".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better late than never.
predictions = [ | ||
self.classes_[min(range(len(values)), key=values.__getitem__)] | ||
for values in dist | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference with predictions = self.classes_[dist.argmin(axis=1)]
?
for test_sample in X: | ||
dist_sample = self._process_sample(test_sample) | ||
dist.append(dist_sample) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add dist = np.concatenate(dist, axis=1)
here, in order to transform list into array.
distances_to_covs = [ | ||
distance_logeuclid(test_sample, cov) | ||
for cov in self.matrices_per_class_[c] | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using from pyriemann.utils.distance import distance
, you can simplify code this way
distances_to_covs = distance(self.matrices_per_class_[c], test_sample, metric="logeuclid")[:, 0]
Then, you can compute np.argsort(distances_to_covs)
instead of np.argsort(np.array(distances_to_covs))
.
QuanticNCH uses NearestConvexHull classifier (non quantum version)
Resolves #246
Resolves #254