2024-06-17|閱讀時間 ‧ 約 25 分鐘

AI說書 - 從0開始 - 24

我想要一天分享一點「LLM從底層堆疊的技術」,並且每篇文章長度控制在三分鐘以內,讓大家不會壓力太大,但是又能夠每天成長一點。


延續AI說書 - 從0開始 - 23示範了ChatGPT回答的能力,現在我們來看看ChatGPT撰寫程式的能力。


嘗試問以下問題:Write a detailed explanation for a beginner in Python for this code.


其回答如下:

  1. Import libaries

We import several libraries that we will use throughout the code. NumPy and Pandas are used for data manipulation, Matplotlib is used for data visualization, Scikit-learn is used for machine learning, and we import specific functions like load_iris, train_test_split, DecisionTreeClassifier, confusion_matrix, and plot_tree from the respective Scikit-learn modules.

import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import confusion_matrix
from sklearn.tree import plot_tree
  1. Load the Iris dataset

We use the load_iris function from Scikit-learn's datasets module to load the Iris dataset into a variable called iris.

iris = load_iris()
  1. Split the dataset into training and testing sets

We use Scikit-learn's train_test_split function to split the dataset into training and testing sets. We pass in iris.data as the features and iris.target as the labels. We set the test size to 20%, which means that 20% of the data will be used for testing and 80% will be used for training. We also set the random state to 42 to ensure that the results are reproducible.

X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)


此時,當我看著 ChatGPT 寫下到目前為止的所有內容並仍在瘋狂地打字時,我開始想我在這一切中扮演了什麼角色?人工智慧會接管我的工作嗎?儘管我知道生成式人工智慧有很多局限性,但它仍然讓我感到困惑。

分享至
成為作者繼續創作的動力吧!
© 2024 vocus All rights reserved.