U
U
UserTwo2021-06-08 17:59:23
PHP
UserTwo, 2021-06-08 17:59:23

How to get cosine similarity?

I'm trying to compare two sentences using the fastText library. I get the vectors of these two sentences:
1. English teacher -
-0.055822 -0.018352 0.041013 0.18283 -0.16821 0.02311 0.0076828 0.0016724 -0.04036 -0.081545 -0.11313 0.18787 -0.090292 -0.11296 0.13054 0.036814 -0.057317 -0.10382 0.077644 0.067797 -0.15164 -0.16492 0.013967 -0.14933 -0.0083086 0.11905 0.11409 -0.088192 0.068585 -0.040738 0.14539 -0.084863 0.088691 -0.031784 0.082985 0.12521 0.036087 0.19473 0.13803 0.079901 -0.11304 -0.071186 -0.012686 -0.051359 -0.011205 0.069676 -0.064156 -0.0095245 0.044792 -0.040233 0.1476 -0.0013512 0.15569 -0.1376 -0.019672 0.11137 0.19998 -0.16124 -0.044039 -0.041473 0.24008 -0.030634 -0.10616 -0.030441 0.11672 -0.0053124 0.12936 -0.01343 -0.064216 -0.02774 0.093166 -0.00051435 -0.054074 0.10338 0.053023 0,163 -0.095045 -0.26146 0.048235 -0.013532 0.18109 -0.18041 -0.19942 -0.075534 0.075379 0.0097478 0.098965 0.2549 -0.052498 -0.072675 -0.093332 -0.060324 -0.24482 0.12241 -0.011947 0.00047545 -0.067178 -0.095532 0.15733 0.13313

2. English teacher -
-0.16328 0.1851 -0.090825 0.074221 0.0034957 -0.047249 0.20726 0.014848 -0.039114 -0.0037184 0.10744 0.25127 0.23009 0.1975 -0.15777 -0.035879 0.019297 0.027774 -0.0028902 -0.029605 -0.11882 -0.077638 0.054071 -0.24271 0.12261 -0.17708 0.10784 -0.14237 0.14881 0.33588 0.001376 -0.090709 -0.071973 - 0.10867 -0.24047 0.11315 0.050643 -0.046273 0.06889 -0.1932 0.070134 0,162 0.19377 -0.033411 -0.14804 0.030256 -0.26307 -0.17315 0.01144 0.15979 0.090993 0.29336 0.00058415 0.024732 0.024734 0.06211 0.20404 -0.043189 0.045792 0.051823 -0.085374 0.1359 0.18853 0.24812 -0.16606 0.04118 -0.15131 -0.023159 0,278 0.29566 - 0.063098 0.041345 -0.16097 0.22505 -0.010126 0.086565 -0.029572 -0.016097 0.10529 -0.19746 0.073197 0.064993 -0.14755 -0.22785 -0.14847 -0.33231 -0.11838 0.28551 0.12125 -0.099142 -0.056241 0.16649 0.018352 -0.33078 -0.098743 -0.007438 0.14388 0.11397 -0.025489 0.1323

Tell me how you can get cosine similarity for these two vectors?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question