Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage / Structure #9

Open
ludaavics opened this issue Sep 16, 2012 · 5 comments
Open

Usage / Structure #9

ludaavics opened this issue Sep 16, 2012 · 5 comments

Comments

@ludaavics
Copy link

Hi,

Thanks for this, great project.

what's the standard way of using the code? do you just run the successive exercise files (e.g. ex1.py) from the shell?

I think a natural way (at least for me) to use this would be to clone py-coursera in a folder in my python path, and then, in Ipython:

from py-coursera import ML
ML.ex1()
ML.ex1_multi()

or something along those lines. basically one package per class and one function per assignment / task / etc.

Would it be possible to re-organize the code to allow for that usage?
One thing that would get messy is that you would need to handle imports / reload, but i think the hassle is worth it to make usage more clear?

@tansaku
Copy link
Owner

tansaku commented Sep 17, 2012

HI Ludaavics,

Good question - we are currently discussing that very issue on the
py-coursera mailing list:

https://groups.google.com/group/py-coursera

Ioura just made some changes to the way things work, and is in the
process of changing them back based on the way I was suggesting using
things.

Personally, based on the Octave mode of using things, I was thinking to
be in the ML folder and being able to run:

python ex1.py

of be able to just run "import ex1" from the ipython --pylab command
line, but we'd like to be able to support any sensible usage pattern.
Perhaps you can help us work out what the best approach should be ...

CHEERS> SAM

On 9/16/12 5:40 PM, ludaavics wrote:

Hi,

Thanks for this, great project.

what's the standard way of using the code? do you just run the
successive exercise files (e.g. ex1.py) from the shell?

I think a natural way (at least for me) to use this would be to clone
py-coursera in a folder in my python path, and then, in Ipython:

|from py-coursera import ML
ML.ex1()
ML.ex1_multi()
|

or something along those lines. basically one package per class and
one function per assignment / task / etc.

Would it be possible to re-organize the code to allow for that usage?
One thing that would get messy is that you would need to handle
imports / reload, but i think the hassle is worth it to make usage
more clear?


Reply to this email directly or view it on GitHub
#9.

Sam's Technical Blog
http://linklens.blogspot.com

@tansaku
Copy link
Owner

tansaku commented Sep 22, 2012

i think the most important part is to be able to:
1/ play around with the variables after you've run the script (which i dont think is the case if you just do python ex1)
2/ reload your code without any hassle (which i dont think is the case if you just do import ex1, as that will not reload say computeCost.py which is the file you would actually be updating constantly when doing your homework)

that's why i personally think it makes a lot of sense to just keep everything as a package that has to be imported in your python path. i dont think its that big a hassle, and it would scale much better (multiple courses, each with their own exercises), in my opinion.

On Monday, September 17, 2012 12:32:52 PM UTC-4, Sam Joseph wrote:

HI Ludaavics,

  Good question - we are currently discussing that very issue on the
  py-coursera mailing list:



  https://groups.google.com/group/py-coursera



  Ioura just made some changes to the way things work, and is in the
  process of changing them back based on the way I was suggesting
  using things.



  Personally, based on the Octave mode of using things, I was
  thinking to be in the ML folder and being able to run:



  python ex1.py



  of be able to just run "import ex1" from the ipython --pylab
  command line, but we'd like to be able to support any sensible
  usage pattern.  Perhaps you can help us work out what the best
  approach should be ...



  CHEERS> SAM



  On 9/16/12 5:40 PM, ludaavics wrote:

Hi,

Thanks for this, great project.

what's the standard way of using the code? do you just run the
successive exercise files (e.g. ex1.py) from the shell?

I think a natural way (at least for me) to use this would be to
clone py-coursera in a folder in my python path, and then, in
Ipython:
from py-coursera import ML
ML.ex1()
ML.ex1_multi()

or something along those lines. basically one package per class
and one function per assignment / task / etc.

Would it be possible to re-organize the code to allow for that
usage?

    One thing that would get messy is that you would need to handle
    imports / reload, but i think the hassle is worth it to make
    usage more clear?


    —

    Reply to this email directly or view it
      on GitHub. 






-- 

Sam's Technical Blog
http://linklens.blogspot.com

@tansaku
Copy link
Owner

tansaku commented Sep 23, 2012

Hi,

That's almost what I did, except I made the mlclass_ex1 (and others at the
same level) a package, not the whole py-coursera/ML directory.It just means
you have to add the ML directory to your python path.
With the latest changes, relative imports are now used again inside the
package (i.e., the package is not referred to explicitly), so that it
should support either ways of working.

Progress report: Yesterday, I successfully submitted ex3 in python to
coursera servers. I'll remove my solutions and probably commit the code
tomorrow. I don't think I'll be adding more tests soon, as I'm trying to
follow the current ML course schedule. I don't know for how long the
servers will accept submissions after the end of the course.

Some remarks about ex3:

  • I didn't port "fmincg" to python, but the "Newton-CG" algorithm from
    scipy works well for this exercise. It gives similar quality solutions for
    the exercise, and the same answer for the submit test and so is accepted by
    coursera servers.
  • Some "Matlabisms" in the exercise, such as choosing labels from 1 to 10
    instead of from 0 to 9, is unfortunate in python. Be wary of "off-by-1"
    errors.

On Saturday, September 22, 2012 10:05:12 PM UTC+2, [email protected]
wrote:

i think the most important part is to be able to:
1/ play around with the variables after you've run the script (which i
dont think is the case if you just do python ex1)
2/ reload your code without any hassle (which i dont think is the case if
you just do import ex1, as that will not reload say computeCost.py which
is the file you would actually be updating constantly when doing your
homework)

that's why i personally think it makes a lot of sense to just keep
everything as a package that has to be imported in your python path. i dont
think its that big a hassle, and it would scale much better (multiple
courses, each with their own exercises), in my opinion.

On Monday, September 17, 2012 12:32:52 PM UTC-4, Sam Joseph wrote:

HI Ludaavics,

  Good question - we are currently discussing that very issue on the 
  py-coursera mailing list: 



  https://groups.google.com/group/py-coursera 



  Ioura just made some changes to the way things work, and is in the 
  process of changing them back based on the way I was suggesting 
  using things. 



  Personally, based on the Octave mode of using things, I was 
  thinking to be in the ML folder and being able to run: 



  python ex1.py 



  of be able to just run "import ex1" from the ipython --pylab 
  command line, but we'd like to be able to support any sensible 
  usage pattern.  Perhaps you can help us work out what the best 
  approach should be ... 



  CHEERS> SAM 



  On 9/16/12 5:40 PM, ludaavics wrote: 

Hi,

Thanks for this, great project.

what's the standard way of using the code? do you just run the
successive exercise files (e.g. ex1.py) from the shell?

I think a natural way (at least for me) to use this would be to
clone py-coursera in a folder in my python path, and then, in
Ipython:
from py-coursera import ML
ML.ex1()
ML.ex1_multi()

or something along those lines. basically one package per class
and one function per assignment / task / etc.

Would it be possible to re-organize the code to allow for that
usage?

    One thing that would get messy is that you would need to handle 
    imports / reload, but i think the hassle is worth it to make 
    usage more clear? 


    — 

    Reply to this email directly or view it 
      on GitHub. 






-- 

Sam's Technical Blog
http://linklens.blogspot.com

@tansaku
Copy link
Owner

tansaku commented Oct 2, 2012

Hi Ioura and Ludaavics,

Sorry not to come back to you faster on this. My workload has shot up
and we've had a bereavement in the family.

I think I'll have to come back to this when the courses start again next
year.

Apologies and thanks for all your input.

CHEERS> SAM

On 9/23/12 7:27 PM, Ioura Batugowski wrote:

Hi,

That's almost what I did, except I made the mlclass_ex1 (and others at
the same level) a package, not the whole py-coursera/ML directory.It
just means you have to add the ML directory to your python path.
With the latest changes, relative imports are now used again inside
the package (i.e., the package is not referred to explicitly), so that
it should support either ways of working.

Progress report: Yesterday, I successfully submitted ex3 in python to
coursera servers. I'll remove my solutions and probably commit the
code tomorrow. I don't think I'll be adding more tests soon, as I'm
trying to follow the current ML course schedule. I don't know for how
long the servers will accept submissions after the end of the course.

Some remarks about ex3:

  • I didn't port "fmincg" to python, but the "Newton-CG" algorithm from
    scipy works well for this exercise. It gives similar quality solutions
    for the exercise, and the same answer for the submit test and so is
    accepted by coursera servers.
  • Some "Matlabisms" in the exercise, such as choosing labels from 1 to
    10 instead of from 0 to 9, is unfortunate in python. Be wary of
    "off-by-1" errors.

On Saturday, September 22, 2012 10:05:12 PM UTC+2, [email protected]
wrote:

i think the most important part is to be able to:
1/ play around with the variables after you've run the script
(which i dont think is the case if you just do python ex1)
2/ reload your code without any hassle (which i dont think is the
case if you just do import ex1, as that will *not* reload say
computeCost.py which is the file you would actually be updating
constantly when doing your homework)

that's why i personally think it makes a lot of sense to just keep
everything as a package that has to be imported in your python
path. i dont think its that big a hassle, and it would scale much
better (multiple courses, each with their own exercises), in my
opinion.

On Monday, September 17, 2012 12:32:52 PM UTC-4, Sam Joseph wrote:
> HI Ludaavics,
>
>
>
>       Good question - we are currently discussing that very
issue on the
>       py-coursera mailing list:
>
>
>
> https://groups.google.com/group/py-coursera
<https://groups.google.com/group/py-coursera>
>
>
>
>       Ioura just made some changes to the way things work, and
is in the
>       process of changing them back based on the way I was
suggesting
>       using things.
>
>
>
>       Personally, based on the Octave mode of using things, I was
>       thinking to be in the ML folder and being able to run:
>
>
>
>       python ex1.py
>
>
>
>       of be able to just run "import ex1" from the ipython --pylab
>       command line, but we'd like to be able to support any
sensible
>       usage pattern.  Perhaps you can help us work out what the
best
>       approach should be ...
>
>
>
>       CHEERS> SAM
>
>
>
>       On 9/16/12 5:40 PM, ludaavics wrote:
>
>
>
>
> Hi,
>
> Thanks for this, great project.
>
> what's the standard way of using the code? do you just run the
>         successive exercise files (e.g. ex1.py) from the shell?
>
> I think a natural way (at least for me) to use this would be to
>         clone py-coursera in a folder in my python path, and
then, in
>         Ipython:
>       from py-coursera import ML
> ML.ex1()
> ML.ex1_multi()
>
>
> or something along those lines. basically one package per class
>         and one function per assignment / task / etc.
>
> Would it be possible to re-organize the code to allow for that
>         usage?
>
>         One thing that would get messy is that you would need to
handle
>         imports / reload, but i think the hassle is worth it to
make
>         usage more clear?
>
>
>         —
>
>         Reply to this email directly or view it
>           on GitHub.
>
>
>
>
>
>
>     --
> Sam's Technical Blog
> http://linklens.blogspot.com

You received this message because you are subscribed to the Google
Groups "py-coursera" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/py-coursera/-/mTeBHgV8pAUJ.
For more options, visit https://groups.google.com/groups/opt_out.

Sam's Technical Blog
http://linklens.blogspot.com

@tansaku
Copy link
Owner

tansaku commented Oct 4, 2012

I'm sorry for your loss, Sam.
Hopefully, you'll see some progress when you get back.
In a few weeks, I should have every ML programming exercise translated to
python.

I have committed ex4 and ex5 tonight; if someone wants to check it out:
https://github.com/ibatugow/py-coursera

Ioura

On Tuesday, October 2, 2012 3:56:17 PM UTC+2, Sam Joseph wrote:

Hi Ioura and Ludaavics,

Sorry not to come back to you faster on this.� My workload has shot up
and we've had a bereavement in the family.

I think I'll have to come back to this when the courses start again next
year.

Apologies and thanks for all your input.

CHEERS> SAM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants