Skip to content
··7 min basahin

Namangha ako sa kaya gawin ng ChatGPT na may code interpreter para sa data analysis

Nagtanong ako sa ChatGPT ng mga vague na tanong tulad ng "sabihin mo sa akin ang isang interesting" tungkol sa Treasury data—agad itong gumawa ng insightful na mga graphs na tumatagal sa akin ng ilang oras na gawin nang manual.

Ang post na ito ay isinulat noong 2023. Maaaring may mga detalyeng nagbago na mula noon.

Noong sumulat si Ethan Mollick tungkol sa kung gaano kapowerful ang chatGPT na may Code Interpreter, naging napaka-curious ako. Naka-holiday ako noong oras na iyon kaya ngayon ko lang nakausap ito. At grabe, namangha talaga ako!

Para sa context, nagdesisyon akong gumamit ng data tungkol sa iba't ibang US government security issues mula sa website na Treasury Direct. Pinili ko ang dataset na ito dahil sumulat ako ng nakaraang blog post tungkol sa "Why You Shouldn't Believe the Hype About the TreasuryDirect Website Being Outdated" kaya medyo pamilyar na ako sa dataset. At mas mahalaga pa, humigit-kumulang naaalala ko kung gaano katagal bago ko nagawa ang mga graphs.

Napakadaling mag-upload ng buong dataset

Sa isang click lang ng button, na-upload ko ang buong dataset kasama ang data dictionary. At hindi ko kailangang magsabi ng marami tungkol sa dataset, ang mga pangungusap na ito lang mula sa website "The Securities Issued in TreasuryDirect dataset details how many of each type of Treasury bonds are issued, redeemed, or outstanding in TreasuryDirect from Fiscal Year (FY) 2002 until present. Outstanding bonds refer to those which are still in circulation, and have not yet been redeemed. The number of outstanding Treasury bonds is determined by taking the difference between the numbers of Treasury bonds issued and redeemed. This dataset does not contain any information on the values or yields of the Treasury bonds."

Gusto ko ang fact na walang prompt, sinasabi sa akin ng chatGPT kung paano nito naintindihan ang dataset sa high level at binibigyan ako ng initial rows ng data bilang preview.

Ngayon ay pwede ko nang "kausapin" ang data

Pwede mo bang sabihin sa akin ang isang interesting tungkol sa dataset na ito?

Nagtanong ako sa chatGPT ng medyo malabong tanong na "can you tell me something interesting about this dataset?" Napaka-generic na tanong ito dahil gusto kong makita kung kaya bang hulaan ng chatGPT kung ano ang maaaring maging interesante sa mga tao.

At ito ang sagot:

can you tell me something interesting about this dataset

can you tell me something interesting about this dataset

can you tell me something interesting about this dataset

Gaya ng nakikita mo, tamang hula ng chatGPT na marahil ang gross sales amount trend sa paglipas ng panahon ay isa sa mga unang interesting notes tungkol sa dataset na maaaring interesado ako. Pagkatapos ay bini-break down nito ang gross sales ayon sa security type sa susunod na chart. (Kung mapapansin mo nang mabuti ang pagkakaiba ng wording at ng final chart, makikita mo na maling kulay ang sinabi ng chatGPT na "orange" sa halip na "darker blue", pero hindi naman ito deal breaker).

Susunod, nagtanong ako sa chatGPT ng isa pang malabong tanong :P

"Based on this dataset, do you think that the website treasury direct is getting more popular?"

At gusto ko ang sagot na ibinigay nito "The popularity of the TreasuryDirect website could be inferred by examining the trends in sales and the number of transactions over time. If we see an increase in these metrics, it could suggest that more people are using the website to purchase Treasury bonds. However, it's important to note that this is a rough estimation and might not represent the full picture of the website's popularity, as there might be other factors at play."

Gusto ko ang response dahil tama ang tone of voice. Malinaw na sinasabi ng ChatGPT na hindi ito sigurado at ang sagot ay isa lamang sa maraming posibleng sagot.

Ito ang graph na ginawa ng chatGPT

the number of transactions over time chatGPT first try

Ang iteration ang susi

Habang ang mga chart sa itaas ay ok, hindi pa sila ang final products na hinahanap ko. Kaya sinabi ko sa chatGPT "I want to include the chart about the number of transactions over time on my blog, can you reformat the chart so that it is easier to read?"

At makikita mo ang improvement sa paglipas ng panahon sa ibaba, isa-isa:

Unang improvement

Ito ang sinagot ng chatGPT pagkatapos ng aking request:

Absolutely, I can modify the chart to make it easier to read. Some changes that could improve the chart's readability include:

  1. Increasing the font size of the title, labels, and ticks.
  2. Adjusting the linewidth of the plot for better visibility.
  3. Adding a more descriptive title and labels.
  4. Making the gridlines lighter to avoid distraction.

At ito ang chart

First chart improvement chatGPT

Ikalawang improvement

Napansin ko ang isang kakaibang bagay sa vertical axis kaya sinabi ko "for the vertical axis, I am not sure if my audience will understand what 1e6 means?"

at ito ang resulta

"Understandable, scientific notation can sometimes be confusing for a general audience. Instead, we can convert the y-axis labels to millions and add that information to the label. This way, the numbers will be more straightforward to understand. Let's make that adjustment."

TreasuryDirect transactions trend over time with y-axis fixed

Ikatlong revision

Ito ang response ko pagkatapos makita ang chart sa itaas "yes this graph is getting much better! I notice from the trend that the number of transactions increased significantly over the past few years. How do we show this better to my audience?"

at sumagot ang chatGPT:

"One common method for highlighting trends in data over time is to include a trend line in the graph. A trend line (also called a line of best fit) is a line that is used to represent the behavior of a group of data to see if there's a certain pattern.

In the context of your data, adding a trend line can help visualize whether there's an overall increase in the number of transactions over time, despite any short-term fluctuations.

Let's add a trend line to the graph. We'll use a simple linear regression model to estimate the trend. We'll also include the equation of the trend line and the R-squared value (which measures how closely the data fit the regression line) in the graph's legend to provide more context for the audience."

third revision and chatGPT gets it wrong

Habang ang sagot ng chatGPT ay parang confident, makikita mo na walang red trend line sa chart sa itaas. Kaya nagbigay ako ng feedback

Ika-apat na revision

"I dont see the red line at all from the above chart"

at ito ang sinagot ng chatGPT:

"I apologize for the confusion. The red line representing the trend might not be visible due to the large fluctuations in the data. A trend line, especially for a linear regression model, may not adequately represent the data if there are large-scale fluctuations or if the trend is not linear.

An alternative way to highlight the trend could be to use a rolling mean (also known as a moving average). This technique averages out the fluctuations over a certain period to highlight the longer-term trend.

Let's apply a 12-month rolling mean to the data and plot it along with the original data. This should help us better visualize the overall trend."

chatGPT chart revision with trend line

"A rolling mean smooths out short-term fluctuations and highlights longer-term trends in data. In this case, it's calculated by averaging the number of transactions over 12-month periods.

The rolling mean line shows the general trend of the data despite the monthly fluctuations. As we can see, there's a clear upward trend in the number of transactions, which supports your observation that TreasuryDirect is becoming more popular."

Magaling ba? Hindi ko sinabi sa chatGPT na gusto kong tingnan ang 12-month rolling mean pero iminungkahi nito. Sa totoo lang, hindi ko naisip ang ganitong paraan upang i-visualize ang napakalaking pagbabago sa nakalipas na ilang taon kumpara sa nakalipas na 20 taon. Talagang impressive!

Mapapansin mo rin ang pagpili ng kulay, sadyang gumagamit ito ng mas maitim na kulay para sa trend line upang i-highlight ang pagbabago, na siyang gusto ko.

Final na revision

Habang impressed na ako sa huling chart, idinagdag ko ito "actually, one additional question, do we need the gridlines for the above chart? do you think we can simplify the chart further by eliminating the gridlines?"

at ito ang natanggap ko

final chart revision from chatGPT

Sa pagbabasa ng revision process na ito, baka mafeel mo na masyadong matagal pero hindi, sa totoong buhay, bawat iteration ay tumatagal ng mas mababa sa 5-10 segundo. Talagang mas mabilis ito kaysa sa ginagawa ko ito nang mag-isa!

Direktang paghahambing sa sarili kong chart at chatGPT chart

Gaya ng nabanggit sa itaas, sumulat ako ng blog post gamit ang dataset na ito noon kaya gumawa ako ng ilang charts sa nakaraan. Ngayon gusto kong ihambing kung gaano kabilis i-recreate ang parehong chart pero gamit ang chatGPT.

kaya sinulat ko ito "can you generate a graph to show the trend of funded account at treasury direct from Jan 2016 to Feb 2023?"

Ipapakita ko sa'yo ng magkatabi ang sarili kong chart at ang ginawa ng chatGPT. Nasa ibaba ang ginawa ko:

Funded accounts trend at TreasuryDirect January 2016 to February 2023

Kung tama ang naalala ko, tumagal ako ng higit sa 5-10 minuto para gawin ang chart na ito noon.

pero sa chatGPT, ilang segundo lang at ito ang natanggap ko (kasama ang bonus na 12-month rolling mean). Ikaw ang huwes kung aling version ang mas maganda :P

chatGPT with code interpreter revised chart

Konklusyon

Namangha ako sa kaya gawin ng chatGPT na may code interpreter NGAYON para sa data analysis at hindi ako makapaghintay na makita kung ano ang kaya nitong gawin sa hinaharap, na may mas marami pang improvement :D

Ano ang pinaka-nakakapagod na data task na regular mong ginagawa? Nasubukan mo na bang ibato ito sa Code Interpreter? Curious ako kung kaya ba nitong hawakan ang domain-specific data mo nang kasing-husay ng pag-handle nito sa akin.

Maraming salamat,

Chandler

Ipagpatuloy ang Pagbasa

Ang Journey Ko
Kumonekta
Wika
Mga Preference