Skip to content

Instantly share code, notes, and snippets.

View aka7h's full-sized avatar

Akash (Sathya) Kothapalli aka7h

  • Bangalore
View GitHub Profile
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
@aka7h
aka7h / ExplicitMF_ALS.py
Created December 5, 2017 13:03 — forked from EthanRosenthal/ExplicitMF_ALS.py
Class for ALS training of an explicit matrix factorization model
from numpy.linalg import solve
class ExplicitMF():
def __init__(self,
ratings,
n_factors=40,
item_reg=0.0,
user_reg=0.0,
verbose=False):
"""
@aka7h
aka7h / TS using NN
Created November 20, 2017 06:31
Ecoli preduction using mxnet
#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
@aka7h
aka7h / k-fold-ridge.r
Created May 28, 2017 11:33
University of Washington - Machine learning - Regression
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){
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])
@aka7h
aka7h / Play with number
Created January 19, 2016 18:41
n is a number. if n is odd, multiply by 3 and add 1. if n is even divide by 2. Input : 5 Output: 5 16 8 4 2 1
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)
# 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:
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
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
n = int(raw_input())
for i in xrange(n):
w = raw_input()
if w[::1] == w[::-1]:
print "true"
else:
print "false"