简体   繁体   English

__init__() 为参数“use_technical_indicator”获得了多个值 - 错误

[英]__init__() got multiple values for argument 'use_technical_indicator' - error

I can't figure out why I am getting this error.我不知道为什么我会收到这个错误。 If you can figure it out, I'd appreciate it.如果你能弄清楚,我将不胜感激。 If you can provide specific instruction, I'd appreciate it.如果您能提供具体的指导,我将不胜感激。 This code is in one module;此代码在一个模块中; there are 7 modules total.共有7个模块。 在此处输入图像描述 Python 3.7, Mac OS, code from www.finrl.org Python 3.7,Mac OS,代码来自www.finrl.org

# Perform Feature Engineering:
df = FeatureEngineer(df.copy(),
                    use_technical_indicator=True,
                    use_turbulence=False).preprocess_data()


# add covariance matrix as states
df=df.sort_values(['date','tic'],ignore_index=True)
df.index = df.date.factorize()[0]

cov_list = []
# look back is one year
lookback=252
for i in range(lookback,len(df.index.unique())):
  data_lookback = df.loc[i-lookback:i,:]
  price_lookback=data_lookback.pivot_table(index = 'date',columns = 'tic', values = 'close')
  return_lookback = price_lookback.pct_change().dropna()
  covs = return_lookback.cov().values 
  cov_list.append(covs)
  
df_cov = pd.DataFrame({'date':df.date.unique()[lookback:],'cov_list':cov_list})
df = df.merge(df_cov, on='date')
df = df.sort_values(['date','tic']).reset_index(drop=True)
df.head() 

The function definition statement for FeatureEngineer.__init__ is : FeatureEngineer.__init__的 function 定义语句是

 def __init__(
        self,
        use_technical_indicator=True,
        tech_indicator_list=config.TECHNICAL_INDICATORS_LIST,
        use_turbulence=False,
        user_defined_feature=False,
    ):

As you can see there is no argument (other than self which you should not provide) before use_technical_indicator , so you should remove the df.copy() from before the use_techincal_indicator in your line 2.如您所见,在use_technical_indicator之前没有任何参数(除了您不应该提供的 self ),因此您应该从第 2 行中的use_techincal_indicator之前删除 df.copy() 。

Checking the current FeatureEngineer class , you must to provide the df.copy() parameter to the preprocess_data() method.检查当前FeatureEngineer class ,您必须向preprocess_data()方法提供df.copy()参数。

So, your code have to look like:因此,您的代码必须如下所示:

# Perform Feature Engineering:
df = FeatureEngineer(use_technical_indicator=True,
                  tech_indicator_list = config.TECHNICAL_INDICATORS_LIST,
                  use_turbulence=True,
                  user_defined_feature = False).preprocess_data(df.copy())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 __init__() 为参数“crescator”获得了多个值 - __init__() got multiple values for argument 'crescator' __init__() 为参数“填充”获得了多个值 - __init__() got multiple values for argument 'padding' TypeError:__init __()为参数'n_splits'获取了多个值 - TypeError: __init__() got multiple values for argument 'n_splits' __init__() 为关键字参数“列”获得了多个值 - __init__() got multiple values for keyword argument 'columns' TypeError:__init __()为参数'fieldnames'获得了多个值 - TypeError: __init__() got multiple values for argument 'fieldnames' 类型错误:__init__() 为参数“strides”获得了多个值 - TypeError: __init__() got multiple values for argument 'strides' TypeError:__init__() 为参数“轴”获取了多个值 - TypeError: __init__() got multiple values for argument 'axes' Python TypeError:__ init __()为参数'master'获取了多个值 - Python TypeError: __init__() got multiple values for argument 'master' TypeError:__init __()为关键字参数“ choices”获得了多个值 - TypeError: __init__() got multiple values for keyword argument 'choices' windrose:__init __()获得了多个关键字参数值 - windrose: __init__() got multiple values for keyword argument
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM