{"id":28471591,"url":"https://github.com/openml/openml-pytorch","last_synced_at":"2025-10-10T14:02:54.957Z","repository":{"id":62577795,"uuid":"223965043","full_name":"openml/openml-pytorch","owner":"openml","description":"Pytorch extension for openml-python","archived":false,"fork":false,"pushed_at":"2025-04-26T21:02:35.000Z","size":11140,"stargazers_count":6,"open_issues_count":5,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-25T05:20:19.869Z","etag":null,"topics":["hacktoberfest","openml","python","pytorch","pytorch-extension"],"latest_commit_sha":null,"homepage":"https://openml.github.io/openml-pytorch/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openml.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null},"funding":{"github":"openml","open_collective":"openml"}},"created_at":"2019-11-25T14:14:44.000Z","updated_at":"2025-04-26T21:01:54.000Z","dependencies_parsed_at":"2024-03-04T08:25:02.589Z","dependency_job_id":"99ac871d-4555-444f-a351-0a97c3b6adfa","html_url":"https://github.com/openml/openml-pytorch","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"3e404b5f3124898bb6b925e5e9e467c9fe9cc0b6"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/openml/openml-pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openml%2Fopenml-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openml%2Fopenml-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openml%2Fopenml-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openml%2Fopenml-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openml","download_url":"https://codeload.github.com/openml/openml-pytorch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openml%2Fopenml-pytorch/sbom","scorecard":{"id":709780,"data":{"date":"2025-08-11","repo":{"name":"github.com/openml/openml-pytorch","commit":"a952c6edda2c4782e21d0731a54e4b9ba587d1f7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/18 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: topLevel 'contents' permission set to 'write': .github/workflows/ci.yml:8","Warn: no topLevel permission defined: .github/workflows/python-package.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/openml/openml-pytorch/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/openml/openml-pytorch/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/openml/openml-pytorch/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/openml/openml-pytorch/python-package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/openml/openml-pytorch/python-package.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:29","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:30","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:31","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:32","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:33","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:34","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:35","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:36","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:37","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:29","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:30","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:31","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:32","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of  13 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 19 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-8qvm-5x2c-j2w7","Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: PYSEC-2025-49 / GHSA-5rjg-fvgr-3xxf","Warn: Project is vulnerable to: GHSA-3749-ghw9-m3mg","Warn: Project is vulnerable to: GHSA-887c-mr87-cxwp","Warn: Project is vulnerable to: GHSA-48p4-8xcf-vxj5","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T07:47:06.346Z","repository_id":62577795,"created_at":"2025-08-22T07:47:06.346Z","updated_at":"2025-08-22T07:47:06.346Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004066,"owners_count":26083669,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["hacktoberfest","openml","python","pytorch","pytorch-extension"],"created_at":"2025-06-07T11:08:01.043Z","updated_at":"2025-10-10T14:02:54.925Z","avatar_url":"https://github.com/openml.png","language":"Jupyter Notebook","funding_links":["https://github.com/sponsors/openml","https://opencollective.com/openml"],"categories":[],"sub_categories":[],"readme":"# Pytorch extension for OpenML python\n\nPytorch extension for [openml-python API](https://github.com/openml/openml-python). This library provides a simple way to run your Pytorch models on OpenML tasks. \n\nFor a more native experience, PyTorch itself provides OpenML integrations for some tasks. You can find more information [here](\u003cIntegrations of OpenML in PyTorch.md\u003e).\n\n## Installation Instructions:\n\n\u003c!-- `pip install openml-pytorch` --\u003e\nWhile this project does exist on pypi, while everything is being finalized, it is recommended to install the package directly from the repository. \n\n```bash\npip install git+https://github.com/openml/openml-pytorch -U\n```\n\nPyPi link https://pypi.org/project/openml-pytorch/\n\nSet the API key for OpenML from the command line:\n```bash\nopenml configure apikey \u003cyour API key\u003e\n```\n\n## Usage\n### Load Data from OpenML and Train a Model\n```python\n# Import libraries\nimport openml\nimport torch\nimport numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom typing import Any\nfrom tqdm import tqdm\n\nfrom openml_pytorch import GenericDataset\n\n# Get dataset by ID and split into train and test\ndataset = openml.datasets.get_dataset(20)\nX, y, _, _ = dataset.get_data(target=dataset.default_target_attribute)\nX = X.to_numpy(dtype=np.float32)  \ny = y.to_numpy(dtype=np.int64)    \nX_train, X_test, y_train, y_test = train_test_split(X, y, random_state=1, stratify=y)\n\n# Dataloaders\nds_train = GenericDataset(X_train, y_train)\nds_test = GenericDataset(X_test, y_test)\ndataloader_train = torch.utils.data.DataLoader(ds_train, batch_size=64, shuffle=True)\ndataloader_test = torch.utils.data.DataLoader(ds_test, batch_size=64, shuffle=False)\n\n# Model Definition\nclass TabularClassificationModel(torch.nn.Module):\n    def __init__(self, input_size, output_size):\n        super(TabularClassificationModel, self).__init__()\n        self.fc1 = torch.nn.Linear(input_size, 128)\n        self.fc2 = torch.nn.Linear(128, 64)\n        self.fc3 = torch.nn.Linear(64, output_size)\n        self.relu = torch.nn.ReLU()\n        self.softmax = torch.nn.Softmax(dim=1)\n\n    def forward(self, x):\n        x = self.fc1(x)\n        x = self.relu(x)\n        x = self.fc2(x)\n        x = self.relu(x)\n        x = self.fc3(x)\n        x = self.softmax(x)\n        return x\n\n# Train the model. Feel free to replace this with your own training pipeline. \ntrainer = BasicTrainer(\n    model = TabularClassificationModel(X_train.shape[1], len(np.unique(y_train))),\n    loss_fn = torch.nn.CrossEntropyLoss(),\n    opt = torch.optim.Adam,\n    dataloader_train = dataloader_train,\n    dataloader_test = dataloader_test,\n    device= torch.device(\"mps\")\n)\ntrainer.fit(10)\n```\n## More Complex Image Classification Example\n\nImport openML libraries\n```python\n# openml imports\nimport openml\nimport openml_pytorch as op\nfrom openml_pytorch.callbacks import TestCallback\nfrom openml_pytorch.metrics import accuracy\nfrom openml_pytorch.trainer import convert_to_rgb\n\n# pytorch imports\nfrom torch.utils.tensorboard.writer import SummaryWriter\nfrom torchvision.transforms import Compose, Resize, ToPILImage, ToTensor, Lambda\nimport torchvision\n\n# other imports\nimport logging\nimport warnings\n\n# set up logging\nopenml.config.logger.setLevel(logging.DEBUG)\nop.config.logger.setLevel(logging.DEBUG)\nwarnings.simplefilter(action='ignore')\n## Data\n### Define image transformations\n\n\ntransform = Compose(\n    [\n        ToPILImage(),  # Convert tensor to PIL Image to ensure PIL Image operations can be applied.\n        Lambda(convert_to_rgb),  # Convert PIL Image to RGB if it's not already.\n        Resize((64, 64)),  # Resize the image.\n        ToTensor(),  # Convert the PIL Image back to a tensor.\n    ]\n)\n\n### Configure the Data Module and Choose a Task\n\"\"\"\n- Make sure the data is present in the `file_dir` directory, and the `filename_col` is correctly set along with this column correctly pointing to where your data is stored. \n\"\"\"\ndata_module = op.OpenMLDataModule(\n    type_of_data=\"image\",\n    file_dir=\"datasets\",\n    filename_col=\"image_path\",\n    target_mode=\"categorical\",\n    target_column=\"label\",\n    batch_size=64,\n    transform=transform,\n)\n\n# Download the OpenML task for tiniest imagenet\ntask = openml.tasks.get_task(363295)\n\n## Model\nmodel = torchvision.models.resnet18(num_classes=200)\n## Train your model on the data\n#- Note that by default, OpenML runs a 10 fold cross validation on the data. You cannot change this for now.\nimport torch\n\ntrainer = op.OpenMLTrainerModule(\n    experiment_name= \"Tiny ImageNet\",\n    data_module=data_module,\n    verbose=True,\n    epoch_count=2,\n    metrics= [accuracy],\n    # remove the TestCallback when you are done testing your pipeline. Having it here will make the pipeline run for a very short time.\n    callbacks=[\n        # TestCallback,\n    ],\n    opt = torch.optim.Adam,\n)\nop.config.trainer = trainer\nrun = openml.runs.run_model_on_task(model, task, avoid_duplicate_runs=False)\n## View information about your run\n### Learning rate and loss plot\ntrainer.plot_loss()\ntrainer.plot_lr()\ntrainer.plot_all_metrics()\n### Class labels\ntrainer.model_classes\n## Model Vizualization\n#- Sometimes you may want to visualize the model. You can either use netron or tensorboard for this purpose.\n### Netron\ntrainer.export_to_netron()\n### Tensorboard\n\"\"\"\n- By default, openml will log the tensorboard logs in the `tensorboard_logs` directory. You can view the logs by running `tensorboard --logdir tensorboard_logs` in the terminal.\n\"\"\"\n## Publish your model to OpenML\n\"\"\"\n- This is Optional, but publishing your model to OpenML will allow you to track your experiments and compare them with others.\n- Make sure to set your apikey first.\n  - You can find your apikey on your OpenML account page.\n\"\"\"\ntrainer.plot_all_metrics()\nopenml.config.apikey = ''\nrun = op.add_experiment_info_to_run(run=run, trainer=trainer) \nrun.publish()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenml%2Fopenml-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenml%2Fopenml-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenml%2Fopenml-pytorch/lists"}