Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I make z score algorithms work? Where am I going wrong?

I have been having some trouble with my code, about how to use the Kaggle database to find the popularity of data, and analyze it using Z-score algorithms. I have tried a lot, but can never seem to get my code to work. Here is the link to the data: https://docs.google.com/spreadsheets/d/1HIAzQta-dSfoovkdPeqKcBxANhaO9VR_TiNFwnUKFcU/edit?usp=sharing

And here is my code

for header in data.columns:

  # average
  sum = 0
  n = 0
  crab = 0
  for i in data[header]:
    sum += ele
    n += 1
    average = sum / n
    # standard Deviation


  for j in data[header]:
      crab = np.std(crab)

  for k in data[header]:
    k = (k - average) / crab
    print("k = ",k)
    break


print(data.shape) 
data.info()
data.hist(figsize=(14, 14))
%config InlineBackend.print_figure_kwargs={'facecolor' : "w"} 

k is apparently = to – inf? and im really confused

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have written:

crab = 0
# ...
# ...
crab = np.std(crab)
# ...
# ...
k = (k - average) / crab # You are dividing by zero

Hence the infinty in the output

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading