Find Undervalued Stocks Using AI & Python
AI Summary
Video Summary: Predicting Stock Value with Machine Learning
- Introduction
- Welcome to a video on Python, AI, and machine learning.
- The goal is to predict if a stock is undervalued using machine learning.
- Setting Up
- Use Google Colab (collab.research.google.com) for Python programming.
- Log in with a Google account, create a new notebook, and start coding.
- Encouragement to subscribe and like the video for channel support.
- Importing Libraries
- Import necessary libraries in a new cell:
pandas
aspd
RandomForestClassifier
fromsklearn.ensemble
accuracy_score
fromsklearn.metrics
train_test_split
fromsklearn.model_selection
- Run the cell to check for errors.
- Loading Data
- Upload a CSV file containing stock data.
- Rename the file to
data.csv
.- Load the data into a variable and display its contents.
- The data includes columns for ticker symbol, PE ratio, current price, earnings per share, fair market value, over/under value, and value percentage.
- Preparing Data
- Split data into features (X) and target (Y) datasets.
- Features include PE ratio, current price, and earnings per share.
- Target is the column indicating if a stock is undervalued.
- Splitting Data
- Split the data into 80% training and 20% testing datasets using
train_test_split
.- Creating and Training the Model
- Create a
RandomForestClassifier
model with 100 estimators and a random state of 0.- Train the model on the training datasets.
- Making Predictions
- Predict values on both training and testing datasets.
- Store predictions in separate variables for comparison.
- Evaluating Accuracy
- Calculate and print the accuracy of the model on both training and testing datasets.
- Training accuracy is 100%, testing accuracy is around 95%.
- Comparing Predictions
- Show the model’s predictions and actual values from the test dataset to compare.
- Using the Model
- Demonstrate how to use the model to predict the value of other stocks given their features.
- Use an example stock and its features to predict if it’s fair or overvalued.
- Conclusion
- Reminder that the model is simple and not perfect.
- Encouragement to do further research before investing.
- Thanks to viewers and Patreon supporters.
- Support and Code Access
- Patreon support and access to code and dataset mentioned.
- Patreon link: patreon.com/computerscience provided for support.