Sit back
Let's learn

Create a Simple Stock Price Prediction App using ChatGPT

Published on:
May 31, 2023
Published by:
Professor Ishwar Sethi
This post was originally published by one of our partners on:

Since its release about 6 months ago, the ChatGPT, a large language model (LLM) from OpenAI, has created lots of excitement in terms of its impact on the society and a whole range of possible uses for it. With the release of GPT-4, many established commentators have expressed serious concerns about the harm that could come out of such AI tools that are characterized as generative AI models. This has resulted in a number of AI researchers suggesting a six month halt on AI research.

Since ChatGPT’s release, many companies and researchers have been playing with its capabilities. It has been used to write essays, emails, and even scientific articles, prepare travel plans, solve math problems, write code and create websites among many other usages. Many companies have incorporated it into their Apps. And of course, Microsoft has integrated it into its Bing search engine. Some new reports have shown ChatGPT to be a great help in answering medical questions for patients as well as providing a second opinion to physicians.

Driven by all the hoopla about ChatGPT and the generative AI, I have been also playing with it, please see my previous posts on this. In this post, I want to show you my interaction with ChatGPT to create a simple app for stock price prediction. My initial prompt, shown below, is to ask for a prediction model that will take the closing price of any given stock and predict its next day’s closing price.

Next, I prompt ChatGPT to give me a solution to download the stock data from Yahoo finance website.

My next prompt is to ask for an app using the above code.

ChatGPT then proceeds to tell me how to run the app.

The first time I ran the app, I got an error message (value error). While looking at the ChatGPT code, I located the error made by ChatGPT. The second argument in reshape should have been 5 and not 1 as the predictor is suppose to look at the five previous values. Once corrected, the app ran without any flaw. So, we can see that ChatGPT can easily simplify our work and make us more productive.

Check Out These Brilliant Topics
Understanding Tensors and Tensor Decompositions: Part 3
Published on:
April 6, 2023
Published by:
Professor Ishwar Sethi

This is my third post on tensors and tensor decompositions. The first post on this topic primarily introduced tensors and some related terminology. The second post was meant to illustrate a particularly simple tensor decomposition method, called the CP decomposition. In this post, I will describe another tensor decomposition method, known as the Tucker decomposition. While the CP decomposition’s chief merit is its simplicity, it is limited in its approximation capability and it requires the same number of components in each mode. The Tucker decomposition, on the other hand, is extremely efficient in terms of approximation and allows different number of components in different modes. Before going any further, lets look at factor matrices and n-mode product of a tensor and a matrix. Factor Matrices Recall the CP decomposition of an order three tensor expressed as X≈∑r=1Rar∘br∘cr, where (∘ ) represents the outer product. We can also represent this decomposition in terms of organizing the vectors, ar,br,cr,r=1,⋯R , into three matrices, A, B, and C, as A=[a1a2⋯aR], B=[b1b2⋯bR],and C=[c1c2⋯cR] The CP decomposition is then expressed as X≈[Λ;A,B,C], where Λ is a super-diagonal tensor with all zero entries except the diagonal elements. The matrices A, B, and C are called the factor matrices. Next, lets try to understand the n-mode product. Multiplying a Tensor and a Matrix How do you multiply a tensor and a matrix? The answer is via n-mode product. The n-mode product of a tensor X∈RI1×I2×⋯IN with a matrix U∈RJ1×In is a tensor of size I1×I2×⋯In−1×J×In+1×⋯×IN, and is denoted by X×nU . The product is calculated by multiplying each mode-n fibre by the U matrix. Lets look at an example to better understand the n-mode product. Lets consider a 2x2x3 tensor whose frontal slices are:

Want Us to Send You New Posts?

We add Value. Not spam.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Kevadiya INC. © 2023 All Rights Reserved.