You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following implementations use a generic impl Distance parameter, but only provide a Default impl for the Euclidean distance.
KNNClassifier
KNNRegressor
DBSCAN
KMeans
In one way this is nice, because it makes Euclidean the default at the generic level, so that types may be omitted completely, and only inferred during construction. However, this is problematic when parsing partial defaults from JSON, since if the distance type may no longer be inferred, similar to the currently required type annotations required during deserialization where they also cannot be inferred.
a) One fix would be to make Default::defaults generic for the Distance, and require the annotation during construction as well. This means all Distances would get defaults, but doesn't help the JSON w/ default construction case much, since we'd still need to first parse the JSON to get the get the type to get the defaults, and then match.
b) Another possibility would be to approach similar to #169 by making Distances an enum Struct, rather than a generic type. With that avenue we could still have a Euclidean default without type annotations, but also allow for partial JSON construction for non Euclidean defaults. This comes at the cost of the enum Struct reserving the space for the two Matrix params in Mahalanobis distance in all cases.
My preference would be for b since I believe it's a nicer DevX at a small memory cost that shouldn't impact performance.
The text was updated successfully, but these errors were encountered:
The following implementations use a generic
impl Distance
parameter, but only provide aDefault
impl for theEuclidean
distance.In one way this is nice, because it makes Euclidean the default at the generic level, so that types may be omitted completely, and only inferred during construction. However, this is problematic when parsing partial defaults from JSON, since if the distance type may no longer be inferred, similar to the currently required type annotations required during deserialization where they also cannot be inferred.
a) One fix would be to make Default::defaults generic for the Distance, and require the annotation during construction as well. This means all Distances would get defaults, but doesn't help the JSON w/ default construction case much, since we'd still need to first parse the JSON to get the get the type to get the defaults, and then match.
b) Another possibility would be to approach similar to #169 by making Distances an enum Struct, rather than a generic type. With that avenue we could still have a Euclidean default without type annotations, but also allow for partial JSON construction for non Euclidean defaults. This comes at the cost of the enum Struct reserving the space for the two Matrix params in Mahalanobis distance in all cases.
My preference would be for
b
since I believe it's a nicer DevX at a small memory cost that shouldn't impact performance.The text was updated successfully, but these errors were encountered: