Skip to content

Instantly share code, notes, and snippets.

View sanealytics's full-sized avatar

Saurabh Bhatnagar sanealytics

View GitHub Profile
@sanealytics
sanealytics / PinchAnimated.js
Last active May 18, 2021 19:21
Zoom into image and generate images in the zoomed in area
import React, { Component } from 'react';
import { StyleSheet, View, Image, } from 'react-native';
import {
PanGestureHandler,
State,
PinchGestureHandler,
TapGestureHandler,
} from 'react-native-gesture-handler';
import Animated, { Easing } from 'react-native-reanimated';
shinyServer(function(input, output, session) {
# Session level
idx <- round(runif(1, 1, 2500)) # random place to start
state <- reactive({
if(input$submit > 0) { # Not on first page load
isolate({ # Don't get reactive on me now
answer <- input$yesorno
library(shiny)
shinyUI(fluidPage(
# Application title
titlePanel("Verify Auto-tagged dresses from Instagram"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
library(mongolite)
# Connections to mongo
instagram <- mongo(collection = "InstagramV4", db = "DeepDress", url = "mongodb://localhost", verbose = FALSE)
matches <- mongo(collection = "MatchesV4", db = "DeepDress", url = "mongodb://localhost", verbose = FALSE)
corrections <- mongo(collection = "CorrectionsV4", db = "DeepDress", url = "mongodb://localhost", verbose = FALSE)
# Get Instagram data we saved earlier
ids.df <- instagram$find(fields = '{"_id" : 1, "payload.created_time" : 1}')
ids.df.simple <- data.frame(id = ids.df$`_id`,
import urllib.request
import json
from pymongo import MongoClient
import time
from multiprocessing import Pool
DEEP_DRESS_WGET = 'http://localhost/wget/?url='
DEEP_DRESS_PREDICT = 'http://localhost/predict/'
def wget_deep_dress(url):
import urllib.request
import json
from pymongo import MongoClient
import time
def fetchAndStash(url, client):
try:
response = urllib.request.urlopen(url + '&count=100')
f = response.read()
payload = f.decode('utf-8')
@sanealytics
sanealytics / Rcgmin test
Created March 18, 2015 00:34
testing Rcgmin
data(MovieLense)
scheme <- evaluationScheme(MovieLense, method = "split", train = .9,
k = 1, given = 10, goodRating = 4)
scheme
# register recommender
recommenderRegistry$set_entry(
method="RSVD", dataType = "realRatingMatrix", fun=REAL_RSVD,
@sanealytics
sanealytics / recommenderlab-test RSVD
Last active August 29, 2015 14:16
Testing low rank matrix factorization performance
require(recommenderlab) # Install this if you don't have it already
require(devtools) # Install this if you don't have this already
# Get additional recommendation algorithms
install_github("sanealytics", "recommenderlabrats")
data(MovieLense) # Get data
# Divvy it up
scheme <- evaluationScheme(MovieLense, method = "split", train = .9,
k = 1, given = 10, goodRating = 4)
@sanealytics
sanealytics / gist:28739e87f8448ecb378f
Created March 10, 2015 07:10
optim set up for RSVD
unroll_Vecs <- function (params, Y, R, num_users, num_movies, num_features) {
# Unrolls vector into X and Theta
# Also calculates difference between preduction and actual
endIdx <- num_movies * num_features
X <- matrix(params[1:endIdx], nrow = num_movies, ncol = num_features)
Theta <- matrix(params[(endIdx + 1): (endIdx + (num_users * num_features))],
nrow = num_users, ncol = num_features)
runApp(list(
ui = bootstrapPage(
uiOutput("nUI"),
plotOutput('plot'),
submitButton("PlotIt")
),
server = function(input, output, session) {
output$plot <- renderPlot({ hist(runif(input$obs)) })
output$nUI <- renderUI({