{"id":19664851,"url":"https://github.com/fluxml/mljflux.jl","last_synced_at":"2026-01-27T17:36:57.463Z","repository":{"id":38971391,"uuid":"190750820","full_name":"FluxML/MLJFlux.jl","owner":"FluxML","description":"Wrapping deep learning models from the package Flux.jl for use in the MLJ.jl toolbox","archived":false,"fork":false,"pushed_at":"2025-02-13T00:08:40.000Z","size":12295,"stargazers_count":145,"open_issues_count":25,"forks_count":16,"subscribers_count":11,"default_branch":"dev","last_synced_at":"2025-02-23T06:43:57.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://fluxml.ai/MLJFlux.jl/","language":"Julia","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/FluxML.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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},"funding":{"github":["JuliaLang"]}},"created_at":"2019-06-07T13:47:37.000Z","updated_at":"2025-02-12T19:36:34.000Z","dependencies_parsed_at":"2022-07-13T17:20:44.024Z","dependency_job_id":"98e8210b-dfbe-4176-9e7e-6c8e53466ed9","html_url":"https://github.com/FluxML/MLJFlux.jl","commit_stats":{"total_commits":341,"total_committers":18,"mean_commits":"18.944444444444443","dds":"0.32258064516129037","last_synced_commit":"452c09d7dc13914f4057c661448bc310c9362d3d"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluxML%2FMLJFlux.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluxML%2FMLJFlux.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluxML%2FMLJFlux.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluxML%2FMLJFlux.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FluxML","download_url":"https://codeload.github.com/FluxML/MLJFlux.jl/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240974465,"owners_count":19887302,"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":[],"created_at":"2024-11-11T16:19:16.877Z","updated_at":"2026-01-27T17:36:57.418Z","avatar_url":"https://github.com/FluxML.png","language":"Julia","funding_links":["https://github.com/sponsors/JuliaLang"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"left\"\u003e\n    \u003cimg width=\"490\" alt=\"image\" src=\"https://github.com/FluxML/MLJFlux.jl/assets/49572294/f28300e9-44cb-4d1a-8acf-8a682230be31\"\u003e\n    \nAn interface to the Flux deep learning models for the [MLJ](https://github.com/alan-turing-institute/MLJ.jl) machine learning framework\n\n\u003c/div\u003e\n\n[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://fluxml.github.io/MLJFlux.jl/dev/)\n\n\n| Branch   | Julia | CPU CI | GPU CI | Coverage |\n| -------- | ----- | ------ | -----  | -------- |\n| `master` | v1    | [![Continuous Integration (CPU)][gha-img-master]][gha-url] | [![Continuous Integration (GPU)][buildkite-julia1-img-master]][buildkite-url] | [![Code Coverage][coveralls-img-master]][coveralls-url] |\n| `dev`    | v1    | [![Continuous Integration (CPU)][gha-img-dev]][gha-url] | [![Continuous Integration (GPU)][buildkite-julia1-img-dev]][buildkite-url] | [![Code Coverage][coveralls-img-dev]][coveralls-url] |\n\n[gha-img-master]: https://github.com/FluxML/MLJFlux.jl/workflows/CI/badge.svg?branch=master \"Continuous Integration (CPU)\"\n[gha-img-dev]: https://github.com/FluxML/MLJFlux.jl/workflows/CI/badge.svg?branch=dev \"Continuous Integration (CPU)\"\n[gha-url]: https://github.com/FluxML/MLJFlux.jl/actions/workflows/ci.yml\n\n[buildkite-julia1-img-master]: https://badge.buildkite.com/ae439e1f6ed6f178342a0ed166d0983de6ec1b72325e4e3e7e.svg?branch=master\u0026step=Julia%20v1 \"Continuous Integration (GPU)\"\n[buildkite-julia1-img-dev]: https://badge.buildkite.com/ae439e1f6ed6f178342a0ed166d0983de6ec1b72325e4e3e7e.svg?branch=dev\u0026step=Julia%20v1 \"Continuous Integration (GPU)\"\n[buildkite-url]: https://buildkite.com/julialang/mljflux-dot-jl\n\n[coveralls-img-master]: https://coveralls.io/repos/github/alan-turing-institute/MLJFlux.jl/badge.svg?branch=master \"Code Coverage\"\n[coveralls-img-dev]: https://coveralls.io/repos/github/alan-turing-institute/MLJFlux.jl/badge.svg?branch=dev \"Code Coverage\"\n[coveralls-url]: https://github.com/FluxML/MLJFlux.jl/actions/workflows/ci.yml\n\n\n\n## Code Snippet\n\n```julia\nusing MLJ, MLJFlux, RDatasets, Plots\n```\n\nGrab some data and split into features and target:\n\n```julia\niris = RDatasets.dataset(\"datasets\", \"iris\");\ny, X = unpack(iris, ==(:Species), rng=123);\nX = Float32.(X);      # To optmise for GPUs\n```\n\nLoad model code and instantiate an MLJFlux model:\n\n```julia\nNeuralNetworkClassifier = @load NeuralNetworkClassifier pkg=MLJFlux\n\nclf = NeuralNetworkClassifier(\n    builder=MLJFlux.MLP(; hidden=(5,4)),\n    batch_size=8,\n    epochs=50,\n    acceleration=CUDALibs()  # for training on a GPU\n)\n```\n\nWrap in \"iteration controls\":\n\n```julia\nstop_conditions = [\n    Step(1),            # Apply controls every epoch\n    NumberLimit(1000),  # Don't train for more than 1000 steps\n    Patience(4),        # Stop after 4 iterations of deteriation in validation loss\n    NumberSinceBest(5), # Or if the best loss occurred 5 iterations ago\n    TimeLimit(30/60),   # Or if 30 minutes has passed\n]\n\nvalidation_losses = []\ntrain_losses = []\ncallbacks = [\n    WithLossDo(loss-\u003epush!(validation_losses, loss)),\n    WithTrainingLossesDo(losses-\u003epush!(train_losses, losses[end])),\n]\n\niterated_model = IteratedModel(\n    model=clf,\n    resampling=Holdout(fraction_train=0.5); # loss and stopping are based on out-of-sample\n    measures=log_loss,\n    controls=vcat(stop_conditions, callbacks),\n);\n```\n\nTrain the wrapped model:\n\n```julia-repl\njulia\u003e mach = machine(iterated_model, X, y)\njulia\u003e fit!(mach)\n\n[ Info: No iteration parameter specified. Using `iteration_parameter=:(epochs)`. \n[ Info: final loss: 0.1284184007796247\n[ Info: final training loss: 0.055630706\n[ Info: Stop triggered by NumberSinceBest(5) stopping criterion. \n[ Info: Total of 811 iterations. \n```\nInspect results:\n\n```julia-repl\njulia\u003e plot(train_losses, label=\"Training Loss\")\njulia\u003e plot!(validation_losses, label=\"Validation Loss\", linewidth=2, size=(800,400))\n```\n\n![](readme_figure.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluxml%2Fmljflux.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluxml%2Fmljflux.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluxml%2Fmljflux.jl/lists"}