Giter Club home page Giter Club logo

lastancientone / deep_learning_machine_learning_stock Goto Github PK

View Code? Open in Web Editor NEW
1.2K 33.0 305.0 19.38 MB

Deep Learning and Machine Learning stocks represent promising opportunities for both long-term and short-term investors and traders.

License: MIT License

Jupyter Notebook 99.86% Python 0.14%
deep-learning machine-learning stock-price-prediction features-extraction financial-engineering prediction feature-engineering feature-extraction feature-selection stock-data stock-trading stock-analysis stock-prices stock-market stock-prediction algorithms data-science trading technical-analysis neural-network

deep_learning_machine_learning_stock's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn

Buy Me A Coffee

Deep Learning and Machine Learning for Stock Predictions

Description: This is a comprehensive study and analysis of stocks using deep learning (DL) and machine learning (ML) techniques. Both machine learning and deep learning are types of artificial intelligence (AI). The objective is to predict stock behavior by employing various machine learning and deep learning algorithms. The focus is on experimenting with stock data to understand how and why certain methods are effective, as well as identifying reasons for their potential limitations. Different stock strategies are explored within the context of machine learning and deep learning. Technical Analysis and Fundamental Analysis are utilized to predict future stock prices using these AI techniques, encompassing both long-term and short-term predictions.

Machine learning is a branch of artificial intelligence that involves the development of algorithms capable of automatically adapting and generating outputs by processing structured data. On the other hand, deep learning is a subset of machine learning that employs similar algorithms but with additional layers of complexity, enabling different interpretations of the data. The network of algorithms used in deep learning is known as artificial neural networks, which mimic the interconnectedness of neural pathways in the human brain.

Deep learning and machine learning are powerful approaches that have revolutionized the AI landscape. Understanding the fundamentals of these techniques and the commonly used algorithms is essential for aspiring data scientists and AI enthusiasts. Regression, as a fundamental concept in predictive modeling, plays a crucial role in analyzing and predicting continuous variables. By harnessing the capabilities of these algorithms and techniques, we can unlock incredible potential in various domains, leading to advancements and improvements in numerous industries.

Machine Learning Step-by-Step

  1. Collecting/Gathering Data.
  2. Preparing the Data - load data and prepare it for the machine learning training.
  3. Choosing a Model.
  4. Training the Model.
  5. Evaluating the Model.
  6. Parameter Tuning.
  7. Make a Predictions.

Deep Learning Model Step-by-Step

  1. Define the Model.
  2. Complie the Model.
  3. Fit the Model with training dataset.
  4. Make a Predictions.

Programming Languages and Tools:

python Nteract Anaconda Spyder Jupyter Notebook Notepad++

Three main types of data: Categorical, Discrete, and Continuous variables

  1. Categorical variable(Qualitative): Label data or distinct groups.
    Example: location, gender, material type, payment, highest level of education
  2. Discrete variable (Class Data): Numerica variables but the data is countable number of values between any two values.
    Example: customer complaints or number of flaws or defects, Children per Household, age (number of years)
  3. Continuous variable (Quantitative): Numeric variables that have an infinite number of values between any two values. Example: length of a part or the date and time a payment is received, running distance, age (infinitly accurate and use an infinite number of decimal places)

Data Use

  1. For 'Quantitative data' is used with all three centre measures (mean, median and mode) and all spread measures.
  2. For 'Class data' is used with median and mode.
  3. For 'Qualitative data' is for only with mode.

Two types of problems:

  1. Classification (predict label)
  2. Regression (predict values)

Bias-Variance Tradeoff

Bias

  • Bias is the difference between our actual and predicted values.
  • Bias is the simple assumptions that our model makes about our data to be able to predict new data.
  • Assumptions made by a model to make a function easier to learn.

Variance

  • Variance is opposite of bias.
  • Variance is variability of model prediction for a given data point or a value that tells us the spread of our data.
  • If you train your data on training data and obtain a very low error, upon changing the data and then training the same.

Overfitting, Underfitting, and the bias-variance tradeoff

Overfitted is when the model memorizes the noise and fits too closely to the training set. Good fit is a model that learns the training dataset and genernalizes well with the old out dataset. Underfitting is when it cannot establish the dominant trend within the data; as a result, in training errors and poor performance of the model.

Overfitting:

Overfitting model is a good model with the training data that fit or at lease with near each observation; however, the model mist the point and random noise is capture inside the model. The model have low training error and high CV error, low in-sample error and high out-of-sample error, and high variance.

  1. High Train Accuracy
  2. Low Test Accuracy

Avoiding Overfitting:

  1. Early stopping - stop the training before the model starts learning the noise within the model.
  2. Training with more data - adding more data will increase the accuracy of the modelor can help algorithms detect the signal better.
  3. Data augmentation - add clean and relevant data into training data.
  4. Feature selection - Use important features within the data. Remove features.
  5. Regularization - reduce features by using regularization methods such as L1 regularization, Lasso regularization, and dropout.
  6. Ensemble methods - combine predictions from multiple separate models such as bagging and boosting.
  7. Increase training data.

Good fit:

  1. High Train Accuracy
  2. High Test Accuracy

Underfitting:

Underfitting model is not perfect, so it does not capture the underlying logic of the data. Therefore, the model does not have strong predictive power with low accuracy. The model have large training set error, large in-sample error, and high bias.

  1. Low Train Accuracy
  2. Low Test Accuracy

Avoiding Underfitting:

  1. Decrease regularization - reduce the variance with a model by applying a penalty to the input parameters with the larger coefficients such as L1 regularization, Lasso regularization, dropout, etc.
  2. Increase the duration of training - extending the duration of training because stopping the training early will cause underfit model.
  3. Feature selection - not enough predictive features present, then adding more features or features with greater importance would improve the model.
  4. Increase the number of features - performing feature engineering
  5. Remove noise from the data

Python Reviews

Step 1 through step 8 is a review on python.
After step 8, everything you need to know is relates to data analysis, data engineering, data science, machine learning, and deep learning.
Here the link to python tutorial:
Python Tutorial for Stock Analysis

List of Machine Learning Algorithms for Stock Trading

Most Common Regression Algorithms

  1. Linear Regression Model
  2. Logistic Regression
  3. Lasso Regression
  4. Support Vector Machines
  5. Polynomial Regression
  6. Stepwise Regression
  7. Ridge Regression
  8. Multivariate Regression Algorithm
  9. Multiple Regression Algorithm
  10. K Means Clustering Algorithm
  11. NaΓ―ve Bayes Classifier Algorithm
  12. Random Forests
  13. Decision Trees
  14. Nearest Neighbours
  15. Lasso Regression
  16. ElasticNet Regression
  17. Reinforcement Learning
  18. Artificial Intelligence
  19. MultiModal Network
  20. Biologic Intelligence

Different Types of Machine Learning Algorithms and Models

Algorithms are processes and sets of instructions used to solve a class of problems. Additionally, algorithms perform computations such as calculations, data processing, automated reasoning, and other tasks. A machine learning algorithm is a method that enables systems to learn and improve automatically from experience, without the need for explicit formulation.

Prerequistes

Python 3.5+
Jupyter Notebook Python 3
Windows 7 or Windows 10

Download Software

https://www.python.org/

Programming Language:

python

Tools:

Anaconda Spyder Jupyter Notebook Notepad++ Notepad++

Authors

Tin Hang

Disclaimer

πŸ”» Do not use this code for investing or trading in the stock market. However, if you are interest in the stock market, you should read πŸ“š books that relate to stock market, investment, or finance. On the other hand, if you into quant or machine learning, read books about πŸ“˜ machine trading, algorithmic trading, and quantitative trading. You should read πŸ“— about Machine Learning and Deep Learning to understand the concept, theory, and the mathematics. On the other hand, you should read academic paper and do research online about machine learning and deep learning on πŸ’»

Certain portions of the code may encounter issues stemming from updates or obsolescence within specific library packages. Consequently, adjustments will be necessary, contingent upon the Python package library employed. It may be imperative to either upgrade or downgrade certain libraries accordingly.

πŸ”΄ Warning: This is not financial advice; it should not be relied upon for investment or trading decisions, as it is for educational purposes only.

deep_learning_machine_learning_stock's People

Contributors

lastancientone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deep_learning_machine_learning_stock's Issues

Basic_Machine_Learning_Predicts.ipynb

There are errors input onwards :

X = df.drop(['Date','Close'], axis=1, inplace=True)
y = df[['Adj Close']]

Kindly tell us what packages do we need to test and run the files like pip install yfinance, pip install seaborn etc.

The version of the notebook server is: 6.4.8
Python 3.10.7 (main, Sep 8 2022, 14:34:29) [GCC 12.2.0]
Ubuntu : 22.10 (Development Branch)

what does input symbol means in stocks_app.py

got code but is not understanding as if I gave input as stock name its throwing error

File "C:\Users\vaibh\Desktop\Deep-Learning-Machine-Learning-Stock-master\Stock_Apps\Stock_ML_Predict_Apps.py", line 54, in stock_logistic_regression
df = yf.download(sym, s, e)
AttributeError: module 'yahoo_finance' has no attribute 'download'

please help me resolve this issue....

Need correction in cell 16 from '001_Pandas.ipynb'

Below original first line of code doesn't work ⬇️ :

# Move column example
# Move Date in the first column

cols = list(new_df)
cols.insert(0, cols.pop(cols.index('Date')))
cols

Please correct this code to ⬇️ :

# Move column example
# Move Date in the first column
cols = new_df.columns.to_list()
cols.insert(0, cols.pop(cols.index('Date')))
cols

New complemetary tool

My name is Luis, I'm a big-data machine-learning developer, I'm a fan of your work, and I usually check your updates.

I was afraid that my savings would be eaten by inflation. I have created a powerful tool that based on past technical patterns (volatility, moving averages, statistics, trends, candlesticks, support and resistance, stock index indicators).
All the ones you know (RSI, MACD, STOCH, Bolinger Bands, SMA, DEMARK, Japanese candlesticks, ichimoku, fibonacci, williansR, balance of power, murrey math, etc) and more than 200 others.

The tool creates prediction models of correct trading points (buy signal and sell signal, every stock is good traded in time and direction).
For this I have used big data tools like pandas python, stock market libraries like: tablib, TAcharts ,pandas_ta... For data collection and calculation.
And powerful machine-learning libraries such as: Sklearn.RandomForest , Sklearn.GradientBoosting, XGBoost, Google TensorFlow and Google TensorFlow LSTM.

With the models trained with the selection of the best technical indicators, the tool is able to predict trading points (where to buy, where to sell) and send real-time alerts to Telegram or Mail. The points are calculated based on the learning of the correct trading points of the last 2 years (including the change to bear market after the rate hike).

I think it could be useful to you, to improve, I would like to give it to you, and if you are interested in improving and collaborating I am also willing, and if not I would like to file it in the drawer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.