這兩天要來介紹的是Python程式設計的應用,我個人是覺得既然學了不是要拿來用的R,不然學了幹嘛到最後還是忘光光Xd 不知道怎麼安裝的請往前翻 Danke
import os
# 列出文件夾中的文件
files = os.listdir('my_folder')
import pandas as pd
# 載入數據並顯示前幾行
data = pd.read_csv('.csv')
print(data.head())
import wave
# 讀取音頻文件
with wave.open('.wav', 'rb') as audio:
audio_data = audio.readframes(-1)
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_iris
# 載入Iris數據集
iris = load_iris()
X = iris.data
y = iris.target
# 分割數據集為訓練集和測試集及進行預測
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LogisticRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
# 計算模型的準確率
accuracy = (y_pred == y_test).mean()
print("模型的準確率:", accuracy)