強烈先全部看一遍各種報錯原因,先全文瀏覽一遍,坑比較多~~
pandas_profiling安裝的各種問題記錄
常見如下:
MemoryError...
MemoryError: Unable to allocate 201. MiB for an array with shape (33, 800000) and data type float64...
pickler.file_handle.write(chunk.tobytes('C'))...
OSError: [Errno 28] No space left on device...
基本代碼: pandas_profiling可以實現自動的EDA,一鍵生成數據報告
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datetime
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
if __name__ == '__main__':
# 0.1 公共變量
linux_file_path = '/mnt/阿里雲開發者-天池比賽/02_零基礎入門金融風控_貸款違約預測/'
train_file_path = linux_file_path + 'train.csv'
testA_file_path = linux_file_path + 'testA.csv'
now = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
output_path = linux_file_path + '/profiling/'
# 0.2 數據讀取pandas
data_train = pd.read_csv(train_file_path)
data_test_a = pd.read_csv(testA_file_path)
# print('Train Data shape 行*列:',data_train.shape)
# print('TestA Data shape 行*列:',data_test_a.shape)
# 2.3.5 用pandas_profiling生成數據報告
import pandas_profiling
pfr = pandas_profiling.ProfileReport(data_train)
pfr.to_file(output_path + "data_train_pandas_profiling.html")
print('data_train pandas_profiling done')
del pfr
pfr = pandas_profiling.ProfileReport(data_test_a)
pfr.to_file(output_path + "data_test_a_pandas_profiling.html")
print('data_test_a pandas_profiling done')
del pfr
問題,windows環境下我裝的Python是32位的,結果pandas_profiling跑200M的訓練集失敗了
百度后: 更換為64位或者換到linux
切到linux環境下,結果conda安裝的一些package比較老
各種命令,嘗試pip和conda的解決沖突
不停地運行->報錯-》百度解決、運行->報錯->百度解決,逐步嘗試了以上的命令后,可以運行了
幾分鍾后, PicklingError: Could not pickle the task to send it to the workers.
細看是:OSError: [Errno 28] No space left on device
加內存到8G!同樣的問題,加到16G再試試!
VMVare 建議是13G, 於是我就給到了13G再試試!
簡單優化一下代碼,在全局import pandas_profiling
import datetime
import warnings
import pandas as pd
import pandas_profiling
warnings.filterwarnings('ignore')
if __name__ == '__main__':
# 0.1 公共變量
linux_file_path = '/mnt/阿里雲開發者-天池比賽/02_零基礎入門金融風控_貸款違約預測/'
train_file_path = linux_file_path + 'train.csv'
testA_file_path = linux_file_path + 'testA.csv'
now = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
output_path = linux_file_path + 'profiling/'
# 0.2 數據讀取pandas
data_train = pd.read_csv(train_file_path)
data_test_a = pd.read_csv(testA_file_path)
# print('Train Data shape 行*列:',data_train.shape)
# print('TestA Data shape 行*列:',data_test_a.shape)
# print('易得\n'
# '結果列 isDefault\n'
# 'testA相較於train多出兩列: \'n2.2\' \'n2.3\' ')
# 2.3.5 用pandas_profiling生成數據報告
pfr = pandas_profiling.ProfileReport(data_train)
pfr.to_file(output_path + "data_train_pandas_profiling.html")
print('data_train pandas_profiling done')
pfr = pandas_profiling.ProfileReport(data_test_a)
pfr.to_file(output_path + "data_test_a_pandas_profiling.html")
print('data_test_a pandas_profiling done')
pandas_profiling 運行截圖
要是不行的話, 我只能放棄了,上天池新的運行環境了!
還是不行,我仔細看了看報錯原因
是寫操作失敗了, 磁盤容量不足
復現同樣的問題
pickler.file_handle.write(chunk.tobytes('C'))
OSError: [Errno 28] No space left on device
_pickle.PicklingError: Could not pickle the task to send it to the workers.
磁盤擴容沒有生效
VMVare修改磁盤大小后不生效的解決方法
嘗試解決url: https://www.dazhuanlan.com/2020/02/13/5e44f3ad0be26/?cf_chl_jschl_tk=2b53a2c8ea315e4f4cba235c84ac7448a323d431-1600617230-0-AYQU3tXZfEUPfk4xH2FBguZesxOT95zBlsuHO7HmD1S_Rin3dAuzIWYW1O5VFNn_ETNLCSeqYN4tLbSgzrWJV-LImCBYEAdFvop7EoearuJgreFKk1ECqLj1jxUvMLlE8B6u1Ny03hVZRyzHP2V_2ORr8OhceS_8Wa-l4ufY7RO4xVqWJyUQAEwYRUDQB9lbfOYsusuXabD9geOX7QnY7Gn2RX_LnhNtasyziXqohZJJhzKN2Q5muaFVMw969Aj3cimI9NAhGGOgmXajUAWpeNjLNG9LQHjkHsqqWL4zwG1wnW1VZZ6haMbUhURaUAlMxA
fdisk -l 查看磁盤容量,重跑一次,可以
接着清理了/root目錄下的內存
第N次后的結果
報錯:
pickler.file_handle.write(chunk.tobytes('C'))
OSError: [Errno 28] No space left on device...
第N+1次,請教了一下朋友,順帶把他的結果順了過來
接着百度, [可以斷定是內存不足,並且win32位的python不支持超過2G的內存使用,導致存在問題;虛擬機給到了8G,但是臨時存儲不夠導致picklerError]
上阿里雲的免費資源平台, 直接爆了內存
上百度雲的AI Studio平台來跑,倒是可以的; 占用了9.66個G的內存
我當場就知道原因了
https://ai.baidu.com/ai-doc/AISTUDIO/sk3e2z8sb
附上AI-Studio的運行日志
運行時長: 19分34秒132毫秒
結束時間: 2020-09-22 21:46:27
2020-09-22 21:26:53.412621
output_path work/profiling/
HBox(children=(FloatProgress(value=0.0, description='Summarize dataset', max=61.0, style=ProgressStyle(descrip…
HBox(children=(FloatProgress(value=0.0, description='Generate report structure', max=1.0, style=ProgressStyle(…
HBox(children=(FloatProgress(value=0.0, description='Render HTML', max=1.0, style=ProgressStyle(description_wi…
data_train pandas_profiling done
HBox(children=(FloatProgress(value=0.0, description='Export report to file', max=1.0, style=ProgressStyle(desc…
HBox(children=(FloatProgress(value=0.0, description='Summarize dataset', max=62.0, style=ProgressStyle(descrip…
HBox(children=(FloatProgress(value=0.0, description='Generate report structure', max=1.0, style=ProgressStyle(…
HBox(children=(FloatProgress(value=0.0, description='Render HTML', max=1.0, style=ProgressStyle(description_wi…
AI-studio 的 CPU2-4核跑的太慢了,本地重裝了一遍Miniconda3;
卸載了輕量版的Miniconda3, 重裝了一遍全量版的Anaconda——已經預制好了各種package,直接base環境,完美運行了
我哭了,直接裝上Anaconda,就相當於把Python和一些如Numpy、Pandas、Scrip、Matplotlib等常用的庫自動安裝好了,DLL的異常也沒有了(也預制好了)。
(當然你還需要配置好環境變量,小菜一碟,見下,記得重啟)
win10安裝anaconda3和PyCharm教程
https://blog.csdn.net/simonforfuture/article/details/100627338
下一步,上GPU版本的lgb和xgboost來跑模型,不浪費AI-studio 的 32G顯存!
未完待續...
當然還有其他的匪夷所思的問題,比如 “'PandasArray' object has no attribute '_str_len'”
pandas_profiling的github里有issuse,可以具體看看。
我這里直接重新建一個環境,只安裝pandas+pandas_profiling+numpy+python3.7.1這幾個基本庫,這個樣子就沒有沖突了。
conda create -n profling python=3.7.1
conda activate profling
pip install pandas numpy datetime pandas_profiling
數據報告生成完成
-
Overview 數據預覽
-
每種屬性列的詳情信息 非重復率 缺失率 極大值/極小值/MEAN 零值
a. 還可以區分數字類型/對象類型/類別類型 見列名下面的英文字母
b. 還有相應的推測, 如MISSING/ZEROS/高度相關等
-
Interactions 相互作用 (可以沒有label列)
-
相關性 (可以展示相關的詳情)
-
缺失值的展示
-
Sample First rows和Last rows個10列
沒有數據省略,很nice~