Python Forum
Coursera: Where are complete source code examples?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coursera: Where are complete source code examples?
#1
Has anyone tried the Coursera.org class on python machine learning?

They have an example in their "notebook", but their notebooks have a snippet approach. I can't find a complete code example and their code in the class assumes certain variables are there.

https://www.coursera.org/learn/python-ma...regression

What's totally unclear is how they load the X_train and y_train in their working example at about time index 8:55.

The code imports a crime dataset from an included text file and also uses a "load_crime_dataset()" method/function in a helper py file called "adspy_shared_utilities.py". That load_crime_dataset() method returns two values:

1. X_crime = crime.ix[:,range(0,88)]
2. y_crime = crime['ViolentCrimesPerPop']

But, since this helper code is not documented, it's unclear if these translate to X_Train and y_train per the courses's powerpoint slide.

Making the assumption that the code is correct, and running it, gives this error:

ValueError: Found input variables with inconsistent numbers of samples: [499, 1495]

There doesn't seem to be any way for an "auditor" (that is, non-paying participant) of the course to get help. I've downloaded all the sample files, but no complete examples seem to exist with context.

Suggestions?

-- O
Reply
#2
Moved this thread to "Bar" forum, since it has nothing to do with Python or the Forum.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
I can't find (without signing up for the course anyway) the code you're looking for. That said, I thought that even non-paying learners could use the course forums, which would be a more reliable place to get your answer than here (since it's not directly about Python coding). If you definitely can't use their forums, please post back and I'll look a little harder.
Reply
#4
(Dec-08-2017, 05:51 PM)micseydel Wrote: I can't find (without signing up for the course anyway) the code you're looking for. That said, I thought that even non-paying learners could use the course forums, which would be a more reliable place to get your answer than here (since it's not directly about Python coding). If you definitely can't use their forums, please post back and I'll look a little harder.

You have to sign up for a free class. It's a bit of trouble initially to set up and somewhat confusing getting around. I'm using PyCharm so the whole "notebook" think may be what I'm missing, but I just do not see how they load the data. There are no "py" files.

Here's the URL I was using for that module:

https://www.coursera.org/learn/python-ma...regression

I'm a totally newbie to Python (after 15 years doing Java) so I feel like a fish out of water still.

If you're able to run the code (figure out how to load those variables), I'd appreciate it.

(Sorry for posting in the wrong forum. Making lots of mistakes in my transition to Python!) Smile
Reply
#5
I just registered to audit the course and am looking a notepad. I just took a look, and it seems that most but not all of the code is easily runnable from within the browser, but some snippets do lack full definitions.

There's not really anything we can do to help with that. I recommend you use the course forums, and if they're not available, see if you can figure out when the session opens, which should be when the forums are active.
Reply
#6
Is this what you're looking for? https://github.com/MaxPoon/coursera-Appl...ith-Python
Reply
#7
(Dec-08-2017, 11:08 PM)Larz60+ Wrote: Is this what you're looking for? https://github.com/MaxPoon/coursera-Appl...ith-Python

Don't think so. That's a different course. But, similar to my situation, there doesn't seem to be code listings with "py" files. I don't get the whole "notebook" think with Python so maybe I'm missing something.

My link in my reply above is for machine learning with python. Still with coursera though.

Thanks.
Reply
#8
Another eaiser-to-find example of what I'm describing is in the git hub repo for the book "Introduction to Machine Learning" (github.com/amuller/introduction_to_ml_with_python)

Look at: 02-supervised-learning.ipynb

Then, for instance, with Ridge Regression:

from sklearn.linear_model import Ridge

ridge = Ridge().fit(X_train, y_train)
print("Training set score: {:.2f}".format(ridge.score(X_train, y_train)))
print("Test set score: {:.2f}".format(ridge.score(X_test, y_test)))

==

How to X_train and y_train get populated?

The presentation is in snippets not complete ready-to-go code examples. This approach seems like a common theme in this and other books like this leaving it up to the reader to figure things out rather than complete code examples.

I want standalone examples that run so I can focus on using rather than spending time just getting them to work.

Perhaps I don't understand these notebooks....that's possible.

IAC, just wanted to post an easier-to-get-to example of what I was talking about.

Thanks,
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What is the best comment in source code you have ever encountered? buran 1 4,576 Mar-04-2020, 10:34 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020