Project: Reggie's Linear Regression (why?)

I made it to chapter 5 of the Python 3 course and can follow the material pretty good. Then I found Project: Reggie’s Linear Regression and I can’t understand why it’s there at this stage of my path to learn Python!?

Sorry but I hate those kind of traditional school like assignments with a passion! The language is too vague and I fail to visualise what I’m supposed to produce as a result. It simply too vague and that’s makes it not only difficult but simply impossible and frustrating for me to understand.

Observations:

  1. I don’t feel Python Notebooks are appropriate at this point. (but iPython Notebooks on Azure is convenient)
  2. The assignment is too abstract.

" We will use loops, lists, and arithmetic to create a function that will find a line of best fit when given a set of data."

" Reggie wants to try a bunch of different m values and b values and see which line produces the least error. To calculate error between a point and a line, he wants a function called calculate_error() , which will take in m , b , and an [x, y] point called point and return the distance between the line and the point."

  1. An example of the desired result / solution would have been helpful.

So unfortunately I have to skip this Project… I’m pretty sure I could write the code if I understood the assignment, but how it is now I fail to understand.

Why not an assignment like a game, a tool or something else instead of forcing us to data analysing before we are ready? What I like and appreciate about Codecademy are that it takes baby steps trough the material, building on previous material teaching step by step. Unfortunately Reggrions Linear’s Regression doesn’t do that.

PS : Even looking at the solution, and asking someone who is a financial analyst to explain, I still don’t understand the whole thing. This assignment is assuming too much level too soon and fast from some students like me! Teaching Data Analysing is cool but first create the context teaching about it step by step.

47 Likes

I am also struggling with this project. Does anyone know if theres a tutorial/video for this project somewhere ?

11 Likes

same here i dont understand what I should do with the project

10 Likes

I agree. This project is confusing and there seem to be confusing typos throughout?

8 Likes

I’m glad to see i’m not the only one!
This project was not helpful at this point and only served to make me feel like I hadn’t made any progress at all.
The language used in the descriptions is unclear and difficult to follow.

21 Likes

It’s incredibly poorly written and lacks context. I know the math required inside and out, yet I felt completely unprepared for the task at hand. Throughout CodeAcademy’s lessons there are plenty of occasions where a knowledge leap comes into play. the “.pop()” command is one of them. Zero experience and yet we should integrate it on the fly. If I’m paying for a lesson, no stone should be left unturned.

13 Likes

I am trying to understand what the point was in creating the “get_y” function at the beginning of the project to only have to redefine “y” in the second part of the project. The instructions for the second function specifically state (4) "Find the difference between the y from get_y and y_point" yet the recommended solution doesn’t even make use of the get_y function.

9 Likes

Hi. I solved this today. Let me know if you would need some help.

1 Like

Also try pythontutor.com

It helps a lot with visualisation of the code

3 Likes

Hi, I’m struggling on the project and need help. Is there a tutorial video?

Hi. I could not find any tutorial. I first googled about how to get the slope of a line. After I read up on it, I then went back to the exercise and used pythontutor to debug my code repeatedly

I did not get the best fit of “y = 0.3x + 1.7” as the solution proposes. It shouldn’t be that answer anyway, since the part 1 test of calculate_all_error function produced one y=mx+b that had zero error. Obviously that would be the best fit then, and not the proposed solution.

2 Likes

I was struggling with this as well, make sure you are testing your code on the

datapoints = [(1, 2), (2, 0), (3, 4), (4, 4), (5, 3)]

I wasn’t…

9 Likes

The problem I am having with this assignment is that the answer I am getting is .1 off from what the assignment says I should get. I know where the divergence is, but can’t figure out why it matters.

I wrote the list comprehensions using /10.0 rather than * 0.1:
possible_ms = [m / 10 for m in range(-100, 101)]

The solution has this as:
possible_ms = [m * 0.1 for m in range(-100, 101)]

The result of this difference is that I get 0.4, 1.6, 5.0 as answers, whereas solution has .3, 1.7 and 5.0.

Why is this happening? I would think dividing by 10.0 is the exact same thing as multiplying by 0.1.

4 Likes

This had me too, at first. I think this is a small issue that can throw you off for quite some time. Seems like it could easily have been avoided by the person who designed this project. Although it gave me an inmense sense of satisfaction when I figured out the problem on my own, it does not seem like this should be part of this excercise so maybe it should be fixed.

1 Like

Wow! Nice going. Unless I’m mistaken, you have figured out how to solve this problem in a more elegant way than the person who designed this project themselves! Your solution for the possible_ms values gives values evaluted to one decimal place - this is much better than the mess provided by the code included in the solution:

possible_ms = [m * 0.1 for m in range(-100, 101)]

which gives similar values to your code, but many of which are 0.000000000000001 above or below the value we are looking for:

[-10.0, -9.9, -9.8, -9.700000000000001, -9.600000000000001, -9.5, ...]

I don’t think that your answers of 0.4, 1.6, 5.0 are necessarily more correct than the values in the given solution of 0.3, 1.7, 5.0 ( rounded off from their output values of 0.30000000000000004, 1.7000000000000002, and 4.999999999999999) since the values that we include for possible_ms and possible_bs are largely arbitrary (if we wanted more accuracy we could, for example, test every value between -10 and 10 in 0.01 increments instead of 0.1 increments, which would be much more accurate and give very different results).

What’s beyond any doubt, however, is that you have nonetheless given a solution to their problem that is more correct than their own! I quote:

Using a list comprehension, let’s create a list of possible m values to try. Make the list possible_ms that goes from -10 to 10 inclusive, in increments of 0.1.

Which you have definitely done, and they have not (since their code gives a lot of values which are not exactly increments of 0.1).

You should be proud! If I were a board admin I would give you a medal.

2 Likes

It looks like this project contains plenty of functions or format that we haven’t learned. I was stuck on calculate_error() wandering how do I make point as (x, y) and it kept showing me error on it until I looked at the solution. But why should it be x_point, y_point = point, why can’t it be point = x_point, y_point? I really have no idea and I won’t be surprised if there are more things later in this project that we haven’t learned or known.

4 Likes

The main issue I have been having with this project is it has been a long time since I’ve done any thing with geometry or trig. However, it’s easy to figure this stuff out with Google. I’m not new to programming or software development just new to Python. In real life situations, when you don’t know the answer, Google (or your favorite search engine) is the place to go.

3 Likes

I really can’t do this project without the help of the solution. Is that bad because i don’t understand every step and do some of the function and not really working ? Maybe should be some kind of video explanation for every project that is bigger and need more in depth knowledge. I know how to google, but i feel that is cheating, to google everything and not figuring yourself some of the exercise. I don’t know maybe is just me…

1 Like

This is really abstract. Can’t follow. Think I’ll have to skip this one.