KeyError: 'irrelevant' In dictionary while sentiment analysis using Naive and SVMSentiment Analysis DictionariesSentiment Analysis in Spanish - DictionaryHow to train the Stanford NLP Sentiment Analysis toolNaive Bayes Sentiment Analysis of Facebook PostStanford NLP core Sentiment Analysis using Naive Bayes and SVM classifierJavaHow to Improve python code for Sentiment Analysis Using NLTKinterpret sentiment analysis result (naive baye, svm , maxent)Tensorflow lstm for sentiment analysis not learning. UPDATEDPoS Implementation with Naive Bayes Sentiment AnalysisSentiment Analysis, Naive Bayes Accuracy
Cyclic queue using an array in C#
How is it believable that Euron could so easily pull off this ambush?
Was Mohammed the most popular first name for boys born in Berlin in 2018?
What predictive model to use for Gender?
When an electron around an atom drops to a lower state, is 100% of the energy converted to a photon?
And now you see it II (the B side)
How do integrated charger ICs dissipate differences in VCC and the battery voltage?
Why did Ham the Chimp push levers?
Why are thrust reversers not used down to taxi speeds?
Why is the episode called "The Last of the Starks"?
What are my options legally if NYC company is not paying salary?
My Sixteen Friendly Students
How to append code verbatim to .bashrc?
My parents are Afghan
Creating Stored Procedure in local db that references tables in linked server
How can it be that ssh somename works, while nslookup somename does not?
When was it publicly revealed that a KH-11 spy satellite took pictures of the first Shuttle flight?
Is your maximum jump distance halved by grappling?
Is it a good idea to copy a trader when investing?
What's the difference between "ricochet" and "bounce"?
How long can fsck take on a 30 TB volume?
Is there an idiom that means "revealing a secret unintentionally"?
Wiper fluid only squirts out for a second - Hyundai Accent 2006
Is it safe to keep the GPU on 100% utilization for a very long time?
KeyError: 'irrelevant' In dictionary while sentiment analysis using Naive and SVM
Sentiment Analysis DictionariesSentiment Analysis in Spanish - DictionaryHow to train the Stanford NLP Sentiment Analysis toolNaive Bayes Sentiment Analysis of Facebook PostStanford NLP core Sentiment Analysis using Naive Bayes and SVM classifierJavaHow to Improve python code for Sentiment Analysis Using NLTKinterpret sentiment analysis result (naive baye, svm , maxent)Tensorflow lstm for sentiment analysis not learning. UPDATEDPoS Implementation with Naive Bayes Sentiment AnalysisSentiment Analysis, Naive Bayes Accuracy
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am doing Sentiment analysis using Naive bays and SVM,
i refered this code https://github.com/sravyaysk/MyProjects/blob/master/SentimentAnalysis.py
I converted this implementation in python 3, Here is code to implement it assigns positive as 1 and negative as 2, I added neutral as 3 but it still return's error as irrelevant
My code's and dataset
https://drive.google.com/drive/folders/1NiZC7DNOkzpUFZ1X6PjD2rrn99TGXnkL?usp=sharing
this is the part of code where I am getting error: SVM.py
labels_to_array="positive":1,"negative":2
labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
y=np.array(labels)
ERROR:
KeyError Traceback (most recent call last)
<ipython-input-11-d1d8945f9453> in <module>
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
<ipython-input-11-d1d8945f9453> in <listcomp>(.0)
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
KeyError: 'neutral'
python-3.x nltk sentiment-analysis naivebayes
add a comment |
I am doing Sentiment analysis using Naive bays and SVM,
i refered this code https://github.com/sravyaysk/MyProjects/blob/master/SentimentAnalysis.py
I converted this implementation in python 3, Here is code to implement it assigns positive as 1 and negative as 2, I added neutral as 3 but it still return's error as irrelevant
My code's and dataset
https://drive.google.com/drive/folders/1NiZC7DNOkzpUFZ1X6PjD2rrn99TGXnkL?usp=sharing
this is the part of code where I am getting error: SVM.py
labels_to_array="positive":1,"negative":2
labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
y=np.array(labels)
ERROR:
KeyError Traceback (most recent call last)
<ipython-input-11-d1d8945f9453> in <module>
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
<ipython-input-11-d1d8945f9453> in <listcomp>(.0)
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
KeyError: 'neutral'
python-3.x nltk sentiment-analysis naivebayes
1
Hi, you need to post the relevant code you wrote and the full error message in the question. Don't ask people to click on external links and to read long code.
– AlexK
Mar 23 at 7:37
Do you have "neutral" in the labels_to_array dictionary or not? In the code you posted you don't have it, but in the error message you do. KeyError means that Python can't find that key.
– AlexK
Mar 23 at 19:09
@AlexK yes in the dictionary i have added this label , when I remove "neutral" label it returns keyerror : neutral and if i add back into dictionary it returns key error:"irrelevant"
– Ashutosh Eve
Mar 24 at 10:00
1
So then you need to add "irrelevant" to that labels_to_array dictionary, because Python is complaining that it can't find that key.
– AlexK
Mar 24 at 19:38
add a comment |
I am doing Sentiment analysis using Naive bays and SVM,
i refered this code https://github.com/sravyaysk/MyProjects/blob/master/SentimentAnalysis.py
I converted this implementation in python 3, Here is code to implement it assigns positive as 1 and negative as 2, I added neutral as 3 but it still return's error as irrelevant
My code's and dataset
https://drive.google.com/drive/folders/1NiZC7DNOkzpUFZ1X6PjD2rrn99TGXnkL?usp=sharing
this is the part of code where I am getting error: SVM.py
labels_to_array="positive":1,"negative":2
labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
y=np.array(labels)
ERROR:
KeyError Traceback (most recent call last)
<ipython-input-11-d1d8945f9453> in <module>
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
<ipython-input-11-d1d8945f9453> in <listcomp>(.0)
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
KeyError: 'neutral'
python-3.x nltk sentiment-analysis naivebayes
I am doing Sentiment analysis using Naive bays and SVM,
i refered this code https://github.com/sravyaysk/MyProjects/blob/master/SentimentAnalysis.py
I converted this implementation in python 3, Here is code to implement it assigns positive as 1 and negative as 2, I added neutral as 3 but it still return's error as irrelevant
My code's and dataset
https://drive.google.com/drive/folders/1NiZC7DNOkzpUFZ1X6PjD2rrn99TGXnkL?usp=sharing
this is the part of code where I am getting error: SVM.py
labels_to_array="positive":1,"negative":2
labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
y=np.array(labels)
ERROR:
KeyError Traceback (most recent call last)
<ipython-input-11-d1d8945f9453> in <module>
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
<ipython-input-11-d1d8945f9453> in <listcomp>(.0)
161 # Lets map positive to 1 and negative to 2 so that everything is nicely represented as arrays
162 labels_to_array="neutral":1,"negative":2,"positive":3
--> 163 labels=[labels_to_array[tweet[1]] for tweet in ppTrainingData]
164 y=np.array(labels)
165
KeyError: 'neutral'
python-3.x nltk sentiment-analysis naivebayes
python-3.x nltk sentiment-analysis naivebayes
edited Mar 23 at 8:08
Ashutosh Eve
asked Mar 23 at 7:15
Ashutosh EveAshutosh Eve
367
367
1
Hi, you need to post the relevant code you wrote and the full error message in the question. Don't ask people to click on external links and to read long code.
– AlexK
Mar 23 at 7:37
Do you have "neutral" in the labels_to_array dictionary or not? In the code you posted you don't have it, but in the error message you do. KeyError means that Python can't find that key.
– AlexK
Mar 23 at 19:09
@AlexK yes in the dictionary i have added this label , when I remove "neutral" label it returns keyerror : neutral and if i add back into dictionary it returns key error:"irrelevant"
– Ashutosh Eve
Mar 24 at 10:00
1
So then you need to add "irrelevant" to that labels_to_array dictionary, because Python is complaining that it can't find that key.
– AlexK
Mar 24 at 19:38
add a comment |
1
Hi, you need to post the relevant code you wrote and the full error message in the question. Don't ask people to click on external links and to read long code.
– AlexK
Mar 23 at 7:37
Do you have "neutral" in the labels_to_array dictionary or not? In the code you posted you don't have it, but in the error message you do. KeyError means that Python can't find that key.
– AlexK
Mar 23 at 19:09
@AlexK yes in the dictionary i have added this label , when I remove "neutral" label it returns keyerror : neutral and if i add back into dictionary it returns key error:"irrelevant"
– Ashutosh Eve
Mar 24 at 10:00
1
So then you need to add "irrelevant" to that labels_to_array dictionary, because Python is complaining that it can't find that key.
– AlexK
Mar 24 at 19:38
1
1
Hi, you need to post the relevant code you wrote and the full error message in the question. Don't ask people to click on external links and to read long code.
– AlexK
Mar 23 at 7:37
Hi, you need to post the relevant code you wrote and the full error message in the question. Don't ask people to click on external links and to read long code.
– AlexK
Mar 23 at 7:37
Do you have "neutral" in the labels_to_array dictionary or not? In the code you posted you don't have it, but in the error message you do. KeyError means that Python can't find that key.
– AlexK
Mar 23 at 19:09
Do you have "neutral" in the labels_to_array dictionary or not? In the code you posted you don't have it, but in the error message you do. KeyError means that Python can't find that key.
– AlexK
Mar 23 at 19:09
@AlexK yes in the dictionary i have added this label , when I remove "neutral" label it returns keyerror : neutral and if i add back into dictionary it returns key error:"irrelevant"
– Ashutosh Eve
Mar 24 at 10:00
@AlexK yes in the dictionary i have added this label , when I remove "neutral" label it returns keyerror : neutral and if i add back into dictionary it returns key error:"irrelevant"
– Ashutosh Eve
Mar 24 at 10:00
1
1
So then you need to add "irrelevant" to that labels_to_array dictionary, because Python is complaining that it can't find that key.
– AlexK
Mar 24 at 19:38
So then you need to add "irrelevant" to that labels_to_array dictionary, because Python is complaining that it can't find that key.
– AlexK
Mar 24 at 19:38
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311514%2fkeyerror-irrelevant-in-dictionary-while-sentiment-analysis-using-naive-and-sv%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311514%2fkeyerror-irrelevant-in-dictionary-while-sentiment-analysis-using-naive-and-sv%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Hi, you need to post the relevant code you wrote and the full error message in the question. Don't ask people to click on external links and to read long code.
– AlexK
Mar 23 at 7:37
Do you have "neutral" in the labels_to_array dictionary or not? In the code you posted you don't have it, but in the error message you do. KeyError means that Python can't find that key.
– AlexK
Mar 23 at 19:09
@AlexK yes in the dictionary i have added this label , when I remove "neutral" label it returns keyerror : neutral and if i add back into dictionary it returns key error:"irrelevant"
– Ashutosh Eve
Mar 24 at 10:00
1
So then you need to add "irrelevant" to that labels_to_array dictionary, because Python is complaining that it can't find that key.
– AlexK
Mar 24 at 19:38