【问题标题】:pycaret giving error:PermissionError: [WinError 32] The process cannot access the file because it is being used by another processpycaret 给出错误:PermissionError: [WinError 32] 该进程无法访问该文件,因为它正在被另一个进程使用
【发布时间】:2020-07-16 18:07:36
【问题描述】:

我在安装了 pycaret 和 pycharm 的 Windows 上使用 anaconda 环境。 我想用 pycaret 运行一个基本的玩具示例(不使用免费提供的数据集), 作为一个简单的 y=mx+c,其中 x 是 1-d

这是我使用 scikit 的工作代码。

import numpy as np
from sklearn.linear_model import LinearRegression
import pandas as pd
x= np.arange(0,1000,dtype = 'float64')
Y = (x*2) + 1
X = x.reshape(-1,1)
reg = LinearRegression().fit(X, Y)
# if predicting on same model,perfect score
score = reg.score(X,Y)
print('1- RSS/TSS: 1 for perfect regression=' + str(score))
print('coef =' + str(reg.coef_[0]))  # slope
print('intercept =' + str(reg.intercept_))  # intercept

这给出了如下的预期结果:

现在,我创建了可以传递给 pycaret pacakge 的 Dataframe。

data1 = np.vstack((x,Y)).transpose()
# create dataframe as required by Pandas
N= data1.shape[0]
# add first row
dat2 = np.array(['','Col1','Col2'])
for i in range(N):
    dat_row = list(data1[i,:].flatten())
    nm = ['row'+ str(i)]
    dat_row = nm + dat_row
    dat2 = np.vstack ((dat2, dat_row) )

df= pd.DataFrame(data=dat2[1:,1:],
                  index=dat2[1:,0],
                  columns=dat2[0,1:])
print(df)
print('***************************')
columns = df.applymap(np.isreal).all()
print(columns)
print('***************************')
# now, using Pycaret
from pycaret.regression import *
exp_reg = setup(df, html= False,target='Col2')
print('********************************')
compare_models()

当我这样做时, 我创建的数字列 (x,y) 显示为分类。这也认 由 pyCaret 作为 Categorical.see 下图。 为什么这是分类的?我可以将其更改为数字吗?

一旦我按下回车键,Pycaret 就会给我下面的错误:

对这个错误有什么想法吗?
赛迪

【问题讨论】:

    标签: python pycaret


    【解决方案1】:

    您可以通过在setup 函数中使用numeric_featurescategorical_features 参数来强制在setup 函数中使用PyCaret 中的数据类型。

    例如:

    clf1 = setup(data, target = 'target', numeric_features = ['X1', 'X2'])
    

    【讨论】:

      猜你喜欢
      • 2015-11-13
      • 2015-01-28
      • 2020-10-31
      • 2017-06-02
      • 2021-09-21
      • 2019-11-26
      • 1970-01-01
      • 2018-10-28
      • 2022-11-14
      相关资源
      最近更新 更多