{"id":43526645,"url":"https://github.com/birchkwok/spinesutils","last_synced_at":"2026-02-03T15:13:43.341Z","repository":{"id":183639607,"uuid":"668520206","full_name":"BirchKwok/spinesUtils","owner":"BirchKwok","description":"A library that provides template code for Python development to shorten the project development cycle.","archived":false,"fork":false,"pushed_at":"2025-03-08T00:56:58.000Z","size":214,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-25T10:44:54.377Z","etag":null,"topics":["data-science","machine-learning","machine-learning-algorithms","preprocessing-data"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BirchKwok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-20T02:28:00.000Z","updated_at":"2025-03-08T00:57:02.000Z","dependencies_parsed_at":"2023-08-22T07:09:13.857Z","dependency_job_id":"f6ac1456-dd03-4994-b605-76b2bd650df8","html_url":"https://github.com/BirchKwok/spinesUtils","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":0.0888888888888889,"last_synced_commit":"c1b60803b4c279bfb60f774c8b498a6bde0d226b"},"previous_names":["birchkwok/spines","birchkwok/spinesutils"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/BirchKwok/spinesUtils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirchKwok%2FspinesUtils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirchKwok%2FspinesUtils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirchKwok%2FspinesUtils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirchKwok%2FspinesUtils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BirchKwok","download_url":"https://codeload.github.com/BirchKwok/spinesUtils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirchKwok%2FspinesUtils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29047826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T14:55:20.264Z","status":"ssl_error","status_checked_at":"2026-02-03T14:55:19.725Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","machine-learning","machine-learning-algorithms","preprocessing-data"],"created_at":"2026-02-03T15:13:42.566Z","updated_at":"2026-02-03T15:13:43.315Z","avatar_url":"https://github.com/BirchKwok.png","language":"Python","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003ci\u003e\u003cb\u003espinesUtils\u003c/b\u003e\u003c/i\u003e\u003c/h1\u003e\n  \u003cp\u003e\u003cb\u003e\u003ci\u003eAccelerate your Python development workflow\u003c/i\u003e\u003c/b\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n## Overview\n\n**spinesUtils** is a powerful library that provides ready-to-use features and utilities for Python development to shorten the project development cycle. Our goal is to help developers focus on solving their core problems instead of reimplementing common functionality.\n\n## Features\n\n- [x] **Logging functionality** - High-performance logging tools with zero learning curve\n- [x] **Type checking and parameter validation** - Robust validation decorators\n- [x] **CSV file reading acceleration** - Performance-optimized data loading\n- [x] **Imbalanced data classifiers** - Specialized ML tools for imbalanced datasets\n- [x] **Pandas DataFrame data compression** - Memory optimization for large datasets\n- [x] **DataFrame insight tools** - Quick data analysis and visualization\n- [x] **Large data train-test splitting** - Efficient data partitioning for ML pipelines\n- [x] **Intuitive timer** - Feature-rich yet easy-to-use precision timer\n\nThis library is currently undergoing rapid iteration. If you encounter any issues with its functionalities, feel free to [raise an issue](https://github.com/BirchKwok/spinesUtils/issues).\n\n## Installation\n\nYou can install spinesUtils from PyPI:\n\n```bash\npip install spinesUtils\n```\n\n## Usage Examples\n\n### Logger\n\nThe Logger class provides convenient logging without worrying about handler conflicts with the native Python logging module.\n\n```python\n# load spinesUtils module\nfrom spinesUtils.logging import Logger # The alias is FastLogger\n\n# create a logger instance, with name \"MyLogger\", and no file handler, the default level is \"INFO\"\n# You can specify a file path `fp` during instantiation. If not specified, logs will not be written to a file.\nlogger = Logger(name=\"MyLogger\", fp=None, level=\"DEBUG\")\n\nlogger.log(\"This is an info log emitted by the log function.\", level='INFO')\nlogger.debug(\"This is an debug message\")\nlogger.info(\"This is an info message.\")\nlogger.warning(\"This is an warning message.\")\nlogger.error(\"This is an error message.\")\nlogger.critical(\"This is an critical message.\")\n```\n\n#### Performance Comparison\n\nFastLogger vs Python's standard logging library (1 million messages, 20 threads):\n\n| Metric | Standard logging | FastLogger | Improvement |\n|--------|-----------------|------------|-------------|\n| Total time (seconds) | 17.73 | 0.82 | 21.58x faster |\n| Messages per second | 56,389 | 1,216,862 | 21.58x higher |\n| Write speed (MB/s) | 6.94 | 14.04 | 2.02x faster |\n| Average message size (bytes) | 129.00 | 12.10 | 10.66x smaller |\n| Total log file size (MB) | 123.02 | 11.54 | 10.66x smaller |\n\n*Test environment: MacBook Pro (Apple Silicon M1 Pro, 32GB RAM)*\n\n### Type Checking and Parameter Validation\n\nEnsure your functions receive the correct input types and values:\n\n```python\nfrom spinesUtils.asserts import *\n\n# Check parameter type\n@ParameterTypeAssert({\n    'a': (int, float),\n    'b': (int, float)\n})\ndef add(a, b):\n    return a + b\n\n# Check parameter value\n@ParameterValuesAssert({\n    'a': lambda x: x \u003e 0,\n    'b': lambda x: x \u003e 0\n})\ndef divide(a, b):\n    return a / b\n\n# Generate function kwargs\nparams = generate_function_kwargs(add, a=1, b=2)\n```\n\n### CSV Reading Acceleration\n\nRead large CSV files efficiently:\n\n```python\nfrom spinesUtils import read_csv\n\ndf = read_csv(\n    fp='/path/to/your/file.csv',\n    sep=',',  # equal to pandas read_csv.sep\n    turbo_method='polars',  # use turbo_method to speed up load time\n    chunk_size=None,  # it can be integer if you want to use pandas backend\n    transform2low_mem=True,  # compresses file to save memory\n    verbose=False\n)\n```\n\n### Classifiers for Imbalanced Data\n\nHandle imbalanced datasets effectively:\n\n```python\nfrom spinesUtils.models import MultiClassBalanceClassifier\nfrom sklearn.ensemble import RandomForestClassifier\n\nclassifier = MultiClassBalanceClassifier(\n    base_estimator=RandomForestClassifier(n_estimators=100),\n    n_classes=3,\n    random_state=0,\n    verbose=0\n)\n\n# Fit and predict as you would with any scikit-learn estimator\nclassifier.fit(X_train, y_train)\ny_pred = classifier.predict(X_test)\n```\n\n### DataFrame Data Compression\n\nOptimize memory usage for large DataFrames:\n\n```python\nfrom spinesUtils import transform_dtypes_low_mem\n\n# Compress a single DataFrame\ntransform_dtypes_low_mem(df, verbose=True, inplace=True)\n\n# Batch compress multiple DataFrames\nfrom spinesUtils import transform_batch_dtypes_low_mem\ntransform_batch_dtypes_low_mem([df1, df2, df3, df4], verbose=True, inplace=True)\n```\n\n### DataFrame Insight Tools\n\nQuickly analyze your data:\n\n```python\nfrom spinesUtils import df_preview, classify_samples_dist\n\n# Get comprehensive DataFrame insights\ndf_insight = df_preview(df)\n```\n\n### Data Splitting Utilities\n\nEfficiently split large datasets:\n\n```python\nfrom spinesUtils import train_test_split_bigdata, train_test_split_bigdata_df\nfrom spinesUtils.feature_tools import get_x_cols\n\n# Return numpy arrays\nX_train, X_valid, X_test, y_train, y_valid, y_test = train_test_split_bigdata(\n    df=df, \n    x_cols=get_x_cols(df, y_col='target_column'),\n    y_col='target_column', \n    shuffle=True,\n    return_valid=True,\n    train_size=0.8,\n    valid_size=0.5\n)\n\n# Return pandas DataFrames\ntrain_df, valid_df, test_df = train_test_split_bigdata_df(\n    df=df, \n    x_cols=get_x_cols(df, y_col='target_column'),\n    y_col='target_column', \n    shuffle=True,\n    return_valid=True,\n    train_size=0.8,\n    valid_size=0.5\n)\n```\n\n### Timer Utility\n\nTime your code execution simply:\n\n```python\nfrom spinesUtils.timer import Timer\n\n# As a context manager\nwith Timer().session() as t:\n    # Your code here\n    t.sleep(1)\n    print(f\"Step 1 time: {t.last_timestamp_diff():.2f}s\")\n    \n    # Mark a middle point\n    t.middle_point()\n    \n    # More code\n    t.sleep(2)\n    print(f\"Step 2 time: {t.last_timestamp_diff():.2f}s\")\n    \nprint(f\"Total time: {t.total_elapsed_time():.2f}s\")\n\n# Or use it manually\ntimer = Timer()\ntimer.start()\n# Your code here\ntimer.end()\nprint(f\"Elapsed: {timer.total_elapsed_time():.2f}s\")\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirchkwok%2Fspinesutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbirchkwok%2Fspinesutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirchkwok%2Fspinesutils/lists"}