第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

將過采樣數(shù)據(jù)集保存為 pandas 中的 csv 文件

將過采樣數(shù)據(jù)集保存為 pandas 中的 csv 文件

瀟瀟雨雨 2023-06-20 15:18:59
我是 Python 新手,如果太簡(jiǎn)單,請(qǐng)?zhí)崆爸虑?。我的代碼是# Split datay = starbucks_smote.iloc[:, -1]X = starbucks_smote.drop('label', axis = 1)# Count labels by typecounter = Counter(y)print(counter)Counter({0: 9634, 1: 2895})# Transform the datasetoversample = SMOTE()X, y = oversample.fit_resample(X, y)# Print the oversampled datasetcounter = Counter(y)print(counter)Counter({0: 9634, 1: 9634})如何保存過采樣數(shù)據(jù)集以備將來使用?我試過data_res = np.concatenate((X, y), axis = 1)data_res.to_csv('sample_smote.csv')出錯(cuò)了ValueError: all the input arrays must have same number of dimensions,?but the array at index 0 has 2 dimension(s) and the array at index 1 has 1 dimension(s)感謝任何提示!
查看完整描述

1 回答

?
紫衣仙女

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個(gè)贊

您可以創(chuàng)建數(shù)據(jù)框:

data_res?=?pd.DataFrame(X)
data_res['y']?=?y

然后保存data_res到 CSV。

基于連接 od 的解決方案numpy.arrays也是可能的,但np.vstack需要使維度兼容:

data_res?=?np.concatenate((X,?np.vstack(y)),?axis?=?1)
data_res?=?pd.DataFrame(data_res)


查看完整回答
反對(duì) 回復(fù) 2023-06-20
  • 1 回答
  • 0 關(guān)注
  • 98 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)