Skip to content

Instantly share code, notes, and snippets.

View ravi07bec's full-sized avatar
🏠
Senior Applied Scientist

ravi Shankar ravi07bec

🏠
Senior Applied Scientist
View GitHub Profile
from numpy import array
from numpy import asarray
from numpy import zeros
from keras.preprocessing.text import Tokenizer
from keras.preprocessing.sequence import pad_sequences
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Flatten
from keras.layers import Embedding
# define documents
#Term Frequency
def termfreq(document, word):
N = len(document)
occurance = len([token for token in document if token == word])
return occurance/N
#Inverse Document Frequency
def inverse_doc_freq(word):
try:
from math import exp
from random import seed
from random import random
# Initialize a network
def initialize_network(n_inputs, n_hidden, n_outputs):
network = list()
hidden_layer = [{'weights':[random() for i in range(n_inputs + 1)]} for i in range(n_hidden)]
network.append(hidden_layer)
output_layer = [{'weights':[random() for i in range(n_hidden + 1)]} for i in range(n_outputs)]
# Make a prediction with weights
def predict(row, weights):
activation = weights[0]
for i in range(len(row)-1):
activation += weights[i + 1] * row[i]
return 1.0 if activation >= 0.0 else 0.0
# Estimate Perceptron weights using stochastic gradient descent
def train_weights(train, l_rate, n_epoch):
# Example of making predictions
from math import sqrt
# calculate the Euclidean distance between two vectors
def euclidean_distance(row1, row2):
distance = 0.0
for i in range(len(row1)-1):
distance += (row1[i] - row2[i])**2
return sqrt(distance)
# Make a prediction with coefficients
def predict(row, coefficients):
yhat = coefficients[0]
for i in range(len(row)-1):
yhat += coefficients[i + 1] * row[i]
return yhat
# Estimate linear regression coefficients using stochastic gradient descent
def coefficients_sgd(train, l_rate, n_epoch):
coef = [0.0 for i in range(len(train[0]))]
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
artist
jr.
stills & nash
the creator
wind & fire
!!!
10cc
112
12 stones
2 chainz
We can't make this file beautiful and searchable because it's too large.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
0.3477159 -0.10670821 0.45994064 -0.34369546 -0.122856915 -0.7744754 0.19030279 0.05720891 0.1698621 -0.169827 -0.40953735 -0.23523934 0.048396867 0.7052571 0.34191108 -0.049767286 0.21731612 -0.64538217 -0.23329686 0.34425774 0.051952425 -0.4196746 -0.17587171 0.55343366 0.35680598 -0.16747452 -0.87103546 -0.030037874 -0.7526807 0.40080637 -0.22336994 0.021601401 -0.20519453 -0.60855657 0.32687736 0.27665842 -0.16321175 -0.5943156 0.31605804 -0.4849278 -0.039805546 -0.5149964 0.5394806 0.12340542 -0.29706863 -0.21343571 -0.17491385 0.25965297 -0.061519373 -0.1642966 -0.53483236 -0.8100034 0.01949798 0.11995843 0.003958153 -0.27783373 0.13840675 -0.23143578 0.3111198 -0.19826624 -0.05331649 0.42159384 0.04027778 0.24033114 0
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
joe echo
crowded house
paul mccartney
joshua radin
the len price 3
noah and the whale
pearl jam
bruce springsteen
miles kane
tom petty
Time Commitment: 50 hours, Nov 23- Nov 30 ‘2018
Create baseline model with python:
* Graph theory with python
* Poster representation
* Search-Even Misspelled words
* Multiple movies attributes- Persona and Word Cloud
* Filter of Genre, IMDB rating, Popularity and actor
* Comments and Screenshot capability- Login
* Hosting with a Virtual Machine