Comments (7)
this link may help
from rportfoliosimilarity.
After testing a couple alternatives, I figured out that the weighted cosine similarity function is using the following formula (matching this example):
sum(x*y*w)/(sqrt(sum(x^2*w))*sqrt(sum(y^2*w)))
This includes the weights in the denominator, multiplying each vector value, raised to the second power, by the corresponding weight.
from rportfoliosimilarity.
It would be great if the formulas are explicitly listed in the docs!
from rportfoliosimilarity.
After testing a couple alternatives, I figured out that the weighted cosine similarity function is using the following formula (matching this example):
sum(x*y*w)/(sqrt(sum(x^2*w))*sqrt(sum(y^2*w)))
This includes the weights in the denominator, multiplying each vector value, raised to the second power, by the corresponding weight.
Yep, thanks, a look in the source code confirms that:
double wtVCosSimilarity(NumericVector a, NumericVector b, NumericVector w) {
double sA, sB, sI;
sA = sum(w*a*a);
sB = sum(w*b*b);
sI = sum(w*a*b);
return (sI/sqrt(sA * sB));
}
I will put in the docs.
from rportfoliosimilarity.
Great, thanks for confirming the formula. Do you have a link to an external source that helps to confirm this formula? It makes sense as I experiment with it, but a general online search does not return any robust use cases or studies that help with validation.
from rportfoliosimilarity.
Closed in 8a4094d
from rportfoliosimilarity.
I am not aware of any solid reference right now. It has been some time since I wrote this part of my dissertation. But I think this was the only formula that behaved well (a.k.a. met some basic requirements on edge cases, equal weights etc...).
from rportfoliosimilarity.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rportfoliosimilarity.