1<!DOCTYPE html> 2<html lang="en-US"> 3 4<head> 5 <meta charset="utf-8"> 6 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 7 <meta name="viewport" content="width=device-width, initial-scale=1"> 8 9 <link rel="stylesheet" href="/css/main.css"> 10 <link rel="stylesheet" href="/css/font-awesome.min.css"> 11 12 <link rel="shortcut icon" href="/favicon.ico?1"> 13 <title>Why modelx | modelx</title> 14 <!-- Begin Jekyll SEO tag v2.8.0 --> 15<meta name="generator" content="Jekyll v3.10.0" /> 16<meta property="og:title" content="Why modelx" /> 17<meta name="author" content="modelx developers" /> 18<meta property="og:locale" content="en_US" /> 19<meta name="description" content="Build actuarial models as code. modelx is an open-source Python modeling system with formula dependency tracing, Git-friendly plain-text models, export to standalone pure-Python packages, and native compilation via modelx-cython." /> 20<meta property="og:description" content="Build actuarial models as code. modelx is an open-source Python modeling system with formula dependency tracing, Git-friendly plain-text models, export to standalone pure-Python packages, and native compilation via modelx-cython." /> 21<link rel="canonical" href="https://modelx.io/features.html" /> 22<meta property="og:url" content="https://modelx.io/features.html" /> 23<meta property="og:site_name" content="modelx" /> 24<meta property="og:type" content="website" /> 25<meta name="twitter:card" content="summary" /> 26<meta property="twitter:title" content="Why modelx" />
27<script type="application/ld+json"> 28{"@context":"https://schema.org","@type":"WebPage","author":{"@type":"Person","name":"modelx developers"},"description":"Build actuarial models as code. modelx is an open-source Python modeling system with formula dependency tracing, Git-friendly plain-text models, export to standalone pure-Python packages, and native compilation via modelx-cython.","headline":"Why modelx","url":"https://modelx.io/features.html"}</script>
28 29<!-- End Jekyll SEO tag --> 30 31 <!-- TODO(fumito): provide a social card image for og:image --> 32 33 <link rel="canonical" href="https://modelx.io/features.html"> 34 <link rel="alternate" type="application/rss+xml" title="modelx" href="https://modelx.io/feed.xml" /> 35 36 <!-- Google Tag Manager --> 37
37<script>
vendor: 343 bytes, lines 37-41
37(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 38 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 39 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 40 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 41 })(window,document,'script','dataLayer','
41GTM-TGFDZ8H
vendor: 3 bytes, line 41
41');
41</script>
41 42 <!-- End Google Tag Manager --> 43 44</head> 45 46 47<body> 48 <!-- Google Tag Manager (noscript) -->
vendor: 70 bytes, lines 48-49
48 49 <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=
49GTM-TGFDZ8H
vendor: 87 bytes, lines 49-51
49" 50 height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> 51
51<!-- End Google Tag Manager (noscript) --> 52 53 <nav class="navbar-inverse navbar-default navbar-fixed-top"> 54 <div class="container navbar-container"> 55 <div class="navbar-header"> 56 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> 57 <span class="sr-only">Toggle navigation</span> 58 <span class="icon-bar"></span> 59 <span class="icon-bar"></span> 60 <span class="icon-bar"></span> 61 </button> 62 <a class="navbar-brand" href="/"> 63 <span><img src="/img/logonav.png" alt="Logo"></span> modelx 64 </a> 65 </div> 66 <div id="navbar" class="collapse navbar-collapse"> 67 <ul class="nav navbar-nav"> 68 <!-- 69 <li ><a href="/docs">Docs</a></li> 70 --> 71 <li><a href="/#install">Install</a></li> 72 <li><a href="https://docs.modelx.io/en/latest/tutorial/index.html">Get Started</a></li> 73 <li><a href="/features.html">Why modelx</a></li> 74 <li><a href="/ai.html">AI Agents</a></li> 75 <li><a href="https://lifelib.io">Examples (lifelib)</a></li> 76 <li><a href="https://docs.modelx.io/en/latest/index.html">Docs</a></li> 77 <li ><a href="/allposts.html">Blog</a></li> 78 </ul> 79 <div class="navbar-right"> 80 <ul class="nav navbar-nav"> 81 <li><a href="https://github.com/fumitoh/modelx"><i class="fa fa-github" aria-hidden="true"></i></a></li> 82 </ul> 83 </div> 84 </div> 85 </div> 86</nav> 87 88 89 <div class="page-content"> 90 <div class="wrapper"> 91 <div class="container"> 92 <div class="row"> 93 <div class="col-md-3"> 94 <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> 95 96 <div class="panel panel-default"> 97 <div class="panel-heading"> 98 <h4 class="panel-title"> 99 <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-" aria-expanded="false" aria-controls="collapse-"> 100 Features 101 </a> 102 </h4> 103 </div> 104 <div id="collapse-" class="panel-collapse" role="tabpanel" aria-label="Side Navigation"> 105 <div class="list-group"> 106 <span class="list-group-item disabled"><strong>Why modelx</strong></span> 107 <a class="list-group-item" href="/features.html#coming-from-excel">Coming from Excel</a> 108 <a class="list-group-item" href="/features.html#coming-from-plain-python">Coming from plain Python</a> 109 <a class="list-group-item" href="/features.html#coming-from-commercial-modeling-systems">Coming from commercial systems</a> 110 111 <span class="list-group-item disabled"><strong>Deployment & performance</strong></span> 112 113 114 115 116 <a class="list-group-item" href="/features.html#export-to-pure-python">Export to pure Python</a> 117 118 119 120 121 <a class="list-group-item" href="/features.html#native-compilation-with-modelx-cython">Native compilation with modelx-cython</a> 122 123 124 <span class="list-group-item disabled"><strong>Modeling in a GUI</strong></span> 125 126 127 128 129 <a class="list-group-item" href="/features.html#gui-as-spyder-plugin">GUI as Spyder plugin</a> 130 131 132 <span class="list-group-item disabled"><strong>Governance & auditability</strong></span> 133 134 135 136 137 <a class="list-group-item" href="/features.html#dependency-tracing">Dependency tracing</a> 138 139 140 141 142 <a class="list-group-item" href="/features.html#version-control">Version control</a> 143 144 145 146 147 <a class="list-group-item" href="/features.html#document-integration">Document integration</a> 148 149
150 <span class="list-group-item disabled"><strong>Model design & productivity</strong></span> 151 152 153 154 155 <a class="list-group-item" href="/features.html#no-programming">Automatic calculation order</a> 156 157 158 159 160 <a class="list-group-item" href="/features.html#readable-formulas">Readable formulas</a> 161 162 163 164 165 <a class="list-group-item" href="/features.html#object-oriented">Object-oriented</a> 166 167 168 169 170 <a class="list-group-item" href="/features.html#parameterization">Parameterization</a> 171 172 173 174 175 <a class="list-group-item" href="/features.html#excel-interface">Excel Interface</a> 176 177 178 </div> 179 </div> 180 </div> 181 182</div> 183 184 <!-- 185 <div class="bs-component"> 186 <div class="list-group"> 187 188 </div> 189 </div> 190 --> 191 </div> 192 <div class="col-md-9"> 193 <h1>Why modelx</h1> 194 <div id="markdown-content-container"><p>An actuarial modeling system has to deliver four things at once: 195<strong>transparency</strong>, <strong>auditability</strong>, <strong>performance</strong> and 196<strong>maintainability</strong>. modelx approaches all four with a single principle: 197actuarial models are code â plain, readable Python.</p> 198 199<div class="row feature-signposts"> 200 <div class="col-sm-4"> 201 <h3 id="coming-from-excel">Coming from Excel</h3> 202 <ul> 203 <li><a href="#dependency-tracing">Trace any result to its inputs</a></li> 204 <li><a href="#version-control">Git diffs, not workbook copies</a></li> 205 <li><a href="#excel-interface">Excel stays your data interface</a></li> 206 </ul> 207 </div> 208 <div class="col-sm-4"> 209 <h3 id="coming-from-plain-python">Coming from plain Python</h3> 210 <ul> 211 <li><a href="#no-programming">No orchestration code to write</a></li> 212 <li><a href="#object-oriented">Structure: spaces, inheritance, parameters</a></li> 213 <li><a href="#document-integration">Models double as documentation</a></li> 214 </ul> 215 </div> 216 <div class="col-sm-4"> 217 <h3 id="coming-from-commercial-modeling-systems">Coming from commercial systems</h3> 218 <ul> 219 <li>Every formula inspectable, no license cost (LGPLv3)</li> 220 <li><a href="ai.html">Open Python ecosystem and AI agents</a></li> 221 <li><a href="#export-to-pure-python">No lock-in—not even to modelx</a></li> 222 </ul> 223 </div> 224</div> 225 226<h2 id="deployment--performance">Deployment & performance</h2> 227 228<p>Build in modelx; ship plain Python; compile it native when you need speed. 229No step requires a proprietary runtime.</p> 230 231<pre><code class="language-mermaid"> 232graph LR 233A(Build in modelx) -- "model.export()" --> B(Pure-Python package<br />runs without modelx) 234B -- mx2cy --> C(Native-compiled model) 235</code></pre> 236 237<h3 id="export-to-pure-python">Export to pure Python</h3> 238 239<p>Since modelx 0.22.0, <a href="https://docs.modelx.io/en/latest/reference/generated/modelx.core.model.Model.export.html"><code class="language-plaintext highlighter-rouge">Model.export</code></a> turns any model into a 240self-contained Python packageâplain code with no runtime dependency 241on modelx, deployable wherever Python runs:</p> 242 243<div class="language-py highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">model</span><span class="p">.</span><span class="n">export</span><span class="p">(</span><span class="s">"TermLife_ex"</span><span class="p">)</span> 244 245<span class="o">>>></span> <span class="kn">from</span> <span class="nn">TermLife_ex</span> <span class="kn">import</span> <span class="n">mx_model</span> <span class="c1"># no modelx needed 246</span> 247<span class="o">>>></span> <span class="n">mx_model</span><span class="p">.</span><span class="n">Projection</span><span class="p">.</span><span class="n">net_cf</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> 248<span class="mf">11.725013975627874</span> 249</code></pre></div></div> 250 251<p>Some features are not supported in exported modelsâsee 252<a href="https://docs.modelx.io/en/latest/reference/generated/modelx.core.model.Model.export.html"><code class="language-plaintext highlighter-rouge">Model.export</code></a> for current limitations and 253<a href="/blog/2023/07/29/export-feature-intro/">Introducing the Export Feature</a> 254for background.</p> 255 256<h3 id="native-compilation-with-modelx-cython">Native compilation with modelx-cython</h3> 257 258<p><a href="https://github.com/fumitoh/modelx-cython">modelx-cython</a> translates exported models to <a href="https://cython.org/">Cython</a> and compiles them 259to native code with a single command:</p> 260 261<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>mx2cy TermLife_ex 262</code></pre></div></div> 263 264<p>modelx-cython is at an early, experimental stageâsee the 265<a href="https://github.com/fumitoh/modelx-cython">modelx-cython</a> repository for status, and 266<a href="/blog/2023/10/21/introducing-modelx-cython/">Introducing modelx-cython</a> 267for background and measurements.</p> 268 269<h2 id="modeling-in-a-gui">Modeling in a GUI</h2> 270 271<h3 id="gui-as-spyder-plugin">GUI as Spyder plugin</h3> 272 273<p><a href="https://docs.modelx.io/en/latest/spyder.html">spyder-modelx</a> embeds 274modelx in <a href="https://www.spyder-ide.org/">Spyder</a>, the open-source Python 275IDE: <em>MxExplorer</em> shows the model as a tree with each cellâs formula a 276click away, <em>MxDataViewer</em> inspects results as DataFrames, and the 277precedents/dependents pane traces values interactively.</p> 278 279<p><a href="/img/MxPluginImage.png"> 280 <img src="/img/MxPluginImage.png" alt="spyder-modelx in Spyder: MxExplorer model tree, formula pane, MxDataViewer and dependency tracing" class="img-responsive" /> 281</a></p> 282 283<!-- TODO(fumito): fresh MxExplorer / MxDataViewer screenshots at the current spyder-modelx ver
283sion --> 284 285<p>Watch the <a href="https://www.youtube.com/watch?v=rHPuXmZd0TY">demo video</a> to 286see it in action.</p> 287 288<h2 id="governance--auditability">Governance & auditability</h2> 289 290<h3 id="dependency-tracing">Dependency tracing</h3> 291 292<p>Every calculated value knows its precedents and dependents, so you can 293trace an entire projection from result to assumptions:</p> 294 295<div class="language-py highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">Balance</span><span class="p">.</span><span class="n">preds</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> 296<span class="p">[</span><span class="n">Model1</span><span class="p">.</span><span class="n">Space1</span><span class="p">.</span><span class="n">Balance</span><span class="p">(</span><span class="n">t</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span><span class="o">=</span><span class="mi">400</span><span class="p">,</span> <span class="n">Model1</span><span class="p">.</span><span class="n">Space1</span><span class="p">.</span><span class="n">Cashflow</span><span class="p">(</span><span class="n">t</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span><span class="o">=</span><span class="mi">100</span><span class="p">]</span> 297 298<span class="o">>>></span> <span class="n">Balance</span><span class="p">.</span><span class="n">succs</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> 299<span class="p">[</span><span class="n">Model1</span><span class="p">.</span><span class="n">Space1</span><span class="p">.</span><span class="n">Balance</span><span class="p">(</span><span class="n">t</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span><span class="o">=</span><span class="mi">500</span><span class="p">]</span> 300</code></pre></div></div> 301 302<div class="row"> 303 <div class="col-sm-6"> 304 <img src="/img/features/DependencyTracingPrecedents.png" alt="Trace precedents" /> 305 </div> 306 <div class="col-sm-6"> 307 <img src="/img/features/DependencyTracingDependents.png" alt="Trace dependents" /> 308 </div> 309</div> 310 311<h3 id="version-control">Version control</h3> 312 313<p>Models are saved as plain Python text, so <a href="https://git-scm.com/">Git</a> gives you meaningful 314diffs, history, branches and code review. Plain text is also what AI 315coding agents readâsee <a href="ai.html">modelx and AI agents</a>.</p> 316 317<h3 id="document-integration">Document integration</h3> 318 319<p>Docstrings written on models, spaces and cells render into full model 320documentation with <a href="https://www.sphinx-doc.org/en/master/">Sphinx</a>âHTML, PDF and other formats, with math, 321images and code samples. See <a href="https://lifelib.io">lifelib</a> for samples.</p> 322 323<h2 id="model-design--productivity">Model design & productivity</h2> 324 325<h3 id="no-programming">Automatic calculation order</h3> 326 327<p>Define formulas like you do on spreadsheets; modelx resolves the 328calculation order from their dependencies and caches results until they 329need recalculating. No run scripts to write:</p> 330 331<div class="language-py highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="kn">import</span> <span class="nn">modelx</span> <span class="k">as</span> <span class="n">mx</span> 332 333<span class="o">>>></span> <span class="o">@</span><span class="n">mx</span><span class="p">.</span><span class="n">defcells</span> 334<span class="p">...</span> <span class="k">def</span> <span class="nf">Cashflow</span><span class="p">(</span><span class="n">t</span><span class="p">):</span> 335<span class="p">...</span> <span class="k">return</span> <span class="mi">100</span> 336 337<span class="o">>>></span> <span class="o">@</span><span class="n">mx</span><span class="p">.</span><span class="n">defcells</span> 338<span class="p">...</span> <span class="k">def</span> <span class="nf">Balance</span><span class="p">(</span><span class="n">t</span><span class="p">):</span> 339<span class="p">...</span> <span class="k">if</span> <span class="n">t</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> 340<span class="p">...</span>
340 <span class="k">return</span> <span class="n">Balance</span><span class="p">(</span><span class="n">t</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="n">Cashflow</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> 341<span class="p">...</span> <span class="k">else</span><span class="p">:</span> 342<span class="p">...</span> <span class="k">return</span> <span class="mi">0</span> 343 344<span class="o">>>></span> <span class="n">Balance</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> 345<span class="mi">500</span> 346</code></pre></div></div> 347 348<h3 id="readable-formulas">Readable formulas</h3> 349 350<p>Formulas are ordinary 351<a href="https://docs.python.org/3/tutorial/controlflow.html#defining-functions">Python functions</a>âfar 352more readable than spreadsheet formulas, with Pythonâs control flow, 353data structures and 354<a href="https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions">lambda expressions</a> 355available.</p> 356 357<h3 id="object-oriented">Object-oriented</h3> 358 359<p>You build models from objectsâ<strong>Models</strong>, <strong>Spaces</strong> and 360<strong>Cells</strong>âwith <a href="https://en.wikipedia.org/wiki/Object_composition">composition</a> and <a href="https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)">inheritance</a> as in 361object-oriented programming:</p> 362 363<pre><code class="language-mermaid"> 364graph TD 365A(Model1) --- B[Space1] 366B --- C[Cells1] 367B --- D[Space2] 368D --- E(Cells2) 369</code></pre> 370 371<h3 id="parameterization">Parameterization</h3> 372 373<p>Write a space once, then apply it to arbitrary combinations of inputs 374without changing formula signatures:</p> 375 376<div class="language-py highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">space</span><span class="p">.</span><span class="n">parameters</span> <span class="o">=</span> <span class="p">(</span><span class="s">"Rate"</span><span class="p">,</span> <span class="s">"Term"</span><span class="p">)</span> 377 378<span class="o">>>></span> <span class="n">space</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">10</span><span class="p">].</span><span class="n">Payment</span><span class="p">()</span> 379<span class="mf">117.23050660515952</span> 380</code></pre></div></div> 381 382<p><img src="/img/features/Parameterization.png" alt="Parameterization" /></p> 383 384<h3 id="excel-interface">Excel Interface</h3> 385 386<p>Excel files are great for storing data of relatively small sizes. 387You can create new spaces and populate new cells in the space with data 388from Excel files.</p> 389 390<h2 id="get-started">Get started</h2> 391 392<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pip install modelx 393# or 394conda install -c conda-forge modelx 395</code></pre></div></div> 396 397<p>Then follow the 398<a href="https://docs.modelx.io/en/latest/tutorial/index.html">tutorial</a>, or 399explore working actuarial models at <a href="https://lifelib.io">lifelib</a>.</p> 400</div> 401 </div> 402 403 </div> 404</div> 405 406 </div> 407 </div> 408 409 <footer class="footer"> 410 <div class="container"> 411 412 <div class="row footer-cols"> 413 <div class="col-sm-4 footer-col"> 414 <h5>Product</h5> 415 <ul class="list-unstyled"> 416 <li><a href="/#install">Install</a></li> 417 <li><a href="/features.html">Why modelx</a></li> 418 <li><a href="/ai.html">AI Agents</a></li> 419 </ul> 420 </div> 421 <div class="col-sm-4 footer-col"> 422 <h5>Learn</h5> 423 <ul class="list-unstyled"> 424 <li><a href="https://docs.modelx.io/en/latest/tutorial/index.html">Get Started</a></li> 425 <li><a href="https://docs.modelx.io/en/latest/index.html">Docs</a></li> 426 <li><a href="https://lifelib.io">Examples (lifelib)</a></li> 427 <li><a href="/allposts.html">Blog</a></li> 428 </ul> 429 </div> 430 <div class="col-sm-4 footer-col"> 431 <h5>Community</h5> 432 <ul class="list-unstyled"> 433 <li><a href="https://github.com/fumitoh/modelx">GitHub</a></li> 434 <li><a href="https://github.com/fumitoh/modelx/discussions">Discussions</a></li> 435 </ul> 436 </div> 437 </div> 438 439 <p class="footer-legal text-center"> 440 © 2017-2026, <a href="https://github.com/fumitoh/modelx">modelx developers</a> | 441 Powered by <a href="https://github.com/aksakalli/jekyll-doc-theme">Jekyll Doc Theme</a> 442 </p> 443 <!-- <p class="text-muted">Place sticky footer content here.</p> --> 444 </div> 445</footer> 446 447
447<script> 448 var baseurl = '' 449</script>
vendor: 1 bytes, line 449
449
450<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
vendor: 1 bytes, line 450
450
451<script src="/js/bootstrap.min.js "></script>
vendor: 1 bytes, line 451
451
452<script src="/js/typeahead.bundle.min.js "></script>
452 453
454<script src="/js/main.js "></script>
454 455 456<!-- for mathjax support --> 457<!-- source1: https://qiita.com/memakura/items/e4d2de379f98ad7be498 --> 458<!-- source2: https://github.com/memakura/mathjax-test/blob/master/_includes/mathjax-v3.html --> 459 460 461 462
462<script>
vendor: 368 bytes, lines 462-467
462 463 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 464 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 465 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 466 })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); 467 ga('create', '
467UA-108824439-4
vendor: 50 bytes, lines 467-469
467', 'auto'); 468 ga('send', 'pageview'); 469
469</script>
469 470 471</body> 472 473
473<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.0.0/mermaid.min.js"></script>
vendor: 1 bytes, line 473
473
474<script> 475 mermaid.initialize({ 476 startOnLoad:true, 477 theme: 'default' 478 }); 479 window.mermaid.init(undefined, document.querySelectorAll('.language-mermaid')); 480</script>
480 481 482</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.