In [2]:
print ('hello')


hello

In [3]:
1 / 2


Out[3]:
0.5

In [11]:
import plotly.plotly as py
from plotly.graph_objs import *

trace0 = Scatter(
  x=[1, 2, 3, 4],
  y=[10, 15, 13, 17]
)
trace1 = Scatter(
  x=[1, 2, 3, 4],
  y=[16, 5, 11, 9]
)
data = Data([trace0, trace1])

py.iplot(data, filename = 'basic-line')


High five! You successfuly sent some data to your account on plotly. View your plot in your browser at https://plot.ly/~tcrowley/0 or inside your plot.ly account where it is named 'basic-line'
Out[11]:

In [10]:
>>> import plotly.tools as tls
>>> tls.set_credentials_file(username='tcrowley', api_key='J79K0YUhEyglMiBOyIs4')

In [28]:
import matplotlib.pyplot as plt
import numpy as np
import plotly.plotly as py

n = 50
x, y, z, s, ew = np.random.rand(5, n)
c, ec = np.random.rand(2, n, 4)
area_scale, width_scale = 500, 5

fig, ax = plt.subplots()
sc = ax.scatter(x, y, c=c,
                s=np.square(s)*area_scale,
                edgecolor=ec,
                linewidth=ew*width_scale)
ax.grid()

py.iplot_mpl(fig)


Out[28]:

In [1]:
from sklearn import datasets
from sklearn.cross_validation import cross_val_predict
from sklearn import linear_model
import matplotlib.pyplot as plt
%matplotlib inline

lr = linear_model.LinearRegression()
boston = datasets.load_boston()
y = boston.target

predicted = cross_val_predict(lr, boston.data, y, cv=10)

fig, ax = plt.subplots()
ax.scatter(y, predicted)
ax.plot([y.min(), y.max()], [y.min(), y.max()], 'k--', lw=4)
ax.set_xlabel('Measured')
ax.set_ylabel('Predicted')
plt.show()



In [18]:
import seaborn as sns

# Load one of the data sets that come with seaborn
tips = sns.load_dataset("tips")

sns.jointplot("total_bill", "tip", tips, kind='reg');



In [19]:
import numpy as np
import pandas as pd
from scipy import stats, integrate
import matplotlib.pyplot as plt
import seaborn as sns

sns.set(color_codes=True)
np.random.seed(sum(map(ord, "distributions")))

x = np.random.normal(size=100)
sns.distplot(x);



In [20]:
sns.distplot(x, kde=False, rug=True);



In [22]:
mean, cov = [0, 1], [(1, .5), (.5, 1)]
data = np.random.multivariate_normal(mean, cov, 200)
df = pd.DataFrame(data, columns=["x", "y"])

sns.jointplot(x="x", y="y", data=df);



In [23]:
x, y = np.random.multivariate_normal(mean, cov, 1000).T
with sns.axes_style("white"):
    sns.jointplot(x=x, y=y, kind="hex", color="k");



In [24]:
f, ax = plt.subplots(figsize=(6, 6))
cmap = sns.cubehelix_palette(as_cmap=True, dark=0, light=1, reverse=True)
sns.kdeplot(df.x, df.y, cmap=cmap, n_levels=60, shade=True);



In [25]:
iris = sns.load_dataset("iris")
sns.pairplot(iris);



In [26]:
iris.describe()


Out[26]:
sepal_length sepal_width petal_length petal_width
count 150.000000 150.000000 150.000000 150.000000
mean 5.843333 3.057333 3.758000 1.199333
std 0.828066 0.435866 1.765298 0.762238
min 4.300000 2.000000 1.000000 0.100000
25% 5.100000 2.800000 1.600000 0.300000
50% 5.800000 3.000000 4.350000 1.300000
75% 6.400000 3.300000 5.100000 1.800000
max 7.900000 4.400000 6.900000 2.500000

In [27]:
sns.boxplot(data=iris, orient="h");



In [28]:
import numpy as np 
from pandas import DataFrame
import matplotlib.pyplot as plt

Index= ['aaa', 'bbb', 'ccc', 'ddd', 'eee']
Cols = ['A', 'B', 'C', 'D']
df = DataFrame(abs(np.random.randn(5, 4)), index=Index, columns=Cols)

plt.pcolor(df)
plt.yticks(np.arange(0.5, len(df.index), 1), df.index)
plt.xticks(np.arange(0.5, len(df.columns), 1), df.columns)
plt.show()



In [29]:
x = np.linspace(0, 10, 1000)
plt.plot(x, np.sin(x), x, np.cos(x));



In [38]:
import nltk
nltk.download('punkt')


[nltk_data] Downloading package punkt to /home/jovyan/nltk_data...
[nltk_data]   Package punkt is already up-to-date!
Out[38]:
True

In [43]:
tokens = nltk.word_tokenize('provides a practical introduction to programming for language processing. Written by the creators of NLTK, it guides the reader through the fundamentals of writing Python programs, working with corpora, categorizing text, analyzing linguistic structure, and more. The book is being updated for Python 3 and NLTK 3. (The original Python 2 version is still available at ')

In [42]:
a = 1
print (a)


1

In [44]:
tagged = nltk.pos_tag(tokens)


---------------------------------------------------------------------------
LookupError                               Traceback (most recent call last)
<ipython-input-44-a5b8b750f7f7> in <module>()
----> 1 tagged = nltk.pos_tag(tokens)

/opt/conda/lib/python3.5/site-packages/nltk/tag/__init__.py in pos_tag(tokens, tagset, lang)
    126     :rtype: list(tuple(str, str))
    127     """
--> 128     tagger = _get_tagger(lang)
    129     return _pos_tag(tokens, tagset, tagger)
    130 

/opt/conda/lib/python3.5/site-packages/nltk/tag/__init__.py in _get_tagger(lang)
     88         tagger.load(ap_russian_model_loc)
     89     elif lang == 'eng':
---> 90         tagger = PerceptronTagger()
     91     else:
     92         tagger = PerceptronTagger()

/opt/conda/lib/python3.5/site-packages/nltk/tag/perceptron.py in __init__(self, load)
    138         self.classes = set()
    139         if load:
--> 140             AP_MODEL_LOC = 'file:'+str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
    141             self.load(AP_MODEL_LOC)
    142 

/opt/conda/lib/python3.5/site-packages/nltk/data.py in find(resource_name, paths)
    646     sep = '*' * 70
    647     resource_not_found = '\n%s\n%s\n%s' % (sep, msg, sep)
--> 648     raise LookupError(resource_not_found)
    649 
    650 

LookupError: 
**********************************************************************
  Resource 'taggers/averaged_perceptron_tagger/averaged_perceptron
  _tagger.pickle' not found.  Please use the NLTK Downloader to
  obtain the resource:  >>> nltk.download()
  Searched in:
    - '/home/jovyan/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************

In [ ]:
nltk.download(movie_reviews)

In [ ]: