• Stars
    star
    632
  • Rank 70,731 (Top 2 %)
  • Language
    JavaScript
  • Created almost 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

In this repository, I have developed the entire server-side principal architecture for real-time stock market prediction with Machine Learning. I have used Tensorflow.js for constructing ml model architecture, and Kafka for real-time data streaming and pipelining.

Server architecture for Real-time Stock-market prediction with ML

architecture

In this repository, I have developed the entire server-side principal architecture for real-time stock market prediction with Machine Learning. I have used TensorFlow.js for constructing ml model architecture, and Kafka for real-time data streaming and pipelining.

Technologies used:

  1. Kafka.kafka
    • Pipelining logs from source to topics.
    • Topics are subscribed by consumer for real-time ml prediction and model training in parallel.
  2. TensorFlow.js.tf
    • Construction of tensorflow model in node.js.
    • Training model with time-series stock market data.
    • Use tfjs model for real-time prediction.
  3. MongoDB.mongodb
    • Update data-base with incoming stock market logs.
    • Use stored logs for analysis, and model training.
    • Store performance of the ml model for monitoring purpose.
  4. Node.js node
    • The entire server architecture is developed with node.js

Implementation

Start the Kafka environment

Start the ZooKeeper service.

$ bin/zookeeper-server-start.sh config/zookeeper.properties

Start the Kafka broker service

$ bin/kafka-server-start.sh config/server.properties

Start Streaming of logs.

Here, I have used .csv files in the dataset folder as the source of data. The data-source is pipelined with Kafka Topics. The first topic pipelines logs to MongoDB and the second topic pipelines logs to Tensorflow model for real-time prediction.
The streaming of logs from data-source through producer and consumer makes this architecture suitable for real-time analysis, ML model training and model prediction in parallel.
The producer could be started from

$ node producer.js
# or
$ start.sh

Streaming producer logs.
producer

$ node consumer.js

Streaming consumer logs.
consumer
In the consumer(consumer.js) the incoming logs are updated to MongoDB for further model training and analysis.

Machine Learning model.

The machine learning model architecture has been developed with TensorFlow.js. The model is trained with 80% of the stored data and validated against 20% of them. As the problem statement focuses over a time-series problem so we need to pre-process the data before training. Data have been pre-processed with MinMax-Scalar algorithm.
Training the ml model.

$ node tf_train.js
# or
$ server.sh

train

Validating the model.
$ node tf_validate.js

train
After validation the real and predicted values along with date and attribute of the stock-market time-series data that the model is trained against are updated to the MongoDB.

Model performance chart from MongoDB

performance

Real-time prediction.

The weights of the trained model are saved and loaded at the consumer side that subscribes to the second topic of the Kafka stream and predicts the output of the time-series event in real-time. As both topics of the Kafka pipeline are working in parallel, parallelism is achieved and logs are streamed by Kafka is real-time, which indeed implies the machine learning model could train and predict target in real-time.

$ node ml_consumer.js

ml_consumer

Prediction [attribute] [predicted value].
example - Prediction Open 0.12453 

This line in the above image(ml_consumer.js output) indicates the prediction of the model in real-time. The model utilizes 7 prior time-series logs as input and predicts the 8th time-series event.

Future Scopes.

  1. I have created the server-side architecture of the model, for which the client-side also needed to be developed.
  2. I was researching on react.js for construction of the client-side, but I failed at some aspects due to which I left the client-side for future development.
  3. The code I have written could be further optimised for better architectural design and model performance.

More Repositories

1

Respiratory-diseases-recognition-through-respiratory-sound-with-the-help-of-deep-neural-network

Prediction of respiratory diseases such as COPD(Chronic obstructive pulmonary disease), URTI(upper respiratory tract infection), Bronchiectasis, Pneumonia, Bronchiolitis with the help of deep neural networks or deep learning. We have constructed a deep neural network model that takes in respiratory sound as input and classifies the condition of its respiratory system. It not only classifies among the above-mentioned disease but also classifies if a personโ€™s respiratory system is healthy or not with higher accuracy and precision.
Python
36
star
2

End2EndAutomaticSpeechRecognition

In this repository, I have developed an end to end Automatic speech recognition project. I have developed the neural network model for automatic speech recognition with PyTorch and used MLflow to manage the ML lifecycle, including experimentation, reproducibility, deployment, and a central model registry.
Python
29
star
3

facial-emotion-recognition

This repository demonstrates an end-to-end pipeline for real-time Facial emotion recognition application through full-stack development. The frontend is developed in react.js and the backend is developed in FastAPI. The emotion prediction model is built with Tensorflow Keras, and for real-time face detection with animation on the frontend, Tensorflow.js have been used.
JavaScript
27
star
4

CycleGAN-with-Self-Attention

In this repository, I have developed a CycleGAN architecture with embedded Self-Attention Layers, that could solve three different complex tasks. Here the same principle Neural Network architecture has been used to solve the three different task. Although truth be told, my model has not exceeded any state of the art performances for the given task, but the architecture was powerful enough to understand the task that has been given to solve and produce considerably good results.
Python
23
star
5

Audio-Track-Separation

In this Repository, We developed an audio track separator in tensorflow that successfully separates Vocals and Drums from an input audio song track.
Python
19
star
6

MyosuiteDDQN

In this repository, we try to solve musculoskeletal tasks with `Double DQN reinforcement learning` by using a `transformer` model has been used as the base model architecture.
Python
13
star
7

SagemakerHuggingfaceDashboard

This is a solution that demonstrates how to train and deploy a pre-trained Huggingface model on AWS SageMaker and publish an AWS QuickSight Dashboard that visualizes the model performance over the validation dataset and Exploratory Data Analysis for the pre-processed training dataset.
Jupyter Notebook
11
star
8

ProteinStructurePrediction

Protein structure prediction is the task of predicting the 3-dimensional structure (shape) of a protein given its amino acid sequence and any available supporting information. In this section, we will Install and inspect sidechainnet, a dataset with tools for predicting and inspecting protein structures, complete two simplified implementations of Attention based Networks for predicting protein angles from amino acid sequences, and visualize our predictions along the way.
Python
11
star
9

victor369basu

About Me.
3
star
10

GoogleSheetPlot

This library helps a user to select a google sheet from their Google drive and plots a chart with the values on the sheet. The user only needs to select the column for the x-axis and the y-axis.
Jupyter Notebook
2
star
11

Intelligent-Alarm-clock-with-todo-list

An intellegent GUI alarmclock integrated with todo list in python progamming language
Python
2
star
12

e-commerce-website

Developing an e-commerce website with HTML, CSS, js, bootstrap and PHP.
PHP
1
star
13

RasaChatbot

Developing a chatbot assistant using RASA. The chatbot is built to handle basic hotel chat functionlities like Book room, Request Room Cleaning, Handle FAQs, Handle Greetings
Python
1
star
14

MongoDBFlask

This repository explains how to create a REST API using Python and host it locally using Docker. The goal of this task is to allow the user to interact with a database of products using APIs which are available on localhost via Docker. REST API has been created with the help of flask, that allows the user to do basic CRUD operations on the data.
Python
1
star
15

Exoplanet-Hunting-in-Deep-Space

Exoplanet hunting in deep space with the help of gradient boosting algorithm
Jupyter Notebook
1
star