This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
print 'downloading crude oil data' | |
urllib.urlretrieve("https://fred.stlouisfed.org/graph/fredgraph.csv?chart_type=line&recession_bars=on&log_scales=&bgcolor=%23e1e9f0&graph_bgcolor=%23ffffff&fo=Open+Sans&ts=12&tts=12&txtcolor=%23444444&show_legend=yes&show_axis_titles=yes&height=450&stacking=&range=1yr&mode=fred&id=DCOILWTICO&transformation=lin&nd=1986-01-02&ost=-99999&oet=99999&lsv=&lev=&mma=0&fml=a&fgst=lin&fgsnd=2009-06-01&fq=Daily&fam=avg&vintage_date=&revision_date=&line_color=%234572a7&line_style=solid&lw=2&scale=left&mark_type=none&mw=2&width=1168", "crude-oil.csv") | |
print 'downloading diesel data' | |
urllib.urlretrieve("https://fred.stlouisfed.org/graph/fredgraph.csv?chart_type=line&recession_bars=on&log_scales=&bgcolor=%23e1e9f0&graph_bgcolor=%23ffffff&fo=Open+Sans&ts=12&tts=12&txtcolor=%23444444&show_legend=yes&show_axis_titles=yes&drp=0&cosd=2017-01-08&coed=2018-01-08&height=450&stacking=&range=1yr&mode=fred&id=DDFUELUSGULF&transformation=lin&nd=2006-06-14&ost=-99999&oet=99999&lsv=&lev=& |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.ensemble import * | |
import xgboost as xgb | |
from sklearn.cross_validation import train_test_split | |
X = np.random.uniform(size=(100,10)) | |
Y = np.random.uniform(size=(100)) | |
# split our dataset for validation | |
train_X, test_X, train_Y, test_Y = train_test_split(X, Y, test_size = 0.2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import speechpy | |
import scipy.io.wavfile as wav | |
import numpy as np | |
def extract_features(signal, fs): | |
frames = speechpy.processing.stack_frames(signal, sampling_frequency=fs, frame_length=0.020, frame_stride=0.01, filter=lambda x: np.ones((x,)),zero_padding=True) | |
power_spectrum = speechpy.processing.power_spectrum(frames, fft_points=1) | |
logenergy = speechpy.feature.lmfe(signal, sampling_frequency=fs, frame_length=0.020, frame_stride=0.01,num_filters=1, fft_length=512, low_frequency=0, high_frequency=None) | |
mfcc = speechpy.feature.mfcc(signal, sampling_frequency=fs, frame_length=0.020, frame_stride=0.01,num_filters=1, fft_length=512, low_frequency=0, high_frequency=None) | |
mfcc_cmvn = speechpy.processing.cmvnw(mfcc,win_size=301,variance_normalization=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = np.random.randint(0, 100, size=(100)) | |
rects1=plt.bar(np.arange(x.shape[0]), x) | |
def autolabel(rects): | |
(y_bottom, y_top) = plt.ylim() | |
y_height = y_top - y_bottom | |
for rect in rects: | |
height = rect.get_height() | |
p_height = (height / y_height) | |
if p_height > 0.95: | |
label_position = height - (y_height * 0.05) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import tensorflow as tf | |
class Feed_forward: | |
def __init__(self, input_dimension): | |
self.X = tf.placeholder(tf.float32, [None, input_dimension]) | |
self.Y = tf.placeholder(tf.float32, [None, 1]) | |
hidden_layer = tf.Variable(tf.random_uniform([input_dimension, 1], -1.0, 1.0)) | |
logits = tf.matmul(self.X, hidden_layer) | |
self.cost = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits = logits, labels = self.Y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import tensorflow as tf | |
class Model: | |
def __init__(self): | |
def conv_layer(x, conv, stride = 1): | |
return tf.nn.conv2d(x, conv, [1, stride, stride, 1], padding = 'SAME') | |
def pooling(x, k = 2, stride = 2): | |
return tf.nn.max_pool(x, ksize = [1, k, k, 1], strides = [1, stride, stride, 1], padding = 'SAME') | |
self.X = tf.placeholder(tf.float32, [None, 80, 80, 4]) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer