This is the code you need to align images to the left:
| import tensorflow as tf | |
| import pandas as pd | |
| import numpy as np | |
| import joblib | |
| import os | |
| from loguru import logger | |
| @logger.catch | |
| def get_predictions(data): |
| import time | |
| import ast | |
| import sqlite3 | |
| import pandas as pd | |
| from typing import List | |
| from polygon import WebSocketClient, STOCKS_CLUSTER, CRYPTO_CLUSTER, FOREX_CLUSTER | |
| def my_custom_process_message(messages: List[str]): | |
| """ |
| # Build a clustering model with Elkan variant of kmeans algorithm | |
| results = kmeans(Elkan(), X, 10, tol=1e-10, max_iters=300) | |
| # results contains all the learned artifacts that can be accessed as; | |
| results.centers # cluster centers (d x k) | |
| results.assignments # label assignments (n) | |
| results.totalcost # total cost (i.e. objective) | |
| results.iterations # number of elapsed iterations | |
| results.converged # whether the procedure converged |
| # Load Packages | |
| using MLDatasets | |
| using ParallelKMeans | |
| # | |
| # Load MNIST Training Data | |
| # | |
| train = MNIST.traintensor() | |
| # Get number of features from the pixel (28 by 28) |
| using MLDatasets | |
| using DataFrames | |
| train_x, train_y = MNIST.traindata(); | |
| test_x, test_y = MNIST.testdata(); | |
| X_train = Float64.(reshape(train_x, 60000, :)); | |
| X_test = Float64.(reshape(test_x, 10000, :)); | |
| DataFrame(X_train) |
| Overhead ╎ [+additional indent] Count File:Line; Function | |
| ========================================================= | |
| ╎14238 @Base/task.jl:358; (::REPL.var"#26#27"{REPL.REPLBackend})() | |
| ╎ 14238 ...ia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118; macro expansion | |
| ╎ 14238 ...ia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86; eval_user_input(::Any, ::REPL.REPLBackend) | |
| ╎ 14238 @Base/boot.jl:331; eval(::Module, ::Any) | |
| ╎ 14238 @Atom/src/repl.jl:227; evalrepl(::Module, ::String) | |
| ╎ 14238 @Base/logging.jl:505; with_logger | |
| ╎ ╎ 14238 @Base/logging.jl:398; with_logstate(::Atom.var"#228#230"{Module}, ::Base.CoreLogging.LogState) | |
| ╎ ╎ 14238 @Atom/src/repl.jl:236; (::Atom.var"#228#230"{Module})() |
| Overhead ╎ [+additional indent] Count File:Line; Function | |
| ========================================================= | |
| ╎16463 @Base/task.jl:358; (::REPL.var"#26#27"{REPL.REPLBackend})() | |
| ╎ 16463 ...ia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118; macro expansion | |
| ╎ 16463 ...ia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86; eval_user_input(::Any, ::REPL.REPLBackend) | |
| ╎ 16463 @Base/boot.jl:331; eval(::Module, ::Any) | |
| ╎ 16463 @Atom/src/repl.jl:227; evalrepl(::Module, ::String) | |
| ╎ 16463 @Base/logging.jl:505; with_logger | |
| ╎ ╎ 16463 @Base/logging.jl:398; with_logstate(::Atom.var"#228#230"{Module}, ::Base.CoreLogging.LogState) | |
| ╎ ╎ 16463 @Atom/src/repl.jl:236; (::Atom.var"#228#230"{Module})() |
| """ | |
| smart_init(X, k; init="k-means++") | |
| This function handles the random initialisation of the centroids from the | |
| design matrix (X) and desired groups (k) that a user supplies. | |
| `k-means++` algorithm is used by default with the normal random selection | |
| of centroids from X used if any other string is attempted. | |
| A tuple representing the centroids, number of rows, & columns respecitively |