Inter-topic Distance Map (Multidimensional Scaling) The visualization represents different topics as clusters in a two-dimensional space, showing how topics relate to each other based on the distances between them. Each cluster grouping can help identify overarching themes or categories in the dataset, useful for understanding the diversity of content or for segmenting data for more focused analysis.
Advanced ML Analytics
Topic Modeling
from gensim.parsing.preprocessing import preprocess_stringfrom gensim import corpora, modelsimport gensimimport pyLDAvis.gensim_models as gensimvisimport pyLDAvisimport pandas as pd# Load the datasetdata = pd.read_csv('main.csv')# Preprocess the textdef preprocess(text):return preprocess_string(text)# Apply preprocessingprocessed_docs = data['cleaned'].map(preprocess)# Create a dictionary and corpus needed for Topic Modelingdictionary = corpora.Dictionary(processed_docs)corpus = [dictionary.doc2bow(doc) for doc in processed_docs]# LDA modellda_model = models.LdaModel(corpus, num_topics=5, id2word=dictionary, passes=15, random_state=42)# Display the topicstopics = lda_model.print_topics(num_words=5)for topic in topics:print(topic)# Visualize the topicspyLDAvis.enable_notebook()# Visualize the topics with adjusted sizelda_display = gensimvis.prepare(lda_model, corpus, dictionary, sort_topics=False, plot_opts={'width': 800, 'height': 600}) # Adjust width and height as neededpyLDAvis.display(lda_display)
C:\Users\srinivas\AppData\Roaming\Python\Python38\site-packages\pyLDAvis\_prepare.py:243: FutureWarning:
In a future version of pandas all arguments of DataFrame.drop except for the argument 'labels' will be keyword-only
Sunburst Chart of Sentiment and Emotion This sunburst chart provides a hierarchical view of sentiment and emotion classification within your dataset. The inner rings may represent high-level sentiments (like positive, neutral, negative), while the outer rings show specific emotions (joy, anger, fear, etc.). This visualization is beneficial for quickly assessing the emotional tone and variability across the content, aiding in tasks like sentiment analysis or consumer perception studies.
Emotion Recognition and Sentiment Analysis
import pandas as pdimport plotly.express as pximport plotly.graph_objects as go# Load the datasetdata = pd.read_csv('main.csv')# Create a sunburst chart with sentiment (inside) and emotion (outside) using Plotlyfig_sunburst = px.sunburst(data, path=['sentiment', 'emotion'], title='Sunburst Chart of Sentiment and Emotion', color_continuous_scale='RdBu')fig_sunburst.show()
C:\Users\srinivas\AppData\Roaming\Python\Python38\site-packages\plotly\io\_renderers.py:396: DeprecationWarning:
distutils Version classes are deprecated. Use packaging.version instead.
C:\Users\srinivas\AppData\Roaming\Python\Python38\site-packages\plotly\io\_renderers.py:396: DeprecationWarning:
distutils Version classes are deprecated. Use packaging.version instead.