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
music-classification
RSK World
music-classification
Music Classification Dataset - Genre Classification + Music AI + Audio ML
music-classification
  • __pycache__
  • data
  • models
  • notebooks
  • utils
  • .gitignore1.2 KB
  • ADVANCED_FEATURES.md10.7 KB
  • COMPLETE_PROJECT_INFO.txt16.3 KB
  • CONTRIBUTING.md2 KB
  • DATASET_INFO.md8.5 KB
  • INSTALLATION.md8.4 KB
  • LICENSE2.1 KB
  • PROJECT_STRUCTURE.md8.4 KB
  • PROJECT_SUMMARY.md12.7 KB
  • README.md5.7 KB
  • START_HERE.md7 KB
  • USAGE_GUIDE.md11.1 KB
  • WHATS_NEW.md8.9 KB
  • config.py4.3 KB
  • demo.py11.9 KB
  • example_usage.py8.8 KB
  • index.html38.8 KB
  • music-classification.png2.1 MB
  • quick_start.py5.7 KB
  • requirements.txt1.1 KB
  • setup.py2.9 KB
  • validate_project.py7 KB
load_dataset.pyexample_usage.py
example_usage.py
Raw Download
Find: Go to:
#!/usr/bin/env python3
"""
Example Usage Script for Music Classification Dataset

Project: Music Classification Dataset
Author: Molla Samser
Company: RSK World
Designer & Tester: Rima Khatun
Website: https://rskworld.in
Email: help@rskworld.in, support@rskworld.in
Phone: +91 93305 39277
Description: Example code snippets for using the dataset
License: Educational Purpose Only
"""

print("""
========================================================================
MUSIC CLASSIFICATION DATASET - EXAMPLE USAGE
========================================================================
Author: Molla Samser | Company: RSK World
Website: https://rskworld.in | Email: help@rskworld.in
========================================================================

This file contains example code snippets for using the dataset.
Copy and paste these into your own scripts or Jupyter notebooks.

========================================================================
EXAMPLE 1: Load and Explore Data
========================================================================
""")

example1 = '''
import pandas as pd

# Load training data
train_df = pd.read_csv('data/train_data.csv')
print(f"Training samples: {len(train_df)}")
print(f"Columns: {train_df.columns.tolist()}")

# Show genre distribution
print("\\nGenre Distribution:")
print(train_df['genre'].value_counts())

# Load features
features_df = pd.read_csv('data/features.csv')
print(f"\\nFeatures shape: {features_df.shape}")
'''
print(example1)

print("""
========================================================================
EXAMPLE 2: Audio Processing
========================================================================
""")

example2 = '''
from utils.audio_processor import AudioProcessor

# Initialize processor
processor = AudioProcessor(sample_rate=22050, duration=30.0)

# Load audio file
audio = processor.load_audio('data/audio/jazz/jazz_001.wav')
print(f"Audio shape: {audio.shape}")

# Normalize audio
audio_normalized = processor.normalize_audio(audio)
print(f"Normalized range: [{audio_normalized.min():.4f}, {audio_normalized.max():.4f}]")
'''
print(example2)

print("""
========================================================================
EXAMPLE 3: Feature Extraction
========================================================================
""")

example3 = '''
from utils.feature_extractor import FeatureExtractor
from utils.audio_processor import AudioProcessor

# Initialize
processor = AudioProcessor()
extractor = FeatureExtractor()

# Load audio
audio = processor.load_audio('path/to/audio.wav')

# Extract all features
features = extractor.extract_all_features(audio)

print("Extracted Features:")
print(f"  MFCC: {features['mfcc'].shape}")
print(f"  Spectral Centroid: {features['spectral_centroid']:.2f}")
print(f"  Tempo: {features['tempo']:.2f} BPM")
print(f"  Zero Crossing Rate: {features['zero_crossing_rate']:.6f}")
'''
print(example3)

print("""
========================================================================
EXAMPLE 4: Advanced Feature Extraction
========================================================================
""")

example4 = '''
from utils.advanced_features import AdvancedFeatureExtractor

# Initialize
extractor = AdvancedFeatureExtractor(sample_rate=22050)

# Extract all advanced features
features = extractor.extract_all_advanced_features(audio)

print("Advanced Features:")
print(f"  Spectral Contrast: {features['spectral_contrast'].shape}")
print(f"  Tonnetz: {features['tonnetz'].shape}")
print(f"  Spectral Flatness: {features['spectral_flatness']:.6f}")
print(f"  Tempo: {features['tempo']:.2f} BPM")
print(f"  Harmonic Ratio: {features['harmonic_ratio']:.4f}")
'''
print(example4)

print("""
========================================================================
EXAMPLE 5: Audio Augmentation
========================================================================
""")

example5 = '''
from utils.audio_augmentation import AudioAugmenter

# Initialize
augmenter = AudioAugmenter(sample_rate=22050)

# Apply different augmentations
noisy_audio = augmenter.add_noise(audio, noise_factor=0.005)
stretched_audio = augmenter.time_stretch(audio, rate=1.1)
pitched_audio = augmenter.pitch_shift(audio, n_steps=2)

# Random augmentation
random_augmented = augmenter.random_augmentation(audio)

# Batch augmentation
augmented_batch = augmenter.augment_batch([audio1, audio2], augmentations_per_sample=3)
'''
print(example5)

print("""
========================================================================
EXAMPLE 6: Train a Model
========================================================================
""")

example6 = '''
# Using command line:
# python models/train_model.py --model random_forest

# Using Python:
from models.train_model import MusicClassifier

# Initialize classifier
classifier = MusicClassifier(model_type='random_forest')

# Extract features from CSV
X_train, y_train = classifier.extract_features_from_csv('data/train_data.csv')
X_test, y_test = classifier.extract_features_from_csv('data/test_data.csv')

# Train
classifier.train(X_train, y_train)

# Evaluate
classifier.evaluate(X_test, y_test)

# Save model
classifier.save_model('models/saved_models')
'''
print(example6)

print("""
========================================================================
EXAMPLE 7: Make Predictions
========================================================================
""")

example7 = '''
# Using command line:
# python models/predict.py --audio your_music.wav --model random_forest

# Using Python:
from models.predict import MusicPredictor

# Initialize predictor
predictor = MusicPredictor(model_dir='models/saved_models', model_type='random_forest')

# Predict
result = predictor.predict('path/to/your/music.wav')

print(f"Predicted Genre: {result['predicted_genre']}")
print(f"Confidence: {result['confidence']:.2f}%")

# Show all probabilities
for genre, prob in result['all_probabilities'].items():
    print(f"  {genre}: {prob:.2f}%")
'''
print(example7)

print("""
========================================================================
EXAMPLE 8: Model Comparison
========================================================================
""")

example8 = '''
from utils.model_comparison import ModelComparator

# Initialize comparator
comparator = ModelComparator()

# Train and evaluate all models
comparator.train_and_evaluate(X_train, y_train, X_test, y_test)

# Get results
df = comparator.get_results_dataframe()
print(df)

# Plot comparison
comparator.plot_comparison(save_path='model_comparison.png')

# Get best model
best_name, best_model = comparator.get_best_model()
print(f"Best model: {best_name}")
'''
print(example8)

print("""
========================================================================
EXAMPLE 9: Deep Learning (Neural Networks)
========================================================================
""")

example9 = '''
from models.neural_network_model import DeepMusicClassifier

# Initialize classifier
classifier = DeepMusicClassifier(
    input_shape=(30,),
    num_classes=8,
    model_type='cnn'  # Options: 'dense', 'cnn', 'lstm', 'hybrid'
)

# Build model
classifier.build_model()

# Train
classifier.train(X_train, y_train, X_val, y_val, epochs=100, batch_size=32)

# Evaluate
classifier.evaluate(X_test, y_test)

# Save
classifier.save_model('models/saved_models')
'''
print(example9)

print("""
========================================================================
EXAMPLE 10: Real-Time Processing
========================================================================
""")

example10 = '''
from utils.realtime_processor import RealtimeAudioProcessor

# Define classification function
def classify_audio(audio_chunk):
    # Extract features and classify
    features = extractor.extract_all_features(audio_chunk)
    prediction = model.predict(features)
    return {'genre': prediction, 'confidence': 0.85}

# Initialize processor
processor = RealtimeAudioProcessor(sample_rate=22050, chunk_duration=2.0)

# Start processing
processor.start_processing(classify_audio)

# Process audio stream
processor.process_stream(audio_stream, classify_audio, duration=60)

# Stop processing
processor.stop_processing()
'''
print(example10)

print("""
========================================================================
CONTACT INFORMATION
========================================================================

Author: Molla Samser
Company: RSK World
Designer & Tester: Rima Khatun

Website: https://rskworld.in
Email: help@rskworld.in, support@rskworld.in
Phone: +91 93305 39277

(c) 2026 RSK World - Free Programming Resources & Source Code

========================================================================
""")

314 lines•8.8 KB
python

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