0

i preparing a model where the input is "tweets", then i pass those tweets to VADER (to calculate polarity of each word to get a list finally, I pass it to fuzzy model:

# range input and output
text = ctrl.Antecedent(np.arange(-1, 1.1, 0.1), 'text')
hashtag = ctrl.Antecedent(np.arange(-1, 1.1, 0.1), 'hashtag')
emoji = ctrl.Antecedent(np.arange(-1, 1.1, 0.1), 'emoji')

sentiment = ctrl.Consequent(np.arange(-1, 1.1, 0.1), 'sentiment')

# status input and output

text['negative'] = fuzz.trapmf(text.universe, [-1,-1, -0.5, -0.1])
text['neutral'] = fuzz.trimf(text.universe, [ -0.2,0, 0.2])
text['positive'] = fuzz.trapmf(text.universe, [0.1, 0.5,1, 1])


hashtag['negative'] = fuzz.trapmf(hashtag.universe, [-1,-1, -0.5, -0.1])
hashtag['neutral'] = fuzz.trimf(hashtag.universe, [ -0.2,0, 0.2])
hashtag['positive'] = fuzz.trapmf(hashtag.universe, [0.1, 0.5,1, 1])

emoji['negative'] = fuzz.trapmf(emoji.universe, [-1,-1, -0.5, -0.1])
emoji['neutral'] = fuzz.trimf(emoji.universe, [ -0.2,0, 0.2])
emoji['positive'] = fuzz.trapmf(emoji.universe, [0.1, 0.5,1, 1])

and the rules are :

rule1 = ctrl.Rule( antecedent= text['positive'] & emoji['positive'] & (hashtag['positive'] | hashtag['neutral'])
                  |text['positive'] & emoji['neutral'] & hashtag['positive'],
                  consequent= sentiment['strongly positive'])

rule2 = ctrl.Rule(antecedent= text['positive'] & emoji['negative']& hashtag['positive'] |text['positive']& emoji['neutral']& hashtag['neutral'] |text['positive']& emoji['positive'] & hashtag['negative']
                  |text['neutral'] & emoji['positive']& hashtag['positive']|text['negative'] & emoji['positive']& hashtag['positive']| 
                  text['neutral'] & emoji['positive']& hashtag['neutral']| text['neutral'] & emoji['neutral']&hashtag['positive'],
                  consequent= sentiment['positive'])

rule3 = ctrl.Rule(antecedent= text['neutral'] & emoji['neutral']& hashtag['neutral']|text['positive']& emoji['negative'] & hashtag['negative'],
                  consequent= sentiment['neutral'])

rule4 = ctrl.Rule(antecedent= text['negative'] & emoji['positive']& hashtag['negative']| text['negative'] & emoji['neutral']& hashtag['neutral'] | text['neutral'] & emoji['neutral']& hashtag['negative']
                  |text['negative'] & emoji['negative']& hashtag['positive']|text['neutral'] & emoji['negative']& hashtag['negative']
                  |text['neutral'] & emoji['negative']& hashtag['neutral'],
                  consequent= sentiment['negative'])


rule5 = ctrl.Rule(antecedent= text['negative'] & emoji['negative']& hashtag['negative'] | text['negative'] & emoji['neutral'] & hashtag['negative']| 
                  text['negative'] & emoji['negative']&  hashtag['neutral'],
                  consequent= sentiment['strongly negative'])

when I run the fuzzy model error appears:

    l=[]
for dic_tweets in liste:
    for key in dic_tweets:
        bot.input['text'] = dic_tweets['text']
        bot.input['hashtag'] = dic_tweets['hashtag']
        bot.input['emoji'] = dic_tweets['emoji']
        bot.compute()
        l.append(bot.output['sentiment'])

ValueError: Crisp output cannot be calculated, likely because the system is too sparse. Check to make sure this set of input values will activate at least one connected Term in each Antecedent via the current set of Rules. and the output dataframe shows: the output

0 Answers0