Skip to content

Instantly share code, notes, and snippets.

View tbass134's full-sized avatar

Tony Hung tbass134

  • Upstate New York
View GitHub Profile
let input = coffee_predictionInput(input: mlMultiArray)
guard let prediction = try? model.prediction(input: input) else {
return
}
let result = prediction
print("classLabel \(result.classLabel)")
if result.classLabel == 1 {
self.class_image.image = UIImage.init(named: "coffee_hot")
func toOneHot(_ string:String) -> [Double] {
var str = string
var items = [Double](repeating: 0.0, count: 7)
let weather_conds:[String] = ["Clear", "Clouds", "Fog", "Haze", "Rain", "Smoke", "Snow"]
if str.lowercased().range(of:"cloud") != nil || str.lowercased().range(of:"overcast") != nil{
str = "Clouds"
}
if str.lowercased().range(of:"snow") != nil {
@tbass134
tbass134 / getInfo.js
Last active May 25, 2019 22:18
Dialogflow webhook to transfer user to live agent
function getInfo(contexts) {
var product = contexts[contexts.length - 1]['parameters']['Product']
var state = contexts[contexts.length - 1]['parameters']['geo-state-us']
for (var i = 0; i < contexts.length; i++) {
var context = contexts[i]['parameters']
if (typeof context['Product'] != "undefined" && typeof context['geo-state-us'] != "undefined") {
return context
}
@tbass134
tbass134 / download.py
Last active September 8, 2018 20:43
Download Transcriptions from Youtube playlist
import requests
import json
import pandas as pd
from pandas.io.json import json_normalize #package for flattening json in pandas df
from xml.etree import ElementTree
from pandas.io.json import json_normalize
import sys
YT_API_KEY = '{youtube_api_key}'
playlist_id = '{playlist_id}'
import sys
import os
import shutil
import time
import traceback
import requests
import numpy as np
from flask import Flask, request, jsonify
from google.cloud import storage
import joblib
import sklearn
def predict(request):
"""Responds to any HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
The response text or any set of values that can be turned into a