真实数据的模糊逻辑

时间:2019-06-02 00:39:18

标签: python fuzzy-logic skfuzzy

有人可以帮我吗?如何将真实的财务数据重写为模糊逻辑?我已经制定了会员职能和规则。我正在使用带有skfuzzy库的Python 3.7。

#Input (I have around 12)
candle1_UpperShadow = ctrl.Antecedent(np.arange(0,math.ceil(df5.UpperShadow1.max()),1), 'candle1_UpperShadow')

#Output (I have 3)
pattern_Single = ctrl.Consequent(np.arange(0,9,1),'pattern_Single')

#Membership function 
names_UpperShadow1 = ['Very_Short','Short','Long','Very_Long']
candle1_UpperShadow.automf(names=names_UpperShadow1)

#Rules (I have 18)
hammer = ctrl.Rule(candle1_Color['Bullish'] | candle1_UpperShadow['Very_Short']| candle1_LowerShadow['Very_Long'], pattern_Single['Hammer'])

patterns_ctrl = ctrl.ControlSystem([hammer, hanging_man, inverted_hammer, shooting_star, bullish_engulfing, bearish_engulfing,
                                    tweezer_tops, tweezer_bottoms, morning_star, evening_star,three_white_soldiers, three_black_crows,
                                    three_inside_up, three_inside_down, spinning_top, doji, white_marubozu, black_marubozu])

patterns = ctrl.ControlSystemSimulation(patterns_ctrl)

patterns.input['candle1_Body'] = df5.Body1

df5['Pattern'] = patterns.compute()

但是当我尝试计算输出时,会显示此错误:

  

ValueError:具有多个元素的数组的真值是   暧昧。使用a.any()或a.all()。

我想要一个带有模糊逻辑输出的单独列。

我希望我的数据框看起来像这样:

    Body  Color    UpperShadow  LowerShadow  Pattern
1     Short |Bullish | Very_Short | Very_Long  | Hammer 

2     Long  |Bearish |Very_Short  | Very_Short | Black_Marubozu

0 个答案:

没有答案