शुरू करेंमुफ़्त में शुरू करें

Scaled Comparison Cloud

क्या आपको रेंटल रिव्यूज़ में polarity स्कोर की "grade inflation" याद है? कई बार, नई इंसाइट निकालने का एक तरीका यह है कि स्कोर को 0 के आसपास स्केल कर दें और फिर कॉर्पस का subset बनाएं. ऐसा करने पर, मीन 0 होने से पहले जो कमेंट पॉज़िटिव थे वे नेगेटिव हिस्से में जा सकते हैं या उल्टा भी हो सकता है. इस अभ्यास में आप स्कोर को स्केल करेंगे और फिर comparison.cloud() दोबारा प्लॉट करेंगे. "grade inflation" हटाने से अतिरिक्त समझ मिल सकती है.

पहले आपने polarity() को bos_reviews$comments पर लगाया था और एक comparison.cloud() बनाया था. इस अभ्यास में आप scale() को आउटपुट पर लागू करेंगे और फिर comparison.cloud() बनाएँगे. देखें कि क्या विज़ुअल में कुछ नया दिखता है!

क्योंकि यह काफी हद तक रिव्यू अभ्यास है, ज़्यादातर कोड मौजूद है. बस सही ऑब्जेक्ट्स और पैरामीटर्स भरिए!

यह अभ्यास पाठ्यक्रम का हिस्सा है

R में Sentiment Analysis

पाठ्यक्रम देखें

अभ्यास निर्देश

  • प्री-लोडेड bos_pol$all का एक हिस्सा इंडेक्सिंग [1:6,1:3] से रिव्यू करें.
  • scaled_polarity नाम का नया कॉलम जोड़ें और scale() को polarity स्कोर कॉलम bos_pol$all$polarity पर लागू करें.
  • पॉज़िटिव कमेंट्स के लिए, वहाँ subset() करें जहाँ नया कॉलम bos_reviews$scaled_polarity शून्य से बड़ा (>) हो.
  • नेगेटिव कमेंट्स के लिए, वहाँ subset() करें जहाँ नया कॉलम bos_reviews$scaled_polarity शून्य से छोटा (<) हो.
  • pos_comments पर paste() लगाकर pos_terms बनाएँ.
  • अब neg_comments पर paste() लगाकर neg_terms बनाएँ.
  • collapsed डॉक्यूमेंट्स pos_terms और neg_terms को एक ही कॉर्पस में संगठित करें जिसका नाम all_terms हो.
  • सामान्य tm workflow का पालन करते हुए VectorSource() को VCorpus() के भीतर nest करके all_terms पर लागू करें.
  • all_corpus ऑब्जेक्ट का उपयोग करते हुए TermDocumentMatrix() बनाएँ. ध्यान दें, यह TfIdf weighted TDM है जिसमें बेसिक क्लीनिंग फंक्शंस हैं.
  • as.matrix() से all_tdm को all_tdm_m में बदलें. फिर मौजूदा कोड में कॉलम के नाम "positive" और "negative" रखें.
  • आखिर में! मैट्रिक्स ऑब्जेक्ट all_tdm_m पर comparison.cloud() लगाएँ. नए सबसे अधिक बार आने वाले नेगेटिव शब्दों पर ध्यान दें. हो सकता है इससे कोई छुपी हुई इंसाइट मिले!

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Review
___

# Scale/center & append
bos_reviews$___ <- scale(___)

# Subset positive comments
pos_comments <- subset(bos_reviews$comments, ___)

# Subset negative comments
neg_comments <- subset(bos_reviews$comments, ___)

# Paste and collapse the positive comments
pos_terms <- paste(___, collapse = " ")

# Paste and collapse the negative comments
neg_terms <- paste(___, collapse = " ")

# Organize
all_terms<- c(___, ___)

# VCorpus
all_corpus <- ___(VectorSource(___))

# TDM
all_tdm <- TermDocumentMatrix(
  ___, 
  control = list(
    weighting = weightTfIdf, 
    removePunctuation = TRUE, 
    stopwords = stopwords(kind = "en")
  )
)

# Column names
___ <- as.matrix(___)
colnames(all_tdm_m) <- c("___", "___")

# Comparison cloud
comparison.cloud(
  ___, 
  max.words = 100,
  colors = c("darkgreen", "darkred")
)
कोड संपादित करें और चलाएँ