Python error TypeError range integer end argument expected got numpy float64

0 votes

I'm trying to run the following section of python code

for i in range(0, int(m)):
    y_pred = c + m * X[i]
    ss_t += (Y[i] - mean_y) ** 2
    ss_r += (Y[i] - y_pred) ** 2
    r2 = 1 - (ss_r/ss_t)
    print(r2)

I get the following error

TypeError: range() integer end argument expected, got numpy.float64.
May 27, 2019 in Python by Kashish
2,690 views

1 answer to this question.

0 votes

Hi @Kashish, try something like this:

for i in range(0, int(m)):
    y_pred = c + m * X[i]
    ss_t += (Y[i] - mean_y) ** 2
    ss_r += (Y[i] - y_pred) ** 2
    r2 = 1 - (ss_r/ss_t)
    print(r2)
answered May 27, 2019 by Harish

Related Questions In Python

0 votes
1 answer

Error saying "TypeError: range() integer end argument expected"

Try this: [x * 0.01 for x in ...READ MORE

answered May 27, 2019 in Python by Keshav
1,079 views
0 votes
1 answer

i am normalizing the data set iris in python and get the error ::TypeError: 'numpy.float64' object is not callable

TRY THIS   #Nomalisation for i in names:     print(i)   ...READ MORE

answered Aug 20, 2019 in Python by Noel Deepak Palle
5,525 views
0 votes
0 answers

Help, How can I fix this? TypeError: Getting error as __init__() got an unexpected keyword argument 'rotaion_range'.

datagen = ImageDataGenerator(zoom_range=0.2,rotaion_range=10,width_shift_range=0.1, height_shift_range=0.1,horizontal_flip=True, vertical_flip = False ...READ MORE

Oct 20, 2021 in Python by anonymous
• 120 points
335 views
0 votes
0 answers

Error in Python script "Expected 2D array, got 1D array instead:"?

I wanted to make this ML prediction ...READ MORE

May 18, 2022 in Python by Kichu
• 19,050 points
1,221 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,069 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,489 views
0 votes
1 answer

Python error "TypeError: 'encoding' is an invalid keyword argument for this function"

Trying using the io module for this ...READ MORE

answered Aug 2, 2019 in Python by Vaishali

edited Oct 7, 2021 by Sarfaraz 14,055 views
0 votes
2 answers

Python error "TypeError: Can't convert 'int' object to str implicitly"

A TypeError can occur if the type ...READ MORE

answered Feb 5, 2020 in Python by lovelmark
• 160 points
1 flag 18,197 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP