{"id":13716265,"url":"https://github.com/enochkan/torch-metrics","last_synced_at":"2025-05-07T05:32:28.244Z","repository":{"id":47166368,"uuid":"309782802","full_name":"enochkan/torch-metrics","owner":"enochkan","description":"Metrics for model evaluation in pytorch","archived":false,"fork":false,"pushed_at":"2021-03-22T18:02:50.000Z","size":43,"stargazers_count":113,"open_issues_count":0,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-27T10:04:23.100Z","etag":null,"topics":["computer-vision","deep-learning","machine-learning","metrics","pytorch","pytorch-cnn","pytorch-implementation","torch-metrics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enochkan.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}},"created_at":"2020-11-03T19:08:46.000Z","updated_at":"2025-01-28T08:16:53.000Z","dependencies_parsed_at":"2022-09-12T14:34:20.617Z","dependency_job_id":null,"html_url":"https://github.com/enochkan/torch-metrics","commit_stats":null,"previous_names":["chinokenochkan/torch-metrics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enochkan%2Ftorch-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enochkan%2Ftorch-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enochkan%2Ftorch-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enochkan%2Ftorch-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enochkan","download_url":"https://codeload.github.com/enochkan/torch-metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252823192,"owners_count":21809702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["computer-vision","deep-learning","machine-learning","metrics","pytorch","pytorch-cnn","pytorch-implementation","torch-metrics"],"created_at":"2024-08-03T00:01:08.697Z","updated_at":"2025-05-07T05:32:27.943Z","avatar_url":"https://github.com/enochkan.png","language":"Python","funding_links":[],"categories":["Pytorch \u0026 related libraries｜Pytorch \u0026 相关库","Pytorch \u0026 related libraries"],"sub_categories":["NLP \u0026 Speech Processing｜自然语言处理 \u0026 语音处理:","NLP \u0026 Speech Processing:"],"readme":"# Torch-metrics\n\n[![PyPI version](https://badge.fury.io/py/torch-metrics.svg)](https://badge.fury.io/py/torch-metrics)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nModel evaluation metrics for PyTorch\n\nTorch-metrics serves as a custom library to provide common ML evaluation metrics in Pytorch, similar to `tf.keras.metrics`.\n\nAs summarized in this [issue](https://github.com/pytorch/pytorch/issues/22439), Pytorch does not have a built-in libary `torch.metrics` for model evaluation metrics. This is similar to the metrics library in [PyTorch Lightning](https://pytorch-lightning.readthedocs.io/en/latest/metrics.html#class-metrics).\n\n## Usage\n\n- `pip install --upgrade torch-metrics`\n\n```python\nfrom torch_metrics import Accuracy\n\n## define metric ##\nmetric = Accuracy(from_logits=False)\ny_pred = torch.tensor([1, 2, 3, 4])\ny_true = torch.tensor([0, 2, 3, 4])\n\nprint(metric(y_pred, y_true))\n```\n\n```python\n\n## define metric ##\nmetric = Accuracy()\ny_pred = torch.tensor([[0.2, 0.6, 0.1, 0.05, 0.05],\n                       [0.2, 0.1, 0.6, 0.05, 0.05],\n                       [0.2, 0.05, 0.1, 0.6, 0.05],\n                       [0.2, 0.05, 0.05, 0.05, 0.65]])\ny_true = torch.tensor([0, 2, 3, 4])\n\nprint(metric(y_pred, y_true))\n```\n\n## Implementation\n\nMetrics from `tf.keras.metrics` and other metrics that are already implemented vs to-do\n\n- [x] MeanSquaredError class\n- [x] RootMeanSquaredError class\n- [x] MeanAbsoluteError class\n- [x] Precision class\n- [x] Recall class\n- [x] MeanIoU class\n- [x] DSC class (Dice Similarity Coefficient)\n- [x] F1Score class\n- [x] RSquared class\n- [x] Hinge class\n- [x] SquaredHinge class\n- [x] LogCoshError class\n- [x] Accuracy class\n- [x] KLDivergence class\n- [ ] CosineSimilarity class\n- [ ] AUC class\n- [ ] BinaryCrossEntropy class\n- [ ] CategoricalCrossEntropy class\n- [ ] SparseCategoricalCrossentropy class\n\n## Local Development and Testing\n\nTo quickly get started with local development, run:\n```python\nmake develop\n```\n\nTo test, run:\n```python\npython3 -m pytest\n```\n\n### Pre-commit hooks\n\nTo run pre-commit against all files:\n\n```python\npre-commit run --all-files\n```\n\n## Contributing\n\nPlease raise issues or feature requests [here](https://github.com/enochkan/torch-metrics/issues). It will be extremely helpful if you comment on a specific issue before working on it. This provides visibility for others who also intend to work on the same issue. Reference any pull requests to their original issues. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenochkan%2Ftorch-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenochkan%2Ftorch-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenochkan%2Ftorch-metrics/lists"}