{"id":20063744,"url":"https://github.com/geometric-intelligence/dyn","last_synced_at":"2025-10-17T03:55:46.505Z","repository":{"id":103709951,"uuid":"503111738","full_name":"geometric-intelligence/dyn","owner":"geometric-intelligence","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-13T21:02:01.000Z","size":38529,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T17:33:14.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/geometric-intelligence.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}},"created_at":"2022-06-13T20:53:42.000Z","updated_at":"2024-06-12T18:30:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"2e5c703d-5871-46ea-87f2-a99e420f55fb","html_url":"https://github.com/geometric-intelligence/dyn","commit_stats":null,"previous_names":["geometric-intelligence/dyn"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/geometric-intelligence/dyn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometric-intelligence%2Fdyn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometric-intelligence%2Fdyn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometric-intelligence%2Fdyn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometric-intelligence%2Fdyn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geometric-intelligence","download_url":"https://codeload.github.com/geometric-intelligence/dyn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometric-intelligence%2Fdyn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279279821,"owners_count":26139194,"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-17T02:00:07.504Z","response_time":56,"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":[],"created_at":"2024-11-13T13:43:39.347Z","updated_at":"2025-10-17T03:55:46.440Z","avatar_url":"https://github.com/geometric-intelligence.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Regression-Based Elastic Metric Learning #\n\nOfficial implementation of the paper “Regression-Based Elastic Metric Learning on Shape Spaces of Cell Curves”.\n\n***[[Paper](https://arxiv.org/abs/2210.01932)] published at [[NeurIPS Workshop Learning Meaningful Representations of Life](https://www.lmrl.org/)]***\n\n## 💥 NeurIPS LMRL Poster ##\n\n![NeurIPS Poster](/images/poster.jpg)\n\n## 🎤 See our Interview on Machine Learning Street Talk! ##\n\n[![MLST Interview](/images/interview.jpg)](https://www.youtube.com/watch?v=24u6CTV4t1k)\n\n## ⭐️ Overview of Goals ##\n\n- Regression-Based Elastic Metric Learning is a machine learning tool designed to improve analysis of discrete parameterizations of 2D cures changing over time.\n- Specifically, we optimize geodesic regression analysis by learning the elastic metric parameters that model a given data trajectory close to a geodesic.\n\n![Overview of REML's goal and results](/images/summary.jpg)\n\nLeft: A trajectory may follow a geodesic as calculated by one metric but not follow a geodesic as calculated by another metric. Our paradigm learns the elastic metric (parameterized by $a$) that best models the data trajectory as a geodesic on the manifold of discrete curves. Right: true cell trajectory overlaid with 1) cells predicted by a regression which utilizes our paradigm’s learned metric parameter ($a*$) 2) cells predicted by a square-root-velocity (SRV) regression. Regression predictions using the SRV metric (red) do not match the data trajectory (blue), but our algorithm’s $a*$ predicts the data trajectory perfectly: our prediction (green) perfectly overlays the data trajectory (blue).\n\n### Elastic Metric ###\n- We consider a family of elastic metrics [given by:](https://www.researchgate.net/publication/225134644_On_Shape_of_Plane_Elastic_Curves)\n\n$$g^{a, b}\\_c(h, k) = a^2 \\int_{0}^1\\langle D_sh, N\\rangle\\langle D_sk, N\\rangle ds + b^2 \\int_{0}^1\\langle D_sh, T\\rangle\\langle D_sk, T\\rangle ds$$\n\n- We use the elastic metric implementation in [Geomstats](https://geomstats.github.io/).\n- The elastic metric is parameterized by $a$ and $b$ which quantify how much two shapes are \"stretched\" or \"bent\" compared to each other, respectively.\n- Changing $a$ and $b$ of the elastic metric changes the distance between various points on the manifold of discrete curves: the space where we analyze curves. As such, changing $a$ and $b$ changes the nature of geodesics on the manifold of discrete curves.\n\n![\"a\" and \"b\" = \"stretching\" and \"bending\"](/images/bend_stretch_operations.jpg)\n\n- Note that the ratio $a/b$ is sufficient to describe variationos of $ g^{a, b}$. Thus, we set $b=0.5$, as varying $b$ only changes units of the calculation.\n- Our paradigm learns the $a*$ (and therefore the ratio $a*/b$) which models the data trajectory as being closest to a geodesic, as evaluated by the coefficient of determination $R^2$.\n- We use a gradient ascent algorithm, along with our derived analytical expression of $R^2$ in terms of $a$, to find the $a*$ which maximizes $R^2$ for a given trajectory.\n\n### Experiments ###\n\n- We apply our paradigm to data trajectories of cell outlines changing over time\n- For each experiement, we generate a semi-synthetic data trajectory by drawing a geodesic between two real cancer cells\n\n![semi-synthetic cell trajectory](/images/synthetic_trajectory.jpg)\n\n- We create the trajectory with a predetermined 1) number of cells 2) number of sampling points (how many times each cell outline is sampled) 3) amount of noise 4) \"true $a$\" (the metric used to draw the geodesic between real cancer cells). Note that because the semi-synthetic geodesic is drawn with the metric parameter $a_{true}$, the metric parameter $a_{true}$ WILL model the trajectory as a geodesic.\n- Thus, the gradient ascent learning scheme aims to learn an $a*$ close to $a_{true}$.\n\n\n### Results ###\n- We compare the predictive power of $a*$ regression to the predictive power of regression with the square-root-velocity (SRV) metric, which is a special case of the elastic metric where $a = 1$ and $b = 0.5$.\n- Performing geodesic regression with our learned $a*$ metric parameter improves predictive power to geodesic regression, as geodesic regression is more accurate when the data trajectory is close to a geodesic.\n\n![REML increases predictive power of geodesic regression](/images/ideal_conditions.jpg)\n\n![REML converges a* to a_true and r2 to 1](/images/convergence_results.jpg)\n\n\n## 🌎 Bibtex ##\nIf this code is useful to your research, please cite:\n\n```\n@misc{https://doi.org/10.48550/arxiv.2210.01932,\n  doi = {10.48550/ARXIV.2210.01932},\n\n  url = {https://arxiv.org/abs/2210.01932},\n\n  author = {Myers, Adele and Miolane, Nina},\n\n  keywords = {Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},\n\n  title = {Regression-Based Elastic Metric Learning on Shape Spaces of Elastic Curves},\n\n  publisher = {arXiv},\n\n  year = {2022},\n\n  copyright = {Creative Commons Attribution 4.0 International}\n}\n```\n\n## 🏡 Installation ##\n\nThis codes runs on Python 3.8. We recommend using Anaconda for easy installation. To create the necessary conda environment, run:\n```\ncd dyn\nconda env create -f environment.yml\nconda activate dyn\n```\n\n## 🏃‍♀️ Run the Code ##\n\nWe use Wandb to keep track of our runs. To launch a new run, follow the steps below.\n\n#### 1. Set up [Wandb](https://wandb.ai/home) logging.\n\nWandb is a powerful tool for logging performance during training, as well as animation artifacts. To use it, simply [create an account](https://wandb.auth0.com/login?state=hKFo2SBNb0U4SjE0ZWN3OGZtbTlJWTRpYkNmU0dUTWZKSDk3Y6FupWxvZ2luo3RpZNkgODhWd254WW1zdG51RTREd0pWOGVKWVVzZkVOZ0dydGqjY2lk2SBWU001N1VDd1Q5d2JHU3hLdEVER1FISUtBQkhwcHpJdw\u0026client=VSM57UCwT9wbGSxKtEDGQHIKABHppzIw\u0026protocol=oauth2\u0026nonce=dEZVS3dvYXFVSjdjZFFGdw%3D%3D\u0026redirect_uri=https%3A%2F%2Fapi.wandb.ai%2Foidc%2Fcallback\u0026response_mode=form_post\u0026response_type=id_token\u0026scope=openid%20profile%20email\u0026signup=true), then run:\n```\nwandb login\n```\nto sign into your account.\n\n#### 2. Create a new project in Wandb.\n\nCreate a new project in Wandb called \"metric-learning-TEST\".\n\n#### 3. Specify hyperparameters in default_config.py.\n\n\"main.py\" of our program runs through every combination of hyperparameters specified in \"default_config.py\". Change any of the following hyperparameters:\n- a_true: \"a\" is the metric parameter used to generate the synthetic shape trajectory. This is the metric parameter that the code is trying to learn.\n- n_sampling_points: the number of points in each cell shape\n- n_times: the number of cell shapes in the data trajectory\n- noise_std: the amount of noise added to the synthetic data. (how \"noisy\" is each cell shape)\n- percent_train: percent of the data trajectory used to train the regression model in our code\n- percent_val: percent of the data trajectory used to validate the regression model (using the coefficient of determination $R^2$) and learn a* (our code's best estimate of a_true). Note: the rest of the data trajectory that is not used to train or validate the model will be used to test the predictive power of a* regression against the baseline square-root-velocity (SRV) metric regression.\n- dataset: you can either test the code on a synthetic geodesic between a circle and an ellipse or a semi-synthetic geodesic between two real cancer cells.\n\n#### 4. Run!\nFor a single run, use the command:\n```\npython main.py\n```\nThis will initiate runs with every combination of hyperparameters detailed in default_config.py.\n\n### 5. 👀 See Results.\n\nYou can see all of your runs by logging into the Wandb webpage and looking under your project name \"metric-learning-TEST\". Our code automatically names each run as\n\n```\n\u003cdataset-used\u003e_\u003ca_true\u003e_\u003cgradient-ascent-initiation\u003e_mt1_\u003cn_times\u003e_\u003cn_sampling_points\u003e_\u003cnoise_std\u003e_\u003ctime-of-run\u003e\n```\n\n## 👩‍🔧 Authors ##\n[Adele Myers](https://ahma2017.wixsite.com/adelemyers)\n\n[Nina Miolane](https://www.ninamiolane.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeometric-intelligence%2Fdyn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeometric-intelligence%2Fdyn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeometric-intelligence%2Fdyn/lists"}