Time Series Analysis with Python
With Applications of Machine Learning Algorithms
Session by Dr. Yves J. Hilpisch | The Python Quants GmbH
Hyderabad, 07. October 2017
| def getage(): | |
| subscription_key = '2c2c93c599a841e5ac01a2e0635fe3be' | |
| uri_base = 'https://westcentralus.api.cognitive.microsoft.com' | |
| # Request headers. | |
| headers = { | |
| 'Content-Type': 'application/octet-stream', | |
| 'Ocp-Apim-Subscription-Key': subscription_key, | |
| } | |
| # Request parameters. | |
| params = { |
| """ | |
| Measure the frequencies coming in through the microphone | |
| Patchwork of wire_full.py from pyaudio tests and spectrum.py from Chaco examples | |
| """ | |
| import pyaudio | |
| import numpy as np | |
| import scipy.signal | |
| CHUNK = 1024 * 2 |
| #Just replace Ashish and manoj.jpg | |
| import cv2 | |
| import dlib | |
| import numpy | |
| import sys | |
| PREDICTOR_PATH = "shape_predictor_68_face_landmarks.dat" | |
| SCALE_FACTOR = 1 | |
| FEATHER_AMOUNT = 11 |
| import re, collections | |
| def get_words(text): | |
| return re.findall('[a-z]+', text.lower()) | |
| def langModel(wordseq): | |
| wordCount = collections.defaultdict(lambda: 1) | |
| for word in wordseq: | |
| wordCount[word] += 1 | |
| return wordCount |
install zbar on windows with include and library files
make sure mingw installed and bin directory added to the path
in PYTHONPATH\Lib\distutils, create a file distutils.cfg and add two lines:
[build]
compiler=mingw32
get dll lib and include file from ftp://sourceware.org/pub/pthreads-win32/dll-latest
copy files to PATH_MINGW32/[lib,bin,include] separately, just need file name like pthreadGC2 and remember to chang the name to libpthread
change or add lines in setup.py:
| import requests | |
| from bs4 import BeautifulSoup | |
| import re | |
| from urllib.parse import urlparse | |
| import csv | |
| """Define the links you do not want""" | |
| stop_links = ["flowingdata.com/", "facebook.com/", "twitter.com/", "eepurl.com/"] | |
| def get_content(URL): |
| import string | |
| import requests | |
| html = 'https://s3.amazonaws.com/.../email.htm' | |
| content = requests.get(html) | |
| DJANGO_MAILGUN_SERVER_NAME = '' | |
| DJANGO_MAILGUN_API_KEY = '' | |
| recipient_list = ['[email protected]', '[email protected]'] |
| requests.post("https://api.mailgun.net/v2/DOMAIN/messages", | |
| auth=("api", "key-SECRET"), | |
| files={ | |
| "attachment[0]": ("FileName1.ext", open(FILE_PATH_1, 'rb')), | |
| "attachment[1]": ("FileName2.ext", open(FILE_PATH_2, 'rb')) | |
| }, | |
| data={"from": "FROM_EMAIL", | |
| "to": [TO_EMAIL], | |
| "subject": SUBJECT, | |
| "html": HTML_CONTENT |
| from flask import Flask, request | |
| app = Flask(__name__) | |
| @app.route('/', methods=['GET']) | |
| def add(): | |
| num1 = request.args.get('num1') | |
| num2 = request.args.get('num2') | |
| return num1 + num2 |