This file contains hidden or 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 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 |
This file contains hidden or 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
| import sys | |
| import os | |
| import shutil | |
| import time | |
| import traceback | |
| import requests | |
| import numpy as np | |
| from flask import Flask, request, jsonify |
This file contains hidden or 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
| 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}' |
This file contains hidden or 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
| 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 | |
| } |
This file contains hidden or 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
| 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 { |
This file contains hidden or 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
| 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") |