Skip to content

About

I collect interesting codes and thoughts

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

🧰 ML Collections

Python Pandas NumPy Matplotlib Kaggle

A curated collection of ready-to-use ML/Data Science code snippets and utilities

Stop rewriting the same exploratory data analysis code β€” just copy, paste, and explore! πŸš€

Features β€’ Installation β€’ Usage β€’ Scripts β€’ Kaggle Resources β€’ Contributing


πŸ“– About

ML Collections is a practical repository containing reusable Python scripts and utilities for machine learning and data science workflows. Whether you're working on Kaggle competitions or exploring datasets, this collection provides battle-tested code snippets that save time and reduce repetitive coding.

πŸ’‘ Why This Repository?

  • ⚑ Quick Start: Copy-paste ready code for common ML tasks
  • 🎯 Practical: Real-world utilities used in actual Kaggle competitions
  • πŸ“Š Exploratory: Tools focused on dataset exploration and visualization
  • πŸ”§ Modular: Each script is self-contained and easy to integrate
  • πŸ“š Educational: Learn from curated Kaggle resources and techniques

✨ Features

  • Data Exploration Tools: Quickly analyze datasets with unique value counting and visualizations
  • Distribution Analysis: Compare train/test distributions with KDE and box plots
  • Dataset Utilities: Print directory trees and explore Kaggle dataset structures
  • Kaggle Resources: Curated collection of valuable discussions and notebooks
  • TensorFlow Setup: Pre-configured environment setup scripts

πŸš€ Installation

Prerequisites

  • Python 3.7 or higher
  • pip package manager

Required Libraries

Install the necessary dependencies:

pip install pandas numpy matplotlib seaborn scikit-learn

For TensorFlow-based scripts:

pip install tensorflow

Clone the Repository

git clone https://github.com/Sanjidh090/ml-collections.git
cd ml-collections

πŸ“ Usage

Quick Start: Dataset Exploration

The simplest way to explore a dataset:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')

# Load your dataset
df = pd.read_csv('path/to/your/dataset.csv')

# Analyze unique values
for column in df.columns:
    print(f"="*100)
    print(f" Unique values in {column}:")
    print(df[column].value_counts())

print(f"=="*50)
print(f" Unique Value Report:")
print(df.nunique())

# Visualize distributions
df.hist(figsize=(16, 16), bins=30)
plt.tight_layout()
plt.show()

πŸ“¦ Scripts

1. unique.py - Unique Value Analysis

Purpose: Quickly analyze unique values and distributions in your dataset.

Features:

  • Count unique values per column
  • Display value frequency distributions
  • Generate histogram visualizations

Usage:

# Analyze any CSV file
df = pd.read_csv('/path/to/dataset.csv')
# Run the unique value analysis (see script for details)

2. plot_train_test_csv.py - Train/Test Distribution Comparison

Purpose: Compare feature distributions between training and test sets to detect data drift.

Features:

  • Automatic label encoding for categorical variables
  • KDE (Kernel Density Estimation) plots
  • Box plots for outlier detection
  • Train vs Test comparison for all features

Key Functions:

  • convert_all_to_numeric(train, test): Converts all columns to numeric format
  • dist_plots(train, test, num_features): Generates distribution comparison plots

Usage:

train = pd.read_csv('train.csv')
test = pd.read_csv('test.csv')

# Convert and get numeric columns
tr_all, te_all, numeric_cols = convert_all_to_numeric(train, test)

# Plot distributions
dist_plots(tr_all, te_all, numeric_cols)

3. intro.py - Environment Setup

Purpose: Standard setup script for TensorFlow-based Kaggle notebooks.

Features:

  • TensorFlow version upgrade
  • Protobuf compatibility fix
  • CPU-only mode (CUDA disabled)
  • Log level configuration
  • Dataset file exploration

Usage:

# Run at the start of your Kaggle notebook
# Automatically lists first 5 files in /kaggle/input

4. prompt_style_dataset.py - Directory Tree Visualization

Purpose: Print dataset directory structure in a clean ASCII tree format.

Features:

  • Recursive directory traversal
  • Beautiful ASCII tree formatting
  • Error handling for permissions and missing paths

Usage:

from prompt_style_dataset import print_tree

# Print dataset structure
print_tree("/path/to/dataset")

Output Example:

Dataset structure for: /kaggle/working/
β”œβ”€β”€ data
β”‚   β”œβ”€β”€ train.csv
β”‚   └── test.csv
└── models
    └── model_v1.pkl

πŸ“š Kaggle Resources

The kaggle/ directory contains a curated collection of valuable Kaggle discussions, notebooks, and insights:

These resources serve as a personal knowledge base for:

  • πŸ’‘ Competition strategies and winning approaches
  • πŸ” Advanced ML techniques
  • πŸ› οΈ Practical tips discovered across various competitions
  • πŸ“– Concepts to revisit when they become relevant

Check out the Kaggle README for more details!


πŸ› οΈ Additional Resources


🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-utility)
  3. Commit your changes (git commit -m 'Add amazing utility')
  4. Push to the branch (git push origin feature/amazing-utility)
  5. Open a Pull Request

Guidelines

  • Keep scripts self-contained and well-documented
  • Add usage examples in comments
  • Follow existing code style
  • Test your code before submitting

πŸ“„ License

This project is open source and available for educational and personal use.


πŸ™ Acknowledgments

  • Inspired by common Kaggle workflows and community best practices
  • Built for the data science community to reduce repetitive coding
  • Special thanks to Kaggle competition participants for sharing insights

πŸ“¬ Contact

Author: Sanjidh090

Repository: github.com/Sanjidh090/ml-collections


⭐ Star this repository if you find it helpful!

Made with ❀️ for the Data Science Community

About

I collect interesting codes and thoughts

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages