Skip to content

Instantly share code, notes, and snippets.

View dipanjanS's full-sized avatar
:octocat:

Dipanjan (DJ) Sarkar dipanjanS

:octocat:
View GitHub Profile
items_popularity = pd.read_csv('datasets/item_popularity.csv',
encoding='utf-8')
items_popularity['popularity_scale_10'] = np.array(
np.round((items_popularity['pop_percent'] * 10)),
dtype='int')
items_popularity['popularity_scale_100'] = np.array(
np.round((items_popularity['pop_percent'] * 100)),
dtype='int')
items_popularity
from sklearn.preprocessing import Binarizer
bn = Binarizer(threshold=0.9)
pd_watched = bn.transform([popsong_df['listen_count']])[0]
popsong_df['pd_watched'] = pd_watched
popsong_df.head(11)
watched = np.array(popsong_df['listen_count'])
watched[watched >= 1] = 1
popsong_df['watched'] = watched
popsong_df = pd.read_csv('datasets/song_views.csv', encoding='utf-8')
popsong_df.head(10)
poke_df[['HP', 'Attack', 'Defense']].describe()
poke_df[['HP', 'Attack', 'Defense']].head()
poke_df = pd.read_csv('datasets/Pokemon.csv', encoding='utf-8')
poke_df.head()
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as spstats
%matplotlib inline
%%time
responses = []
for i in tqdm(range(10000)):
API_URL = 'http://0.0.0.0:5000/apparel_classifier/api/v1/model2_predict'
# sending post request and saving response as response object
r = requests.post(url=API_URL, data=data)
responses.append(r.json())
len(responses)
print('Inference time per image: {} ms'.format((326 / 10000) * 1000))
import base64
import requests
with open('sneaker.jpg', "rb") as imageFile:
img_b64enc = base64.b64encode(imageFile.read())
data = {'b64_img': img_b64enc}
API_URL = 'http://0.0.0.0:5000/apparel_classifier/api/v1/model2_predict'
# sending post request and saving response as response object
r = requests.post(url=API_URL, data=data)