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
from __future__ import print_function | |
import os | |
import numpy as np | |
from keras.layers import RepeatVector | |
from keras.layers.core import Dropout | |
from keras.layers.recurrent import LSTM | |
from keras.models import Sequential | |
from keras.models import load_model |
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
from numpy.linalg import solve | |
class ExplicitMF(): | |
def __init__(self, | |
ratings, | |
n_factors=40, | |
item_reg=0.0, | |
user_reg=0.0, | |
verbose=False): | |
""" |
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
#forecasting the number of new cases in EColi | |
data('ecoli', package = "tscount") | |
head(ecoli) | |
class(ecoli) | |
data <- as.numeric(unlist(ecoli[3])) | |
data <- ts(matrix(data),start = c(2001,1),end = c(2013,20), frequency = 52) | |
data |
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
require(pracma) | |
require(ridge) | |
train_valid_shuffle <- read.csv('wk3_kc_house_train_valid_shuffled.csv') | |
test_v <- read.csv('wk3_kc_house_test_data.csv') | |
polynomial_sframe <- function(feature , degree){ | |
df_frame = data.frame('power_1' = feature) | |
if(degree > 2){ | |
for(i in 2:degree){ |
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
regression_gradient_decent <- function(feature_matrix, output, initial_weight,step_size, tolerance){ | |
converged = FALSE | |
weights = initial_weight | |
while(!(converged)){ | |
predictions = predict_output(feature_matrix, weights) | |
err = predictions - output | |
gradient_sum_square = 0 | |
for(i in 1:length(weights)){ | |
derivative = feature_derivative(err,feature_matrix[,i]) |
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
n = int(raw_input()) | |
c=[] | |
c.append(n) | |
def a(n): | |
global c | |
if n==1: | |
return | |
if n%2==0: | |
c.append(n/2) | |
a(n/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
# Input | |
# 9 | |
# 1 2 3 4 5 6 7 8 9 | |
# Output | |
# 987654321 | |
n = int(raw_input()) | |
d = [i for i in raw_input().split()] | |
if d.count('0') != n: |
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
elem_count = int(raw_input()) | |
el= [i for i in raw_input().split()] | |
for x in xrange(1,len(el)-1): | |
j=x | |
while j>0 and el[j-1]>el[j]: | |
el[j],el[j-1] = el[j-1],el[j] | |
j-=1 | |
print el |
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
n = int(raw_input()) | |
c = [str(x) for x in xrange(0,10)] | |
for i in xrange(n): | |
line = [x for x in raw_input()] | |
r = set(c) - set(line) | |
for x in r: | |
print x | |
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
n = int(raw_input()) | |
for i in xrange(n): | |
w = raw_input() | |
if w[::1] == w[::-1]: | |
print "true" | |
else: | |
print "false" | |
NewerOlder