0

I am working on cosine similarity and I am struggling with below two problems:

1- When two text are exact match, I am getting score as 5.000000000000023.

2- When only one character is changed, I am getting score as 4.999999999999999.

When I save the result in excel. For both the case,values are coming as 5.

I tried math.isclose function to handle the above situation for my further analysis. But I want to save the exact score as it is irrespective of the Decimal places in Excel file as I want to use this output file in Qliksense for visualization and there if I keep the Threshold value for my score as 5.0 I may loose few records with value 5.000000000000023.

Aditya sharma
  • 143
  • 2
  • 11
  • @Tim Biegeleisen - I have gone through this link and Understood that float value has some precision but When I print this value in python it is printing the exact value and when saving the same value in Excel why it is rounding off the value. Is there any way I can save the exact value in excel from python? – Aditya sharma Jan 15 '20 at 08:08
  • 1
    It is possible that the Excel spreadsheet is doing the rounding or showing the rounded version. Make sure you are showing sufficient decimal places in the spreadsheet. https://www.lifewire.com/excel-decimal-format-options-3124037 – Mason Jan 15 '20 at 08:22
  • @Mason - I did that, excel advance settings and change the column type from General to Numbers , with 15 Decimal places. But the issue is from Python only when we save the file, it is not taking it as exact Float value. – Aditya sharma Jan 15 '20 at 11:39

0 Answers0