<jupyter_start><jupyter_text>Table of Contents 1&nbsp;&nbsp;Imports and settings2&nbsp;&nbsp;DNN3&nbsp;&nbsp;Working with time series  Imports and settings<jupyter_code>import scipy.stats as st
import numpy as np
import numpy.random as rd
import pandas as pd
import sklearn.datasets as dt
from keras.layers import Convolution1D, Convolution2D, BatchNormalization, Dense, Dropout
from keras.models import Sequential
import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns
%matplotlib inline

sns.set_style('darkgrid')
plt.style.use('dark_background')
mpl.rc("figure", figsize=(10,6))
mpl.rcParams['lines.linewidth'] = 3
mpl.rcParams['axes.facecolor'] = (1,1,1,0)
mpl.rcParams['figure.facecolor'] = (1,1,1,0)
sns.set_palette('deep', color_codes=True)
def sinplot(flip=1):
    x = np.linspace(0, 14, 100)
    for i in range(1, 7):
        plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip)<jupyter_output><empty_output><jupyter_text>DNN<jupyter_code>cd = {0:'r',1:'b', 2:'g'}

blob = dt.make_blobs(3000, cluster_std=3)
c = [cd[l] for l in blob[1]]
plt.scatter(blob[0][:,0], blob[0][:,1], c=c, s=10)
from keras.utils.np_utils import to_categorical
model = Sequential()
model.add(Dense(10, input_shape=(2,) , activation= 'relu'))
model.add(Dense(5 , activation= 'relu'))
model.add(Dense(3, activation= 'sigmoid'))
model.compile(optimizer='adam', loss='categorical_crossentropy')
model.summary()

model.fit(blob[0][:2000], to_categorical(blob[1][:2000]), batch_size=3)
plt.scatter(blob[0][2000:][:,0], blob[0][2000:][:,1], c=model.predict(blob[0][2000:]).argmax(axis=1), s=10)<jupyter_output><empty_output><jupyter_text>Working with time series<jupyter_code>X, y = dt.make_friedman1(3000)
plt.scatter(X[:,0], X[:,1], c=y)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup