Videos

Use Artificial Intelligence (AI) to Predict the Stock Market with Python



Computer Science (compsci112358)

#Programming #Python
How I used AI & XGBoost to predict the stock market

Disclaimer: The material in this video is purely for educational purposes and should not be taken as professional investment advice. Invest at your own discretion.
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
⭐Please Subscribe !⭐
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🐦🔥🐤 Support The Channel🐤🔥🐦
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
⭐Get the code and data sets or just support the channel by becoming a supporter on Patreon:
https://www.patreon.com/computerscience
⭐Website:
http://everythingcomputerscience.com/

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
📚Helpful Python Programming Books📚
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
► Hands-On Machine Learning with Scikit-Learn and TensorFlow:
https://amzn.to/2AD1axD
► Learning Python:
https://amzn.to/3dQGrEB
►Head First Python:
https://amzn.to/3fUxDiO

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
📚Helpful Financial Books📚
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🌟Stock Market Investing Books:
✔️The Bogleheads’ Guide to Investing
https://amzn.to/3s0icxA
✔️The Intelligent Investor
https://amzn.to/34Mj7t1
✔️A Random Walk Down Wall Street
https://amzn.to/3Bv0ghW

🌟Money Mindset Books
✔️Rich Dad Poor Dad:
https://amzn.to/3rZW6eE
✔️Get Good With Money: Ten Simple Steps To Becoming Financially Whole:
https://amzn.to/3I1UXc1

Source

Similar Posts

38 thoughts on “Use Artificial Intelligence (AI) to Predict the Stock Market with Python
  1. typo? train_data= data.iloc[:int(.99 * len(data)), :]

    test_data= data.iloc[int(.99 * len(data)):,:] <———test data 1%
    i also get a xgboost error. probably has something to do with the shape of the train and test data not matching

  2. This type of algo is usefull just to predict the next time event. You have 70% accuracy but you are predicting just the next day price based in the last day price multiple times

  3. Use Your prediction and check the return %, the results is very very poor. The prediction is basically noise with baseline of open price. You can just plot open price vs close price, the are similar to your prediction.

  4. How the flow of a forwardtest such prediction is:
    Step 1: Download the csv till current date
    Step 2: Delete the last 20% of the timestamps of the csv so if it's like data of 2000 till 2023 then cut till 2019 and save this as training_SP500.csv
    Step 3: Do the opposite of step 2 wich u cut the first 80% off and save it as future_Sp500.csv
    Step 4: train only on the data of training_SP500.csv
    Step 5: u test the the prediction for the missing 20% of the current data
    Step 6: on same chart plot the original data of the current s&p500 data

    And Voila a chart wich u can clearly see is those prediction where in the right direction!!

    Nice vid, good education

  5. #Import the libraries

    import pandas as pd

    import xgboost as xgb

    import matplotlib.pyplot as plt

    #load the data

    data= pd.read_csv('all_stocks_5yr.csv')

    data

    #show th data

    data['close'].plot()

    #split the data in to training and testing data sets

    train_data= data.iloc[:int(.99*len(data)),:]

    test_data= data.iloc[:int(.99*len(data)):,:]

    #Define the features and target variable

    features=['open','volume']

    target='close'

    #create and train the model

    model= xgb.XGBRegressor()

    model.fit(train_data[features],train_data[target])

    #makeand show the predictions on the test data

    predictions= model.predict(test_data[features])

    print('Model predictions:')

    print(predictions)

    #Show the actual valurs

    print('Actual values:')

    print(test_data[target])

    #Show the model's accuracy

    accuracy=model.score(test_data[features],test_data[target])

    print('Accuracy')

    print(accuracy)

    #plot the predictions and the close price

    plt.plot(data['close'],label='close price')

    plt.plot(test_data[target].index,predictions,label='predictions')

    plt.legend()

    plt.show()

    😄

  6. I'm surprised why this video is getting so many views and likes.
    You made a huge mistake in your logic.
    This is not the accuracy of your model. This is a coefficient of determination that does not play any useful role in building a trading strategy.
    The coefficient of determination shows how strongly you can describe the target variable using your features.
    If you take data from the previous day, and without a model. Your coefficient of determination will be 0.99
    In short, it’s not accurate and it’s useless what you did

  7. I run the same test on 30 years of data from Yahoo Finance, the score was 96%. Also ran the same on 30 years of data of Nasdaq(NDX) and again the score was 97%. The prediction does not look bad.

  8. found on tests with ticker 'SAP.DE' and other stocks
    at 5 min, 1h , 1d interval
    to get max accuracy in those intervals:
    5 min: 99.55 % accuracy
    1 h : 80.12 %
    1 d : 94.46 %
    ————————————-
    using notebook: type into cell: !pip install xgboost
    helped me to import xgboost as xgb (py)
    and
    import yfinance as yf
    data = yf.download(ticker, period='60d', interval='5m')

Comments are closed.

WP2Social Auto Publish Powered By : XYZScripts.com