This file contains 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 scipy.spatial.distance as dist | |
import numpy as np | |
# Prepare 2 vectors (data points) of 10 dimensions | |
A = np.random.uniform(0, 10, 10) | |
B = np.random.uniform(0, 10, 10) | |
print '\n2 10-dimensional vectors' | |
print '------------------------' | |
print A |
This file contains 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 os | |
import speech_recognition as sr | |
from pydub import AudioSegment | |
from pydub.playback import play | |
from gtts import gTTS as tts | |
def speak(text): |
This file contains 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 keras.models import Sequential | |
from keras.layers import Dense, Activation | |
dims = X_train.shape[1] | |
print(dims, 'dims') | |
print("Building model...") | |
nb_classes = Y_train.shape[1] | |
print(nb_classes, 'classes') |
This file contains 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 sklearn.datasets import load_iris | |
from sklearn.model_selection import train_test_split | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.decomposition import PCA | |
from sklearn.pipeline import Pipeline | |
from sklearn import tree | |
# Load and split the data | |
iris = load_iris() | |
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42) |
This file contains 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 tpot import TPOTClassifier | |
from sklearn.cross_validation import train_test_split | |
from sklearn.datasets import load_iris | |
import time | |
# Load and split the data | |
iris = load_iris() | |
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42) | |
# Construct and fit TPOT classifier |
This file contains 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
print mldb.put('/v1/functions/fetch', { | |
"type": 'fetcher', | |
"params": {} | |
}) | |
print mldb.put('/v1/functions/inception', { | |
"type": 'tensorflow.graph', | |
"params": { | |
"modelFileUrl": 'archive+'+ | |
'http://public.mldb.ai/models/inception_dec_2015.zip'+ |
This file contains 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
pd.DataFrame(runResults["confusionMatrix"])\ | |
.pivot_table(index="actual", columns="predicted", fill_value=0) |
This file contains 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
rez = mldb.post("/v1/procedures", { | |
"type": "classifier.experiment", | |
"params": { | |
"experimentName": "car_brand_cls", | |
"inputData": """ | |
SELECT | |
{* EXCLUDING(brand)} as features, | |
brand as label | |
FROM training_dataset | |
""", |
This file contains 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
print mldb.post("/v1/procedures", { | |
"type": "transform", | |
"params": { | |
"inputData": """ | |
SELECT brand, | |
inception({url}) as * | |
FROM images | |
""", | |
"outputDataset": "training_dataset" | |
} |
This file contains 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
mldb.query("SELECT count(*) FROM images GROUP BY brand") |