This file contains hidden or 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 json | |
| import sqlite3 | |
| # Make some fresh tables using executescript() | |
| conn = sqlite3.connect('booksRDBMS.sqlite', timeout=10) | |
| cur = conn.cursor() | |
| cur.executescript(''' |
This file contains hidden or 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
| # Creating a database table from a cvs file | |
| import csv, sqlite3 | |
| conn = sqlite3.connect('wrangling/data_wrangling.sqlite') | |
| cur = conn.cursor() | |
| cur.executescript(''' | |
| DROP TABLE IF EXISTS view_item_event; | |
| CREATE TABLE view_item_event( | |
| event_id VARCHAR(32) NOT NULL PRIMARY KEY, |
This file contains hidden or 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
| # old fashion way: | |
| listA = [1, 2, 3, 4] | |
| squares = [] | |
| for i in listA: | |
| square.append(i**2) | |
| # Ahora con LofC | |
| square = [i**2 for i in listA] |
This file contains hidden or 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
| from keras.models import Sequential | |
| from keras.layers import Dense, Activation, Conv2D, MaxPooling2D, Flatten | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from cnn_utils import * | |
| from scipy import ndimage | |
| import math | |
| from mreDeepLTools import * | |
| # Loading the data (signs) |
This file contains hidden or 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
| from keras.models import Sequential | |
| from keras.layers import Dense, Activation, Conv2D, MaxPooling2D, Flatten | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from cnn_utils import * | |
| from scipy import ndimage | |
| import math | |
| from mreDeepLTools import * | |
| # Loading the data (signs) |
This file contains hidden or 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
| # Print the only the lastname | |
| people = ['Dr. Christopher Brooks', 'Dr. Kevyn Collins-Thompson', | |
| 'Dr. VG Vinod Vydiswaran', 'Dr. Daniel Romero'] | |
| for person in people: | |
| g = (lambda x: x.split()[0] + x.split()[-1]) | |
| print g(person) | |
| # result: | |
| # Dr.Brooks | |
| # Dr.Collins-Thompson |
This file contains hidden or 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 re | |
| # The simplest use of the regular expression library is the search() function. | |
| hand = open('mbox-short.txt') | |
| for line in hand: | |
| line = line.rstrip() | |
| if re.search('From:', line) : | |
| print line | |
| # Handling The Data |
This file contains hidden or 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
| def mapFeature(x1, x2): | |
| ''' | |
| Maps the two input features to quadratic features. | |
| Returns a new feature array with more features, comprising of | |
| X1, X2, X1 ** 2, X2 ** 2, X1*X2, X1*X2 ** 2, etc... | |
| Inputs X1, X2 must be the same size | |
| ''' | |
| x1.shape = (x1.size, 1) | |
| x2.shape = (x2.size, 1) | |
| degree = 6 |
This file contains hidden or 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
| training_error = sum(yr != y)/float(m) | |
| print training_error |
This file contains hidden or 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
| # numero de m - filas, n numero de colunmas | |
| m , n = X.shape | |
| #print m, n | |
| def sigmoid(x): | |
| return 1 /(1 + np.exp(-x)) | |
| # Esta funcion de costo esta perfecta y los vectores | |
| # entran directamente. | |
| # No hay necesidad de vector colunma para theta |
NewerOlder