Skip to content

Instantly share code, notes, and snippets.

@glamp
Last active January 16, 2019 15:22
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save glamp/5716253 to your computer and use it in GitHub Desktop.
Save glamp/5716253 to your computer and use it in GitHub Desktop.
import numpy as np
import pylab as pl
x = np.random.uniform(1, 100, 1000)
y = np.log(x) + np.random.normal(0, .3, 1000)
pl.scatter(x, y, s=1, label="log(x) with noise")
pl.plot(np.arange(1, 100), np.log(np.arange(1, 100)), c="b", label="log(x) true function")
pl.xlabel("x")
pl.ylabel("f(x) = log(x)")
pl.legend(loc="best")
pl.title("A Basic Log Function")
pl.show()
@Chuck-UGA
Copy link

Thanks for tutorial!

@mkcor
Copy link

mkcor commented Nov 10, 2016

Hi!

Thanks for all the nice blog posts.

I'm surprised you still import pylab. This practice is no longer recommended, as you can read here :
http://matplotlib.org/faq/usage_faq.html#matplotlib-pyplot-and-pylab-how-are-they-related

Best,
Marianne

PS: This http://blog.yhat.com/posts/python-random-forest.html took me here, and it was posted on November 7, 2016.

@maomaochonghuang
Copy link

Thank you for your simple and excellent example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment