After discovering the usefulness of Google Colab, I ran some small programs there as practice. Some of them were interesting, so I moved them to this GitHub repository to share.
These notebooks are currently divided into the following categories:
- Pytorch Tutorial Series
- Visualizing Stocks
This Colab notebook files of PytorchTutorial series includes the following:
- PytorchTutorial2_Regression.ipynb
- PytorchTutorial3_Classfication.ipynb
- PytorchTutorial6_min_batch.ipynb
- PytorchTutorial7_CNN.ipynb
I initially copied and pasted these files from Professor Mofan's teaching website to Colab for code verification and familiarization with PyTorch.
After performing a lot of refactoring, I also added new features for them.The original example code's visualization was through Matplotlib, to better compatibility with Colab, I added a Plotly version. Both are side by side, allowing for easy comparison.
The following chart is the final result from PytorchTutorial7_CNN.ipynb, which is a CNN model trained using PyTorch in Google Colab to recognize the Arabic numerals 0 to 9 in the MNIST dataset. During the process, it was dimensionality reduced using TSNE and visualized using Plotly.
Initially, just for fun, I gave ChatGPT a simple task, to write a program to draw basic charts such as candlesticks, moving average lines, and volume. However, after ChatGPT struggled for a whole day, it still couldn't produce accurate results. So I had to roll up my sleeves, with the assistance of ChatGPT, and spend two days studying Plotly to finally achieve the current result. The following is its Colab notebook file.
- ViStock.ipynb
- Please also refer to vistock_demo.ipynb which is a demonstration of the extending project.
I retrieve the historical data of a stock using yfinance, after obtaining the stock's DataFrame table, I plot related charts using both mplfinance (a Matplotlib utilities for the visualization, and visual analysis, of financial data) and Plotly. I also tried using TA-Lib with mplfinance to plot technical analysis indicators.
As an example, below are the TSLA's price and volume accumulation charts so-called Volume Profile (or Price-by-Volume), the first one is plotted using mplfinance and the latter two are plotted using Plotly.