亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我在 Python 中使用帶有 MLeap 的 Scikit-Learn

我在 Python 中使用帶有 MLeap 的 Scikit-Learn

精慕HU 2022-12-20 16:44:40
試過了:#Generate dataimport pandas as pd import numpy as npdf = pd.DataFrame(np.random.randn(100, 5), columns=['a', 'b', 'c', 'd', 'e'])df["y"] = (df['a'] > 0.5).astype(int)df.head()from mleap.sklearn.ensemble.forest import RandomForestClassifierforestModel = RandomForestClassifier()forestModel.mlinit(input_features='a',                   feature_names='a',                           prediction_column='e_binary')forestModel.fit(df[['a']], df[['y']])forestModel.serialize_to_bundle("jar:file:/dbfs/FileStore/tables/mleaptestmodelforestpysparkzip", "randomforest.zip")我收到此錯誤:No such file or directory: 'jar:file:/dbfs/FileStore/tables/mleaptestmodelforestpysparkzip/randomforest.zip.node'我也試過了:forestModel.serialize_to_bundle("jar:file:/dbfs/FileStore/tables/mleaptestmodelforestpysparkzip/randomforest.zip")并收到一條錯誤消息,指出缺少“model_name”屬性。請問你能幫幫我嗎?我添加了我嘗試做的所有事情以及我得到的結果:管道到 Zip:1.pipeline.serialize_to_bundle("jar:file:/dbfs/FileStore/tables/mleap/pipeline_zip/1/model.zip", model_name="forest")=> FileNotFoundError: [Errno 2] 沒有這樣的文件或目錄:'jar:file:/dbfs/FileStore/tables/mleap/pipeline_zip/1/model.zip/model.json'2.pipeline.serialize_to_bundle("jar:file:/dbfs/FileStore/tables/mleap/pipeline_zip/1/model.zip", model_name="forest", init=True)FileNotFoundError: [Errno 2] 沒有這樣的文件或目錄:'jar:file:/dbfs/FileStore/tables/mleap/pipeline_zip/1/model.zip/forest'要壓縮的模型forest.serialize_to_bundle("jar:file:/dbfs/FileStore/tables/mleap/random_forest_zip/1/model.zip", model_name="forest")=> FileNotFoundError: [Errno 2] 沒有這樣的文件或目錄:'jar:file:/dbfs/FileStore/tables/mleap/random_forest_zip/1/model.zip/forest.node'forest.serialize_to_bundle("jar:file:/dbfs/FileStore/tables/mleap/random_forest_zip/1", model_name="model.zip")=> FileNotFoundError: [Errno 2] 沒有這樣的文件或目錄:'jar:file:/dbfs/FileStore/tables/mleap/random_forest_zip/1/model.zip.node'forest.serialize_to_bundle("/dbfs/FileStore/tables/mleap/random_forest_zip/1", model_name="model.zip")=> 不要保存 zip。而是保存一個包。
查看完整描述

1 回答

?
天涯盡頭無女友

TA貢獻1831條經驗 獲得超9個贊

我發現了問題和解決方法。

不再可能使用 Databricks 進行隨機寫入,如下所述:https ://docs.databricks.com/data/databricks-file-system.html?_ga=2.197884399.1151871582.1592826411-509486897.1589442523#local-file-apis

解決方法是在本地文件系統中寫入 zip 文件,然后將其復制到 DBFS 中。所以:

  1. 使用“init=True”在管道中序列化您的模型,將其保存在本地目錄中

  2. 使用“dbutils.fs.cp(source, destination)”將其復制到您的數據湖

dbutils.fs.cp(來源,目的地)


查看完整回答
反對 回復 2022-12-20
  • 1 回答
  • 0 關注
  • 118 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號