
HDB Trends Auto-Updating Report Using OpenAI API
Project Details:
This project analyzes Singaporean HDB resale data, integrating geographic and classification information. Leveraging OpenAI's natural language generation, it provides insights into monthly median prices and town-to-town comparisons, aiding informed decision-making in the real estate market.
Software / programming language used:
Python
SQL
Hex Tech
OpenAI
Highlights
OpenAIAPI
This Python function utilizes OpenAI's API to generate insights on real estate data. It's designed to interact with OpenAI's GPT-3.5 model for text completion. The 'chat_gpt' function takes a prompt (i.e., input text) as an argument and sends it to the API for completion. The API returns a response containing generated text based on the prompt. The 'max_tokens' parameter ensures the generated text doesn't exceed a specified length. This function allows for seamless integration of AI-generated insights into real estate analysis and decision-making processes.
SQL Query
This SQL query selects resale data such as resale date, price, location, and property details from the 'fct_pty_transaction_hdb_resale' table. It filters records where 'hdb_town' is not null and the 'resale_date' falls within the last 13 months from the current date.
Python Code
This Python code complements the SQL query by processing and analyzing HDB resale data in Singapore.
First, it loads a shapefile containing geographical information about Singapore's HDB towns. The data is standardized by converting town names to uppercase and renaming the column to match the SQL query's 'hdb_town' field.
Next, the code merges this geographical information with the main dataset using the 'hdb_town' column as the key. Additionally, it incorporates information from another CSV file, likely containing classification data related to HDB towns.
For analysis, the code generates a textual prompt, 'teststr', which describes the dataset and task to be performed. It calculates the median resale price per month and compares the latest month's results to others. This prompt is then passed to the OpenAI API for natural language generation (NLG).
Similarly, another prompt, 'mapteststr', is created to analyze and compare median prices between different HDB towns using the geographical information. This prompt is also sent to the OpenAI API for NLG.
The results from the NLG model are stored in variables 'hdb' and 'hdbmap', which likely contain human-readable summaries or insights derived from the data analysis.
In essence, this Python code automates the analysis and reporting process of HDB resale data in Singapore. By leveraging OpenAI's NLG capabilities, it transforms raw data into concise and informative narratives, facilitating better understanding and decision-making in the real estate domain. The use of geospatial data enriches the analysis by considering the geographical aspect of HDB resale prices across different towns. Overall, this integration of data processing, analysis, and NLG demonstrates a sophisticated approach to deriving insights from complex datasets.
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
