help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
text-classification
RSK World
text-classification
Text Classification Dataset - NLP + Multi-Class Classification + Machine Learning
text-classification
  • assets
  • data
  • models
  • notebooks
  • scripts
  • .gitignore1.4 KB
  • CHANGELOG.md2.6 KB
  • LICENSE3.2 KB
  • README.md11.1 KB
  • classifier.html34.1 KB
  • dashboard.html41.4 KB
  • explorer.html41.4 KB
  • index.html28.4 KB
  • requirements.txt1.8 KB
  • text-classification.svg4.6 KB
train.jsonindex.htmlfull_dataset.csvtext_classification_tutorial.ipynb
index.html
Raw Download
Find: Go to:
<!--
================================================================================
  Text Classification Dataset Project
================================================================================
  Project: Text Classification Dataset
  Category: Text Data / NLP
  Description: Multi-class text classification dataset with labeled documents 
               for news categorization, topic classification, and document analysis.
  
  Author: Molla Samser
  Designer & Tester: Rima Khatun
  Website: https://rskworld.in
  Email: help@rskworld.in | support@rskworld.in
  Phone: +91 93305 39277
  
  Copyright (c) 2026 RSK World - All Rights Reserved
  This content is provided for educational purposes only.
  
  Created: December 2026
  Last Modified: December 2026
================================================================================
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Text Classification Dataset - Multi-class text classification dataset with labeled documents for news categorization, topic classification, and document analysis. By RSK World.">
    <meta name="keywords" content="text classification, NLP, machine learning, dataset, news categorization, BERT, transformers, document classification, RSK World">
    <meta name="author" content="Molla Samser - RSK World">
    <meta name="robots" content="index, follow">
    
    <!-- Open Graph Meta Tags -->
    <meta property="og:title" content="Text Classification Dataset - RSK World">
    <meta property="og:description" content="Multi-class text classification dataset with labeled documents for NLP tasks.">
    <meta property="og:image" content="text-classification.png">
    <meta property="og:url" content="https://rskworld.in/text-classification/">
    <meta property="og:type" content="website">
    
    <!-- Twitter Card Meta Tags -->
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:title" content="Text Classification Dataset - RSK World">
    <meta name="twitter:description" content="Multi-class text classification dataset for NLP and machine learning.">
    
    <title>Text Classification Dataset | RSK World</title>
    
    <!-- Favicon -->
    <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
    
    <!-- Google Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Source+Sans+3:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
    
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    
    <!-- Custom CSS -->
    <link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
    <!-- Animated Background -->
    <div class="bg-animation">
        <div class="floating-shapes">
            <span></span><span></span><span></span><span></span><span></span>
            <span></span><span></span><span></span><span></span><span></span>
        </div>
    </div>

    <!-- Header -->
    <header class="header">
        <div class="container">
            <nav class="navbar">
                <a href="https://rskworld.in" class="logo">
                    <i class="fas fa-brain"></i>
                    <span>RSK<span class="highlight">World</span></span>
                </a>
                <ul class="nav-links">
                    <li><a href="#overview">Overview</a></li>
                    <li><a href="#features">Features</a></li>
                    <li><a href="#dataset">Dataset</a></li>
                    <li><a href="#usage">Usage</a></li>
                    <li><a href="#download">Download</a></li>
                    <li><a href="explorer.html"><i class="fas fa-search"></i> Explorer</a></li>
                    <li><a href="classifier.html"><i class="fas fa-robot"></i> Classifier</a></li>
                    <li><a href="dashboard.html" class="nav-highlight"><i class="fas fa-chart-line"></i> Dashboard</a></li>
                </ul>
                <button class="mobile-menu-btn" aria-label="Toggle Menu">
                    <span></span>
                    <span></span>
                    <span></span>
                </button>
            </nav>
        </div>
    </header>

    <!-- Hero Section -->
    <section class="hero">
        <div class="container">
            <div class="hero-content">
                <div class="hero-badge">
                    <i class="fas fa-file-alt"></i>
                    <span>Text Data</span>
                </div>
                <h1 class="hero-title">
                    Text Classification
                    <span class="gradient-text">Dataset</span>
                </h1>
                <p class="hero-description">
                    Multi-class text classification dataset with labeled documents for news categorization, 
                    topic classification, and document analysis. Perfect for NLP model training and research.
                </p>
                <div class="hero-stats">
                    <div class="stat-item">
                        <span class="stat-number" data-target="10000">0</span>
                        <span class="stat-label">Documents</span>
                    </div>
                    <div class="stat-item">
                        <span class="stat-number" data-target="6">0</span>
                        <span class="stat-label">Categories</span>
                    </div>
                    <div class="stat-item">
                        <span class="stat-number" data-target="3">0</span>
                        <span class="stat-label">Formats</span>
                    </div>
                </div>
                <div class="hero-actions">
                    <a href="#download" class="btn btn-primary">
                        <i class="fas fa-download"></i>
                        Download Dataset
                    </a>
                    <a href="#dataset" class="btn btn-outline">
                        <i class="fas fa-eye"></i>
                        Preview Data
                    </a>
                </div>
            </div>
            <div class="hero-visual">
                <div class="code-window">
                    <div class="window-header">
                        <div class="window-dots">
                            <span class="dot red"></span>
                            <span class="dot yellow"></span>
                            <span class="dot green"></span>
                        </div>
                        <span class="window-title">text_classifier.py</span>
                    </div>
                    <pre class="code-content"><code><span class="comment"># Text Classification with Transformers</span>
<span class="keyword">from</span> transformers <span class="keyword">import</span> AutoTokenizer
<span class="keyword">from</span> transformers <span class="keyword">import</span> AutoModelForSequenceClassification

<span class="comment"># Load pretrained model</span>
model_name = <span class="string">"bert-base-uncased"</span>
tokenizer = AutoTokenizer.from_pretrained(model_name)

<span class="comment"># Categories</span>
categories = [
    <span class="string">"Technology"</span>, <span class="string">"Sports"</span>,
    <span class="string">"Politics"</span>, <span class="string">"Entertainment"</span>,
    <span class="string">"Business"</span>, <span class="string">"Science"</span>
]

<span class="comment"># Classify text</span>
<span class="keyword">def</span> <span class="function">classify</span>(text):
    inputs = tokenizer(text, return_tensors=<span class="string">"pt"</span>)
    outputs = model(**inputs)
    <span class="keyword">return</span> categories[outputs.argmax()]</code></pre>
                </div>
            </div>
        </div>
    </section>

    <!-- Overview Section -->
    <section id="overview" class="section overview">
        <div class="container">
            <div class="section-header">
                <span class="section-badge">About Dataset</span>
                <h2 class="section-title">Comprehensive Text Classification Resource</h2>
                <p class="section-subtitle">
                    This dataset includes labeled documents across multiple categories for text classification tasks. 
                    Perfect for news categorization, topic classification, document analysis, and NLP model training.
                </p>
            </div>
            <div class="overview-grid">
                <div class="overview-card">
                    <div class="card-icon">
                        <i class="fas fa-newspaper"></i>
                    </div>
                    <h3>News Categorization</h3>
                    <p>Classify news articles into categories like technology, sports, politics, and more.</p>
                </div>
                <div class="overview-card">
                    <div class="card-icon">
                        <i class="fas fa-tags"></i>
                    </div>
                    <h3>Topic Classification</h3>
                    <p>Identify main topics and themes from unstructured text documents.</p>
                </div>
                <div class="overview-card">
                    <div class="card-icon">
                        <i class="fas fa-file-alt"></i>
                    </div>
                    <h3>Document Analysis</h3>
                    <p>Analyze and categorize large volumes of documents automatically.</p>
                </div>
                <div class="overview-card">
                    <div class="card-icon">
                        <i class="fas fa-robot"></i>
                    </div>
                    <h3>Model Training</h3>
                    <p>Train and fine-tune transformer models like BERT for text classification.</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Features Section -->
    <section id="features" class="section features">
        <div class="container">
            <div class="section-header">
                <span class="section-badge">Features</span>
                <h2 class="section-title">Dataset Features</h2>
            </div>
            <div class="features-list">
                <div class="feature-item">
                    <div class="feature-icon">
                        <i class="fas fa-layer-group"></i>
                    </div>
                    <div class="feature-content">
                        <h3>Multiple Document Categories</h3>
                        <p>6 distinct categories covering technology, sports, politics, entertainment, business, and science topics.</p>
                    </div>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">
                        <i class="fas fa-check-circle"></i>
                    </div>
                    <div class="feature-content">
                        <h3>Labeled Training Data</h3>
                        <p>All documents are professionally labeled with accurate category assignments for supervised learning.</p>
                    </div>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">
                        <i class="fas fa-balance-scale"></i>
                    </div>
                    <div class="feature-content">
                        <h3>Test and Validation Sets</h3>
                        <p>Pre-split into training, validation, and test sets for proper model evaluation.</p>
                    </div>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">
                        <i class="fas fa-cogs"></i>
                    </div>
                    <div class="feature-content">
                        <h3>Preprocessed Versions</h3>
                        <p>Includes cleaned, tokenized, and normalized versions ready for immediate use.</p>
                    </div>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">
                        <i class="fas fa-microchip"></i>
                    </div>
                    <div class="feature-content">
                        <h3>Transformer Ready Format</h3>
                        <p>Formatted for direct use with BERT, RoBERTa, and other transformer architectures.</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Technologies Section -->
    <section class="section technologies">
        <div class="container">
            <div class="section-header">
                <span class="section-badge">Technologies</span>
                <h2 class="section-title">Compatible Technologies</h2>
            </div>
            <div class="tech-grid">
                <div class="tech-card">
                    <i class="fas fa-file-csv"></i>
                    <span>CSV</span>
                </div>
                <div class="tech-card">
                    <i class="fas fa-file-alt"></i>
                    <span>TXT</span>
                </div>
                <div class="tech-card">
                    <i class="fas fa-code"></i>
                    <span>JSON</span>
                </div>
                <div class="tech-card">
                    <i class="fas fa-exchange-alt"></i>
                    <span>Transformers</span>
                </div>
                <div class="tech-card">
                    <i class="fas fa-brain"></i>
                    <span>BERT</span>
                </div>
            </div>
        </div>
    </section>

    <!-- Dataset Preview Section -->
    <section id="dataset" class="section dataset-preview">
        <div class="container">
            <div class="section-header">
                <span class="section-badge">Data Preview</span>
                <h2 class="section-title">Sample Dataset</h2>
            </div>
            <div class="preview-tabs">
                <button class="tab-btn active" data-tab="csv">CSV Format</button>
                <button class="tab-btn" data-tab="json">JSON Format</button>
                <button class="tab-btn" data-tab="stats">Statistics</button>
            </div>
            <div class="preview-content">
                <div class="tab-content active" id="csv">
                    <div class="data-table-wrapper">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Text</th>
                                    <th>Category</th>
                                    <th>Label</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>1</td>
                                    <td>Apple announces new iPhone with revolutionary AI features...</td>
                                    <td><span class="category-badge tech">Technology</span></td>
                                    <td>0</td>
                                </tr>
                                <tr>
                                    <td>2</td>
                                    <td>Manchester United wins Premier League title after dramatic finish...</td>
                                    <td><span class="category-badge sports">Sports</span></td>
                                    <td>1</td>
                                </tr>
                                <tr>
                                    <td>3</td>
                                    <td>Senate passes new climate bill with bipartisan support...</td>
                                    <td><span class="category-badge politics">Politics</span></td>
                                    <td>2</td>
                                </tr>
                                <tr>
                                    <td>4</td>
                                    <td>Marvel releases trailer for upcoming superhero movie...</td>
                                    <td><span class="category-badge entertainment">Entertainment</span></td>
                                    <td>3</td>
                                </tr>
                                <tr>
                                    <td>5</td>
                                    <td>Stock market reaches all-time high amid economic recovery...</td>
                                    <td><span class="category-badge business">Business</span></td>
                                    <td>4</td>
                                </tr>
                                <tr>
                                    <td>6</td>
                                    <td>NASA discovers new exoplanet potentially habitable...</td>
                                    <td><span class="category-badge science">Science</span></td>
                                    <td>5</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="tab-content" id="json">
                    <div class="code-window">
                        <div class="window-header">
                            <div class="window-dots">
                                <span class="dot red"></span>
                                <span class="dot yellow"></span>
                                <span class="dot green"></span>
                            </div>
                            <span class="window-title">dataset.json</span>
                        </div>
                        <pre class="code-content json-preview"><code>{
  <span class="json-key">"dataset"</span>: {
    <span class="json-key">"name"</span>: <span class="json-string">"Text Classification Dataset"</span>,
    <span class="json-key">"version"</span>: <span class="json-string">"1.0.0"</span>,
    <span class="json-key">"total_samples"</span>: <span class="json-number">10000</span>,
    <span class="json-key">"categories"</span>: [
      <span class="json-string">"Technology"</span>,
      <span class="json-string">"Sports"</span>,
      <span class="json-string">"Politics"</span>,
      <span class="json-string">"Entertainment"</span>,
      <span class="json-string">"Business"</span>,
      <span class="json-string">"Science"</span>
    ]
  },
  <span class="json-key">"samples"</span>: [
    {
      <span class="json-key">"id"</span>: <span class="json-number">1</span>,
      <span class="json-key">"text"</span>: <span class="json-string">"Apple announces new iPhone..."</span>,
      <span class="json-key">"category"</span>: <span class="json-string">"Technology"</span>,
      <span class="json-key">"label"</span>: <span class="json-number">0</span>
    }
  ]
}</code></pre>
                    </div>
                </div>
                <div class="tab-content" id="stats">
                    <div class="stats-grid">
                        <div class="stat-card">
                            <div class="stat-chart">
                                <canvas id="categoryChart"></canvas>
                            </div>
                        </div>
                        <div class="stat-card">
                            <h3>Dataset Statistics</h3>
                            <ul class="stats-list">
                                <li><span>Total Documents:</span> <strong>10,000</strong></li>
                                <li><span>Training Set:</span> <strong>7,000 (70%)</strong></li>
                                <li><span>Validation Set:</span> <strong>1,500 (15%)</strong></li>
                                <li><span>Test Set:</span> <strong>1,500 (15%)</strong></li>
                                <li><span>Avg. Document Length:</span> <strong>256 tokens</strong></li>
                                <li><span>Vocabulary Size:</span> <strong>50,000+</strong></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Usage Section -->
    <section id="usage" class="section usage">
        <div class="container">
            <div class="section-header">
                <span class="section-badge">How to Use</span>
                <h2 class="section-title">Quick Start Guide</h2>
            </div>
            <div class="usage-steps">
                <div class="step">
                    <div class="step-number">01</div>
                    <div class="step-content">
                        <h3>Download Dataset</h3>
                        <p>Download the dataset in your preferred format (CSV, JSON, or TXT).</p>
                        <div class="code-snippet">
                            <code>wget https://rskworld.in/datasets/text-classification.zip</code>
                        </div>
                    </div>
                </div>
                <div class="step">
                    <div class="step-number">02</div>
                    <div class="step-content">
                        <h3>Load Data</h3>
                        <p>Load the dataset using pandas or your preferred library.</p>
                        <div class="code-snippet">
                            <code>import pandas as pd<br>df = pd.read_csv('train.csv')</code>
                        </div>
                    </div>
                </div>
                <div class="step">
                    <div class="step-number">03</div>
                    <div class="step-content">
                        <h3>Preprocess</h3>
                        <p>Apply tokenization and preprocessing using provided scripts.</p>
                        <div class="code-snippet">
                            <code>from preprocessing import TextPreprocessor<br>preprocessor = TextPreprocessor()</code>
                        </div>
                    </div>
                </div>
                <div class="step">
                    <div class="step-number">04</div>
                    <div class="step-content">
                        <h3>Train Model</h3>
                        <p>Train your classification model using transformers or sklearn.</p>
                        <div class="code-snippet">
                            <code>model.fit(X_train, y_train)<br>predictions = model.predict(X_test)</code>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Download Section -->
    <section id="download" class="section download">
        <div class="container">
            <div class="section-header">
                <span class="section-badge">Download</span>
                <h2 class="section-title">Get the Dataset</h2>
            </div>
            <div class="download-options">
                <div class="download-card featured">
                    <div class="card-badge">Recommended</div>
                    <div class="card-icon">
                        <i class="fas fa-file-archive"></i>
                    </div>
                    <h3>Complete Package</h3>
                    <p>All formats, preprocessed data, and Python scripts included.</p>
                    <ul class="download-features">
                        <li><i class="fas fa-check"></i> CSV, JSON, TXT formats</li>
                        <li><i class="fas fa-check"></i> Train/Val/Test splits</li>
                        <li><i class="fas fa-check"></i> Preprocessing scripts</li>
                        <li><i class="fas fa-check"></i> Sample notebooks</li>
                    </ul>
                    <a href="text-classification.zip" class="btn btn-primary" download>
                        <i class="fas fa-download"></i>
                        Download ZIP (45 MB)
                    </a>
                </div>
                <div class="download-card">
                    <div class="card-icon">
                        <i class="fas fa-file-csv"></i>
                    </div>
                    <h3>CSV Only</h3>
                    <p>Raw dataset in CSV format.</p>
                    <a href="data/csv/full_dataset.csv" class="btn btn-outline" download>
                        <i class="fas fa-download"></i>
                        Download CSV
                    </a>
                </div>
                <div class="download-card">
                    <div class="card-icon">
                        <i class="fas fa-code"></i>
                    </div>
                    <h3>JSON Only</h3>
                    <p>Dataset in JSON format.</p>
                    <a href="data/json/full_dataset.json" class="btn btn-outline" download>
                        <i class="fas fa-download"></i>
                        Download JSON
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="footer">
        <div class="container">
            <div class="footer-content">
                <div class="footer-brand">
                    <a href="https://rskworld.in" class="logo">
                        <i class="fas fa-brain"></i>
                        <span>RSK<span class="highlight">World</span></span>
                    </a>
                    <p>Your one-stop destination for free programming resources, source code, and development tools.</p>
                    <div class="social-links">
                        <a href="#" aria-label="Facebook"><i class="fab fa-facebook-f"></i></a>
                        <a href="#" aria-label="Twitter"><i class="fab fa-twitter"></i></a>
                        <a href="#" aria-label="Instagram"><i class="fab fa-instagram"></i></a>
                        <a href="#" aria-label="GitHub"><i class="fab fa-github"></i></a>
                        <a href="#" aria-label="LinkedIn"><i class="fab fa-linkedin-in"></i></a>
                    </div>
                </div>
                <div class="footer-links">
                    <div class="footer-column">
                        <h4>Quick Links</h4>
                        <ul>
                            <li><a href="https://rskworld.in">Home</a></li>
                            <li><a href="https://rskworld.in/about.php">About</a></li>
                            <li><a href="https://rskworld.in/contact.php">Contact</a></li>
                        </ul>
                    </div>
                    <div class="footer-column">
                        <h4>Resources</h4>
                        <ul>
                            <li><a href="#">Documentation</a></li>
                            <li><a href="#">Tutorials</a></li>
                            <li><a href="#">API Reference</a></li>
                        </ul>
                    </div>
                    <div class="footer-column">
                        <h4>Contact</h4>
                        <ul>
                            <li><i class="fas fa-envelope"></i> help@rskworld.in</li>
                            <li><i class="fas fa-phone"></i> +91 93305 39277</li>
                            <li><i class="fas fa-globe"></i> rskworld.in</li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="footer-bottom">
                <p>&copy; 2026 RSK World. All Rights Reserved. | Founded by <strong>Molla Samser</strong> | Designer & Tester: <strong>Rima Khatun</strong></p>
                <p>Content used for educational purposes only.</p>
            </div>
        </div>
    </footer>

    <!-- Back to Top Button -->
    <button class="back-to-top" aria-label="Back to Top">
        <i class="fas fa-arrow-up"></i>
    </button>

    <!-- Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    
    <!-- Custom JavaScript -->
    <script src="assets/js/main.js"></script>
</body>
</html>

599 lines•28.4 KB
markup
data/csv/full_dataset.csv
Raw Download
Find: Go to:
# ================================================================================
# Text Classification Dataset - Full Dataset (CSV Format)
# ================================================================================
# Project: Text Classification Dataset
# Author: Molla Samser | Designer & Tester: Rima Khatun
# Website: https://rskworld.in | Email: help@rskworld.in
# Phone: +91 93305 39277
# Copyright (c) 2026 RSK World - All Rights Reserved
# ================================================================================
id,text,category,label,split
1,"Apple unveils revolutionary new iPhone featuring advanced AI capabilities and enhanced camera system that promises to transform mobile photography and computing experience.",Technology,0,train
2,"Tesla announces breakthrough in battery technology that could extend electric vehicle range by 50% while reducing charging time significantly.",Technology,0,train
3,"Microsoft releases new version of Windows with integrated AI assistant that can help users with daily tasks and improve productivity.",Technology,0,train
4,"Google introduces quantum computing breakthrough that could revolutionize drug discovery and climate modeling simulations.",Technology,0,train
5,"Amazon Web Services launches new cloud computing services designed for artificial intelligence and machine learning applications.",Technology,0,train
6,"SpaceX successfully launches Starship rocket in historic test flight marking major milestone in space exploration technology.",Technology,0,train
7,"Meta unveils next-generation virtual reality headset with improved display resolution and tracking capabilities for immersive experiences.",Technology,0,train
8,"NVIDIA announces new GPU architecture that delivers unprecedented performance for gaming and professional applications.",Technology,0,train
9,"Samsung introduces foldable smartphone with improved durability and enhanced multitasking features for modern users.",Technology,0,train
10,"Intel unveils new processor line featuring advanced manufacturing process and improved energy efficiency for laptops.",Technology,0,train
11,"Manchester United secures Premier League title in dramatic final day showdown against rival Manchester City.",Sports,1,train
12,"LeBron James breaks NBA all-time scoring record in historic game against Oklahoma City Thunder.",Sports,1,train
13,"Lionel Messi leads Inter Miami to MLS Cup victory in his first season with the American club.",Sports,1,train
14,"Serena Williams announces comeback to professional tennis after two-year absence from the sport.",Sports,1,train
15,"Formula One championship decided in thrilling final race as Max Verstappen claims third consecutive title.",Sports,1,train
16,"India wins Cricket World Cup in dominant performance against Australia at home stadium in Mumbai.",Sports,1,train
17,"USA women's soccer team wins Olympic gold medal in penalty shootout thriller against Germany.",Sports,1,train
18,"Roger Federer inducted into Tennis Hall of Fame in emotional ceremony at Wimbledon.",Sports,1,train
19,"New York Yankees win World Series in seven-game classic against Los Angeles Dodgers.",Sports,1,train
20,"Usain Bolt's world record in 100m sprint finally broken by young American sprinter.",Sports,1,train
21,"Congress passes historic infrastructure bill with bipartisan support allocating trillions for roads and bridges.",Politics,2,train
22,"Supreme Court delivers landmark ruling on voting rights that could reshape elections nationwide.",Politics,2,train
23,"President announces major climate initiative with ambitious targets for carbon neutrality by 2040.",Politics,2,train
24,"Senate confirms new Supreme Court justice in closely contested vote along party lines.",Politics,2,train
25,"International summit addresses global migration crisis with new framework for refugee assistance.",Politics,2,train
26,"State governors form coalition to address housing affordability crisis affecting millions of residents.",Politics,2,train
27,"Prime Minister announces major tax reform package aimed at stimulating economic growth.",Politics,2,train
28,"European Union reaches agreement on comprehensive digital privacy regulations for member states.",Politics,2,train
29,"United Nations Security Council passes resolution addressing humanitarian crisis in conflict zones.",Politics,2,train
30,"Parliament debates controversial education reform bill that would change university funding.",Politics,2,train
31,"Marvel releases trailer for upcoming superhero blockbuster featuring multiple fan-favorite characters.",Entertainment,3,train
32,"Taylor Swift breaks streaming records with new album release that dominates charts worldwide.",Entertainment,3,train
33,"Netflix announces new season of popular series that became global phenomenon during pandemic.",Entertainment,3,train
34,"Hollywood awards season kicks off with surprising nominations that defy industry expectations.",Entertainment,3,train
35,"Iconic rock band announces reunion tour that will span multiple continents over two years.",Entertainment,3,train
36,"Streaming platforms engage in bidding war for rights to anticipated fantasy book adaptation.",Entertainment,3,train
37,"Grammy Awards ceremony honors diverse range of artists across multiple musical genres.",Entertainment,3,train
38,"Broadway reopening marks cultural milestone as theaters welcome audiences at full capacity.",Entertainment,3,train
39,"Legendary director announces final film project that will reunite him with longtime collaborators.",Entertainment,3,train
40,"Video game adaptation becomes highest-grossing film of the year breaking box office records.",Entertainment,3,train
41,"Stock market reaches all-time high as investors respond positively to economic recovery signals.",Business,4,train
42,"Federal Reserve announces interest rate decision that will impact borrowing costs for consumers.",Business,4,train
43,"Major tech company completes largest acquisition in industry history valued at record billions.",Business,4,train
44,"Unemployment rate drops to historic low as job market continues strong recovery trajectory.",Business,4,train
45,"Cryptocurrency market experiences volatility as major institutional investors adjust their positions.",Business,4,train
46,"Electric vehicle startup announces successful IPO that exceeds analyst expectations significantly.",Business,4,train
47,"Retail sales surge during holiday shopping season breaking previous records for online purchases.",Business,4,train
48,"Oil prices fluctuate amid global supply concerns and geopolitical tensions affecting markets.",Business,4,train
49,"Banking sector reports strong quarterly earnings driven by increased lending activity and fees.",Business,4,train
50,"Real estate market shows signs of cooling as mortgage rates climb to multi-year highs.",Business,4,train
51,"NASA discovers potentially habitable exoplanet within nearby star system using advanced telescope.",Science,5,train
52,"Scientists achieve breakthrough in nuclear fusion research that could lead to clean energy revolution.",Science,5,train
53,"New study reveals connection between gut microbiome and mental health offering treatment possibilities.",Science,5,train
54,"Researchers develop revolutionary vaccine platform that could protect against multiple disease variants.",Science,5,train
55,"Archaeological discovery in Egypt reveals previously unknown pharaonic tomb with remarkable artifacts.",Science,5,train
56,"Climate scientists warn of accelerating ice sheet melting that could raise sea levels significantly.",Science,5,train
57,"Astronomers detect mysterious radio signals from distant galaxy sparking scientific investigation.",Science,5,train
58,"Geneticists successfully edit disease-causing mutation in human embryos using CRISPR technology.",Science,5,train
59,"Paleontologists discover new dinosaur species that challenges existing theories about evolution.",Science,5,train
60,"Marine biologists document previously unknown deep-sea ecosystem teeming with unique life forms.",Science,5,train
101,"Wearable technology market expands with new health monitoring devices approved for medical use.",Technology,0,validation
102,"Open source software community releases major update to popular development framework.",Technology,0,validation
103,"Digital payment systems see surge in adoption as cashless transactions become preferred method.",Technology,0,validation
104,"Mixed reality applications find new uses in industrial training and maintenance procedures.",Technology,0,validation
105,"Renewable energy technology advances make solar power more affordable than fossil fuels.",Technology,0,validation
106,"Swimming world record shattered by young athlete at international championship meet.",Sports,1,validation
107,"Golf tournament concludes with playoff drama as veterans battle rising stars.",Sports,1,validation
108,"Marathon runner achieves historic time breaking longstanding course record by minutes.",Sports,1,validation
109,"Hockey team completes remarkable playoff run to claim championship trophy.",Sports,1,validation
110,"Boxing match generates massive pay-per-view numbers setting new industry record.",Sports,1,validation
111,"Senate committee launches investigation into foreign election interference concerns.",Politics,2,validation
112,"Municipal bonds approved for major urban renewal project in downtown district.",Politics,2,validation
113,"Governor signs executive order addressing public safety and criminal justice reform.",Politics,2,validation
114,"Coalition government formed after weeks of negotiations following inconclusive election.",Politics,2,validation
115,"Diplomatic relations restored between nations after decades of tension and isolation.",Politics,2,validation
116,"Animation studio announces sequel to beloved franchise that defined generation.",Entertainment,3,validation
117,"Literary adaptation wins multiple awards during television critics ceremony.",Entertainment,3,validation
118,"Podcast phenomenon secures multi-platform deal worth reported nine figures.",Entertainment,3,validation
119,"Dance competition show returns with celebrity judges and updated format.",Entertainment,3,validation
120,"Theatre production transfers to West End after successful Broadway premiere.",Entertainment,3,validation
121,"Consumer confidence index rises as economic outlook improves among households.",Business,4,validation
122,"Manufacturing sector rebounds with strong orders and production increases.",Business,4,validation
123,"Commercial real estate market adapts to changing workplace dynamics post-pandemic.",Business,4,validation
124,"Small business formation reaches record levels as entrepreneurship flourishes.",Business,4,validation
125,"International shipping costs normalize after years of pandemic-related disruptions.",Business,4,validation
126,"Volcanic activity detected in region prompts scientific monitoring and evacuation planning.",Science,5,validation
127,"Renewable materials research yields biodegradable plastic alternative from agricultural waste.",Science,5,validation
128,"Sleep study reveals optimal duration for cognitive performance and health benefits.",Science,5,validation
129,"Earthquake prediction model shows promising accuracy in recent tremor forecasts.",Science,5,validation
130,"Arctic expedition discovers ancient artifacts preserved in melting permafrost.",Science,5,validation
131,"Artificial general intelligence research raises ethical questions about machine consciousness and rights.",Technology,0,test
132,"Quantum internet prototype demonstrates secure communication across metropolitan network.",Technology,0,test
133,"Biotechnology firm develops personalized medicine platform using genetic sequencing data.",Technology,0,test
134,"Edge computing infrastructure deployed for real-time industrial automation applications.",Technology,0,test
135,"Neural interface technology enables paralyzed patients to control computer cursor with thoughts.",Technology,0,test
136,"Cricket league introduces innovative format to attract younger audience demographic.",Sports,1,test
137,"Sailing competition features cutting-edge foiling technology in challenging conditions.",Sports,1,test
138,"Wrestling championships showcase international talent from over fifty countries.",Sports,1,test
139,"Cycling race concludes with photo finish after grueling mountain stage competition.",Sports,1,test
140,"Gymnastics scoring system updated to encourage artistic expression alongside difficulty.",Sports,1,test
141,"Budget proposal allocates funding for infrastructure and social programs amid deficit concerns.",Politics,2,test
142,"Redistricting process completed following census data analysis and public input sessions.",Politics,2,test
143,"International climate summit produces agreement on emissions reduction targets.",Politics,2,test
144,"Labor law reforms passed to address gig economy worker classification issues.",Politics,2,test
145,"Immigration policy debate intensifies as border security measures are reassessed.",Politics,2,test
146,"Independent film earns surprise Oscar nomination challenging studio dominance.",Entertainment,3,test
147,"Virtual concert experience attracts millions of viewers in groundbreaking digital event.",Entertainment,3,test
148,"Comedy special generates controversy while breaking streaming viewership records.",Entertainment,3,test
149,"Fashion week highlights sustainable design trends and ethical manufacturing practices.",Entertainment,3,test
150,"Art exhibition featuring AI-generated works sparks debate about creativity and authorship.",Entertainment,3,test
151,"Currency markets react to central bank policy divergence between major economies.",Business,4,test
152,"Agricultural commodities prices surge amid weather-related supply concerns globally.",Business,4,test
153,"Insurance industry adapts products for climate change risk and natural disaster coverage.",Business,4,test
154,"Fintech innovation transforms cross-border payment processing with blockchain solutions.",Business,4,test
155,"Retail sector experiments with augmented reality shopping experiences in flagship stores.",Business,4,test
156,"Ocean acidification study reveals alarming impact on marine shell-forming organisms.",Science,5,test
157,"Artificial photosynthesis research achieves efficiency milestone for clean fuel production.",Science,5,test
158,"Psychology research challenges long-held assumptions about human decision-making processes.",Science,5,test
159,"Satellite data reveals acceleration of global ice loss exceeding model predictions.",Science,5,test
160,"Stem cell therapy shows promise for treating degenerative neurological conditions.",Science,5,test

132 lines•14.5 KB
csv
notebooks/text_classification_tutorial.ipynb
Raw Download
Find: Go to:
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Text Classification Tutorial\n",
        "\n",
        "---\n",
        "\n",
        "## Project Information\n",
        "\n",
        "- **Project:** Text Classification Dataset\n",
        "- **Category:** Text Data / NLP\n",
        "- **Author:** Molla Samser\n",
        "- **Designer & Tester:** Rima Khatun\n",
        "- **Website:** [https://rskworld.in](https://rskworld.in)\n",
        "- **Email:** help@rskworld.in | support@rskworld.in\n",
        "- **Phone:** +91 93305 39277\n",
        "\n",
        "**Copyright (c) 2026 RSK World - All Rights Reserved**\n",
        "\n",
        "---\n",
        "\n",
        "This notebook demonstrates how to:\n",
        "1. Load and explore the text classification dataset\n",
        "2. Preprocess text data\n",
        "3. Train traditional ML classifiers\n",
        "4. Evaluate and compare model performance\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Text Classification Dataset - Tutorial Notebook\n",
        "# Author: Molla Samser | Website: https://rskworld.in\n",
        "# Copyright (c) 2026 RSK World - All Rights Reserved\n",
        "# ================================================================================\n",
        "\n",
        "import os\n",
        "import warnings\n",
        "warnings.filterwarnings('ignore')\n",
        "\n",
        "# Data manipulation\n",
        "import pandas as pd\n",
        "import numpy as np\n",
        "\n",
        "# Visualization\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "\n",
        "# Text processing\n",
        "import re\n",
        "import string\n",
        "from collections import Counter\n",
        "\n",
        "# ML libraries\n",
        "from sklearn.feature_extraction.text import TfidfVectorizer\n",
        "from sklearn.naive_bayes import MultinomialNB\n",
        "from sklearn.linear_model import LogisticRegression\n",
        "from sklearn.svm import LinearSVC\n",
        "from sklearn.metrics import classification_report, confusion_matrix, accuracy_score\n",
        "\n",
        "# Set style\n",
        "plt.style.use('seaborn-v0_8-darkgrid')\n",
        "sns.set_palette('Set2')\n",
        "\n",
        "print(\"Libraries imported successfully!\")\n",
        "print(\"Author: Molla Samser | Website: https://rskworld.in\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Load Dataset - RSK World (https://rskworld.in)\n",
        "# ================================================================================\n",
        "\n",
        "DATA_DIR = '../data/csv'\n",
        "\n",
        "# Load datasets\n",
        "train_df = pd.read_csv(f'{DATA_DIR}/train.csv', comment='#')\n",
        "val_df = pd.read_csv(f'{DATA_DIR}/validation.csv', comment='#')\n",
        "test_df = pd.read_csv(f'{DATA_DIR}/test.csv', comment='#')\n",
        "\n",
        "# Category mapping\n",
        "CATEGORIES = {\n",
        "    0: 'Technology', 1: 'Sports', 2: 'Politics',\n",
        "    3: 'Entertainment', 4: 'Business', 5: 'Science'\n",
        "}\n",
        "\n",
        "print(\"Dataset Loaded Successfully!\")\n",
        "print(f\"Training samples: {len(train_df)}\")\n",
        "print(f\"Validation samples: {len(val_df)}\")\n",
        "print(f\"Test samples: {len(test_df)}\")\n",
        "train_df.head()\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Text Preprocessing - RSK World (https://rskworld.in)\n",
        "# ================================================================================\n",
        "\n",
        "def preprocess_text(text):\n",
        "    \"\"\"Preprocess text for classification.\"\"\"\n",
        "    text = text.lower()\n",
        "    text = re.sub(r'https?://\\S+|www\\.\\S+', '', text)\n",
        "    text = text.translate(str.maketrans('', '', string.punctuation))\n",
        "    text = ' '.join(text.split())\n",
        "    return text\n",
        "\n",
        "# Apply preprocessing\n",
        "train_df['processed_text'] = train_df['text'].apply(preprocess_text)\n",
        "val_df['processed_text'] = val_df['text'].apply(preprocess_text)\n",
        "test_df['processed_text'] = test_df['text'].apply(preprocess_text)\n",
        "\n",
        "print(\"Preprocessing complete!\")\n",
        "print(f\"\\nOriginal: {train_df['text'].iloc[0][:80]}...\")\n",
        "print(f\"Processed: {train_df['processed_text'].iloc[0][:80]}...\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Feature Extraction & Model Training - RSK World (https://rskworld.in)\n",
        "# ================================================================================\n",
        "\n",
        "# TF-IDF Vectorization\n",
        "tfidf = TfidfVectorizer(max_features=10000, ngram_range=(1, 2), stop_words='english')\n",
        "X_train = tfidf.fit_transform(train_df['processed_text'])\n",
        "X_val = tfidf.transform(val_df['processed_text'])\n",
        "X_test = tfidf.transform(test_df['processed_text'])\n",
        "\n",
        "y_train = train_df['label'].values\n",
        "y_val = val_df['label'].values\n",
        "y_test = test_df['label'].values\n",
        "\n",
        "# Train models\n",
        "models = {\n",
        "    'Naive Bayes': MultinomialNB(),\n",
        "    'Logistic Regression': LogisticRegression(max_iter=1000, class_weight='balanced'),\n",
        "    'Linear SVM': LinearSVC(max_iter=1000, class_weight='balanced')\n",
        "}\n",
        "\n",
        "results = {}\n",
        "for name, model in models.items():\n",
        "    model.fit(X_train, y_train)\n",
        "    test_acc = accuracy_score(y_test, model.predict(X_test))\n",
        "    results[name] = test_acc\n",
        "    print(f\"{name}: {test_acc:.4f}\")\n",
        "\n",
        "print(f\"\\nBest Model: {max(results, key=results.get)}\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Sample Predictions - RSK World (https://rskworld.in)\n",
        "# ================================================================================\n",
        "\n",
        "lr_model = models['Logistic Regression']\n",
        "\n",
        "sample_texts = [\n",
        "    \"New AI-powered smartphone features revolutionary camera technology.\",\n",
        "    \"Team wins championship in overtime thriller at stadium.\",\n",
        "    \"Government announces new policy to address climate change.\"\n",
        "]\n",
        "\n",
        "print(\"Sample Predictions:\")\n",
        "print(\"=\" * 60)\n",
        "for text in sample_texts:\n",
        "    processed = preprocess_text(text)\n",
        "    features = tfidf.transform([processed])\n",
        "    prediction = lr_model.predict(features)[0]\n",
        "    print(f\"\\nText: {text}\")\n",
        "    print(f\"Predicted: {CATEGORIES[prediction]}\")\n",
        "\n",
        "print(\"\\n\" + \"=\" * 60)\n",
        "print(\"Tutorial Complete!\")\n",
        "print(\"Author: Molla Samser | Website: https://rskworld.in\")\n",
        "print(\"Copyright (c) 2026 RSK World - All Rights Reserved\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Advanced Visualizations\n",
        "The following cells demonstrate advanced data visualization techniques for understanding your text classification dataset.\n",
        "\n",
        "**Author:** Molla Samser | **Website:** [rskworld.in](https://rskworld.in)\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Confusion Matrix Visualization - RSK World (https://rskworld.in)\n",
        "# ================================================================================\n",
        "\n",
        "from sklearn.metrics import confusion_matrix\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "\n",
        "# Set dark theme for visualization\n",
        "plt.style.use('dark_background')\n",
        "\n",
        "# Get predictions from our best model (Logistic Regression)\n",
        "best_model = models['Logistic Regression']\n",
        "y_pred = best_model.predict(X_test)\n",
        "\n",
        "# Create confusion matrix\n",
        "cm = confusion_matrix(y_test, y_pred)\n",
        "cm_normalized = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n",
        "\n",
        "# Plot\n",
        "fig, axes = plt.subplots(1, 2, figsize=(16, 6))\n",
        "\n",
        "# Raw counts\n",
        "sns.heatmap(cm, annot=True, fmt='d', cmap='Reds', \n",
        "            xticklabels=CATEGORIES.values(), yticklabels=CATEGORIES.values(),\n",
        "            ax=axes[0], linewidths=0.5, linecolor='#333')\n",
        "axes[0].set_title('Confusion Matrix (Counts)', fontsize=14, fontweight='bold')\n",
        "axes[0].set_xlabel('Predicted Label')\n",
        "axes[0].set_ylabel('True Label')\n",
        "\n",
        "# Normalized\n",
        "sns.heatmap(cm_normalized, annot=True, fmt='.2%', cmap='Blues',\n",
        "            xticklabels=CATEGORIES.values(), yticklabels=CATEGORIES.values(),\n",
        "            ax=axes[1], linewidths=0.5, linecolor='#333')\n",
        "axes[1].set_title('Confusion Matrix (Normalized)', fontsize=14, fontweight='bold')\n",
        "axes[1].set_xlabel('Predicted Label')\n",
        "axes[1].set_ylabel('True Label')\n",
        "\n",
        "plt.suptitle('Model Performance Analysis - RSK World | rskworld.in', \n",
        "             fontsize=16, fontweight='bold', y=1.02)\n",
        "plt.tight_layout()\n",
        "plt.show()\n",
        "\n",
        "print(f\"\\nConfusion Matrix Analysis Complete!\")\n",
        "print(f\"Author: Molla Samser | Website: https://rskworld.in\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Category Distribution & Word Cloud - RSK World (https://rskworld.in)\n",
        "# ================================================================================\n",
        "\n",
        "# Category Distribution\n",
        "fig, axes = plt.subplots(1, 2, figsize=(14, 5))\n",
        "\n",
        "# Color palette for categories\n",
        "category_colors = ['#3b82f6', '#22c55e', '#8b5cf6', '#ec4899', '#f59e0b', '#06b6d4']\n",
        "\n",
        "# Pie chart\n",
        "category_counts = train_df['label'].map(CATEGORIES).value_counts()\n",
        "wedges, texts, autotexts = axes[0].pie(\n",
        "    category_counts.values, \n",
        "    labels=category_counts.index,\n",
        "    autopct='%1.1f%%',\n",
        "    colors=category_colors,\n",
        "    explode=[0.02] * len(category_counts),\n",
        "    shadow=True\n",
        ")\n",
        "axes[0].set_title('Category Distribution', fontsize=14, fontweight='bold')\n",
        "\n",
        "# Bar chart\n",
        "bars = axes[1].bar(category_counts.index, category_counts.values, color=category_colors)\n",
        "axes[1].set_xlabel('Category', fontsize=12)\n",
        "axes[1].set_ylabel('Count', fontsize=12)\n",
        "axes[1].set_title('Documents per Category', fontsize=14, fontweight='bold')\n",
        "axes[1].tick_params(axis='x', rotation=45)\n",
        "\n",
        "# Add value labels on bars\n",
        "for bar in bars:\n",
        "    height = bar.get_height()\n",
        "    axes[1].text(bar.get_x() + bar.get_width()/2., height,\n",
        "                f'{int(height)}', ha='center', va='bottom', fontsize=10, fontweight='bold')\n",
        "\n",
        "plt.suptitle('Dataset Analysis - RSK World | rskworld.in', fontsize=16, fontweight='bold', y=1.02)\n",
        "plt.tight_layout()\n",
        "plt.show()\n",
        "\n",
        "# Word Count Distribution\n",
        "train_df['word_count'] = train_df['text'].str.split().str.len()\n",
        "\n",
        "fig, ax = plt.subplots(figsize=(12, 5))\n",
        "for i, category in enumerate(CATEGORIES.values()):\n",
        "    data = train_df[train_df['label'].map(CATEGORIES) == category]['word_count']\n",
        "    ax.hist(data, bins=20, alpha=0.6, label=category, color=category_colors[i])\n",
        "\n",
        "ax.set_xlabel('Word Count', fontsize=12)\n",
        "ax.set_ylabel('Frequency', fontsize=12)\n",
        "ax.set_title('Word Count Distribution by Category', fontsize=14, fontweight='bold')\n",
        "ax.legend(loc='upper right')\n",
        "plt.tight_layout()\n",
        "plt.show()\n",
        "\n",
        "print(f\"\\nDataset statistics:\")\n",
        "print(f\"Total documents: {len(train_df)}\")\n",
        "print(f\"Average word count: {train_df['word_count'].mean():.1f}\")\n",
        "print(f\"Min word count: {train_df['word_count'].min()}\")\n",
        "print(f\"Max word count: {train_df['word_count'].max()}\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# ================================================================================\n",
        "# Advanced Model Evaluation & Feature Analysis - RSK World (https://rskworld.in)\n",
        "# ================================================================================\n",
        "\n",
        "from sklearn.model_selection import cross_val_score, StratifiedKFold\n",
        "from sklearn.metrics import classification_report\n",
        "\n",
        "# Cross-validation analysis\n",
        "print(\"=\" * 60)\n",
        "print(\"Cross-Validation Analysis\")\n",
        "print(\"=\" * 60)\n",
        "\n",
        "skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)\n",
        "\n",
        "for name, model in models.items():\n",
        "    # Note: We need to fit on processed text, so we'll use the already fitted model\n",
        "    scores = cross_val_score(model, X_train, y_train, cv=skf, scoring='f1_macro')\n",
        "    print(f\"\\n{name}:\")\n",
        "    print(f\"  Mean F1 Score: {scores.mean():.4f} (+/- {scores.std() * 2:.4f})\")\n",
        "    print(f\"  All Folds: {[f'{s:.4f}' for s in scores]}\")\n",
        "\n",
        "# Detailed classification report for best model\n",
        "print(\"\\n\" + \"=\" * 60)\n",
        "print(\"Detailed Classification Report - Logistic Regression\")\n",
        "print(\"=\" * 60)\n",
        "print(classification_report(\n",
        "    y_test, \n",
        "    models['Logistic Regression'].predict(X_test),\n",
        "    target_names=list(CATEGORIES.values())\n",
        "))\n",
        "\n",
        "# Top features per category\n",
        "print(\"\\n\" + \"=\" * 60)\n",
        "print(\"Top Predictive Words per Category\")\n",
        "print(\"=\" * 60)\n",
        "\n",
        "feature_names = tfidf.get_feature_names_out()\n",
        "lr_coefs = models['Logistic Regression'].coef_\n",
        "\n",
        "for i, category in CATEGORIES.items():\n",
        "    top_indices = np.argsort(lr_coefs[i])[-10:][::-1]\n",
        "    top_words = [feature_names[idx] for idx in top_indices]\n",
        "    print(f\"\\n{category}:\")\n",
        "    print(f\"  {', '.join(top_words)}\")\n",
        "\n",
        "print(\"\\n\" + \"=\" * 60)\n",
        "print(\"Advanced Analysis Complete!\")\n",
        "print(\"Author: Molla Samser | Website: https://rskworld.in\")\n",
        "print(\"Copyright (c) 2026 RSK World - All Rights Reserved\")\n",
        "print(\"=\" * 60)\n"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}
401 lines•16.6 KB
json

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer