All Projects → kaiwaehner → Python Jupyter Apache Kafka Ksql Tensorflow Keras

kaiwaehner / Python Jupyter Apache Kafka Ksql Tensorflow Keras

Licence: apache-2.0
Making Machine Learning Simple and Scalable with Python, Jupyter Notebook, TensorFlow, Keras, Apache Kafka and KSQL

Projects that are alternatives of or similar to Python Jupyter Apache Kafka Ksql Tensorflow Keras

Srgan Keras
Implementation of SRGAN in Keras. Try at: www.fixmyphoto.ai
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Mlhep2016
Machine Learning in High Energy Physics 2016
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Attack Datasources
This content is analysis and research of the data sources currently listed in ATT&CK.
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Deep Learning Map
Map of deep learning and notes from papers.
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Mlatimperial2017
Materials for the course of machine learning at Imperial College organized by Yandex SDA
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Static resources
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Hashtable Benchmarks
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Viztech
Plotnine replication of Financial Times Visual Vocabulary; Inspired by Vega
Stars: ✭ 72 (+4.35%)
Mutual labels:  jupyter-notebook
Ag Ve Bilgi Guvenligi Ders Notlari
Ağ ve Bilgi Güvenliği; Linux & Temel Komutlar, Python, Risk Analizi, Kriptoloji, Stenografi, Zararlı Kod Analizi, Sızma Testi, Pasif Bilgi Toplama, Pasif Bilgi Toplama, Ağ Güvenliği, Zaafiyet Keşfi, Zararlı Kod Oluşturma Yöntemleri, Dijital Adli Analiz, Web Güvenliği, Sosyal Mühendislik Saldırıları, Mobil Sistem Güvenliği konularında sunum ve uygulamaların olduğu ağ ve bilgi güvenliği ders sayfası.
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Zaoqi Data
公众号:可视化图鉴
Stars: ✭ 72 (+4.35%)
Mutual labels:  jupyter-notebook
Cs231n
My Solution to Assignments of CS231n in Winter2016
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
My Journey In The Data Science World
📢 Ready to learn or review your knowledge!
Stars: ✭ 1,175 (+1602.9%)
Mutual labels:  jupyter-notebook
Smart On Fhir.github.io
SMART on FHIR Docs
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Big Data Engineering Coursera Yandex
Big Data for Data Engineers Coursera Specialization from Yandex
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Hacktoberfest2020
Contribute for hacktoberfest 2020
Stars: ✭ 72 (+4.35%)
Mutual labels:  jupyter-notebook
Hadron Collider Machine Learning
Materials for "Addressing Large Hadron Collider Challenges by Machine Learning" Coursera MOOC
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
Prml notes
该项目是关于机器学习经典书籍《Pattern Recognition and Machine Learning》的学习笔记,我用python实现了书中的一些实例,希望帮助感兴趣的人更好的理解
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook
3d Shapes
This repository contains the 3D shapes dataset, used in Kim, Hyunjik and Mnih, Andriy. "Disentangling by Factorising." In Proceedings of the 35th International Conference on Machine Learning (ICML). 2018. to assess the disentanglement properties of unsupervised learning methods.
Stars: ✭ 72 (+4.35%)
Mutual labels:  jupyter-notebook
Ge tutorials
Learn how to add data validation and documentation to a data pipeline built with dbt and Airflow.
Stars: ✭ 72 (+4.35%)
Mutual labels:  jupyter-notebook
Cbe30338
Chemical Process Control
Stars: ✭ 71 (+2.9%)
Mutual labels:  jupyter-notebook

Technology: Python, Jupyter, TensorFlow, Keras, Apache Kafka, KSQL

This project shows a demo which combines

  • simplicity of data science tools (Python, Jupyter notebooks, NumPy, pandas)
  • powerful Machine Learning / Deep Learning frameworks (TensorFlow, Keras)
  • reliable, scalable event-based streaming technology for production deployments (Apache Kafka, Kafka Connect, KSQL).

If you want to learn more about the relation between the Apache Kafka open source ecosystem and Machine Learning, please check out these two blog posts:

Use Case: Fraud Detection for Credit Card Payments

We use test data set from Kaggle as foundation to train an unsupervised autoencoder to detect anomalies and potential fraud in payments.

Focus of this project is not just model training, but the whole Machine Learning infrastructure including data ingestion, data preprocessing, model training, model deployment and monitoring. All of this needs to be scalable, reliable and performant.

Requirements

ksql-python Installation

If you have problems installing ksql-python in your environment via 'pip install ksql', use the commands described in the Github project instead.

After installation, for some reason, the 'from ksql import KSQLAPI' statement did not work with Python 2.7.x in my Jupyter notebook (but in Mac terminal), so I used Python 3.6 (which also worked in Jupyter).

Live Demo using KSQL and Keras / TensorFlow from Jupyter Notebook

We will do the following:

  1. Data Integration (Kafka Connect): Integrate a stream of data from CSV file or continuous data stream (in real world you can connect directly to an existing Kafka stream from the Jupyter notebook). As alternative, you can create new events manually in command line
  2. Data Preprocessing (KSQL): Preprocess the data, e.g. filter, anonymize, aggreate / concatenate
  3. *Machine Learning specific preprocessing (NumPy, pandas, Scikit-learn): Normalize, split train / test data
  4. Model Training (TensorFlow + Keras)
  5. Model Deployment (KSQL + Tensorflow)
  6. Monitoring of Model Behaviour (KSQL) like accuracy and performance

While all of this can be done in a Jupyter notebook for interactive analysis, we can then deploy the same pipeline to production at scale. For instance, you can re-use the KSQL preprocessing statements and run them in your production infrastructure to do model inference with KSQL and the TensorFlow model at scale on new incoming event streams.

Streaming Analytics and Preprocessing with KSQL using a Jupyter notebook

Interactive analysis and data-preprocessing with Python and KSQL:

Apache Kafka + KSQL + Python for Interactive Data Processing

Step-By-Step Guide

Check out this step-by-step guide to start the backend and notebook. The main demo is running in the Jupyter notebook 'python-jupyter-apache-kafka-ksql-tensorflow-keras.ipynb' afterwards.

Separation between Apache Kafka Administration and KSQL Statements

You can either do everything within Jupyter or separate administration commands such as starting backends or creating Kafka Topics to command line and only run KSQL commands in Jupyter.

Here is an example where even the Kafka administration in done in Jupyter:

Apache Kafka Administration in Jupyter Notebook

Additional Information (AutoEncoder, TensorBoard, TensorFlow Model Export / Import)

The following describes some more details of this project like the concept of an Autoencoder, visualisation with TensorBoard and issues with exporting / importing TensorFlow models in different environments.

Autoencoder for Credit Card Fraud Detection build with Keras and TensorFlow

An autoencoder is an unsupervised neural network which encodes (i.e. compresses) the input and then decodes (i.e. decompresses) it again:

Autoencoder (Unsupervised neural network)

The goal is to lose as little information as possible. This way we can use an autoencoder to detect anomalies if the decoding cannot reconstruct the input well (showing potential fraud).

Hands-On with Python, TensorFlow, Keras, Apache Kafka and KSQL

We use KSQL for preprocessing, Numpy, pandas and scikit-learn for ML-specific tasks like array shapes or splitting training and test data, TensorFlow + Keras for model training, and Kafka Streams or KSQL for model deployment and monitoring.

Here is a TensorBoard screenshot of the trained Autoencoder:

Autoencoder for Fraud Detection (TensorBoard)

TensorFlow Model Serialisation - Keras model (.h5) vs. TensorFlow model (.pb)

Different model serialisation mechanisms exist. Also product vendors and cloud providers add additional features (like for any other standard). Therefore, your TensorFlow model might not work everywhere out-of-the-box.

This will probably get better with release of TensorFlow 2.0 in 2019, but as of today (January 2019), you need to think about where you want to deploy your model before you train and export it.

This demo uses plain Keras API. This is fine e.g. if you want to load the model via Java API from a Java application (see e.g. my Kafka Streams + Keras + TensorFlow example where I load the H5 model file).

If you want to deploy the model in a specific TensorFlow infrastructure like Google ML Engine (based on TensorFlow Serving model server), it is best to train the model with GCP's tools as described in this [Google ML Getting Started] (https://cloud.google.com/ml-engine/docs/tensorflow/getting-started-training-prediction) guide.

Otherwise, you need to convert the H5 Keras file to a TensorFlow Proto Buffers file and fulfil some more tasks, e.g. described in this blog post.

The Python tool Keras to TensorFlow is a good and simple solution:

            python keras_to_tensorflow.py --input_model="/Users/kai.waehner/git-projects/python-jupyter-apache-kafka-ksql-tensorflow-keras/models/autoencoder_fraud.h5" --output_model="/Users/kai.waehner/git-projects/python-jupyter-apache-kafka-ksql-tensorflow-keras/models/autoencoder_fraud.pb"

The tool freezes the nodes (converts all TF variables to TF constants), and saves the inference graph and weights into a binary protobuf (.pb) file.

You can also use keras.estimator.model_to_estimator (included in tf.keras): Example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].