Reggies Linear Regression

Hi. So I am doing this project and I am not understanding what I am doing. I mean am I just solving word problems or is there something I am missing? Please let me know and also where to look for a reference to some of these questions the problems ask.

What exactly has you stuck? Do you have formatted code to post? Did you get an error message?

1 Like

It’s not that. I don’t understand what I am doing. I didn’t get any kind of error message because I didn’t even know that was possible as this page seems like a standard digital school worksheet. This project comes completely out of nowhere and completely throws the rhythm of what I was doing up until then off. Even looking at Github and I am not understanding what the lesson I am learning here is. If I was designing something I would understand but it looks like I am just answering word problems at school. Furthermore it says the command line will come into play on this project but I have yet to see that.

This is in the Python 3 course, yes?
It’s an off-platform project–to get people used to doing projects of their own, away from the CC learning environment. It can seem a little daunting at first, but once you’ve done it you’ll catch on for other future projects you may do.

Questions for you that the info page asks of learners:

  • do you know the command line?
  • do you have python installed on your machine and do you know how to use it/access it?
  • are you familiar with Jupyter Notebook and do you have it installed on your machine?
  • did you download the project file and unzip it?

You can learn the command line anywhere–not just with CC. It’s helpful for moving around in files, accessing, and modifying files on your computer. (an aside, are you on a Windows or Mac?). On a mac, open up terminal. it’s like Finder, but you’re entering commands to access files rather than using a GUI. Knowing a few basic unix commands is helpful, not just here, but for anything.

See:
https://www.techrepublic.com/article/macos-terminal-commands-every-mac-user-should-know/
And learn the CL for Macs:
https://youtu.be/5XgBd6rjuDQ

what are the purpose of the word problems though?

I’m sorry, I’m not understanding.

What do you mean by word problems? The Jupyter Notebook has questions and asks one to write code…there are steps.

Are you asking if it s solving word problems or what is the purpose of doing it?

If its word problems, pretty sure that it is.

If you are asking about the purpose of the project is to demonstrate mastery with the unit you are learning.

As you progress through the coursework, the instructions on projects become more open ended for you to explore and demonstrate your knowledge - like the US Insurance Project where you are given the dataset and you have to figure out what you want to do with that dataset and how you approach the solution to the problem you want to solve.

There needs to be a walkthrough video of this project. Cause this makes no sense whatsoever. Yes, I found where the input is where I can see my error messages but the answer I am supposed to get makes no sense.

Search the forums for the project. It has been discussed a lot. Maybe something there could help you(?) too.

can someone explain this? the errors are not formatted like I am used to.

NameError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_23088/3715831653.py in <module>
      1 #every point in this dataset lies upon y=x, so the total error should be zero:
      2 datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
----> 3 print(calculate_all_error(1, 0, datapoints))
      4 
      5 #every point in this dataset is 1 unit away from y = x + 1, so the total error should be 4:

NameError: name 'calculate_all_error' is not defined

Is “calculate_all_error” defined?
Can you post your formatted code?

Here. Sorry if I sound frustrated. I hate feeling dumb.

def get_y(m, b, x):
  y = m*x + b
  return y

get_y(1, 0, 7) == 7
get_y(5, 10, 3) == 25
def calculate_error(m, b, point):
  x_point, y_point = point
  y = m*x_point + b
  distance = abs(y - y_point)
  return distance
def calculate_all_error(m, b, points):
    total_error = 0
    for point in datapoints:
        point_error = calculate_error(m, b, point)
        total_error += point_error
    return total_error
#every point in this dataset lies upon y=x, so the total error should be zero:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, 0, datapoints))

#every point in this dataset is 1 unit away from y = x + 1, so the total error should be 4:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, 1, datapoints))

#every point in this dataset is 1 unit away from y = x - 1, so the total error should be 4:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, -1, datapoints))


#the points in this dataset are 1, 5, 9, and 3 units away from y = -x + 1, respectively, so total error should be
# 1 + 5 + 9 + 3 = 18
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(-1, 1, datapoints))
1 Like

You’re not dumb. We all get frustrated, no worries.

I copied your code and ran it and I don’t get any errors. So, perhaps you fixed it already(?)

1 Like