File size: 1,373 Bytes
8c2d9a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from wordcloud import WordCloud

# Load the dataset internally within the EDA module
df = pd.read_csv('Danamon Mobile Banking Reviews(D-Bank Pro).csv')

def visualize_wordcloud():
    """Generate a word cloud for the 'content' column."""
    wordcloud = WordCloud(width=800, height=400, background_color='white').generate(' '.join(df['content']))
    
    plt.figure(figsize=(10, 7))
    plt.imshow(wordcloud, interpolation='bilinear')
    plt.axis('off')
    plt.title('Word Cloud for Reviews')
    return plt.gcf()  # Return the current figure

def plot_review_lengths():
    """Plot the distribution of review lengths."""
    review_lengths = df['content'].str.len()

    plt.figure(figsize=(12, 6))
    sns.histplot(review_lengths, bins=50, kde=True)
    plt.title('Distribution of Review Lengths')
    plt.xlabel('Review Length (characters)')
    plt.ylabel('Number of Reviews')
    return plt.gcf()  # Return the current figure

def rating_distribution():
    """Plot the distribution of ratings."""
    ratings = df['score'].value_counts()

    plt.figure(figsize=(10, 6))
    sns.barplot(x=ratings.index, y=ratings.values, palette="viridis")
    plt.title('Rating Distribution')
    plt.xlabel('Rating')
    plt.ylabel('Number of Reviews')
    return plt.gcf()  # Return the current figure