Skip to content

Instantly share code, notes, and snippets.

import json
import sqlite3
# Make some fresh tables using executescript()
conn = sqlite3.connect('booksRDBMS.sqlite', timeout=10)
cur = conn.cursor()
cur.executescript('''
@margrami
margrami / gistdb1.txt
Last active August 21, 2019 09:20
Creating a database table from a cvs file
# 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,
# 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]
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)
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)
# 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
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
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
training_error = sum(yr != y)/float(m)
print training_error
# 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