Mljar python包装器api“没有这样的文件或目录”

2024-05-14 06:15:28 发布

您现在位置:Python中文网/ 问答频道 /正文

当我尝试使用mljarapi的python包装器来拟合模型时,出现了Ups, [Errno 2] No such file or directory错误

有人知道怎么解决这个问题吗

代码:

from sklearn import datasets

iris = datasets.load_iris()
X, y = iris.data, iris.target

from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)

from mljar import Mljar

models = Mljar(
    project='MLJAR api test', experiment='Iris',
    metric='logloss',
    validation_kfolds=5, # we will use 5-fold CV with stratify and shuffle
    validation_shuffle=True,
    validation_stratify=True,
    algorithms=['xgb', 'lgb', 'mlp'], # select Xgboost, LightGBM and Neural Network
    tuning_mode='Normal', # number of models to be checked for each algorithm
    single_algorithm_time_limit=5
)

models.fit(X_train, y_train)

出于某种原因,没有回溯。我只是得到一个错误: Ups, [Errno 2] No such file or directory: /tmp/dataset-002317be.csv


Tags: ornofromtestimportirismodels错误
1条回答
网友
1楼 · 发布于 2024-05-14 06:15:28

我刚想出来

这是位于C:\Users\username\AppData\Local\Continuum\anaconda2\Lib\site packages\mljar\client\dataset.py的python api包装器代码的一部分

def add_new_dataset(self, data, y, title_prefix = 'dataset-'):
    [...]
    file_path = '/tmp/dataset-'+ str(uuid.uuid4())[:8]+'.csv'
    [...]
    data.to_csv(file_path, index=False)

它试图在/tmp创建数据集文件,但目录不存在。 在我看来,解决这个问题的最好方法是在当前驱动器的根目录下创建一个tmp文件夹。 在我的例子中,这是共享网络驱动器,其中没有/tmp文件夹

我还找到了导致丢失回溯的代码部分: C:\Users\username\AppData\Local\Continuum\anaconda2\Lib\site packages\mljar\mljar.py

except Exception as e:
    print 'Ups, %s' % str(e)

相关问题 更多 >