How to make cosine Distance classify
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kong
el 13 de Mzo. de 2020
Comentada: Kong
el 17 de Mzo. de 2020
Hello! I am a beginner in Matlab.
I have dataset that consisted of 90 data (10 label x 9 data).
Can I get an idea to make classify based on cosine distance or euclidean distance, etc?
2 comentarios
Ameer Hamza
el 13 de Mzo. de 2020
Can you show an example of your dataset. For example, attach a small dataset and describe what is your expected output.
Respuesta aceptada
Ameer Hamza
el 14 de Mzo. de 2020
If you want to classify a new vector by using the Euclidean or cosine distance between the rows of your matrix and the new vector the try this
data = readmatrix('geo01_KTH.csv');
predictors = data(:, 1:end-1);
labels = data(:, end);
predictors = normalize(predictors, 2, 'range'); % normalize each row to be in range 0-1
x = rand(1, 2352); % generate a random vector
euclidean_dist = pdist2(predictors, x, 'euclidean');
cosine_dist = pdist2(predictors, x, 'cosine');
[~, euclidean_index] = min(euclidean_dist);
[~, cosine_index] = min(cosine_dist);
euclidean_prediction = labels(euclidean_index);
cosine_prediction = labels(cosine_index);
11 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Classification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!