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;








0















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'









share|improve this question



















  • 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

















0















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'









share|improve this question



















  • 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













0












0








0








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'









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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












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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript