Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

KNearestNeighbors Constructor (Int32, Int32, Double[][], Int32[], IMetric(Double[])) #386

@Lyubna

Description

@Lyubna

How to generate the IMetric(Double[]) parameter? I need to calculate the Cosine distance

My input is double[][]
output is int []

it works fine when I use
KNearestNeighbors knn = new KNearestNeighbors(k: 10, classes: 3, inputs: inputs, outputs: outputs);

but when I want to change the distance as you showed in the example like that
KNearestNeighbors knn = new KNearestNeighbors(k: 10, classes: 3, inputs: inputs, outputs: outputs,distance: Distance.Cosine);

it shows me the following error:
Error 1 The best overloaded method match for 'Accord.MachineLearning.KNearestNeighbors.KNearestNeighbors(int, int, double[][], int[], Accord.Math.Distances.IMetric<double[]>)' has some invalid arguments

Error 2 Argument 5: cannot convert from 'method group' to 'Accord.Math.Distances.IMetric<double[]>'

What can I do to solve this and change the default Euclidean distance to Cosine?
p.s. I also tried the example you used with classifying the strings, it also showed error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions