<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel rdf:about="https://community.wolfram.com">
    <title>Community RSS Feed</title>
    <link>https://community.wolfram.com</link>
    <description>RSS Feed for Wolfram Community showing ideas tagged with Packages sorted by most viewed.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/787142" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3118205" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2330900" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/214901" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/984003" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1170226" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/560469" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1484511" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1646303" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1655203" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1527021" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1736686" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/963158" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1039591" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1468475" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/866748" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/824280" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2445356" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/762950" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1421180" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/787142">
    <title>Crystallica: A package to plot crystal structures</title>
    <link>https://community.wolfram.com/groups/-/m/t/787142</link>
    <description>## General information and download links ##&#xD;
&#xD;
If you&amp;#039;re interested in crystal structures, you can now download the Crystallica application from the Wolfram Library Archive, and then you can do things like this:&#xD;
&#xD;
    Needs[&amp;#034;Crystallica`&amp;#034;];&#xD;
    CrystalPlot[&#xD;
    {{5.4,0,0},{0,5.4,0},{0,0,5.4}},&#xD;
    {{0,0,0},{0,0,.5},{0,.5,0},{.5,0,0},{.24,.24,.24},{.24,.76,.76},{.76,.24,.76},{.76,.76,.24}},&#xD;
    {1,2,2,2,3,3,3,3},&#xD;
    AtomCol-&amp;gt;{&amp;#034;Firebrick&amp;#034;,&amp;#034;YellowGreen&amp;#034;,White},AtomRad-&amp;gt;.4,&#xD;
    BondStyle-&amp;gt;2,BondDist-&amp;gt;3,&#xD;
    CellLineStyle-&amp;gt;False,AddQ-&amp;gt;True,Lighting-&amp;gt;{{&amp;#034;Directional&amp;#034;,White,ImageScaled[{0,0,1}]}},Background-&amp;gt;Black]&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
Here are the download links for Crystallica and two other packages you may need:&#xD;
&#xD;
[Crystallica][2] - contains the functions `CrystalPlot` and `CrystalChange`&#xD;
&#xD;
[CifImport][3] - contains an import function for CIF files&#xD;
&#xD;
[VaspImport][4] - contains an import function for files related to [VASP][5]&#xD;
&#xD;
Once you&amp;#039;ve installed Crystallica (by saving the entire Crystallica folder - not the zip archive - to `$USerBaseDirectory/Applications` and re-starting the Kernel), you can enter Crystallica into the Documentation Center and you&amp;#039;ll find lots of useful examples. Most of the examples in this post are taken from the Documentation. For the other two packages, just install them and evaluate this:&#xD;
&#xD;
    ?CifImport&#xD;
    ?VaspImport&#xD;
&#xD;
I&amp;#039;ll first show you a few things the `CrystalPlot` function can do when you already have crystal structure data inside Mathematica, wherever it may have come from. Then we&amp;#039;ll take a look at how to get the data into Mathematica in the first place, which is where `CifImport` and `VaspImport` will come into play - but we&amp;#039;ll get data from other sources as well. I&amp;#039;ll cover the different import solutions in separate replies to this thread, because I have a feeling that I&amp;#039;ll be rambling on and on and on...&#xD;
&#xD;
## Simple plot ##&#xD;
&#xD;
Traditional ball-and-stick plots are usually just fine, so the simplest thing you can do is this:&#xD;
&#xD;
    CrystalPlot[&#xD;
    {{4.5,0,0},{0,4.5,0},{0,0,3}},&#xD;
    {{0,0,0},{.5,.5,.5},{.2,.8,.5},{.3,.3,0},{.7,.7,0},{.8,.2,.5}},&#xD;
    {1,1,2,2,2,2}]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
As you can see, `CrystalPlot` expects three arguments. The first one contains the lattice vectors, which are simply the three vectors that create the parallelepiped that constitutes the cell. The second argument contains the atomic coordinates, but they&amp;#039;re given in the basis of the lattice vectors (which is quite useful in crystallography). The third argument is a list of integers that gives the atom types, with one entry for each atom. If you want to plot a molecule instead, you can call `CrystalPlot` with just two arguments: A list of atom coordinates in cartesian space, and a list of atom types. Everything else you see in the plot - the atoms, bonds, colours, arrows etc. - represents the default settings of various layout options.&#xD;
&#xD;
## Advanced atoms and bonds ##&#xD;
&#xD;
Let&amp;#039;s take a look at some more advanced options just for fun. For instance, atoms and bonds can look any way you need them to, because you can specify your own functions for them. You can also fine-tune where to put bonds and what to do with their thickness and colour in a physically (or chemically) meaningful way, but I won&amp;#039;t show that here. So here are some customized atoms and bonds:&#xD;
&#xD;
    Row[Table[&#xD;
    CrystalPlot[{{4,0,0},{0,4,0},{0,0,4}},{{0,0,0},{.4,.4,.4},{.8,.8,.8}},{1,2,3},&#xD;
    AtomRad-&amp;gt;{.4,1.2,.7},AtomFunction-&amp;gt;style,ImageSize-&amp;gt;400],&#xD;
    {style,{&#xD;
    (Ball[#1,#2]&amp;amp;),&#xD;
    (Scale[Sphere[#1,#2],{1,1,.5}]&amp;amp;),&#xD;
    ({EdgeForm[Thick],Opacity[.7],Cuboid[#1-.5*#2,#1+.5*#2]}&amp;amp;)&#xD;
    }}]]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
    Row[Table[&#xD;
    CrystalPlot[{{0,0,0},{5,0,0},{2.5,4,0}},{1,2,3},BondDist-&amp;gt;6,BondStyle-&amp;gt;style,ImageSize-&amp;gt;400],&#xD;
    {style,{&#xD;
    1,&#xD;
    Function[{bonds,partcol},Table[{If[ii&amp;lt;.5,partcol[#,1],partcol[#,2]],Sphere[bonds[[#,1]]+ii*(bonds[[#,2]]-bonds[[#,1]]),.15]},{ii,0,1,1/9}]&amp;amp;/@Range[Length[bonds]]],&#xD;
    Function[{bonds,partcol},Module[{spiral,points,rad=.05},&#xD;
    spiral[atoms_]:=Module[{scale=.5,dist=atoms[[2]]-atoms[[1]],curls=60,normal,rot,scaled},&#xD;
    normal=Table[{scale*Cos[ii],scale*Sin[ii],.1*ii},{ii,0,curls,\[Pi]/10}];&#xD;
    scaled={#[[1]],#[[2]],10*Norm[dist]/curls*#[[3]]}&amp;amp;/@normal;&#xD;
    rot=scaled.Quiet[RotationMatrix[{dist,{0,0,1}}]];&#xD;
    Join[{atoms[[1]]},#+atoms[[1]]&amp;amp;/@(rot[[25;;-25]]),{atoms[[2]]}]];&#xD;
    points=spiral/@bonds;&#xD;
    {partcol[#,1],Tube[BSplineCurve[points[[#,;;Round[Length[points[[#]]]/2]]],rad]],partcol[#,2],Tube[BSplineCurve[points[[#,Round[Length[points[[#]]]/2];;]],rad]]}&amp;amp;/@Range[Length[bonds]]&#xD;
    ]]&#xD;
    }}]]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
## Lattice planes ##&#xD;
&#xD;
Crystallica can also add lattice planes to the plot. You can specify them using [h,k,l] Miller indices and distance to the origin.&#xD;
&#xD;
    CrystalPlot[{{3,0,0},{0,3,0},{0,0,3}},{{0,0,0}},{1},&#xD;
    AddQ-&amp;gt;True,AtomRad-&amp;gt;.3,AtomCol-&amp;gt;&amp;#034;CadmiumYellow&amp;#034;,Sysdim-&amp;gt;2,CellLineStyle-&amp;gt;2,&#xD;
    LatticePlanes-&amp;gt;Table[{{1,1,1},dist},{dist,1,5}],ContourStyle-&amp;gt;{&amp;#034;TerreVerte&amp;#034;,Opacity[.7]},BoundaryStyle-&amp;gt;Thick]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
## Coordination polyhedra ##&#xD;
&#xD;
You can automatically search for and plot coordination polyhedra. This is not limited to the commonly occurring tetrahedra and octahedra - you can actually look for polyhedra with arbitrary numbers of corners. There are also options to fine-tune both the searching and the rendering.&#xD;
&#xD;
    plot[corners_,mixed_]:=CrystalPlot[{{0,0,0},{0,0,1.8},{-.9,-1.5,-.6},{-.9,1.5,-.6},{1.7,0,-.6},{.8,.8,.8}},{1,2,2,2,2,3},&#xD;
    BondStyle-&amp;gt;False,ImageSize-&amp;gt;250,&#xD;
    PolyMode[corners]-&amp;gt;{&amp;#034;Show&amp;#034;-&amp;gt;All,&amp;#034;AllowMixed&amp;#034;-&amp;gt;mixed},PolyStyle[corners]-&amp;gt;Directive[Opacity[.5],EdgeForm[Thick]]];&#xD;
    Grid[{{&#xD;
    &amp;#034;&amp;#034;,&#xD;
    &amp;#034;Search for polyhedra with \n4 corners&amp;#034;,&#xD;
    &amp;#034;Search for polyhedra with \n5 corners&amp;#034;&#xD;
    },{&#xD;
    &amp;#034;Allow \nmixed corners&amp;#034;,&#xD;
    plot[4,True],&#xD;
    plot[5,True]&#xD;
    },{&#xD;
    &amp;#034;Don&amp;#039;t allow \nmixed corners&amp;#034;,&#xD;
    plot[4,False],&#xD;
    plot[5,False]&#xD;
    }},Dividers-&amp;gt;All]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
    CrystalPlot[{{2.5,-4.3,0},{2.5,4.3,0},{0,0,5.5}},&#xD;
    {{.5,0,0},{0,.5,.7},{.5,.5,.3},{.2,.4,.5},{.6,.8,.2},{.2,.8,.8},{.8,.6,.5},{.4,.2,.2},{.8,.2,.8}},{1,1,1,2,2,2,2,2,2},&#xD;
    PolyMode[4]-&amp;gt;True,PolyStyle[4]-&amp;gt;EdgeForm[None],AddQ-&amp;gt;True,&#xD;
    Sysdim-&amp;gt;2,AtomRad-&amp;gt;0,CellLineStyle-&amp;gt;False,AtomCol-&amp;gt;{&amp;#034;SlateGray&amp;#034;,&amp;#034;Firebrick&amp;#034;},&#xD;
    ViewAngle-&amp;gt;.4,ViewPoint-&amp;gt;{3.2,0,1.1},ViewVertical-&amp;gt;{.5,0,1.2}]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
## Other things ##&#xD;
&#xD;
Visualization aside, you can also build supercells, change cell shapes, or add, remove and sort atoms... but that&amp;#039;s a bit boring to read, so I&amp;#039;ll refer you to the Documentation page of the `CrystalChange` function instead.&#xD;
&#xD;
If you&amp;#039;re interested, we can use this thread to talk about any questions you may have, or you can share your use of the package (if you decide to use it). I&amp;#039;m not offering full support here, but I&amp;#039;ll be floating around, and I&amp;#039;d like to hear your feedback. We don&amp;#039;t have any intentions to be involved in further development. But if you have a good idea and some time, then by all means, work on it for yourself, or host it on your favourite code collaboration site.&#xD;
&#xD;
Bianca Eifert and Christian Heiliger&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=teaser.png&amp;amp;userId=69107&#xD;
  [2]: http://library.wolfram.com/infocenter/MathSource/9372/&#xD;
  [3]: http://library.wolfram.com/infocenter/MathSource/9373/&#xD;
  [4]: http://library.wolfram.com/infocenter/MathSource/9375/&#xD;
  [5]: http://vasp.at/&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=9692simple.png&amp;amp;userId=69107&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=atoms.png&amp;amp;userId=69107&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=bonds.png&amp;amp;userId=69107&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=planes.png&amp;amp;userId=69107&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=polys.png&amp;amp;userId=69107&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=polys2.png&amp;amp;userId=69107&#xD;
  [12]: http://rruff.geo.arizona.edu/AMS/CIF_text_files/13532_cif.txt&#xD;
  [13]: http://cms.mpi.univie.ac.at/vasp/vasp/POSCAR_file.html&#xD;
  [14]: http://wiki.jmol.org/index.php/File:Caffeine.mol</description>
    <dc:creator>Bianca Eifert</dc:creator>
    <dc:date>2016-02-05T18:43:18Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3118205">
    <title>Wolfram quantum framework: tensor networks, spiders, and ZX formalism</title>
    <link>https://community.wolfram.com/groups/-/m/t/3118205</link>
    <description>![enter image description here][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=heroimage.png&amp;amp;userId=1539902&#xD;
  [2]: https://www.wolframcloud.com/obj/5b3b5265-f1e2-406c-aef4-45a5f9ec363b</description>
    <dc:creator>Mohammad Bahrami</dc:creator>
    <dc:date>2024-02-07T19:21:52Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2330900">
    <title>[WSG21] Daily Study Group: programming tutorials</title>
    <link>https://community.wolfram.com/groups/-/m/t/2330900</link>
    <description>Daily Study Groups are back, now providing expertise on practical programming! After a short break, we&amp;#039;re starting up with a series that picks up where Wolfram Language Basics sessions ended. This 3-week series will take you from basic programming concepts to package development. &#xD;
&#xD;
Need tips on improving your code’s speed or functionality? Programming Tutorials offer a great opportunity to level-up your skills while interacting with software development professionals. See hands-on examples and get questions answered by Wolfram Language experts. Plus: participants who pass weekly quizzes are awarded a program completion certificate. Level 1 certification is available for those who pass manually graded exercises. &#xD;
&#xD;
Join us any time between August 2 and August 20! Check out our [registration page][1] for more details.&#xD;
&#xD;
&#xD;
&#xD;
 [1]: https://wolfr.am/Study_Group15</description>
    <dc:creator>Wolfram U</dc:creator>
    <dc:date>2021-07-30T15:24:02Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/214901">
    <title>Building Packages: A basic tutorial</title>
    <link>https://community.wolfram.com/groups/-/m/t/214901</link>
    <description>In a response to an earlier thread I posted a notebook containing a basic tutorial on creating packages in Mathematica. Since the link to the notebook was embedded down in the responses to that post I thought it might be useful to some folks to have access to it at the top level here since they might have missed it. &#xD;
&#xD;
I have updated that notebook a bit since the last time.  I hope it is useful to some people.  It was originally written as a tutorial for a consulting client of mine and he agreed to allow me to share with others.  &#xD;
&#xD;
Enjoy. It is attached to this posting</description>
    <dc:creator>David Reiss</dc:creator>
    <dc:date>2014-03-08T02:32:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/984003">
    <title>How to use Mathematica in a high-performance computing (HPC) environment</title>
    <link>https://community.wolfram.com/groups/-/m/t/984003</link>
    <description>I&amp;#039;m going to show you how you can use existing functionality to run a Mathematica script across a managed HPC cluster. Before I start, I must be upfront with you: though the individual commands are documented, this method, as a whole, is not. Thus, support for this procedure is outside the scope of Wolfram Technical Support. However, I&amp;#039;m hoping that once the ground-work has been laid, that Wolfram Community members can work together to fill in the missing details.&#xD;
&#xD;
My assumptions:&#xD;
&#xD;
 1. Mathematica is installed and properly licensed on the managed cluster&#xD;
 2. once your job has been given resources, that you can freely SSH between them&#xD;
&#xD;
(1) This is up to your local cluster&amp;#039;s System Admin to figure out by talking with their organization and a Wolfram Sales Representative, and possibly Wolfram Technical Support ([support.wolfram.com][1]).&#xD;
(2) Again, this is up to your local SysAdmin to ensure. It&amp;#039;s also known as a public/private key pair between nodes.&#xD;
&#xD;
In the following, I&amp;#039;m assuming the cluster uses Torque ([Torque SysAdmin Guide][2]), but in principle other managers can be used. A generic Mathematica script job submission may look like the following:&#xD;
&#xD;
    #PBS -N Job_name&#xD;
    #PBS -l walltime=10:30&#xD;
    #PBS -l nodes=4:ppn=6&#xD;
    #PBS -m be&#xD;
&#xD;
    math -script hpc.wl&#xD;
    &#xD;
In this example, &#xD;
&#xD;
 - the job is called &amp;#034;Job_name&amp;#034;&#xD;
 - the job will finish in 10 and a half minutes&#xD;
 - it is requesting 4 nodes with 6 processors-per-node, for a total of 24 resources (CPU cores)&#xD;
 - an email will be sent to the account associated with the username when the job (b)egins and when it (e)nds&#xD;
&#xD;
If you are not familiar with job submissions to a managed HPC cluster, then I suggest you read any guides provided by your organization&#xD;
&#xD;
The Wolfram Language script &amp;#034;hpc.wl&amp;#034; does the rest of the work. It generically follows this order:&#xD;
&#xD;
 1. gather the environment variables associated with the list of provided resources&#xD;
 2. launch remote subkernels for each CPU core&#xD;
 3. do the parallel computations&#xD;
 4. close the subkernels&#xD;
 5. end the job&#xD;
&#xD;
        (*get association of resources, name of local host, and remove local host from available resources*)&#xD;
        hosts = Counts[ReadList[Environment[&amp;#034;PBS_NODEFILE&amp;#034;], &amp;#034;String&amp;#034;]];&#xD;
        local = First[StringSplit[Environment[&amp;#034;HOSTNAME&amp;#034;],&amp;#034;.&amp;#034;]];&#xD;
        hosts[local]--;&#xD;
        &#xD;
        (*launch subkernels and connect them to the controlling Wolfram Kernel*)&#xD;
        Needs[&amp;#034;SubKernels`RemoteKernels`&amp;#034;];&#xD;
        Map[If[hosts[#] &amp;gt; 0, LaunchKernels[RemoteMachine[#, hosts[#]]]]&amp;amp;, Keys[hosts]];&#xD;
&#xD;
        (* ===== regular Wolfram Language code goes here ===== *)&#xD;
        Print[ {$MachineName, $KernelID} ]&#xD;
        (* ===== end of Wolfram Language program ===== *)&#xD;
&#xD;
        CloseKernels[];&#xD;
        Quit&#xD;
&#xD;
On Torque there is the environment variable &amp;#034;PBS\_NODEFILE&amp;#034; ([Torque environment variables][3]) that lists the different nodes that are provided to the job. It is my understanding that the name is repeated for each CPU core. That&amp;#039;s why a simple Count of the node list tells us everything. The other piece of information, which is probably not necessary, is &amp;#034;HOSTNAME&amp;#034;. This is where the Wolfram controlling kernel is running. In the above, we remove it from the list of available resources, but I don&amp;#039;t believe this is necessary. According to the documentation ([3]), this may be known as &amp;#034;PBS\_O\_HOSTNAME&amp;#034;.  &#xD;
&#xD;
The Mathematica script should not need to change save for the code between the commented lines. I&amp;#039;m also assuming that `$RemoteCommand` (provided by Subkernels\`RemoteKernels\`) is the same on each node. This is usually the case as most clusters use a cloned file system. &#xD;
&#xD;
SLURM should be very similar except that the environment variables will be different. It is my understanding that&#xD;
&#xD;
        headNode = Environment[&amp;#034;SLURMD_NODENAME&amp;#034;];&#xD;
        nodes = ReadList[&amp;#034;!scontrol show hostname $SLURM_NODELIST&amp;#034;,String]; &#xD;
&#xD;
provides the headnode and list of resources.&#xD;
&#xD;
&#xD;
I encourage discussion.&#xD;
&#xD;
&#xD;
  [1]: http://support.wolfram.com&#xD;
  [2]: http://docs.adaptivecomputing.com/torque/4-0-2/help.htm&#xD;
  [3]: http://docs.adaptivecomputing.com/torque/4-0-2/help.htm#topics/2-jobs/exportedBatchEnvVar.htm</description>
    <dc:creator>Kevin Daily</dc:creator>
    <dc:date>2016-12-19T21:29:53Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1170226">
    <title>Package development: How to spend less time creating a polished interface?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1170226</link>
    <description>One of the great things about Mathematica is that it makes it so easy to do so much in so little code.  It is partly because of this that I am so frustrated with the amount of time I need to spend developing the *interface* of package functions compared to their *functionality*.&#xD;
&#xD;
Suppose you wrote a Wolfram Language function that does something useful and interesting.  Now you want to wrap it up into a package, and make it usable by everyone.  A polished package is expected to have functions that:&#xD;
&#xD;
 - Will check their input for errors&#xD;
 - Will report errors in an informative way&#xD;
 - Will use messages appropriately (i.e. associate them with the correct symbol name)&#xD;
 - Will adhere to the de-facto Mathematica interface conventions: proper use of optional arguments, options, option inheritance (as in Graphics -&amp;gt; Plot), default option value handling, use of `Automatic`, etc.&#xD;
 - Have SyntaxInformation&#xD;
&#xD;
I find that not infrequently I spend more time on making the function user-friendly than developing its functionality.&#xD;
&#xD;
**How do people generally deal with this task?  How do you implement error checking and reporting in your packages?**&#xD;
&#xD;
To give an example, take a function as simple a moving average calculator.  It is really easy to implement:&#xD;
&#xD;
    movingAverage[vec_, n_] := Mean /@ Partition[vec, n, 1]&#xD;
&#xD;
But to bring it to the quality of the built-in `MovingAverage`, it should at least:&#xD;
&#xD;
 - check the number of arguments (precisely 2)&#xD;
 - check the types of arguments (a list and an integer)&#xD;
 - check the values of arguments for correctness (non-empty list and positive integer)&#xD;
 - make sure that all these checks don&amp;#039;t introduce severe performance degradation (such as array unpacking, which can even be triggered by an inefficient argument pattern)&#xD;
&#xD;
This also involves the introduction of multiple messages (for each type of error) associated to `movingAverage`. If we now want to add a `movingMedian`, we will find that we will mostly need to carry out the same checks and report the same messages. There will be small differences though, e.g. average calculations are feasible for symbolic lists like `{1,x}`, but not median calculations.  So the checks won&amp;#039;t quite be identical.  The messages will be mostly identical, but each function must associate messages to its own symbol, which means a lot of duplication.&#xD;
&#xD;
So if we care about a high-quality interface and high-quality error reporting, we will end up writing considerably more code for this than for the function&amp;#039;s core task. We will also end up with a lot of code duplication, which is frustrating and a maintenance burden.  The whole thing ends up being a lot of work and not a lot of fun (which is not very Mathematica-like :-) )&#xD;
&#xD;
Are there good ways to simplify these tasks?  Option handling also used to be error-prone and frustrating, but the introduction of `OptionsPattern[]` and `OptionValue[]` made it much easier.&#xD;
&#xD;
----&#xD;
&#xD;
I can see that there are some built-in tool to ease these tasks, though they are mostly undocumented.  One example is `ArgumentCountQ`, another is ``Developer`CheckArgumentCount``, or some tools in ``GeneralUtilities` ``.  I would love to hear from others about how they deal with the tasks I described, which such internal functions they make use of, etc.</description>
    <dc:creator>Szabolcs Horvát</dc:creator>
    <dc:date>2017-08-25T11:15:29Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/560469">
    <title>IGraph/M: graph theory and network analysis with Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/560469</link>
    <description>*WOLFRAM MATERIALS for the ARTICLE:*&#xD;
&amp;gt; Szabolcs Horvát, Jakub Podkalicki, Gábor Csárdi, Tamás Nepusz, Vincent Traag, Fabio Zanini, Daniel Noom, (2022).&#xD;
&#xD;
&amp;gt; *IGraph/M: graph theory and network analysis for Mathematica*.&#xD;
&#xD;
&amp;gt; arXiv:2209.09145 **[physics.soc-ph]**.&#xD;
&#xD;
&amp;gt; https://doi.org/10.48550/arXiv.2209.09145&#xD;
&#xD;
&#xD;
[![Discourse topics](https://img.shields.io/discourse/topics?color=limegreen&amp;amp;server=https%3A%2F%2Figraph.discourse.group)](https://igraph.discourse.group)&#xD;
[![GitHub (pre-)release](https://img.shields.io/github/release/szhorvat/IGraphM/all.svg)](https://github.com/szhorvat/IGraphM/releases)&#xD;
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](https://github.com/szhorvat/IGraphM#contributions)&#xD;
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1134932.svg)](https://doi.org/10.5281/zenodo.1134932)&#xD;
&#xD;
----&#xD;
&#xD;
##Article abstract&#xD;
&#xD;
IGraph/M is an efficient general purpose graph theory and network analysis package for Mathematica. IGraph/M serves as the Wolfram Language interfaces to the igraph C library, and also provides several unique pieces of functionality not yet present in igraph, but made possible by combining its capabilities with Mathematica&amp;#039;s. The package is designed to support both graph theoretical research as well as the analysis of large-scale empirical networks.&#xD;
&#xD;
----&#xD;
&#xD;
##Introduction&#xD;
&#xD;
The post below was written for the original release of IGraph/M. The package has come a long way since then and now contains ~300 functions. See http://szhorvat.net/mathematica/IGraphM for more details on the current release.&#xD;
&#xD;
Compatibility: 64-it Windows/macOS/Linux or Raspberry Pi; Mathematica &amp;lt;del&amp;gt;10.0&amp;lt;/del&amp;gt; 11.0 or later.&#xD;
&#xD;
&amp;lt;a href=&amp;#034;http://szhorvat.net/mathematica/IGraphM&amp;#034;&amp;gt;&amp;lt;img src=&amp;#034;https://community.wolfram.com//c/portal/getImageAttachment?filename=IGraphM-ad-3.png&amp;amp;userId=38370&amp;#034; width=&amp;#034;300&amp;#034;&amp;gt;&amp;lt;/a&amp;gt;&#xD;
&#xD;
----&#xD;
&#xD;
I would like to announce IGraph/M, a new igraph interface for Mathematica: http://szhorvat.net/mathematica/IGraphM&#xD;
&#xD;
[igraph](http://igraph.org/) is a graph manipulation and analysis package.  IGraph/M makes its functionality available from Mathematica.&#xD;
&#xD;
This initial release, version 0.1, covers only some igraph functions, as I focused on the things that I need personally.  However the main framework is complete, and new functions can be added quickly.  If anyone would like to contribute, please contact me.&#xD;
&#xD;
Binary packages for OS X (10.9 or later) and Linux can be downloaded [from GitHub](https://github.com/szhorvat/IGraphM/releases).  Unfortunately, I was unable to compile the development version of igraph for Windows, so I cannot provide a Windows version. If you can help with compiling igraph itself (not IGraph/M) on Windows, please let me know!&#xD;
&#xD;
Functionality in this release that is not built into Mathematica:&#xD;
&#xD;
 * Vertex betweenness centrality for weighted graphs&#xD;
 * Estimates of vertex betweenness, edge betweenness and closeness centrality; for large graphs&#xD;
 * Minimum feedback arc set for weighted and unweighted graphs&#xD;
 * Find all cliques (not just maximal ones)&#xD;
 * Count 3- and 4-motifs&#xD;
 * Rewire edges, keeping either the density or the degree sequence&#xD;
 * Alternative algorithms for isomorphism testing: Bliss, VF2&#xD;
 * Subgraph isomorphism&#xD;
 * Test if a degree sequence is graphical&#xD;
 * Alternative algorithms for generating random graphs with given degree sequence&#xD;
 * Layout algorithms that take weights into account&#xD;
&#xD;
Note that IGraph/M is *not a replacement* for Mathematica&amp;#039;s graphs and networks functionality.  It is meant to complement what is already available in Mathematica, thus it primarily focuses on adding functionality that is not already present.&#xD;
&#xD;
Why did I release the package before covering most of the igraph functionality?  I do not have time to work on things I do not personally need or use, so I am unlikely to extend it further unless the need comes up.  I do think that the functions that are included in v0.1 can already be useful to others too.  I would also like to give the opportunity for people to contribute to the project if they wish to.  The groundwork has been laid, so further extensions should be quick and relatively easy.&#xD;
&#xD;
Also check out a related project, [IGraphR](https://github.com/szhorvat/IGraphR), which makes igraph available for Mathematica users through RLink.  I wrote IGraph/M because I needed higher performance and greater reliability (especially for parallel computing) than what RLink could provide.&#xD;
&#xD;
----&#xD;
&#xD;
**A request:** If any of you have used IGraphR in the past to access igraph from Mathematica, please post a response to this thread and let me know which specific functions you were using.&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][1]&#xD;
&#xD;
&#xD;
  [1]: https://www.wolframcloud.com/obj/94639221-60b4-47e3-8862-d996caa40388</description>
    <dc:creator>Szabolcs Horvát</dc:creator>
    <dc:date>2015-09-06T12:55:14Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1484511">
    <title>Playing with YouTube from Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/1484511</link>
    <description>Originally [here](https://www.wolframcloud.com/objects/b3m2a1/home/playing-with-youtube-from-mathematica.html#main-content) (the embedded iframes actually work there)&#xD;
&#xD;
---&#xD;
&#xD;
Playing with YouTube from Mathematica&#xD;
---&#xD;
&#xD;
Today I&amp;#039;m gonna quickly show off something I made for a friend (and about which I&amp;#039;d been thinking for some time). We&amp;#039;re gonna use the YouTube API in Mathematica to do a have some fun (but not too much fun, mind you!).&#xD;
&#xD;
### Installing the YouTube Connection&#xD;
&#xD;
My connection to the YouTube API is built on Mathematica&amp;#039;s  [```ServiceConnect```](https://reference.wolfram.com/language/ref/ServiceConnect.html) framework. I&amp;#039;ve  [talked](https://www.wolframcloud.com/objects/b3m2a1/home/serviceconnections---mathematica-on-the-web.html)  [about](https://www.wolframcloud.com/objects/b3m2a1/home/questions-on-the-mathematica-stack-exchange.html#main-content)  [these](https://www.wolframcloud.com/objects/b3m2a1/home/questions-on-the-mathematica-stack-exchange-part-2.html#main-content)  [before](https://mathematica.stackexchange.com/questions/163638/how-can-i-access-nasa-images-and-apis) in  [many](http://community.wolfram.com/groups/-/m/t/1261562)  [different](https://mathematica.stackexchange.com/a/167702/38205)  [contexts](https://mathematica.stackexchange.com/questions/163780/sophisticated-api-integrations-making-a-card-game-in-mathematica) but today we&amp;#039;ll just use it. To install we pull the  [paclet off my server](https://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer/serviceconnectionyoutube.html#main-content) :&#xD;
&#xD;
    PacletInstall[&amp;#034;ServiceConnection_YouTube&amp;#034;,&#xD;
      &amp;#034;Site&amp;#034;-&amp;gt;&#xD;
        &amp;#034;http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer/&amp;#034;&#xD;
      ]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-8529256040837869960](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-8529256040837869960.png)&#xD;
&#xD;
### Authenticating with YouTube&#xD;
&#xD;
One installed, we connect to the service as usual:&#xD;
&#xD;
    $so = ServiceConnect[&amp;#034;YouTube&amp;#034;]&#xD;
&#xD;
This will open a dialog:&#xD;
&#xD;
![post22-2534758878895670558](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-2534758878895670558.png)&#xD;
&#xD;
We&amp;#039;ll click the sign in button, pick and account (I&amp;#039;ll use my  [new personal account steve.wolfraum@gmail.com](https://www.wolframcloud.com/objects/b3m2a1/home/making-a-blog-in-30-minutes.html#main-content) ):&#xD;
&#xD;
![post22-6891487155877384696](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-6891487155877384696.png)&#xD;
&#xD;
When we click &amp;#034;Allow&amp;#034; either we&amp;#039;ll be taken to a nicely formatted local page with an access code running via  ```HTTPHandling`StartWebServer``` or if that&amp;#039;s being glitchy as it was right now, we&amp;#039;ll copy the part of the URL starting with  ```&amp;#034;code=4/...&amp;#034;``` :&#xD;
&#xD;
![post22-5755985516881850876](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-5755985516881850876.png)&#xD;
&#xD;
Finally, we&amp;#039;re connected:&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-6049558537553480280](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-6049558537553480280.png)&#xD;
&#xD;
### Getting Data&#xD;
&#xD;
The majority of the currently supported methods have to do with getting data about YouTube:&#xD;
&#xD;
    $so[&amp;#034;Requests&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
    {&amp;#034;Authentication&amp;#034;,&amp;#034;DeleteVideo&amp;#034;,&amp;#034;ID&amp;#034;,&amp;#034;Information&amp;#034;,&amp;#034;LastRequest&amp;#034;,&amp;#034;ListCaptions&amp;#034;,&amp;#034;ListChannelActivity&amp;#034;,&amp;#034;ListChannels&amp;#034;,&amp;#034;ListChannelSections&amp;#034;,&amp;#034;ListComments&amp;#034;,&amp;#034;ListCommentThreads&amp;#034;,&amp;#034;ListPlaylistItems&amp;#034;,&amp;#034;ListPlaylists&amp;#034;,&amp;#034;ListSubscriptions&amp;#034;,&amp;#034;ListVideos&amp;#034;,&amp;#034;Name&amp;#034;,&amp;#034;RawRequests&amp;#034;,&amp;#034;RequestData&amp;#034;,&amp;#034;RequestParameters&amp;#034;,&amp;#034;Search&amp;#034;,&amp;#034;UpdateVideo&amp;#034;,&amp;#034;UploadVideo&amp;#034;,&amp;#034;VideoURL&amp;#034;}&#xD;
&#xD;
We&amp;#039;ll start with a search, maybe. First let&amp;#039;s see what parameters we have to work with:&#xD;
&#xD;
    $so[&amp;#034;RequestParameters&amp;#034;, &amp;#034;Request&amp;#034;-&amp;gt;&amp;#034;Search&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
    &amp;lt;|&amp;#034;Parameters&amp;#034;-&amp;gt;{&amp;#034;q&amp;#034;,&amp;#034;part&amp;#034;,&amp;#034;forContentOwner&amp;#034;,&amp;#034;forDeveloper&amp;#034;,&amp;#034;forMine&amp;#034;,&amp;#034;relatedToVideoId&amp;#034;,&amp;#034;channelId&amp;#034;,&amp;#034;channelType&amp;#034;,&amp;#034;eventType&amp;#034;,&amp;#034;location&amp;#034;,&amp;#034;locationRadius&amp;#034;,&amp;#034;maxResults&amp;#034;,&amp;#034;onBehalfOfContentOwner&amp;#034;,&amp;#034;order&amp;#034;,&amp;#034;pageToken&amp;#034;,&amp;#034;publishedAfter&amp;#034;,&amp;#034;publishedBefore&amp;#034;,&amp;#034;q&amp;#034;,&amp;#034;regionCode&amp;#034;,&amp;#034;relevanceLanguage&amp;#034;,&amp;#034;safeSearch&amp;#034;,&amp;#034;topicId&amp;#034;,&amp;#034;type&amp;#034;,&amp;#034;videoCaption&amp;#034;,&amp;#034;videoCategoryId&amp;#034;,&amp;#034;videoDefinition&amp;#034;,&amp;#034;videoDimension&amp;#034;,&amp;#034;videoDuration&amp;#034;,&amp;#034;videoEmbeddable&amp;#034;,&amp;#034;videoLicense&amp;#034;,&amp;#034;videoSyndicated&amp;#034;,&amp;#034;videoType&amp;#034;},&amp;#034;Required&amp;#034;-&amp;gt;{&amp;#034;part&amp;#034;}|&amp;gt;&#xD;
&#xD;
Then we&amp;#039;ll search for something bland, like &amp;#034;Steve Wolfraum&amp;#034;. The YouTube API requires this  ```&amp;#034;part&amp;#034;``` parameter to know what to return to use. I like to get the  ```&amp;#034;id&amp;#034;``` and  ```&amp;#034;snippet&amp;#034;``` parts, but you can  [pick for yourself](https://developers.google.com/youtube/v3/getting-started#part) which parts you want. Just comma-separate your values and you can get multiple different ones:&#xD;
&#xD;
    mySearch = $so[&amp;#034;Search&amp;#034;, &amp;#034;q&amp;#034;-&amp;gt;&amp;#034;Steve Wolfraum&amp;#034;, &amp;#034;part&amp;#034;-&amp;gt;&amp;#034;id,snippet&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-4316213154658629458](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-4316213154658629458.png)&#xD;
&#xD;
We see there are  *tons* of results for &amp;#034;my&amp;#034; name but we only get them five at a time. We can use the  ```&amp;#034;nextPageToken&amp;#034;``` to get the next page of results, though. We can bump up the number we get with the  ```&amp;#034;maxResults&amp;#034;``` parameter, but I see no need for that right now. Let&amp;#039;s look at the first result here. I&amp;#039;ll drill straight into that snippet parameter, as that&amp;#039;s the most interesting part:&#xD;
&#xD;
    mySearch[&amp;#034;items&amp;#034;, 1, &amp;#034;snippet&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-498969337448306280](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-498969337448306280.png)&#xD;
&#xD;
And we see, sadly, that instead of getting results for my name, Steve Wolfraum, we get them for some random dude name Stephen Wolfram. Not to be deterred, let&amp;#039;s at least get something out of this and see a thumbnail for all our results. Tragically, we can&amp;#039;t download videos with the YouTube API, but at least we get thumbnails...hooray? To make things more fun, we&amp;#039;ll also add a filter to all these results, as the raw thumbnails really aren&amp;#039;t all that interesting.&#xD;
&#xD;
    ImageAdjust@LaplacianGaussianFilter[Import[#], 3]&amp;amp;/@&#xD;
      Normal@mySearch[&amp;#034;items&amp;#034;, All, &amp;#034;snippet&amp;#034;, &amp;#034;thumbnails&amp;#034;, &amp;#034;high&amp;#034;, &amp;#034;url&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-8416895123856568403](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-8416895123856568403.png)&#xD;
&#xD;
Cool. There&amp;#039;s some data. We can also pull out statistics and things, say for different videos broadcast on the Wolfram Research channel. First we&amp;#039;ll get their channel ID:&#xD;
&#xD;
    wriChannel=&#xD;
      $so[&amp;#034;Search&amp;#034;, &amp;#034;q&amp;#034;-&amp;gt;&amp;#034;Wolfram Research&amp;#034;, &amp;#034;type&amp;#034;-&amp;gt;&amp;#034;channel&amp;#034;,&#xD;
        &amp;#034;part&amp;#034;-&amp;gt;&amp;#034;id&amp;#034;, &amp;#034;maxResults&amp;#034;-&amp;gt;&amp;#034;1&amp;#034;][&amp;#034;items&amp;#034;, 1, &amp;#034;id&amp;#034;, &amp;#034;channelId&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
    &amp;#034;UCJekgf6k62CQHdENWf2NgAQ&amp;#034;&#xD;
&#xD;
Now we&amp;#039;ll use this to extract the 50 most popular videos:&#xD;
&#xD;
    wriVids=$so[&amp;#034;Search&amp;#034;, &amp;#034;channelId&amp;#034;-&amp;gt;wriChannel, &amp;#034;type&amp;#034;-&amp;gt;&amp;#034;video&amp;#034;, &#xD;
      &amp;#034;order&amp;#034;-&amp;gt;&amp;#034;viewCount&amp;#034;, &amp;#034;part&amp;#034;-&amp;gt;&amp;#034;id,snippet&amp;#034;, &amp;#034;maxResults&amp;#034;-&amp;gt;&amp;#034;50&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-5403531027782801587](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-5403531027782801587.png)&#xD;
&#xD;
And now we&amp;#039;ll get view counts:&#xD;
&#xD;
    wriStats=$so[&amp;#034;ListVideos&amp;#034;, &#xD;
      &amp;#034;id&amp;#034;-&amp;gt;StringRiffle[Normal@wriVids[&amp;#034;items&amp;#034;, All, &amp;#034;id&amp;#034;, &amp;#034;videoId&amp;#034;], &amp;#034;,&amp;#034;], &#xD;
      &amp;#034;part&amp;#034;-&amp;gt;&amp;#034;statistics&amp;#034;&#xD;
      ]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-4181911101890639189](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-4181911101890639189.png)&#xD;
&#xD;
And then we&amp;#039;ll make a  [```WordCloud```](https://reference.wolfram.com/language/ref/WordCloud.html) of titles vs viewcounts:&#xD;
&#xD;
    WordCloud@&#xD;
      AssociationThread[&#xD;
        Normal@wriVids[&amp;#034;items&amp;#034;, All, &amp;#034;snippet&amp;#034;, &amp;#034;title&amp;#034;],&#xD;
        ToExpression@Normal@wriStats[&amp;#034;items&amp;#034;, All, &amp;#034;statistics&amp;#034;, &amp;#034;viewCount&amp;#034;]&#xD;
        ]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-948349109694102953](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-948349109694102953.png)&#xD;
&#xD;
And we see as far as YouTube cares, there&amp;#039;s really only one video WRI has made. But dropping that one we might see some more interesting structure:&#xD;
&#xD;
    WordCloud@&#xD;
      AssociationThread[&#xD;
        Rest@Normal@wriVids[&amp;#034;items&amp;#034;, All, &amp;#034;snippet&amp;#034;, &amp;#034;title&amp;#034;],&#xD;
        Rest@ToExpression@Normal@wriStats[&amp;#034;items&amp;#034;, All, &amp;#034;statistics&amp;#034;, &amp;#034;viewCount&amp;#034;]&#xD;
        ]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-978266547142309807](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-978266547142309807.png)&#xD;
&#xD;
And it seems that people really like the basics and...really like seismic waves?&#xD;
&#xD;
I&amp;#039;ll embed the first of those so we can see how good the really are:&#xD;
&#xD;
    $so[&amp;#034;EmbedIFrame&amp;#034;, &amp;#034;id&amp;#034;-&amp;gt;wriVids[&amp;#034;items&amp;#034;, 3, &amp;#034;id&amp;#034;, &amp;#034;videoId&amp;#034;]]&#xD;
&#xD;
    (* Out *)&#xD;
    &amp;lt;iframe id=&amp;#034;ytplayer&amp;#034; type=&amp;#034;text/html&amp;#034; width=&amp;#034;640&amp;#034; height=&amp;#034;360&amp;#034;&#xD;
    src=&amp;#034;https://www.youtube.com/embed/2rYjlVPU9U4?autoplay=0&amp;#034;&#xD;
      frameborder=&amp;#034;0&amp;#034;&amp;gt;&amp;lt;/iframe&amp;gt;&#xD;
&#xD;
&#xD;
### Uploading Videos&#xD;
&#xD;
A YouTube API wouldn&amp;#039;t be much of a YouTube API if it couldn&amp;#039;t upload videos, of course, so I cooked that in as well.&#xD;
&#xD;
Here&amp;#039;s a sample of that. We&amp;#039;ll first pull an animation off the  [```Manipulate```](https://reference.wolfram.com/language/ref/Manipulate.html) docs:&#xD;
&#xD;
    anim =&#xD;
      Export[&#xD;
        FileNameJoin@{$TemporaryDirectory, &amp;#034;plot3d.flv&amp;#034;},&#xD;
        Manipulate[&#xD;
          Plot3D[Sin[n x y], &#xD;
            {x, 0, 3}, {y, 0, 3}, &#xD;
            ViewPoint -&amp;gt; Dynamic[{2, v, 2}], SphericalRegion -&amp;gt; True, Ticks -&amp;gt; None,&#xD;
            PerformanceGoal-&amp;gt;&amp;#034;Quality&amp;#034;&#xD;
            ], &#xD;
          {n, 1, 4}, &#xD;
          {v, -2, 2}&#xD;
          ]&#xD;
        ];&#xD;
&#xD;
Then we&amp;#039;ll upload the video we made:&#xD;
&#xD;
    upload = $so[&amp;#034;UploadVideo&amp;#034;, &amp;#034;part&amp;#034;-&amp;gt;&amp;#034;id&amp;#034;, &amp;#034;BodyContent&amp;#034;-&amp;gt;anim];&#xD;
&#xD;
Then we attach a title and things in a second request:&#xD;
&#xD;
    $so[&amp;#034;UpdateVideo&amp;#034;, &amp;#034;id&amp;#034; -&amp;gt; upload[&amp;#034;id&amp;#034;],&#xD;
     &amp;#034;part&amp;#034; -&amp;gt; &amp;#034;snippet&amp;#034;,&#xD;
      &amp;#034;Title&amp;#034; -&amp;gt; &amp;#034;Mathematica Examples: Plot 3D&amp;#034;,&#xD;
     &amp;#034;CategoryID&amp;#034; -&amp;gt; &amp;#034;22&amp;#034;&#xD;
     ]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![post22-4324612576805415951](https://www.wolframcloud.com/objects/b3m2a1/home/img/post22-4324612576805415951.png)&#xD;
&#xD;
And then now we&amp;#039;ll embed that video we just made:&#xD;
&#xD;
    $so[&amp;#034;EmbedIFrame&amp;#034;, &amp;#034;id&amp;#034;-&amp;gt;upload[&amp;#034;id&amp;#034;]]&#xD;
&#xD;
    (* Out *)&#xD;
    &amp;lt;iframe id=&amp;#034;ytplayer&amp;#034; type=&amp;#034;text/html&amp;#034; width=&amp;#034;640&amp;#034; height=&amp;#034;360&amp;#034;&#xD;
    src=&amp;#034;https://www.youtube.com/embed/Quzcr4Vuq_Q?autoplay=0&amp;#034;&#xD;
      frameborder=&amp;#034;0&amp;#034;&amp;gt;&amp;lt;/iframe&amp;gt;</description>
    <dc:creator>b3m2a1 ​ </dc:creator>
    <dc:date>2018-09-29T04:42:36Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1646303">
    <title>UNET: neural network for 2D &amp;amp; 3D image segmentation w/ medical examples</title>
    <link>https://community.wolfram.com/groups/-/m/t/1646303</link>
    <description># UNET [![DOI](https://zenodo.org/badge/137186334.svg)](https://zenodo.org/badge/latestdoi/137186334) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
![Automated 3D muscle segmentation using UNET / RESNET using DIXON MRI data][17]&#xD;
&#xD;
&#xD;
A package to generate and train a UNET deep convolutional network for 2D and 3D image segmentation.&#xD;
&#xD;
Some code was based on [work][1] by [@Ali Hashmi][at0], which was also dicussed in [this post][2] &#xD;
The full version of the toolbox can be found on my [github page][3].&#xD;
&#xD;
* [Information](#information)&#xD;
* [Install toolbox](#install-toolbox)&#xD;
* [Using the toolbox](#using-the-toolbox)&#xD;
* [Functionality](#functionality)&#xD;
* [Visualization](#visualization)&#xD;
* [Example](#example)&#xD;
&#xD;
## Information&#xD;
&#xD;
UNET is developed for [Mathematica](https://www.wolfram.com/mathematica/).&#xD;
It contains the following toolboxes:&#xD;
&#xD;
- UnetCore&#xD;
- UnetSupport&#xD;
&#xD;
Documentation of all functions and their options is fully integrated in the Mathematica documentation.&#xD;
The toolbox always works within the latest version of Mathematica and does not support any backward compatibility.&#xD;
&#xD;
All code and documentation is maintained and uploaded to github using [Workbench](https://www.wolfram.com/workbench/).&#xD;
&#xD;
## Install toolbox&#xD;
&#xD;
Install the toolbox in the Mathematica UserBaseDirectory &amp;gt; Applications.&#xD;
&#xD;
	FileNameJoin[{$UserBaseDirectory, &amp;#034;Applications&amp;#034;}]&#xD;
  &#xD;
## Using the toolbox&#xD;
&#xD;
The toolbox can be loaded by using &amp;lt;&amp;lt;UNET`&#xD;
&#xD;
The notbook ``UNET.nb`` shows examples of how to use the toolbox on artificially generated 2D data. &#xD;
There are also examples how to visualize the layer of your trained network and how to visualize the training itself. &#xD;
&#xD;
## Functionality&#xD;
&#xD;
The network supports multi channel inputs and multi class segmentation.&#xD;
&#xD;
* UNET generates a UNET convolutional network.  &#xD;
    * 2D UNET  &#xD;
![UNET 2D][4]&#xD;
    * 3D UNET  &#xD;
![UNET 3D][5]&#xD;
&#xD;
* Loss Layers: Training the data is done using three loss layers: a SoftDiceLossLayer, BrierLossLayer and a CrossEntropyLossLayer.  &#xD;
![SoftDiceLossLayer, BrierLossLayer and a CrossEntropyLossLayer][6]&#xD;
&#xD;
* Convolution Blocks: The toobox contains five different convolution blocks that build up the network: [UNET][7], UResNet, [RestNet][8], UDenseNet, [DensNet][9].  &#xD;
![Convolution blocks][10]&#xD;
&#xD;
* SplitTrainData splits the data and labels into training, validation and test data.  &#xD;
![split train Data][11]&#xD;
&#xD;
* TrainUNET trains the network.  &#xD;
![Train UNET][12]&#xD;
&#xD;
## Visualization&#xD;
&#xD;
* Visualize the network and results.  &#xD;
    * Visualize the features of the layers.  &#xD;
![Visualize layer features][13]&#xD;
    * Visualize the results.  &#xD;
![Visualize the results][14]&#xD;
    * Animate the training process.  &#xD;
![UNET 2D animation][15]  &#xD;
![UNET 3D animation][16]&#xD;
&#xD;
## Example&#xD;
&#xD;
* Example: 3D segmentation of lower legg muscles using MRI data.  &#xD;
&#xD;
![Automated 3D muscle segmentation using UNET / RESNET using DIXON MRI data][17]&#xD;
&#xD;
&#xD;
  [1]: https://github.com/alihashmiii/UNet-Segmentation-Wolfram&#xD;
  [2]: https://community.wolfram.com/groups/-/m/t/1341081?p_p_auth=w8PIeeiA&#xD;
  [3]: https://github.com/mfroeling&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=UNET2D.PNG&amp;amp;userId=1332602&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=UNET3D.PNG&amp;amp;userId=1332602&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Loss.PNG&amp;amp;userId=1332602&#xD;
  [7]: https://arxiv.org/abs/1505.04597&#xD;
  [8]: https://arxiv.org/abs/1512.03385&#xD;
  [9]: https://arxiv.org/abs/1608.06993&#xD;
  [10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=convblocks.PNG&amp;amp;userId=1332602&#xD;
  [11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Split.PNG&amp;amp;userId=1332602&#xD;
  [12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Train.PNG&amp;amp;userId=1332602&#xD;
  [13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Visualize1.PNG&amp;amp;userId=1332602&#xD;
  [14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Visualize2.PNG&amp;amp;userId=1332602&#xD;
  [15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=amin0-v2.gif&amp;amp;userId=1332602&#xD;
  [16]: https://community.wolfram.com//c/portal/getImageAttachment?filename=amin4-v2.gif&amp;amp;userId=1332602&#xD;
  [17]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Muscle_Segmentation.jpg&amp;amp;userId=1332602&#xD;
&#xD;
 [at0]: https://community.wolfram.com/web/alihashmi87</description>
    <dc:creator>Martijn Froeling</dc:creator>
    <dc:date>2019-04-03T20:01:26Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1655203">
    <title>EasyIDE: An IDE for Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/1655203</link>
    <description>This is a cross-post from [here](https://b3m2a1.github.io/easyide-an-ide-for-mathematica.html)&#xD;
&#xD;
---&#xD;
Contrary to what would probably be best practice, I do all of my Mathematica development inside Mathematica itself. To support this I built out a suite of  [application development tools](https://paclets.github.io/PacletServer/btools.html) , a  [web site builder](https://paclets.github.io/PacletServer/ems.html) , a  [bug tracker](https://github.com/b3m2a1/BugTracker) , and a  [documentation writing system](https://paclets.github.io/PacletServer/simpledocs.html) . Each of these worked nicely for me separately, but each of these required a palette and each one ran on notebooks, which meant that my screen filled with too many notebooks to keep track of. And then for each of these palettes and systems I had to write new resource finding code based off the palette or some arbitrarily imposed root directory or else provide some other way to specify where things would be found.&#xD;
&#xD;
In short, it got messy.&#xD;
&#xD;
Then, in a very relaxing hiatus from Mathematica I did some python development, writing a package for linking  [Mathematica to python](https://paclets.github.io/PacletServer/pjlink.html) as well as some stuff for coordinate transforms and finite differencing and other little utilities. In doing this I noticed that everything was just...better. Partly this is because python is much nicer to write significant amounts of code in, being a language that actually supports developers and with actual object orientation and modularity. But another significant part of it was in the tools available to me. In particular I had the python plugin to  [IntelliJ](https://www.jetbrains.com/idea/) , which is also repackaged as  [PyCharm](https://www.jetbrains.com/pycharm/) . The fact that I had tabbing, plugins (e.g. for  [Git](https://git-scm.com/) ), a file browser inside my dev environment, etc. was at once so entirely normal (I used to be a python programmer before switching over to mostly using Mathematica) and at the same time so nice. I then tried to use the  *very nice and well constructed*  [IntelliJ plugin for Mathematica](https://wlplugin.halirutan.de/) but it was just too much of a hurdle to lose everything I was used to and liked about writing my code directly in Mathematica.&#xD;
&#xD;
And that long, unnecessary background is why today we&amp;#039;re gonna look at a Mathematica IDE written and operating entirely within Mathematica.&#xD;
&#xD;
&#xD;
&#xD;
# EasyIDE&#xD;
&#xD;
Mostly for the rhyme, I called this thing  [EasyIDE](https://paclets.github.io/PacletServer/easyide.html) but it is pretty easy to use, too.&#xD;
&#xD;
&#xD;
&#xD;
## Basics&#xD;
&#xD;
&#xD;
&#xD;
###Installation&#xD;
&#xD;
Install it off the  [Paclet Server](https://paclets.github.io/PacletServer/) :&#xD;
&#xD;
    &amp;lt;&amp;lt; https://paclets.github.io/PacletServer/Install.wl&#xD;
    PublicPacletInstall[&amp;#034;EasyIDE&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
&#xD;
![post27-5677831900721146064](https://b3m2a1.github.io/img/post27-5677831900721146064.png)&#xD;
&#xD;
&#xD;
###Making a New IDE Notebook&#xD;
&#xD;
This IDE system is also basically just a package and a stylesheet, so it&amp;#039;s pretty easy to get started. Simply go to  `Format ? Stylesheet ? EasyIDE ? LightMode` . It&amp;#039;ll prompt you for a directory to use as the root directory. Here&amp;#039;s a video as an example:&#xD;
&#xD;
[![intro1](https://i.stack.imgur.com/YokQs.png)](https://www.youtube.com/watch?v=TMHiN9Ov2fQ)&#xD;
&#xD;
You can play around with the file browser now or the plugin menus in the top right&#xD;
&#xD;
&#xD;
&#xD;
###Notebooks, Packages, and Text Files&#xD;
&#xD;
As things currently stand, the IDE recognizes three types of files to handle in different ways. The first, of course, are plain notebooks. These can be manipulated like normal. Here&amp;#039;s an example of making and editing a notebook file in the IDE:&#xD;
&#xD;
[![intro 2](https://i.stack.imgur.com/76Gcd.png)](https://www.youtube.com/watch?v=I1MnB7duneA)&#xD;
&#xD;
Text and package files can be made in the same way--just assign the appropriate file extension.&#xD;
&#xD;
Each of these files will work basically as a regular file would, except their contents will be saved to their original file on the disk rather than the current  `NotebookFileName[]` .&#xD;
&#xD;
&#xD;
&#xD;
###The File Browser&#xD;
&#xD;
One of the most useful and intuitive features of this IDE is the file browser it has built in. This allows you to quickly find files inside the active directory. Here&amp;#039;s a screen shot of what that can look like:&#xD;
&#xD;
![post27-1442079965320612466](https://b3m2a1.github.io/img/post27-1442079965320612466.png)&#xD;
&#xD;
Each entry in this has a  `ContextMenu` that allows for some file- or directory-specific actions.&#xD;
&#xD;
&#xD;
&#xD;
###Stylesheet / Extension Based Behavior&#xD;
&#xD;
EasyIDE is built to be extensible. It provides a way to get different behavior depending on what would be useful for the specific type of notebook or file is being fed in. These are controlled in the EasyIDE settings, in particular at  `EasyIDE ? Resources ? Settings ? Mappings` where there are many files that control how these should map. This directory may also be created in  `$UserBaseDirectory/ApplicationData` and the settings there will take precedence over those in the paclet folder itself.&#xD;
&#xD;
These customizations include stylesheets, toolbars, and what to do when the file browser is active.&#xD;
&#xD;
&#xD;
&#xD;
###Plugins and Toolbars&#xD;
&#xD;
Probably the best feature of having something like EasyIDE is the ability to hook external code into the IDE and have it give new, more powerful capabilities. To make this easy to work with I added both a plugin system and a toolbar system (although the latter is really just a special case of the first). Plugins appear as either menus--such as the  `File` and  `Project` menus which are themselves just plugins--or as commands under the plugins menu. Currently I already have a decent number of these:&#xD;
&#xD;
![post27-6483075564890356321](https://b3m2a1.github.io/img/post27-6483075564890356321.png)&#xD;
&#xD;
All of these add new functionality to the IDE based on code I&amp;#039;d written before. In that screenshot you can also see a toolbar, which exists right below the tabs. This can be stylesheet specific and thus adds an even more targeted way to add functionality to the system. Here&amp;#039;s an example of the four different toolbars I&amp;#039;ve implemented as well as the different stylesheets they go with:&#xD;
&#xD;
[![intro 3](https://i.stack.imgur.com/QHCwH.png)](https://www.youtube.com/watch?v=fFiDiO-oM7w)&#xD;
&#xD;
In that you can also see the major downside of putting everything into an IDE: when the files get big (as is the one I&amp;#039;m using to write this post) things can get slower. On the other hand as long as one is only writing code, this is never an issue. And even with a ~12MB file like this things are still more than fast enough to not be frustrating to work with.&#xD;
&#xD;
## Extensions&#xD;
&#xD;
###Styles&#xD;
&#xD;
EasyIDE was built to be customizable. This holds first and foremost for the stylesheets it works with. Even though currently there is only a set of LightMode styles, as DarkMode style set could be constructed without too much more difficulty. To do this, one would merely have to take the existing LightMode stylesheet, copy it, and make the necessary cosmetic changes. These changes should then propagate reasonably naturally to the extension styles if the inheritance is changed. This is on the TODO list, but if there is a quality existing DarkMode stylesheet to work off that would also make life much easier.&#xD;
&#xD;
###Plugins and Toolbars&#xD;
&#xD;
These may be hooked in by adding things to  `EasyIDE ? Resources ? Settings ? Plugins` and  `EasyIDE ? Resources ? Settings ? Toolbars` . There are a number of good examples there already.&#xD;
&#xD;
###Miscellaneous Extensions&#xD;
&#xD;
I had already implemented stuff for creating nice docs, Markdown notebooks, websites, bug tracking, paclet creation, etc. and some of this has made it in as plugins already. More is forthcoming, but for now one can always play with what&amp;#039;s in the Plugins menu. In particular the Git plugin is useful for me as I write and develop.&#xD;
&#xD;
###The EasyIDE API&#xD;
&#xD;
EasyIDE is just a collection of functions wrapped into a single unit. These were designed to (hopefully) be modular and clean to work with. Eventually all core functionality will also make its way to being attached to a single object, the  `IDENotebookObject` . The API for this is based off of my  [InterfaceObjects](https://paclets.github.io/PacletServer/interfaceobjects.html) package and is object-oriented. This will be documented in due time, but as a taste here&amp;#039;s what it can look like:&#xD;
&#xD;
&#xD;
    ide = IDENotebookObject[]&#xD;
&#xD;
    (*Out:*)&#xD;
&#xD;
![post27-2774621243698091573](https://b3m2a1.github.io/img/post27-2774621243698091573.png)&#xD;
&#xD;
    ide@&amp;#034;Methods&amp;#034;&#xD;
&#xD;
    (*Out:*)&#xD;
&#xD;
    {&amp;#034;Open&amp;#034;,&amp;#034;Save&amp;#034;,&amp;#034;Close&amp;#034;,&amp;#034;SwitchTab&amp;#034;,&amp;#034;Path&amp;#034;,&amp;#034;Data&amp;#034;,&amp;#034;SetData&amp;#034;,&amp;#034;ToggleFileViewer&amp;#034;,&amp;#034;AddToolbar&amp;#034;,&amp;#034;RemoveToolbar&amp;#034;,&amp;#034;AddStyles&amp;#034;,&amp;#034;RemoveStyles&amp;#034;,&amp;#034;GetStylesheet&amp;#034;,&amp;#034;SetStylesheet&amp;#034;,&amp;#034;SetProjectDirectory&amp;#034;,&amp;#034;CreateMessage&amp;#034;,&amp;#034;CreateDialog&amp;#034;}&#xD;
&#xD;
These  `&amp;#034;Methods&amp;#034;` are all operations that the IDE notebook referenced to by  `EvaluationNotebook[]` can perform. Here&amp;#039;s an example of creating a message:&#xD;
&#xD;
&#xD;
    ide@&amp;#034;CreateMessage&amp;#034;[&amp;#034;Hello!&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
&#xD;
![post27-6469651990570110283](https://b3m2a1.github.io/img/post27-6469651990570110283.png)&#xD;
&#xD;
![post27-316085028871083490](https://b3m2a1.github.io/img/post27-316085028871083490.png)&#xD;
&#xD;
As the IDE grows in sophistication so will the methods the API supports. For now, though, these provide the most direct control that is possible to get with the IDE.</description>
    <dc:creator>b3m2a1 ​ </dc:creator>
    <dc:date>2019-04-09T10:47:07Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1527021">
    <title>MATH-TWS: Connecting Mathematica to Interactive Brokers TWS</title>
    <link>https://community.wolfram.com/groups/-/m/t/1527021</link>
    <description>MATH-TWS is a new Mathematica package that connects Wolfram Mathematica to the Interactive Brokers TWS platform via the C++ API. It enables the user to retrieve information from TWS on accounts, portfolios and positions, as well as historical and real-time market data. MATH-TWS also enables the user to place and amend orders and obtain execution confirmations from Mathematica.&#xD;
&#xD;
I have wanted a way to connect Wolfram Mathematica to Interactive Brokers Trader Workstation for the longest time.  Now that it is finally available with MATH-TWS  I am excited by the possibilities for Mathematica users.&#xD;
&#xD;
The first release of MATH-TWS will be available within a couple of weeks. Anyone interested in licensing a copy should email algorithmicexecution@gmail.com with MATH-TWS in the subject line.&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
![enter image description here][12]&#xD;
&#xD;
![enter image description here][13]&#xD;
&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsConnect.png&amp;amp;userId=773999&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsAccounts.png&amp;amp;userId=773999&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsAccounts2.png&amp;amp;userId=773999&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsAccounts3.png&amp;amp;userId=773999&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=HistoricalData.png&amp;amp;userId=773999&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=DataManipulation.png&amp;amp;userId=773999&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=TimeSeries.png&amp;amp;userId=773999&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=IntradayData.png&amp;amp;userId=773999&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Currentmarketdata.png&amp;amp;userId=773999&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=News.png&amp;amp;userId=773999&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Ordermanagement.png&amp;amp;userId=773999&#xD;
  [12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Modifyorder.png&amp;amp;userId=773999&#xD;
  [13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Cancelorder.png&amp;amp;userId=773999</description>
    <dc:creator>Jonathan Kinlay</dc:creator>
    <dc:date>2018-10-22T12:09:47Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1736686">
    <title>Bayesian linear regression in Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/1736686</link>
    <description>Recently I updated my [Bayesian inference reporitory][1] with a new function called `BayesianLinearRegression` to provide a Bayesian alternative to Mathematica&amp;#039;s `LinearModelFit`. I also submitted the code for this function to the [Wolfram function repository][2] to make it easier to access, so the function can also be used with `ResourceFunction[&amp;#034;BayesianLinearRegression&amp;#034;]`.&#xD;
&#xD;
The example notebook in the repository provides several examples of how the function can be used, some of which I will reproduce below. Please refer to the GitHub README.md file (which is displayed on the homepage of the repository) for instructions about installing the `BayesianInference` package. The code is in [this file][3], in case you&amp;#039;re interested in taking a look under the hood.&#xD;
&#xD;
## Fitting polynomials ##&#xD;
&#xD;
First generate some test data:&#xD;
&#xD;
    data = RandomVariate[&#xD;
      MultinormalDistribution[{{1, 0.7}, {0.7, 1}}],&#xD;
      20&#xD;
    ];&#xD;
    ListPlot[data]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
The usage of `BayesianLinearRegression` is similar to that of `LinearModelFit` with one significant difference: I decided that the `Rule`-based data specification used by `Predict` and `NetTrain` is often more convenient than the matrix input used by the `Fit` family, so I decided that both types of data specifications should work. The main reason for this is that `BayesianLinearRegression` also supports regression of vector outputs (an example of that is given in the repository example notebook), in which case the `Rule`-based format is often easier to understand.&#xD;
&#xD;
When you fit a model, `BayesianLinearRegression` returns an `Association` containing all relevant information about the fit. Fit a model of the form `y == a + b x + randomness` where `randomness`  is distributed as `NormalDistribution[0, sigma]`. Here, `a`, `b` and `sigma` are unknowns that need to be fitted to the data:&#xD;
&#xD;
    In[20]:= Clear[x];&#xD;
    model =  BayesianLinearRegression[data, {1, x}, x];&#xD;
&#xD;
Below is a more detailed description of the information return by `BayesianLinearRegression`, but let&amp;#039;s first concentrate on the main fit result, which is the [posterior predictive distribution][5] :&#xD;
&#xD;
    In[61]:= model[&amp;#034;Posterior&amp;#034;, &amp;#034;PredictiveDistribution&amp;#034;]&#xD;
    &#xD;
    Out[61]= StudentTDistribution[-0.267818 + 0.986121 x, &#xD;
     0.726105 Sqrt[1.05016 + 0.00692863 x + 0.0635094 x^2], &#xD;
     2001/100&#xD;
    ]&#xD;
&#xD;
As you can see, the result is returned is an `x`-dependent `StudentTDistribution`. Visualize the predictions:&#xD;
&#xD;
    With[{&#xD;
      predictiveDist = model[&amp;#034;Posterior&amp;#034;, &amp;#034;PredictiveDistribution&amp;#034;],&#xD;
      bands = {95, 50, 5}&#xD;
      },&#xD;
     Show[&#xD;
      Plot[&#xD;
       Evaluate@InverseCDF[predictiveDist, bands/100],&#xD;
       {x, -4, 4}, Filling -&amp;gt; {1 -&amp;gt; {2}, 3 -&amp;gt; {2}}, PlotLegends -&amp;gt; bands&#xD;
       ],&#xD;
      ListPlot[data],&#xD;
      PlotRange -&amp;gt; All&#xD;
      ]&#xD;
     ]&#xD;
![enter image description here][6]&#xD;
&#xD;
In the `BayesianInference` package on GitHub, I included a function called `regressionPlot1D` which makes it a bit easier to make this plot:&#xD;
&#xD;
    Show[&#xD;
     regressionPlot1D[model[&amp;#034;Posterior&amp;#034;, &amp;#034;PredictiveDistribution&amp;#034;], {x, -4, 4}, {95, 50, 5}],&#xD;
     ListPlot[data]&#xD;
    ] &#xD;
    (* same result*)&#xD;
&#xD;
## Model comparison and model mixing ##&#xD;
&#xD;
Often you&amp;#039;ll want to compare multiple models against a data set to see which one works best. For example, here is some data where it&amp;#039;s a bit unclear if you should use a first or second order model:&#xD;
&#xD;
    data = {{-1.5`,-1.375`},{-1.34375`,-2.375`},{1.5`,0.21875`},{1.03125`,0.6875`},{-0.5`,-0.59375`},&#xD;
      {-1.875`,-2.59375`},{1.625`,1.1875`},{-2.0625`,-1.875`},{1.0625`,0.5`},{-0.4375`,-0.28125`},{-0.75`,-0.75`},{2.125`,0.375`},{0.4375`,0.6875`},{-1.3125`,-0.75`},{-1.125`,-0.21875`},&#xD;
      {0.625`,0.40625`},{-0.25`,0.59375`},{-1.875`,-1.625`},{-1.`,-0.8125`},{0.4375`,-0.09375`}}&#xD;
    ListPlot[data]&#xD;
![enter image description here][7]&#xD;
&#xD;
Fit the data with polynomials up to fourth degree; rank the log-evidences and inspect them. As you can see, the first and second order fits are almost equally likely:&#xD;
&#xD;
    In[152]:= models = AssociationMap[&#xD;
       BayesianLinearRegression[Rule @@@ data, x^Range[0, #], x] &amp;amp;,&#xD;
       Range[0, 4]&#xD;
       ];&#xD;
    ReverseSort@models[[All, &amp;#034;LogEvidence&amp;#034;]]&#xD;
    &#xD;
    Out[153]= &amp;lt;|1 -&amp;gt; -30.0072, 2 -&amp;gt; -30.1774, 3 -&amp;gt; -34.4292, 4 -&amp;gt; -38.7037, 0 -&amp;gt; -38.787|&amp;gt;&#xD;
&#xD;
Show the prediction bands:&#xD;
&#xD;
    Show[&#xD;
     regressionPlot1D[ models[1, &amp;#034;Posterior&amp;#034;, &amp;#034;PredictiveDistribution&amp;#034;], {x, -3, 3}],&#xD;
     regressionPlot1D[models[2, &amp;#034;Posterior&amp;#034;, &amp;#034;PredictiveDistribution&amp;#034;], {x, -3, 3},  PlotStyle -&amp;gt; Dashed, PlotLegends -&amp;gt; None],&#xD;
     ListPlot[data]&#xD;
    ]&#xD;
![Comparison of the first (solid) and second order (dashed) prediction bands][8]&#xD;
&#xD;
Instead of picking just one of the models, we can define a mixture over all of them. First calculate the weights for each fit:&#xD;
&#xD;
    In[94]:= weights = Normalize[&#xD;
       (* subtract the max to reduce rounding error *)&#xD;
       Exp[models[[All, &amp;#034;LogEvidence&amp;#034;]] - Max[models[[All, &amp;#034;LogEvidence&amp;#034;]]]],&#xD;
       Total&#xD;
       ];&#xD;
    ReverseSort[weights]&#xD;
    &#xD;
    Out[95]= &amp;lt;|1 -&amp;gt; 0.516002, 2 -&amp;gt; 0.47702, 3 -&amp;gt; 0.0068122, 4 -&amp;gt; 0.0000982526, &#xD;
     0 -&amp;gt; 0.0000667854|&amp;gt;&#xD;
&#xD;
Define a mixture of posterior predictive distributions and show the predictions:&#xD;
&#xD;
    In[96]:= mixDist = MixtureDistribution[&#xD;
       Values[weights],&#xD;
       Values@models[[All, &amp;#034;Posterior&amp;#034;, &amp;#034;PredictiveDistribution&amp;#034;]]&#xD;
       ];&#xD;
    Show[&#xD;
     regressionPlot1D[mixDist, {x, -3, 3}],&#xD;
     ListPlot[data]&#xD;
     ]&#xD;
![Prediction bands of a mixture of polynomial models up to degree 4][9]&#xD;
&#xD;
As you can see, if one model is not clearly the best, you can just split the difference between them.&#xD;
&#xD;
Another interesting thing you can do with `BayesianLinearRegression` is Bayesian updating. Basically, this means that if you&amp;#039;ve fitted some data in the past and are now finding new data, you can incorporate the new data by updating your fit without having to re-fit all of the data (old and new) in one go. An example of this is given in the example code notebook on GitHub (in the section about the `&amp;#034;PriorParameters&amp;#034;` options of the function). &#xD;
&#xD;
## Detailed explanation about the returned values ##&#xD;
`BayesianLinearRegression` returns an `Association` with the following keys:&#xD;
&#xD;
    Keys[model]&#xD;
    &#xD;
    Out[21]= {&amp;#034;LogEvidence&amp;#034;, &amp;#034;PriorParameters&amp;#034;, &amp;#034;PosteriorParameters&amp;#034;, &amp;#034;Posterior&amp;#034;, &amp;#034;Prior&amp;#034;, &amp;#034;Basis&amp;#034;, &amp;#034;IndependentVariables&amp;#034;}&#xD;
&#xD;
 - `&amp;#034;LogEvidence&amp;#034;`: In a Bayesian setting, the evidence (also called [marginal likelihood][10]) measures how well the model fits the data (with a higher evidence indicating a better fit). The evidence has the virtue that it naturally penalizes models for their complexity and therefore does not suffer from over-fitting in the way that measures like the sum-of-squares or likelihood do. &#xD;
 - `&amp;#034;Basis&amp;#034;`, `&amp;#034;IndependentVariables&amp;#034;`: Simply the basis functions and independent variable specified by the user.&#xD;
 - `&amp;#034;Posterior&amp;#034;`, `&amp;#034;Prior&amp;#034;`: These two keys each hold an association with 4 distributions: &#xD;
 1. `&amp;#034;PredictiveDistribution&amp;#034;`: A distribution that depends on the independent variables (`x` in the example above). By filling in a value for `x`, you get a distribution that tells you where you could expect to find future `y` values. This distribution accounts for all relevant uncertainties in the model: model variance caused by the term `randomness`; uncertainty in the values of `a` and `b`; and uncertainty in `sigma`.&#xD;
 2. `&amp;#034;UnderlyingValueDistribution&amp;#034;`: Similar to `&amp;#034;PredictiveDistribution&amp;#034;`, but this distribution give the possible values of `a + b x` without the `randomness` error term.&#xD;
 3. `&amp;#034;RegressionCoefficientDistribution&amp;#034;`: The join distribution over `a` and `b`.&#xD;
 4. `&amp;#034;ErrorDistribution&amp;#034;`: The distribution of the variance `sigma^2`.&#xD;
 - ` &amp;#034;PriorParameters&amp;#034;`, `&amp;#034;PosteriorParameters&amp;#034;`: These parameters are not immediately important most of the time, but they contain all of the relevant information about the fit. &#xD;
&#xD;
## Sources ##&#xD;
&#xD;
The formulas underlying BayesianLinearRegression are based mainly on the following Wikipedia articles. The names of the hyper parameters returned by the function are based on the article about multivariate linear regression. &#xD;
&#xD;
 - [Bayesian linear regression (Wikipedia)][11]&#xD;
 - [Bayesian multivariate linear regression (Wikipedia)][12]&#xD;
&#xD;
&#xD;
  [1]: https://github.com/ssmit1986/BayesianInference&#xD;
  [2]: https://resources.wolframcloud.com/FunctionRepository/resources/BayesianLinearRegression&#xD;
  [3]: https://github.com/ssmit1986/BayesianInference/blob/master/BayesianInference/BayesianLinearRegression.wl&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=testdata.png&amp;amp;userId=839741&#xD;
  [5]: https://en.wikipedia.org/wiki/Posterior_predictive_distribution&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=fit.png&amp;amp;userId=839741&#xD;
  [7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=testdata2.png&amp;amp;userId=839741&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=fit2.png&amp;amp;userId=839741&#xD;
  [9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=fitmix.png&amp;amp;userId=839741&#xD;
  [10]: https://en.wikipedia.org/wiki/Marginal_likelihood&#xD;
  [11]: https://en.wikipedia.org/wiki/Bayesian_linear_regression&#xD;
  [12]: https://en.wikipedia.org/wiki/Bayesian_multivariate_linear_regression</description>
    <dc:creator>Sjoerd Smit</dc:creator>
    <dc:date>2019-07-14T12:30:33Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/963158">
    <title>Draw: vector drawing &amp;amp; technical illustration application</title>
    <link>https://community.wolfram.com/groups/-/m/t/963158</link>
    <description>Recently John Fultz [announced][1] GitLink as open source on GitHub. He also mentioned the desire to offer more Wolfram related open source to the community. Draw was not mentioned by John but readers of his post followed the GitHub [link][2] and discovered the Draw repository. Naturally questions followed so here we are with an introduction of Draw, the latest open source contribution to the community.&#xD;
&#xD;
Draw is a vector drawing application. Many of the technical illustrations found in the Wolfram Language documentation were created using it. The release of Draw is to promote the advantages of using the Wolfram Language for software development.&#xD;
&#xD;
Draw was a personal project that grew from an idea to develop a simple tool to automate the drawing of flowcharts. This simple tool expanded in response to the need of functionality for solving specific challenges required by various illustrations. The Wolfram Language was very instrumental in helping Draw evolve during this process.&#xD;
&#xD;
Some of the more prominent features of Draw include:&#xD;
&#xD;
 - Orthographic 3D drawing&#xD;
 - Circuit, Mechanical and 3D library presets&#xD;
 - Adjustable shapes such as gears or spirals&#xD;
 - Shape arrays&#xD;
 - Image autotrace&#xD;
&#xD;
The gallery of examples below demonstrate the capabilities of Draw:&#xD;
&#xD;
![gallery][3]&#xD;
&#xD;
A look inside the application reveals an interface divided into four distinct sections:&#xD;
&#xD;
![interface sections][4]&#xD;
&#xD;
An example of Draw being used to work on a flowchart:&#xD;
&#xD;
![interface][5]&#xD;
&#xD;
The Circuit, Mechanical and 3D libraries:&#xD;
&#xD;
![libraries][6]&#xD;
&#xD;
The adjustable gear shape:&#xD;
&#xD;
![gear][7]&#xD;
&#xD;
The shape array:&#xD;
&#xD;
![shape array][8]&#xD;
&#xD;
Hope this brief introduction is enough to inspire you to download the Draw notebook from [this GitHub link][9]. Start creating illustrations or explore the Wolfram Language code to discover how the application works. Support is available by clicking the blue help button for topics such as the basics, features, interaction, tools, examples and tips. Tooltips appear for all buttons detailing their behavior. Remember this is open source software and comes with no guarantee. That being said, feel free to kick the tires and take it for a spin.&#xD;
&#xD;
Draw works best when used in Mathematica 11 but most functionality is supported by Mathematica 10.4.1.&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com/groups/-/m/t/960333&#xD;
  [2]: https://github.com/WolframResearch&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=examples.png&amp;amp;userId=28355&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=interfaceSections.png&amp;amp;userId=28355&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=interface.png&amp;amp;userId=28355&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=libraries.png&amp;amp;userId=28355&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=gear.png&amp;amp;userId=28355&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=shapearray.png&amp;amp;userId=28355&#xD;
  [9]: https://github.com/shdlbwr/draw</description>
    <dc:creator>Tim Shedelbower</dc:creator>
    <dc:date>2016-11-14T20:15:12Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1039591">
    <title>Saving data directly in notebooks</title>
    <link>https://community.wolfram.com/groups/-/m/t/1039591</link>
    <description>Do you ever wish you could save data directly into a notebook instead of having to export it?  I sometimes do things like&#xD;
&#xD;
    mydata = {1,2,3, ...};&#xD;
&#xD;
just to be able to use this data next time I open the notebook.  This could be data I pasted from the web, or something that just took several minutes to generate.&#xD;
&#xD;
But saving it like this is inconvenient, and often takes up a lot of space.&#xD;
&#xD;
Today I published a blog post about a better method that I have been using recently.  I thought people here may be interested:&#xD;
&#xD;
 * [Save data directly in Mathematica notebooks](http://szhorvat.net/pelican/save-data-in-notebooks.html)&#xD;
&#xD;
The idea is to use first `Compress` the data, then use `Interpretation` to create a compact display for it.  Here&amp;#039;s a small function that packages all of this up:&#xD;
&#xD;
    ClearAll[SaveToCell]&#xD;
    &#xD;
    SaveToCell::usage =&#xD;
        &amp;#034;SaveToCell[variable] creates an input cell that reassigns the current value of variable.\n&amp;#034; &amp;lt;&amp;gt;&#xD;
        &amp;#034;SaveToCell[variables, display] shows &amp;#039;display&amp;#039; on the right-hand-side of the assignment.&amp;#034;;&#xD;
    &#xD;
    SetAttributes[SaveToCell, HoldFirst]&#xD;
    SaveToCell[var_, name : Except[_?OptionQ] : &amp;#034;data&amp;#034;, opt : OptionsPattern[]] :=&#xD;
        With[{data = Compress[var],&#xD;
          panel = ToBoxes@Tooltip[Panel[name, FrameMargins -&amp;gt; Small], DateString[]]},&#xD;
          CellPrint@Cell[&#xD;
            BoxData@RowBox[{&#xD;
              MakeBoxes[var],&#xD;
              &amp;#034;=&amp;#034;,&#xD;
              InterpretationBox[panel, Uncompress[data]],&#xD;
              &amp;#034;;&amp;#034;&#xD;
            }],&#xD;
            &amp;#034;Input&amp;#034;,&#xD;
            (* prevent deletion by Cell &amp;gt; Delete All Output: *)&#xD;
            GeneratedCell -&amp;gt; False,&#xD;
            (* CellLabel is special: last occrrence takes precedence, so it comes before opt: *)&#xD;
            CellLabel -&amp;gt; &amp;#034;(saved)&amp;#034;,&#xD;
            opt,&#xD;
            CellLabelAutoDelete -&amp;gt; False&#xD;
          ]&#xD;
        ]&#xD;
&#xD;
If you have your data in the variable `var`, simply run `SaveToCell[var]`, which will create an input cell that re-assign the value of `var`. It looks like this:&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
We can also customize the display:&#xD;
&#xD;
    var = Range[1000];&#xD;
    SaveToCell[var, Short[var]]&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
Hovering the display will show the date when the data was saved.&#xD;
&#xD;
`SaveToCell` also takes arbitrary `Cell` options, and passes them down to the generated cell.  Something strange I observed while writing this function is that with some options, such as `CellLabel`, [it is not the first but the last occurrence of the option that takes precedence][3].  Does anyone know why?&#xD;
&#xD;
We can use this functionality to change the cell style, add a different label, or to protect the cell against accidental deletion: `SaveToCell[var, Deletable -&amp;gt; False]`.&#xD;
&#xD;
I have been using this little function for a while, and I hope that others will find it useful too.&#xD;
&#xD;
Do be careful though: notebooks are not designed for storing large data.  I would avoid storing data as large as several tens of megabytes within notebooks.&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=in1.png&amp;amp;userId=38370&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=in3.png&amp;amp;userId=38370&#xD;
  [3]: http://mathematica.stackexchange.com/q/140989/12</description>
    <dc:creator>Szabolcs Horvát</dc:creator>
    <dc:date>2017-03-25T21:56:48Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1468475">
    <title>PJLink: Hooking up Mathematica and Python</title>
    <link>https://community.wolfram.com/groups/-/m/t/1468475</link>
    <description>Here&amp;#039;s a cross-post of something I originally wrote [here](https://www.wolframcloud.com/objects/b3m2a1/home/pjlink-hooking-up-mathematica-and-python.html) about how to get python and Mathematica to work together like JLink.&#xD;
&#xD;
I thought this might have broad appeal here.&#xD;
&#xD;
PJLink: Hooking up Mathematica and Python&#xD;
---&#xD;
Mathematica is an incredibly powerful platform with a fun and intellectually pleasing language, but is incredibly expensive and closed source. Python is a convenient, pretty powerful language with a lot of support from the developer community. For as long as the two have existed people have been trying to tie them together, but very little has been done to do so at the native level with efficient, convenient exchange between the two. That&amp;#039;s why over the past few weeks I took the time to build a clean, convenient link between the two. This post will go into how the link was built and some of its features, but first I think a little demo is appropriate.&#xD;
&#xD;
&#xD;
&#xD;
## A Quick Demo&#xD;
&#xD;
### Installing PJLink&#xD;
&#xD;
The link is based off of the  [J/Link](https://reference.wolfram.com/language/JLink/tutorial/Overview.html) interface built into Mathematica for hooking up Java and Mathematica. To wit, I called it  [PJ/Link](https://github.com/b3m2a1/PJLink) . It lives on my paclet server as well as GitHub, so we can easily install it from there:&#xD;
&#xD;
    PacletInstall[&amp;#034;PJLink&amp;#034;, &amp;#034;Site&amp;#034;-&amp;gt;&amp;#034;http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
![hookingupmathematicaandpython-274752603667507597](https://www.wolframcloud.com/objects/b3m2a1/home/img/hookingupmathematicaandpython-274752603667507597.png)&#xD;
&#xD;
### Loading PJLink in Jupyter&#xD;
&#xD;
For this demo we&amp;#039;ll need the path to this thing as well (note that the version might change in the future):&#xD;
&#xD;
    %[&amp;#034;Location&amp;#034;]&#xD;
&#xD;
    (*Out:*)&#xD;
    &#xD;
    &amp;#034;~/Library/Mathematica/Paclets/Repository/PJLink-1.0.0&amp;#034;&#xD;
&#xD;
Now we&amp;#039;ll leave Mathematica and open up a Jupyter notebook:&#xD;
&#xD;
![hookingupmathematicaandpython-921972091567300718](https://www.wolframcloud.com/objects/b3m2a1/home/img/hookingupmathematicaandpython-921972091567300718.png)&#xD;
&#xD;
Next we&amp;#039;ll get that path available so we can actually make use of the package. Then we&amp;#039;ll load things from the subsidiary  ```SubprocessKernel``` package which is included in the paclet and makes use of PJLink:&#xD;
&#xD;
&amp;lt;pre&amp;gt;import os, sys&#xD;
pjlink_path = &amp;amp;quot;~/Library/Mathematica/Paclets/Repository/PJLink-1.0.0&amp;amp;quot; #this is whatever path was extracted before&#xD;
sys.path.insert(0, os.path.expanduser (pjlink_path))&#xD;
&#xD;
from SubprocessKernel import SubprocessKernel&#xD;
from SubprocessKernel import MathematicaBlock, LinkEnvironment&#xD;
## these are helpers I&amp;amp;apos; ll use in the demo&amp;lt;/pre&amp;gt;&#xD;
&#xD;
![hookingupmathematicaandpython-695494794636171070](https://www.wolframcloud.com/objects/b3m2a1/home/img/hookingupmathematicaandpython-695494794636171070.png)&#xD;
&#xD;
### Bidirectional Communication&#xD;
&#xD;
Once we have this we can start a subprocess kernel which will open a Mathematica front-end to interact with. We&amp;#039;ll also start and evaluator Mathematica can use to call back into python.&#xD;
&#xD;
You may see a long string of output from your C compiler as the setup.py file builds out the native library that PJLink uses. Don&amp;#039;t worry, this should only happen once. If it fails, raise an issue on  [GitHub](https://github.com/b3m2a1/PJLink/issues) so I can deal with it.&#xD;
&#xD;
Once Mathematica has loaded, we&amp;#039;ll use the  ```MathematicaBlock``` context manager so we can write something that looks a lot like Mathematica code and use the  ```MEval``` function we&amp;#039;ll define to run the code. That code for all this looks like:&#xD;
&#xD;
&amp;lt;pre&amp;gt;ker = SubprocessKernel()&#xD;
def MEval (expr, wait = True, kernel = ker) :&#xD;
     &amp;amp;quot;&amp;amp;quot; &amp;amp;quot;MEval evaluates a Mathematica expression in the Mathematica kernel&#xD;
      &#xD;
      &amp;amp;quot; &amp;amp;quot;&amp;amp;quot;&#xD;
    kernel.drain() # just to make sure things are clen&#xD;
    return kernel.evaluate (expr, wait = wait)&#xD;
ker.start()&#xD;
ker.start_evaluator()&amp;lt;/pre&amp;gt;&#xD;
&#xD;
After that we can simply call into Mathematica:&#xD;
&#xD;
&amp;lt;pre&amp;gt;with MathematicaBlock():&#xD;
      res = MEval (Set (M.hi, &amp;amp;quot;Hello from python!&amp;amp;quot;))&#xD;
res&amp;lt;/pre&amp;gt;&#xD;
&#xD;
![hookingupmathematicaandpython-4447232891793681130](https://www.wolframcloud.com/objects/b3m2a1/home/img/hookingupmathematicaandpython-4447232891793681130.png)&#xD;
&#xD;
We can see string  ```&amp;#034;Hello from python!&amp;#034;``` was set to the symbol  ```hi``` on the Mathematica side and was returned back by  ```MEval``` . Symbols that aren&amp;#039;t in the  ```&amp;#034;System`&amp;#034;```  context need to be prefaced by an  ```M.``` as that&amp;#039;s a special class that can resolve symbol names like that.&#xD;
&#xD;
We can also get efficient data transfer of arrays from either side. Here we&amp;#039;ll take some Mathematica data and get it back out on the python side. The first thing we need to do is go to the Mathematica notebook that opened and load the  ```&amp;#034;PJLink`&amp;#034;``` context. Then we&amp;#039;ll install the python runtime that the  ```SubprocessKernel``` object configured. This looks like:&#xD;
&#xD;
    &amp;lt;&amp;lt;PJLink`&#xD;
    InstallPython[ LinkObject-&amp;gt;SubprocessKernel`$PyEvaluateLink, ProcessObject-&amp;gt;None];&#xD;
&#xD;
Once it&amp;#039;s installed, we&amp;#039;ll use it directly via  ```PyEvaluate``` :&#xD;
&#xD;
    With[{arr= RandomReal[{-1, 1}, {50, 50, 50}]},&#xD;
      PyEvaluate[dat=arr]&#xD;
      ]&#xD;
&#xD;
Calls into python are done in an environment held only by the link, so to access that we need to wrap the evaluator we started ( ```ker.evaluator``` ) in a  ```LinkEnvironment``` context manager:&#xD;
&#xD;
&amp;lt;pre&amp;gt;with LinkEnvironment(ker.evaluator):&#xD;
      res = dat.shape&#xD;
res&amp;lt;/pre&amp;gt;&#xD;
&#xD;
![hookingupmathematicaandpython-8804306407173974153](https://www.wolframcloud.com/objects/b3m2a1/home/img/hookingupmathematicaandpython-8804306407173974153.png)&#xD;
&#xD;
Arrays are held as NumPy arrays by default on the python side, although this may be disabled. If disabled, they&amp;#039;re held as a data type called  ```BufferedNDArray``` which holds the data as a single C-contiguous array and allows slicing and viewing into it (although no efficient math or manipulation of any sort).&#xD;
&#xD;
Finally, to close out the demo, we&amp;#039;ll plot something on the Mathematica side and watch it come back on the python side. The code for this should be pretty self-explanatory by this point, but there is one cute feature to note:&#xD;
&#xD;
&amp;lt;pre&amp;gt;with MathematicaBlock():&#xD;
      res = MEval(&#xD;
           Rasterize(&#xD;
                 Plot(Sin (M.x), List (M.x, 0, Times (2, Pi)),&#xD;
                       ImageSize = [250, 250],&#xD;
                       PlotLabel = &amp;amp;quot;sin(x) as plotted in Mathematica&amp;amp;quot;&#xD;
                       )&#xD;
                 )&#xD;
           )&#xD;
res&amp;lt;/pre&amp;gt;&#xD;
&#xD;
Unfortunately it really does matter that we pass a  ```List``` expression instead of a python list for the second argument to  ```Plot``` as otherwise the system hangs for reasons that aren&amp;#039;t totally clear. On the other hand, we can see how nice options passing is in the interface. We make use of the python  ```**kwargs``` setup and that  ```ImageSize= ...``` and  ```PlotLabel= ...``` both get automatically converted into rules (albeit with a  ```String``` key instead of a  ```Symbol``` ). The  ```Rasterize``` is, sadly, similarly necessary as there is currently no logic in the package to automatically convert  ```Graphics``` expression into their rasterized forms. &#xD;
&#xD;
![hookingupmathematicaandpython-6192533434254394386](https://www.wolframcloud.com/objects/b3m2a1/home/img/hookingupmathematicaandpython-6192533434254394386.png)&#xD;
&#xD;
I think we&amp;#039;ll close out the demo here, though, and move onto a description of how this works.&#xD;
&#xD;
&#xD;
&#xD;
## PJLink Native Library&#xD;
&#xD;
The heart of PJLink is the C library that connects a python runtime to MathLink. The source for this can be found  [here](https://github.com/b3m2a1/PJLink/blob/master/PJLink/PJLinkNativeLibrary/src/PJLinkNativeLibrary.cpp) . This library, once compiled by the setup.py file packaged with it, implements the basic MathLink calls in a way that python can use them and attempts to do so with efficient memory usage and data transfer.&#xD;
&#xD;
### Data Sharing in the Native Library&#xD;
&#xD;
The heart of the native library is the set of  ```PutArray``` and  ```GetArray``` functions it implements. Beyond anything else, it is the fast transfer of large arrays of data that makes a C-level connection so appealing. The way we handle this on the python side is via the python  [buffer protocol](https://docs.python.org/3/c-api/buffer.html) . We enforce the condition that all data sent and received on the python side must be handled by an object that can work with a C-contiguous buffer of data. By default this is done with  [NumPy](http://www.numpy.org/) if it is installed, but if not there is a custom object called  ```BufferedNDArray``` in the  [HelperClasses](https://github.com/b3m2a1/PJLink/blob/master/PJLink/HelperClasses.py) package that deals with this.&#xD;
&#xD;
### Threading in the Native Library&#xD;
&#xD;
Python has something called the  [Global Interpreter Lock (GIL)](https://docs.python.org/3/c-api/init.html#thread-state-and-the-global-interpreter-lock) which is a method for synchronizing python state. Unfortunately for us, the presence of the GIL means that standard C calls of the kind we&amp;#039;ll be using will cause all threads to lock. To get around this, every call into the MathLink library in the native library is wrapped in the  ```MLTHREADED``` macro which handles the releasing and reacquiring of the lock. This allows our threads to work once more. Any extensions to the library should keep this in mind.&#xD;
&#xD;
&#xD;
&#xD;
## Class Structures&#xD;
&#xD;
PJLink provides a glut of classes that handle the details communication, so we will quickly detail what the important ones do. More information is always available upon request.&#xD;
&#xD;
### The *Link classes&#xD;
&#xD;
PJLink is based off of JLink and so it makes use of the same kind of class structure that JLink does. This means that it has a  ```MathLink``` class that provides a template for the kind of link we&amp;#039;ll work with and a  ```KernelLink``` class that works specifically with Mathematica kernels. In general, we will only really work with a subclass of a  ```KernelLink``` called a  ```WrappedKernelLink``` that implements the  ```KernelLink``` interface by calling into a  ```NativeLink``` which is the only class which actually touches the native library at all.&#xD;
&#xD;
If one is controlling a Mathematica kernel from python, it will be handled by a  ```WrappedKernelLink``` .&#xD;
&#xD;
### Reader class&#xD;
&#xD;
The  ```Reader``` class handles the other half of the communication. It waits for calls from Mathematica and processes them via the  ```KernelLink._handlePacket``` function. Most commonly these calls in turn call  ```KernelLink.__callPython``` which builds a python call from the symbolic python packet that  ```PyEvaluate``` sends over the link. A  ```Reader``` does its best not to completely prevent its link from passing data  *to* Mathematica, but in general it is best not to depend on this as the  ```NativeLink``` interface allows only a single thread to access the library at once for reasons of safety and stability.&#xD;
&#xD;
### MathLinkEnvironment and MathLinkException&#xD;
&#xD;
The  ```MathLinkEnvironment``` is a standalone class that handles all of the various flags and state that the links need. It centralizes all information about what a given token or flag from MathLink means and provides utility functions for working with this.  ```MathLinkException``` is a subclass of the standard python  ```Exception``` class that handles the MathLink-specific exceptions that are returned. It in turn calls into  ```MathLinkEnvironment``` to learn what various exceptions mean.&#xD;
&#xD;
### MPackage, MLSym, and MLExpr&#xD;
&#xD;
The HelperClasses package provides a large number of (generally) smaller classes that serve to make code cleaner in its implementation. A big part of this is done by the  ```MPackage``` ,  ```MLSym``` , and  ```MLExpr``` classes, which allow for a way to create packets with a syntax that looks more like standard Mathematica code.  ```MLSym``` and  ```MLExpr``` are types that a  ```KernelLink``` knows how to put onto a link and  ```MPackage``` provides utilities and a custom  ```__getattr__``` so that the packet code can look like Mathematica code.&#xD;
&#xD;
### MathematicaBlock and LinkEnvironment&#xD;
&#xD;
Both  ```MathematicaBlock``` and  ```LinkEnvironment``` are also in the HelperClasses. They both edit the current evaluation state as  [context managers](https://docs.python.org/3/reference/datamodel.html#context-managers) so that explicit references to  ```MPackage``` can be dropped and variables held by a given link can be easily accessed. Being context managers, they are both used via  ```with``` statements and change the execution environment of the enclosing block.&#xD;
&#xD;
### BufferedNDArray, ImageData, and SparseArrayData&#xD;
&#xD;
These are all data classes that allow for more efficient and convenient data transfer. The  ```ImageData``` and  ```SparseArrayData``` classes hold data coming in from Mathematica as put using  ```PJLink`Package`AddTypeHints``` . They have methods to efficiently transform to more standard formats like  ```PIL.Image``` and  ```scipy.sparse.csr_matrix``` . As more data types are handled by  ```AddTypeHints``` it can be assumed that more classes like these will be written.&#xD;
&#xD;
&#xD;
&#xD;
## Mathematica-side Package&#xD;
&#xD;
That was all to do with the python side of things, which is where most of the development work had to go. On the other hand, the Mathematica side of the equation still requires some explanation. The package itself is really quite simple, so please feel free to  [peruse the source](https://github.com/b3m2a1/PJLink/blob/master/Mathematica/PJLink.wl) .&#xD;
&#xD;
### InstallPython&#xD;
&#xD;
```InstallPython``` is the most basic function in the package. It either finds or is given a python version or executable, attempts to open it via  ```StartProcess``` , then links to it via  ```LinkCreate``` and the  ```start_kernel.py``` script provided in the PJLink python package.&#xD;
&#xD;
Notably, all it really requires is a  ```LinkObject``` , so you can pass one directly via the  ```LinkObject``` option. It will also by default try to make a python  ```ProcessObject``` but you can pass that via the  ```ProcessObject``` option or you can pass  ```None``` in which case it won&amp;#039;t attach to a Mathematica controlled process.&#xD;
&#xD;
### ClosePython&#xD;
&#xD;
```ClosePython``` is the counterpart to  ```InstallPython``` . It closes an opened python runtime by version or executable. When a new kernel is installed it is added to  ```PJLink`Package`$PythonKernels``` and this is what  ```ClosePython``` looks for to close. &#xD;
&#xD;
### PyEvaluate / PyEvaluateString&#xD;
&#xD;
This is the heart of the package. It takes Mathematica-esque code, converts it into a structure that can be processed by  ```KernelLink.__callPython()``` and sends it over and waits for a response. The conversion is handled by  ```PJLink`SymbolicPython`ToSymbolicPython``` which was originally written for the  [PyTools package](https://github.com/b3m2a1/mathematica-PyTools) . This is the best way to move data to python as things like  ```Image``` objects, packable arrays, and  ```SparseArray``` objects will be moved over intelligently.&#xD;
&#xD;
```PyEvaluateString``` is like  ```PyEvaluate``` , but with the recognition that  ```ToSymbolicPython``` will always be a little bit lacking. It allows one to simply call a string of python code on the link and get the results back.&#xD;
&#xD;
### PyWrite / PyWriteString / PyRead / PyReadErr&#xD;
&#xD;
These are all functions that make use of the fact that when the  ```Reader``` object started it allowed an interactive session to keep running and reading / writing on stdin, stdout, and stderr. The  ```Read``` functions read from stdout and stderr and the write functions write to stdin. The former takes Mathematica code and auto-converts it into a string. The latter simply passes in the given string.&#xD;
&#xD;
&#xD;
&#xD;
## Future Work&#xD;
&#xD;
PJLink 1.0.0, beefy as it already is, should only really be seen as the beginning. My hope is that much more can be done to allow for more native data type transfer and for intelligent communication between the two systems.&#xD;
&#xD;
In my demo I tried to show some of the things that make the interoperation of the two so nice, but I obviously don&amp;#039;t have the breadth of knowledge to know all of the many applications this can be put to. Applications built off of PJLink are always welcome and I&amp;#039;m happy to provide any requisite information and extensions to PJLink to get them built.&#xD;
&#xD;
Alongside that, I think better integration on the Mathematica side is necessary. There is a partial interface for allowing a  ```PythonObject``` structure to hide the details of  ```PyEvaluate``` on the Mathematica side, but this needs work from both ends, first hooking up the  ```Language`MutatationHandler``` interface and then extending the same on the python side. After that, a  ```JavaBlock``` -like setup that allows a link to be opened, used, and cleaned up would be highly useful for sandboxing.&#xD;
&#xD;
Finally, I&amp;#039;m sure there are numerous bugs hiding in the package as it stands. Please find them and let me know about them so they can be worked out.&#xD;
&#xD;
In the meantime, I hope you enjoy PJLink and being able to use my two favorite languages symbiotically.</description>
    <dc:creator>b3m2a1 ​ </dc:creator>
    <dc:date>2018-09-20T09:18:51Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/866748">
    <title>Facing your data with Chernoff faces</title>
    <link>https://community.wolfram.com/groups/-/m/t/866748</link>
    <description>## Introduction&#xD;
&#xD;
This post describes the use of face-like diagrams to visualize multidimensional data introduced by Herman Chernoff in 1973, see [1].&#xD;
&#xD;
The idea to use human faces in order to understand, evaluate, or easily discern (the records of) multidimensional data is very creative and inspirational. As Chernoff says in [1], the object of the idea is to &amp;#034;represent multivariate data, subject to strong but possibly complex relationships, in such a way that an investigator can quickly comprehend relevant information and then apply appropriate statistical analysis.&amp;#034; It is an interesting question how useful this approach is and it seems that there at least several articles discussing that; see for example [2].&#xD;
&#xD;
I personally find the use of Chernoff faces useful in a small number of cases, but that is probably true for many &amp;#034;creative&amp;#034; data visualization methods.&#xD;
&#xD;
Below are given both simple and more advanced examples of constructing Chernoff faces for data records using the *Mathematica* package [3]. The considered data is categorized as:&#xD;
&#xD;
1. a small number of records, each with small number of elements;&#xD;
2. a large number of records, each with less elements than Chernoff face parts;&#xD;
3. a list of long records, each record with much more elements than Chernoff face parts;&#xD;
4. a list of nearest neighbors or recommendations.&#xD;
&#xD;
For several of the visualizing scenarios the records of two &amp;#034;real life&amp;#034; data sets are used: Fisher Iris flower dataset [7], and &amp;#034;Vinho Verde&amp;#034; wine quality dataset [8]. For the rest of the scenarios the data is generated.&#xD;
&#xD;
A fundamental restriction of using Chernoff faces is the necessity to properly transform the data variables into the ranges of the Chernoff face diagram parameters. Therefore, proper data transformation (standadizing and rescaling) is an inherent part of the application of Chernoff faces, and this document describes such data transformation procedures (also using [3]).&#xD;
&#xD;
### Package load&#xD;
&#xD;
The packages [3,4] are used to produce the diagrams in this post. The following two commands load them.&#xD;
&#xD;
    Import[&amp;#034;https://raw.githubusercontent.com/antononcube/\&#xD;
    MathematicaForPrediction/master/ChernoffFaces.m&amp;#034;]&#xD;
&#xD;
    Import[&amp;#034;https://raw.githubusercontent.com/antononcube/\&#xD;
    MathematicaForPrediction/master/MathematicaForPredictionUtilities.m&amp;#034;]&#xD;
&#xD;
### Mirror&#xD;
This Community post mirrors the blog post [&amp;#034;Making Chernoff faces for data visualization&amp;#034;](https://mathematicaforprediction.wordpress.com/2016/06/03/making-chernoff-faces-for-data-visualization/).&#xD;
&#xD;
## Making faces&#xD;
&#xD;
### Just a face&#xD;
&#xD;
Here is a face produced by the function `ChernoffFace` of [3] with its simplest signature:&#xD;
&#xD;
    SeedRandom[152092]&#xD;
    ChernoffFace[]&#xD;
&#xD;
[![JustAFace](http://i.imgur.com/PIcrIcKm.gif)](http://i.imgur.com/PIcrIcK.gif)&#xD;
&#xD;
Here is a list of faces:&#xD;
&#xD;
    SeedRandom[152092]&#xD;
    Table[ChernoffFace[ImageSize -&amp;gt; Tiny], {7}]&#xD;
&#xD;
[![ ](http://i.imgur.com/SPWgX0r.gif)](http://i.imgur.com/SPWgX0r.gif)&#xD;
&#xD;
### Proper face making&#xD;
&#xD;
The &amp;#034;proper&amp;#034; way to call ChernoffFace is to use an association for the facial parts placement, size, rotation, and color. The options are passed to Graphics.&#xD;
&#xD;
    SeedRandom[2331];&#xD;
    ChernoffFace[ AssociationThread[&#xD;
        Keys[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]] -&amp;gt; &#xD;
       RandomReal[1, Length[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]]]],&#xD;
       ImageSize -&amp;gt; Small , Background -&amp;gt; GrayLevel[0.85]]&#xD;
&#xD;
[![ ](http://i.imgur.com/wY3bgKCm.gif)](http://i.imgur.com/wY3bgKC.gif)&#xD;
&#xD;
The Chernoff face drawn with the function `ChernoffFace` can be parameterized to be asymmetric.&#xD;
&#xD;
The parameters argument mixes (1) face parts placement, sizes, and rotation, with (2) face parts colors and (3) a parameter should it be attempted to make the face symmetric. All facial parts parameters have the range [0,1]&#xD;
&#xD;
Here is the facial parameter list:&#xD;
&#xD;
    Keys[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]]&#xD;
&#xD;
    (* {&amp;#034;FaceLength&amp;#034;, &amp;#034;ForheadShape&amp;#034;, &amp;#034;EyesVerticalPosition&amp;#034;, &amp;#034;EyeSize&amp;#034;, \&#xD;
		&amp;#034;EyeSlant&amp;#034;, &amp;#034;LeftEyebrowSlant&amp;#034;, &amp;#034;LeftIris&amp;#034;, &amp;#034;NoseLength&amp;#034;, \&#xD;
		&amp;#034;MouthSmile&amp;#034;, &amp;#034;LeftEyebrowTrim&amp;#034;, &amp;#034;LeftEyebrowRaising&amp;#034;, &amp;#034;MouthTwist&amp;#034;, \&#xD;
		&amp;#034;MouthWidth&amp;#034;, &amp;#034;RightEyebrowTrim&amp;#034;, &amp;#034;RightEyebrowRaising&amp;#034;, \&#xD;
		&amp;#034;RightEyebrowSlant&amp;#034;, &amp;#034;RightIris&amp;#034;} *)&#xD;
&#xD;
The order of the parameters is chosen to favor making symmetric faces when a list of random numbers is given as an argument, and to make it easier to discern the faces when multiple records are visualized. For experiments and discussion about which facial features bring better discern-ability see [2]. One of the conclusions of [2] is that eye size and eye brow slant are most decisive, followed by face size and shape.&#xD;
&#xD;
Here are the rest of the parameters (colors and symmetricity):&#xD;
&#xD;
    Complement[Keys[ChernoffFace[&amp;#034;Properties&amp;#034;]], &#xD;
     Keys[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]]]&#xD;
&#xD;
    (* {&amp;#034;EyeBallColor&amp;#034;, &amp;#034;FaceColor&amp;#034;, &amp;#034;IrisColor&amp;#034;, &amp;#034;MakeSymmetric&amp;#034;, \&#xD;
		&amp;#034;MouthColor&amp;#034;, &amp;#034;NoseColor&amp;#034;} *)&#xD;
&#xD;
### Face coloring&#xD;
&#xD;
The following code make a row of faces by generating seven sequences of random numbers in $[0,1]$, each sequence with length the number of facial parameters. The face color is assigned randomly and the face color or a darker version of it is used as a nose color. If the nose color is the same as the face color the nose is going to be shown &amp;#034;in profile&amp;#034;, otherwise as a filled polygon. The colors of the irises are random blend between light brown and light blue. The color of the mouth is randomly selected to be black or red.&#xD;
&#xD;
    SeedRandom[201894];&#xD;
    Block[{pars = Keys[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]]},&#xD;
     Grid[{#}] &amp;amp;@&#xD;
      Table[ChernoffFace[Join[&#xD;
         AssociationThread[pars -&amp;gt; RandomReal[1, Length[pars]]],&#xD;
         &amp;lt;|&amp;#034;FaceColor&amp;#034; -&amp;gt; (rc = &#xD;
             ColorData[&amp;#034;BeachColors&amp;#034;][RandomReal[1]]),&#xD;
          &amp;#034;NoseColor&amp;#034; -&amp;gt; RandomChoice[{Identity, Darker}][rc],&#xD;
          &amp;#034;IrisColor&amp;#034; -&amp;gt; Lighter[Blend[{Brown, Blue}, RandomReal[1]]],&#xD;
          &amp;#034;MouthColor&amp;#034; -&amp;gt; RandomChoice[{Black, Red}]|&amp;gt;], &#xD;
        ImageSize -&amp;gt; 100], {7}]&#xD;
     ]&#xD;
&#xD;
[![ ](http://i.imgur.com/QN5Rhvfl.png)](http://i.imgur.com/QN5Rhvf.png)&#xD;
&#xD;
### Symmetric faces&#xD;
&#xD;
The parameter &amp;#034;MakeSymmetric&amp;#034; is by default `True`. Setting &amp;#034;MakeSymmetric&amp;#034; to true turns an incomplete face specification into a complete specification with the missing paired parameters filled in. In other words, the symmetricity is not enforced on the specified paired parameters, only on the ones for which specifications are missing.&#xD;
&#xD;
The following faces are made symmetric by removing the facial parts parameters that start with &amp;#034;R&amp;#034; (for &amp;#034;Right&amp;#034;) and the parameter &amp;#034;MouthTwist&amp;#034;. &#xD;
&#xD;
    SeedRandom[201894];&#xD;
    Block[{pars = Keys[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]]},&#xD;
     Grid[{#}] &amp;amp;@Table[(&#xD;
        asc = &#xD;
         Join[AssociationThread[&#xD;
           pars -&amp;gt; RandomReal[1, Length[pars]]],&#xD;
          &amp;lt;|&amp;#034;FaceColor&amp;#034; -&amp;gt; (rc = &#xD;
              ColorData[&amp;#034;BeachColors&amp;#034;][RandomReal[1]]),&#xD;
           &amp;#034;NoseColor&amp;#034; -&amp;gt; RandomChoice[{Identity, Darker}][rc],&#xD;
           &amp;#034;IrisColor&amp;#034; -&amp;gt; &#xD;
            Lighter[Blend[{Brown, Blue}, RandomReal[1]]],&#xD;
           &amp;#034;MouthColor&amp;#034; -&amp;gt; RandomChoice[{Black, Red}]|&amp;gt;];&#xD;
        asc = &#xD;
         Pick[asc, &#xD;
          StringMatchQ[Keys[asc], &#xD;
           x : (StartOfString ~~ Except[&amp;#034;R&amp;#034;] ~~ __) /; &#xD;
            x != &amp;#034;MouthTwist&amp;#034;]];&#xD;
        ChernoffFace[asc, ImageSize -&amp;gt; 100]), {7}]]&#xD;
&#xD;
[![ ](http://i.imgur.com/7J7vl12l.png)](http://i.imgur.com/7J7vl12.png)&#xD;
&#xD;
Note that for the irises we have two possibilities of synchronization:&#xD;
&#xD;
    pars = &amp;lt;|&amp;#034;LeftIris&amp;#034; -&amp;gt; 0.8, &amp;#034;IrisColor&amp;#034; -&amp;gt; Green|&amp;gt;;&#xD;
    {ChernoffFace[Join[pars, &amp;lt;|&amp;#034;RightIris&amp;#034; -&amp;gt; pars[&amp;#034;LeftIris&amp;#034;]|&amp;gt;], &#xD;
      ImageSize -&amp;gt; 100], &#xD;
     ChernoffFace[&#xD;
      Join[pars, &amp;lt;|&amp;#034;RightIris&amp;#034; -&amp;gt; 1 - pars[&amp;#034;LeftIris&amp;#034;]|&amp;gt;], &#xD;
      ImageSize -&amp;gt; 100]}&#xD;
&#xD;
[![ ](http://i.imgur.com/8i16NUgl.gif)](http://i.imgur.com/8i16NUg.gif)&#xD;
&#xD;
## Visualizing records (first round)&#xD;
&#xD;
The conceptually straightforward application of Chernoff faces is to visualize (&amp;#034;give a face&amp;#034; to) each record in a dataset. Because the parameters of the faces have the same ranges for the different records, proper rescaling of the records have to be done first. Of course standardizing the data can be done before rescaling.&#xD;
&#xD;
First let us generate some random data using different distributions:&#xD;
&#xD;
    SeedRandom[3424]&#xD;
    {dists, data} = Transpose@Table[(&#xD;
         rdist = &#xD;
          RandomChoice[{NormalDistribution[RandomReal[10], &#xD;
             RandomReal[10]], PoissonDistribution[RandomReal[4]], &#xD;
            GammaDistribution[RandomReal[{2, 6}], 2]}];&#xD;
         {rdist, RandomVariate[rdist, 12]}), {10}];&#xD;
    data = Transpose[data];&#xD;
&#xD;
The data is generated in such a way that each column comes from a certain probability distribution. Hence, each record can be seen as an observation of the variables corresponding to the columns.&#xD;
&#xD;
This is how the **columns** of the generated data look like using `DistributionChart`:&#xD;
&#xD;
    DistributionChart[Transpose[data], &#xD;
     ChartLabels -&amp;gt; &#xD;
      Placed[MapIndexed[&#xD;
        Grid[List /@ {Style[#2[[1]], Bold, Red, Larger]}] &amp;amp;, dists], Above], &#xD;
     ChartElementFunction -&amp;gt; &amp;#034;PointDensity&amp;#034;, &#xD;
     ChartStyle -&amp;gt; &amp;#034;SandyTerrain&amp;#034;, ChartLegends -&amp;gt; dists, &#xD;
     BarOrigin -&amp;gt; Bottom, GridLines -&amp;gt; Automatic, &#xD;
     ImageSize -&amp;gt; 900]&#xD;
&#xD;
[![ ](http://i.imgur.com/iXQfzZGl.gif)](http://i.imgur.com/iXQfzZG.gif)&#xD;
&#xD;
At this point we can make a face for each **record** of the rescaled data:&#xD;
&#xD;
    faces = Map[ChernoffFace, Transpose[Rescale /@ Transpose[data]]];&#xD;
&#xD;
and visualize the obtained faces in a grid.&#xD;
&#xD;
    Row[{Grid[&#xD;
       Partition[#, 4] &amp;amp;@Map[Append[#, ImageSize -&amp;gt; 100] &amp;amp;, faces]],&#xD;
      &amp;#034;   &amp;#034;, Magnify[#, 0.85] &amp;amp;@&#xD;
       GridTableForm[&#xD;
        List /@ Take[Keys[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]], &#xD;
          Dimensions[data][[2]]], &#xD;
        TableHeadings -&amp;gt; {&amp;#034;Face part&amp;#034;}]&#xD;
      }]&#xD;
&#xD;
[![ ](http://i.imgur.com/LMTsbCfl.gif)](http://i.imgur.com/LMTsbCf.gif)&#xD;
&#xD;
(The table on the right shows which facial parts are used for which data columns.)&#xD;
&#xD;
## Some questions to consider&#xD;
&#xD;
Several questions and observations arise from the example in the previous section. &#xD;
&#xD;
#### 1. What should we do if the data records have more elements than facial parts parameters of the Chernoff face diagram?&#xD;
&#xD;
This is another fundamental restriction of Chernoff faces -- the number of data columns is limiter by the number of facial features.&#xD;
&#xD;
One way to resolve this is to select important variables (columns) of the data; another is to represent the records with a vector of statistics. The latter is shown in the section &amp;#034;Chernoff faces for lists of long lists&amp;#034;.&#xD;
&#xD;
#### 2. Are there Chernoff face parts that are easier to perceive or judge than others and provide better discern-ability for large collections of records?&#xD;
&#xD;
Research of the [pre-attentiveness](https://en.wikipedia.org/wiki/Pre-attentive_processing) and effectiveness with Chernoff faces, [2], shows that eye size and eyebrow slant are the features that provide best discern-ability. Below this is used to select some of the variable-to-face-part correspondences. &#xD;
&#xD;
#### 3. How should we deal with outliers?&#xD;
&#xD;
Since we cannot just remove the outliers from a record -- we have to have complete records -- we can simply replace the outliers with the minimum or maximum values allowed for the corresponding Chernoff face feature. (All facial features of `ChernoffFace` have the range $[0,1]$.) See the next section for an example.&#xD;
&#xD;
## Data standardizing and rescaling&#xD;
&#xD;
Given a full array of records, we most likely have to standardize and rescale the columns in order to use the function `ChernoffFace`. To help with that the package [3] provides the function `VariablesRescale` which has the options &amp;#034;StandardizingFunction&amp;#034; and &amp;#034;RescaleRangeFunction&amp;#034;.&#xD;
&#xD;
Consider the following example of `VariableRescale` invocation in which:&#xD;
1. each column is centered around its median and then divided by the inter-quartile half-distance (quartile deviation),&#xD;
2. followed by clipping of the outliers that are outside of the disk with radius 3 times the quartile deviation, and&#xD;
3. rescaling to the unit interval.&#xD;
&#xD;
    rdata = VariablesRescale[N@data,&#xD;
       &amp;#034;StandardizingFunction&amp;#034; -&amp;gt; (Standardize[#, Median, QuartileDeviation] &amp;amp;),&#xD;
       &amp;#034;RescaleRangeFunction&amp;#034; -&amp;gt; ({-3, 3} QuartileDeviation[#] &amp;amp;)];&#xD;
    TableForm[rdata /. {0 -&amp;gt; Style[0, Bold, Red], 1 -&amp;gt; Style[1, Bold, Red]}]&#xD;
&#xD;
[![ ](http://i.imgur.com/LdhvQJMl.png)](http://i.imgur.com/LdhvQJM.png)&#xD;
&#xD;
**Remark:** The bottom outliers are replaced with 0 and the top outliers with 1 using `Clip`.&#xD;
&#xD;
## Chernoff faces for a small number of short records&#xD;
&#xD;
In this section we are going use the Fisher Iris flower data set [7]. By &amp;#034;small number of records&amp;#034; we mean few hundred or less.&#xD;
&#xD;
### Getting the data&#xD;
&#xD;
These commands get the Fisher Iris flower data set shipped with *Mathematica*:&#xD;
&#xD;
    irisDataSet = &#xD;
      Map[Flatten, &#xD;
       List @@@ ExampleData[{&amp;#034;MachineLearning&amp;#034;, &amp;#034;FisherIris&amp;#034;}, &amp;#034;Data&amp;#034;]];&#xD;
    irisColumnNames = &#xD;
      Most@Flatten[&#xD;
        List @@ ExampleData[{&amp;#034;MachineLearning&amp;#034;, &amp;#034;FisherIris&amp;#034;}, &#xD;
          &amp;#034;VariableDescriptions&amp;#034;]];&#xD;
    Dimensions[irisDataSet]&#xD;
&#xD;
    (* {150, 5} *)&#xD;
&#xD;
Here is a summary of the data:&#xD;
&#xD;
    Grid[{RecordsSummary[irisDataSet, irisColumnNames]}, &#xD;
     Dividers -&amp;gt; All, Alignment -&amp;gt; Top]&#xD;
&#xD;
[![ ](http://i.imgur.com/upxeRHvl.png)](http://i.imgur.com/upxeRHv.png)&#xD;
&#xD;
### Simple variable dependency analysis&#xD;
&#xD;
Using the function `VariableDependenceGrid` of the package [4] we can plot a grid of variable cross-dependencies. We can see from the last row and column that &amp;#034;Petal length&amp;#034; and &amp;#034;Petal width&amp;#034; separate setosa from versicolor and virginica with a pretty large gap.&#xD;
&#xD;
    Magnify[#, 1] &amp;amp;@&#xD;
     VariableDependenceGrid[irisDataSet, irisColumnNames, &#xD;
      &amp;#034;IgnoreCategoricalVariables&amp;#034; -&amp;gt; False]&#xD;
&#xD;
[![ ](http://i.imgur.com/vJA6kthl.png)](http://i.imgur.com/vJA6kth.png)&#xD;
&#xD;
### Chernoff faces for Iris flower records&#xD;
&#xD;
Since we want to evaluate the usefulness of Chernoff faces for discerning data records groups or clusters, we are going to do the following steps.&#xD;
&#xD;
1. Data transformation. This includes standardizing and rescaling and selection of colors.&#xD;
2. Make a Chernoff face for each record **without** the label class &amp;#034;Species of iris&amp;#034;.&#xD;
3. Plot shuffled Chernoff faces and attempt to visually cluster them or find patterns.&#xD;
4. Make a Chernoff face for each record using the label class &amp;#034;Specie of iris&amp;#034; to color the faces. (Records of the same class get faces of the same color.)&#xD;
5. Compare the plots and conclusions of step 2 and 4.&#xD;
&#xD;
#### 1. Data transformation&#xD;
&#xD;
First we standardize and rescale the data:&#xD;
&#xD;
    chernoffData = VariablesRescale[irisDataSet[[All, 1 ;; 4]]];&#xD;
&#xD;
These are the colors used for the different species of iris:&#xD;
&#xD;
    faceColorRules = &#xD;
     Thread[Union[ irisDataSet[[All, -1]]] \&#xD;
     -&amp;gt; Map[Lighter[#, 0.5] &amp;amp;, {Purple, Blue, Green}]]&#xD;
&#xD;
    (* {&amp;#034;setosa&amp;#034; -&amp;gt; RGBColor[0.75, 0.5, 0.75], &#xD;
        &amp;#034;versicolor&amp;#034; -&amp;gt; RGBColor[0.5, 0.5, 1.], &#xD;
        &amp;#034;virginica&amp;#034; -&amp;gt; RGBColor[0.5, 1., 0.5]} *)&#xD;
&#xD;
Add the colors to the data for the faces:&#xD;
&#xD;
    chernoffData = MapThread[&#xD;
       Append, {chernoffData, irisDataSet[[All, -1]] /. faceColorRules}];&#xD;
&#xD;
Plot the distributions of the rescaled variables:&#xD;
&#xD;
    DistributionChart[&#xD;
     Transpose@chernoffData[[All, 1 ;; 4]], &#xD;
     GridLines -&amp;gt; Automatic, &#xD;
     ChartElementFunction -&amp;gt; &amp;#034;PointDensity&amp;#034;, &#xD;
     ChartStyle -&amp;gt; &amp;#034;SandyTerrain&amp;#034;, &#xD;
     ChartLegends -&amp;gt; irisColumnNames, ImageSize -&amp;gt; Large]&#xD;
&#xD;
[![ ](http://i.imgur.com/rwm71tnm.gif)](http://i.imgur.com/rwm71tn.gif)&#xD;
&#xD;
#### 2. Black-and-white Chernoff faces&#xD;
&#xD;
Make a black-and-white Chernoff face for each record without using the species class:&#xD;
&#xD;
    chfacesBW = &#xD;
      ChernoffFace[&#xD;
         AssociationThread[{&amp;#034;NoseLength&amp;#034;, &amp;#034;LeftEyebrowTrim&amp;#034;, &amp;#034;EyeSize&amp;#034;, &#xD;
            &amp;#034;LeftEyebrowSlant&amp;#034;} -&amp;gt; Most[#]], &#xD;
         ImageSize -&amp;gt; 100] &amp;amp; /@ chernoffData;&#xD;
&#xD;
Since &amp;#034;Petal length&amp;#034; and &amp;#034;Petal width&amp;#034; separate the classes well for those columns we have selected the parameters &amp;#034;EyeSize&amp;#034; and &amp;#034;LeftEyebrowSlant&amp;#034; based on [2].&#xD;
&#xD;
#### 3. Finding patterns in a collection of faces&#xD;
&#xD;
Combine the faces into a image collage:&#xD;
&#xD;
    ImageCollage[RandomSample[chfacesBW], Background -&amp;gt; White]&#xD;
&#xD;
[![ ](http://i.imgur.com/zmBSQZRl.gif)](http://i.imgur.com/zmBSQZR.gif)&#xD;
&#xD;
We can see that faces with small eyes tend have middle-lowered eyebrows, and that faces with large eyes tend to have middle raised eyebrows and large noses.&#xD;
&#xD;
#### 4. Chernoff faces colored by the species&#xD;
&#xD;
Make a Chernoff face for each record using the colors added to the rescaled data:&#xD;
&#xD;
    chfaces = &#xD;
      ChernoffFace[&#xD;
         AssociationThread[{&amp;#034;NoseLength&amp;#034;, &amp;#034;LeftEyebrowTrim&amp;#034;, &amp;#034;EyeSize&amp;#034;, &#xD;
            &amp;#034;LeftEyebrowSlant&amp;#034;, &amp;#034;FaceColor&amp;#034;} -&amp;gt; #], &#xD;
         ImageSize -&amp;gt; 100] &amp;amp; /@ chernoffData;&#xD;
&#xD;
Make an image collage with the obtained faces:&#xD;
&#xD;
    ImageCollage[chfaces, Background -&amp;gt; White]&#xD;
&#xD;
[![ ](http://i.imgur.com/uPBZJufl.gif)](http://i.imgur.com/uPBZJuf.gif)&#xD;
&#xD;
#### 5. Comparison&#xD;
&#xD;
We can see that the collage with colored faces completely explains the patterns found in the black-and-white faces: setosa have smaller petals (both length and width), and virginica have larger petals.&#xD;
&#xD;
## Browsing a large number of records with Chernoff faces&#xD;
&#xD;
If we have a large number of records each comprised of a relative small number of numerical values we can use Chernoff faces to browse the data by taking small subsets of records.&#xD;
&#xD;
Here is an example using &amp;#034;Vinho Verde&amp;#034; wine quality dataset [8].&#xD;
&#xD;
[![ ](http://i.imgur.com/jDwXgfTl.png)](http://i.imgur.com/jDwXgfT.png)&#xD;
&#xD;
[![ ](http://i.imgur.com/ZOqwuFTl.png)](http://i.imgur.com/ZOqwuFT.png)&#xD;
&#xD;
## Chernoff faces for lists of long lists&#xD;
&#xD;
In this section we consider data that is a list of lists. Each of the lists (or rows) is fairly long and represents values of the same variable or process. If the data is a full array, then we can say that in this section we deal with transposed versions of the data in the previous sections.&#xD;
&#xD;
Since each row is a list of many elements visualizing the rows directly with Chernoff faces would mean using a small fraction of the data. A natural approach in those situations is to summarize each row with a set of descriptive statistics and use Chernoff faces for the row summaries. &#xD;
&#xD;
The process is fairly straightforward; the rest of the section gives concrete code steps of executing it.&#xD;
&#xD;
### Data generation&#xD;
&#xD;
Here we create 12 rows of 200 elements by selecting a probability distribution for each row.&#xD;
&#xD;
    SeedRandom[1425]&#xD;
    {dists, data} = Transpose@Table[(&#xD;
         rdist = &#xD;
          RandomChoice[{NormalDistribution[RandomReal[10], &#xD;
             RandomReal[10]], PoissonDistribution[RandomReal[4]], &#xD;
            GammaDistribution[RandomReal[{2, 6}], 2]}];&#xD;
         {rdist, RandomVariate[rdist, 200]}), {12}];&#xD;
    Dimensions[data]&#xD;
&#xD;
    (* {12, 200} *)&#xD;
&#xD;
We have the following 12 &amp;#034;records&amp;#034; each with 200 &amp;#034;fields&amp;#034;:&#xD;
&#xD;
    DistributionChart[data, &#xD;
     ChartLabels -&amp;gt; &#xD;
      MapIndexed[&#xD;
       Row[{Style[#2[[1]], Red, Larger],&#xD;
	        &amp;#034;  &amp;#034;, Style[#1, Larger]}] &amp;amp;, dists], &#xD;
     ChartElementFunction -&amp;gt; &#xD;
      ChartElementData[&amp;#034;PointDensity&amp;#034;, &#xD;
       &amp;#034;ColorScheme&amp;#034; -&amp;gt; &amp;#034;SouthwestColors&amp;#034;], BarOrigin -&amp;gt; Left, &#xD;
     GridLines -&amp;gt; Automatic, ImageSize -&amp;gt; 1000]&#xD;
&#xD;
[![ ](http://i.imgur.com/HJWZo6Tl.gif)](http://i.imgur.com/HJWZo6T.gif)&#xD;
&#xD;
Here is the summary of the records:&#xD;
&#xD;
    Grid[ArrayReshape[RecordsSummary[Transpose@N@data], {3, 4}], &#xD;
     Dividers -&amp;gt; All, Alignment -&amp;gt; {Left}]&#xD;
&#xD;
[![ ](http://i.imgur.com/HmIUX0dl.png)](http://i.imgur.com/HmIUX0d.png)&#xD;
&#xD;
### Data transformation&#xD;
&#xD;
Here we &amp;#034;transform&amp;#034; each row into a vector of descriptive statistics:&#xD;
&#xD;
    statFuncs = {Mean, StandardDeviation, Kurtosis, Median, &#xD;
       QuartileDeviation, PearsonChiSquareTest};&#xD;
    sdata = Map[Through[statFuncs[#]] &amp;amp;, data];&#xD;
    Dimensions[sdata]&#xD;
&#xD;
    (* {12, 6} *)&#xD;
&#xD;
&#xD;
Next we rescale the descriptive statistics data:&#xD;
&#xD;
    sdata = VariablesRescale[sdata, &#xD;
       &amp;#034;StandardizingFunction&amp;#034; -&amp;gt; (Standardize[#, Median, QuartileDeviation] &amp;amp;)];&#xD;
&#xD;
For kurtosis we have to do special rescaling if we want to utilize the property that Gaussian processes have kurtosis 3:&#xD;
&#xD;
    sdata[[All, 3]] = &#xD;
      Rescale[#, {3, Max[#]}, {0.5, 1}] &amp;amp;@Map[Kurtosis, N[data]];&#xD;
&#xD;
Here is the summary of the columns of the rescaled descriptive statistics array:&#xD;
&#xD;
    Grid[{RecordsSummary[sdata, ToString /@ statFuncs]}, Dividers -&amp;gt; All]&#xD;
&#xD;
[![ ](http://i.imgur.com/SHbLThql.png)](http://i.imgur.com/SHbLThq.png)&#xD;
&#xD;
### Visualization&#xD;
&#xD;
First we define a function that computes and tabulates (descriptive) statistics over a record.&#xD;
&#xD;
    Clear[TipTable]&#xD;
    TipTable[vec_, statFuncs_, faceParts_] :=&#xD;
      Block[{},&#xD;
        GridTableForm[&#xD;
         Transpose@{faceParts, statFuncs, &#xD;
           NumberForm[Chop[#], 2] &amp;amp; /@ Through[statFuncs[vec]]}, &#xD;
         TableHeadings -&amp;gt; {&amp;#034;FacePart&amp;#034;, &amp;#034;Statistic&amp;#034;, &amp;#034;Value&amp;#034;}]] /; &#xD;
       Length[statFuncs] == Length[faceParts];&#xD;
&#xD;
To visualize the descriptive statistics of the records using Chernoff faces we have to select appropriate facial features.&#xD;
&#xD;
    faceParts = {&amp;#034;NoseLength&amp;#034;, &amp;#034;EyeSize&amp;#034;, &amp;#034;EyeSlant&amp;#034;, &#xD;
       &amp;#034;EyesVerticalPosition&amp;#034;, &amp;#034;FaceLength&amp;#034;, &amp;#034;MouthSmile&amp;#034;};&#xD;
    TipTable[First@sdata, statFuncs, faceParts]&#xD;
&#xD;
[![ ](http://i.imgur.com/bEOFgXHl.png)](http://i.imgur.com/bEOFgXH.png)&#xD;
&#xD;
One possible visualization of all records is with the following commands. Note the addition of the parameter &amp;#034;FaceColor&amp;#034; to also represent how close a standardized row is to a sample from Normal Distribution.&#xD;
&#xD;
    {odFaceColor, ndFaceColor} = {White,  ColorData[7, &amp;#034;ColorList&amp;#034;][[8]]};&#xD;
    Grid[ArrayReshape[Flatten@#, {4, 3}, &amp;#034;&amp;#034;], Dividers -&amp;gt; All, &#xD;
       Alignment -&amp;gt; {Left, Top}] &amp;amp;@&#xD;
     MapThread[&#xD;
      (asc = AssociationThread[faceParts -&amp;gt; #2];&#xD;
        chFace = &#xD;
         ChernoffFace[&#xD;
          Join[asc, &amp;lt;|&#xD;
            &amp;#034;FaceColor&amp;#034; -&amp;gt; Blend[{odFaceColor, ndFaceColor}, #2[[-1]]], &#xD;
            &amp;#034;IrisColor&amp;#034; -&amp;gt; GrayLevel[0.8], &#xD;
            &amp;#034;NoseColor&amp;#034; -&amp;gt; ndFaceColor|&amp;gt;], ImageSize -&amp;gt; 120, &#xD;
          AspectRatio -&amp;gt; Automatic];&#xD;
        tt = TipTable[N@#3, Join[statFuncs, {Last@statFuncs}], &#xD;
          Join[faceParts, {&amp;#034;FaceColor&amp;#034;}]];&#xD;
        Column[{Style[#1, Red], &#xD;
          Grid[{{Magnify[#4, 0.8], &#xD;
             Tooltip[chFace, tt]}, {Magnify[tt, 0.7], SpanFromAbove}}, &#xD;
           Alignment -&amp;gt; {Left, Top}]}]) &amp;amp;&#xD;
      , {Range[Length[sdata]], sdata, data, dists}]&#xD;
&#xD;
[![ ](http://i.imgur.com/CGVbZck.png)](http://i.imgur.com/CGVbZck.png)&#xD;
&#xD;
## Visualizing similarity with nearest neighbors or recommendations &#xD;
&#xD;
### General idea&#xD;
&#xD;
Assume the following scenario: &#xD;
1. we have a set of items (movies, flowers, etc.), &#xD;
2. we have picked one item,&#xD;
3. we have computed the Nearest Neighbors (NNs) of that item, and&#xD;
4. we want to visualize how much of a good fit the NNs are to the picked item.&#xD;
&#xD;
Conceptually we can translate the phrase &amp;#034;how good the found NNs (or&#xD;
recommendations) are&amp;#034; to:&#xD;
&#xD;
* &amp;#034;how similar the NNs are to the selected item&amp;#034;, or&#xD;
&#xD;
* &amp;#034;how different the NNs are to the selected item.&amp;#034;&#xD;
&#xD;
If we consider the picked item as the prototype of the most normal or central item then we can use Chernoff faces to visualize item&amp;#039;s NNs deviations. &#xD;
&#xD;
**Remark:** Note that Chernoff faces provide similarity visualization most linked to Euclidean distance that to other distances.&#xD;
&#xD;
### Concrete example&#xD;
&#xD;
The code in this section demonstrates how to visualize nearest neighbors by Chernoff faces variations.&#xD;
&#xD;
First we create a nearest neighbors finding function over the Fisher Iris data set (without the species class label):&#xD;
&#xD;
    irisNNFunc = &#xD;
     Nearest[irisDataSet[[All, 1 ;; -2]] -&amp;gt; Automatic, &#xD;
      DistanceFunction -&amp;gt; EuclideanDistance]&#xD;
&#xD;
Here are nearest neighbors of some random row from the data.&#xD;
&#xD;
    itemInd = 67;&#xD;
    nnInds = irisNNFunc[irisDataSet[[itemInd, 1 ;; -2]], 20];&#xD;
&#xD;
We can visualize the distances with of the obtained NNs with the prototype:&#xD;
&#xD;
    ListPlot[Map[&#xD;
      EuclideanDistance[#, irisDataSet[[itemInd, 1 ;; -2]]] &amp;amp;, &#xD;
      irisDataSet[[nnInds, 1 ;; -2]]]]&#xD;
&#xD;
[![ ](http://i.imgur.com/dnUlWSDm.gif)](http://i.imgur.com/dnUlWSD.gif)&#xD;
&#xD;
Next we subtract the prototype row from the NNs data rows, we&#xD;
standardize, and we rescale the interval $[ 0, 3 \sigma ]$ to $[ 0.5, 1 ]$:&#xD;
&#xD;
    snns = Transpose@Map[&#xD;
        Clip[Rescale[&#xD;
           Standardize[#, 0 &amp;amp;, StandardDeviation], {0, 3}, {0.5, 1}], {0, &#xD;
           1}] &amp;amp;,&#xD;
        Transpose@&#xD;
         Map[# - irisDataSet[[itemInd, 1 ;; -2]] &amp;amp;, &#xD;
          irisDataSet[[nnInds, 1 ;; -2]]]];&#xD;
&#xD;
Here is how the original NNs data row look like:&#xD;
&#xD;
    GridTableForm[&#xD;
     Take[irisDataSet[[nnInds]], 12], TableHeadings -&amp;gt; irisColumnNames]&#xD;
&#xD;
[![ ](http://i.imgur.com/7r6habkl.png)](http://i.imgur.com/7r6habk.png)&#xD;
&#xD;
And here is how the rescaled NNs data rows look like:&#xD;
&#xD;
    GridTableForm[Take[snns, 12], &#xD;
     TableHeadings -&amp;gt; Most[irisColumnNames]]&#xD;
&#xD;
[![ ](http://i.imgur.com/P7xnwR5l.png)](http://i.imgur.com/P7xnwR5.png)&#xD;
&#xD;
Next we make Chernoff faces for the rescaled rows and present them in a easier to grasp way. &#xD;
&#xD;
We use the face parts:&#xD;
&#xD;
    Take[Keys[ChernoffFace[&amp;#034;FacePartsProperties&amp;#034;]], 4]&#xD;
&#xD;
    (* {&amp;#034;FaceLength&amp;#034;, &amp;#034;ForheadShape&amp;#034;, &amp;#034;EyesVerticalPosition&amp;#034;, &amp;#034;EyeSize&amp;#034;} *)&#xD;
&#xD;
To make the face comparison easier, the first face is the one of the prototype, each Chernoff face is drawn within the same rectangular frame, and the NNs indices are added on top of the faces.&#xD;
&#xD;
    chfaces = &#xD;
      ChernoffFace[#, Frame -&amp;gt; True, &#xD;
         PlotRange -&amp;gt; {{-1, 1}, {-2, 1.5}}, FrameTicks -&amp;gt; False, &#xD;
         ImageSize -&amp;gt; 100] &amp;amp; /@ snns;&#xD;
    chfaces = &#xD;
      MapThread[&#xD;
       ReplacePart[#1, &#xD;
         1 -&amp;gt; &#xD;
          Append[#1[[1]], &#xD;
           Text[Style[#2, Bold, Red], {0, 1.4}]]] &amp;amp;, {chfaces, nnInds}];&#xD;
    ImageCollage[chfaces, Background -&amp;gt; GrayLevel[0.95]]&#xD;
&#xD;
[![ ](http://i.imgur.com/EKpJ7mjm.gif)](http://i.imgur.com/EKpJ7mj.gif)&#xD;
&#xD;
We can see that the first few - i.e. closest -- NNs have fairly normal looking faces.&#xD;
&#xD;
Note that using a large number of NNs would change the rescaled values and in that way the first NNs would appear more similar.&#xD;
&#xD;
## References&#xD;
&#xD;
\[1\] Herman Chernoff (1973). &amp;#034;The Use of Faces to Represent Points in K-Dimensional Space Graphically&amp;#034; (PDF). Journal of the American Statistical Association (American Statistical Association) 68 (342): 361-368. doi:10.2307/2284077. JSTOR 2284077. URL: [http://lya.fciencias.unam.mx/rfuentes/faces-chernoff.pdf](http://lya.fciencias.unam.mx/rfuentes/faces-chernoff.pdf) .&#xD;
&#xD;
\[2\] Christopher J. Morris; David S. Ebert; Penny L. Rheingans, &amp;#034;Experimental analysis of the effectiveness of features in Chernoff faces&amp;#034;, Proc. SPIE 3905, 28th AIPR Workshop: 3D Visualization for Data Exploration and Decision Making, (5 May 2000); doi: 10.1117/12.384865. URL: [http://www.research.ibm.com/people/c/cjmorris/publications/Chernoff_990402.pdf](http://www.research.ibm.com/people/c/cjmorris/publications/Chernoff_990402.pdf) .&#xD;
&#xD;
\[3\] Anton Antonov, [Chernoff Faces implementation in Mathematica](https://github.com/antononcube/MathematicaForPrediction/blob/master/ChernoffFaces.m), (2016), source code at [MathematicaForPrediction at GitHub](https://github.com/antononcube/MathematicaForPrediction), package [ChernofFacess.m](https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/ChernoffFaces.m) .&#xD;
&#xD;
\[4\] Anton Antonov, [MathematicaForPrediction utilities](https://github.com/antononcube/MathematicaForPrediction/blob/master/MathematicaForPredictionUtilities.m), (2014), source code [MathematicaForPrediction at GitHub](https://github.com/antononcube/MathematicaForPrediction), package [MathematicaForPredictionUtilities.m](https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/MathematicaForPredictionUtilities.m).&#xD;
&#xD;
\[5\] Anton Antonov, [Variable importance determination by classifiers implementation in Mathematica](https://github.com/antononcube/MathematicaForPrediction/blob/master/VariableImportanceByClassifiers.m)[, ](https://github.com/antononcube/MathematicaForPrediction/blob/master/IndependentComponentAnalysis.m)(2015), source code at [MathematicaForPrediction at GitHub](https://github.com/antononcube/MathematicaForPrediction), package [VariableImportanceByClassifiers.m](https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/VariableImportanceByClassifiers.m).&#xD;
&#xD;
\[6\] Anton Antonov, [&amp;#034;Importance of variables investigation guide&amp;#034;](https://github.com/antononcube/MathematicaForPrediction/blob/master/Documentation/Importance-of-variables-investigation-guide.pdf), (2016),  [MathematicaForPrediction at GitHub](https://github.com/antononcube/MathematicaForPrediction), [https://github.com/antononcube/MathematicaForPrediction](https://github.com/antononcube/MathematicaForPrediction), folder [Documentation](https://github.com/antononcube/MathematicaForPrediction/tree/master/Documentation).&#xD;
&#xD;
\[7\] Wikipedia entry, Iris flower data set, [https://en.wikipedia.org/wiki/Iris_flower_data _set](https://en.wikipedia.org/wiki/Iris_flower_data_set) .&#xD;
&#xD;
\[8\] P. Cortez, A. Cerdeira, F. Almeida, T. Matos and J. Reis. Modeling wine preferences by data mining from physicochemical properties. In Decision Support Systems, Elsevier, 47(4):547-553, 2009. URL [https://archive.ics.uci.edu/ml/datasets/Wine+Quality](https://archive.ics.uci.edu/ml/datasets/Wine+Quality) .</description>
    <dc:creator>Anton Antonov</dc:creator>
    <dc:date>2016-06-03T02:17:45Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/824280">
    <title>Deep Learning Library for Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/824280</link>
    <description>Dear all,&#xD;
&#xD;
I have been working on an open source deep learning library in Mathematica which I would like to share.&#xD;
&#xD;
The code is hosted on github under an MIT license: [https://github.com/jfrancis71/Machine-Vision][1]&#xD;
&#xD;
I have succesfully used it to train a face recognition system, and also automatically drive my lego EV3 robot.&#xD;
&#xD;
Face Recognition: [https://www.youtube.com/watch?v=TdRtUnSppB0][2]&#xD;
&#xD;
EV3 Car: [https://www.youtube.com/watch?v=DCad82UdDFA][3]&#xD;
&#xD;
&#xD;
  [1]: https://github.com/jfrancis71/Machine-Vision&#xD;
  [2]: https://www.youtube.com/watch?v=TdRtUnSppB0&#xD;
  [3]: https://www.youtube.com/watch?v=DCad82UdDFA&#xD;
&#xD;
This has arisen from a homegrown project, so the code is probably a little scruffy (and not well documented) at the moment. Having said that it does work and I would welcome constructive feedback and help turning this into an active open source project.&#xD;
&#xD;
It&amp;#039;s not really aimed at someone who just wants a good face recogniser, the new built in Mathematica functions are probably more suitable for that. it&amp;#039;s more suitable for someone interested in the internals or developing their own neural nets.&#xD;
&#xD;
The distinction with the current Mathematica machine learning functionality, is this library is designed to support multiple layer networks including convolutional layers (much used in computer vision presently).&#xD;
&#xD;
There is more information available on the github site in the link above.&#xD;
&#xD;
Thanks,&#xD;
Julian Francis.</description>
    <dc:creator>Julian Francis</dc:creator>
    <dc:date>2016-03-16T16:19:18Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2445356">
    <title>A Wolfram Language facsimile of Wordle</title>
    <link>https://community.wolfram.com/groups/-/m/t/2445356</link>
    <description>![enter image description here][1]&#xD;
&#xD;
The popular game Wordle can take up a lot of your time.  The author designed it so that it you can only play it once a day, thus saving us from ourselves :-).&#xD;
&#xD;
[Wordle][2]&#xD;
&#xD;
[NYTimes article on Wordle][3]&#xD;
&#xD;
But I couldn&amp;#039;t resist the challenge to create a version of it in Mathematica, just for fun and because I was bored this past weekend. &#xD;
&#xD;
See the attached notebook and enjoy.  Alas, since you can run it any number of times you are only to blame for yourself it you spend too much time on it. &#xD;
&#xD;
After executing the notebook just execute &#xD;
&#xD;
    MWordle[Deploy]&#xD;
&#xD;
to bring up the game.&#xD;
&#xD;
A few additional comments.  The notebook MWordle.nb has the option&#xD;
&#xD;
AutoGeneratedPackage -&amp;gt; Automatic&#xD;
&#xD;
which causes it, when saved, to create an MWordle.m package file in its same directory. &#xD;
&#xD;
The code in MWordle.nb is set up as a package with the context MWordle`Mwordle`&#xD;
&#xD;
If you want to set things up so that the package gets loaded and the MWordle game is automatically launched, do the following.&#xD;
&#xD;
Create a directory MWordleGame on your disk  (The name MWordleGame can actually be whatever you wish.)  And in the MWordleGame directory create a new directory called MWordle.  (This name must be exactly that so that the MWordle`Mwordle` Context is property respected.)  Put the MWordle.nb notebook in the MWordle dierectory, open it in Mathematica and save it so that the MWordle.m file is created in the MWordle directory.  Then you can close the MWordle.nb notebook.&#xD;
&#xD;
Now in your MWordleGame directory save a new notebook -- you can call it whatever you wish, but something like LaunchMwordle.nb is a sensible choice.&#xD;
&#xD;
In that notebook create a button with the following command:&#xD;
&#xD;
&#xD;
    CellPrint[TextCell[Button[&amp;#034;Launch MWordle&amp;#034;,&#xD;
       Monitor[&#xD;
        If[! MemberQ[$Path, NotebookDirectory[]], &#xD;
         AppendTo[$Path, NotebookDirectory[]]];&#xD;
        Needs[&amp;#034;MWordle`MWordle`&amp;#034;]; MWordle`MWordle`MWordle[Deploy],&#xD;
        Row[{ProgressIndicator[Appearance -&amp;gt; &amp;#034;Necklace&amp;#034;, &#xD;
           ImageSize -&amp;gt; Small], Spacer[5], &#xD;
          Style[&amp;#034;Launching MWordle...&amp;#034;, 12, Blue, &#xD;
           FontFamily -&amp;gt; &amp;#034;Arial&amp;#034;]}]],&#xD;
       Method -&amp;gt; &amp;#034;Queued&amp;#034;], &amp;#034;Text&amp;#034;, GeneratedCell -&amp;gt; False, &#xD;
      CellAutoOverwrite -&amp;gt; False]]&#xD;
&#xD;
You now have a button in your LaunchMwordle.nb notebook which you can use any time you want to launch MWordle without having to execute the cells in the MWordle.nb notebook.&#xD;
&#xD;
Download the actual notebook from the link at the end of this post. The following is a version here to read.&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][4]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Wordle.gif&amp;amp;userId=20103&#xD;
  [2]: https://www.powerlanguage.co.uk/wordle/&#xD;
  [3]: https://www.nytimes.com/2022/01/03/technology/wordle-word-game-creator.html&#xD;
  [4]: https://www.wolframcloud.com/obj/08c015e2-0d65-4634-bf54-4b73e518f6d5</description>
    <dc:creator>David Reiss</dc:creator>
    <dc:date>2022-01-13T21:47:44Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/762950">
    <title>Package for Radar Charts</title>
    <link>https://community.wolfram.com/groups/-/m/t/762950</link>
    <description>**RadarChart Mathematica Package**&#xD;
&#xD;
The *RadarChart* mathematica package incorporates Radar Charts (also known as Spider Charts, Web Charts and Star Plots) as a new set of visualization tools into the mathematica environment.&#xD;
&#xD;
A detailed explanation on the use of radar charts can be found in the following [wikipedia page](https://en.wikipedia.org/wiki/Radar_chart).&#xD;
&#xD;
The project is listed at the mathematica package repository ([http://packagedata.net][1]), or can be accessed directly at  [github][2].&#xD;
&#xD;
Thanks to [halirutan](https://github.com/halirutan) for his guidance on setting up this project. Installation Instructions are heavily based on his existing projects.&#xD;
&#xD;
---&#xD;
**Navigation**&#xD;
&#xD;
- [Detailed Usage](#-detailed-usage)&#xD;
- [Examples](#examples)&#xD;
- [Neat Examples](#neat-examples)&#xD;
- [Installation](#installation)&#xD;
	- [Automatic Installation for *Mathematica* 9 and above](#automatic-installation-for-mathematica-9-and-above)&#xD;
	- [Manual Installation](#manual-installation)&#xD;
- [Contact](#-contact) &#xD;
	&#xD;
---&#xD;
&#xD;
##![doc image](http://i.stack.imgur.com/erf8e.png) Detailed Usage&#xD;
    RadarChart[{y1,y2,y3,...}]&#xD;
generates a radar plot (also known as web, star, spider, cobweb or kiviat diagram) corresponding to a list of values. This type of chart is suitable for showing commonality and outliers across different variables. &#xD;
     RadarChart[{list1,list2,...}]&#xD;
generates a radar plot to compare several series. &#xD;
&#xD;
     RadarChart[association]&#xD;
generates a radar plot to view the variable values in an association. &#xD;
&#xD;
     RadarChart[{association1,association2,...}]&#xD;
generates a radar plot to compare several series. &#xD;
&#xD;
     RadarChart[dataset]&#xD;
generates a radar plot to compare several series.&#xD;
&#xD;
Options are listed in the help file, and also in the readme document @ the github site.&#xD;
&#xD;
##Examples&#xD;
    Needs[&amp;#034;RadarChart`&amp;#034;]&#xD;
    RadarChart[{1, 2, 4, 5, 3}, &#xD;
    ChartLegends -&amp;gt; {&amp;#034;Private Label Strawberry Juice&amp;#034;}, &#xD;
    AxesLabel -&amp;gt; {&amp;#034;Ripe&amp;#034;, &amp;#034;Green&amp;#034;, &amp;#034;Candy&amp;#034;, &amp;#034;Juicy&amp;#034;, &amp;#034;Sulphur&amp;#034;}, &#xD;
    PlotLabel -&amp;gt; Style[&amp;#034;Sensory Map Strawberry Juice&amp;#034;, Bold, Large], &#xD;
    ImageSize -&amp;gt; Medium]&#xD;
    &#xD;
![Basic Example](http://i.stack.imgur.com/Opnwp.png)    &#xD;
&#xD;
Multiple Series can be charted.&#xD;
&#xD;
     Needs[&amp;#034;RadarChart`&amp;#034;]&#xD;
     RadarChart[{{1, 4, 3, 5, 2}, {2, 4, 3, 2, 1}}, Filling -&amp;gt; Axis, &#xD;
         AxesLabel -&amp;gt; {&amp;#034;Sweet&amp;#034;, &amp;#034;Sour&amp;#034;, &amp;#034;Salty&amp;#034;, &amp;#034;Bitter&amp;#034;, &amp;#034;Umami&amp;#034;}, &#xD;
         PlotStyle -&amp;gt; {Red, Blue}, ChartLegends -&amp;gt; {&amp;#034;Fernet-Cola&amp;#034;, &amp;#034;Jugo&amp;#034;}]&#xD;
![Mathematica graphics](http://i.stack.imgur.com/zvBVd.png)   &#xD;
&#xD;
Example of a start plot.&#xD;
&#xD;
     Needs[&amp;#034;RadarChart`&amp;#034;];&#xD;
     RadarChart[{{1, 4, 3, 5, 2}, {2, 4, 3, 2, 1}}, AxesType -&amp;gt; &amp;#034;Star&amp;#034;]&#xD;
&#xD;
![Mathematica graphics](http://i.stack.imgur.com/umecs.png)&#xD;
&#xD;
Compare survey results.&#xD;
&#xD;
     Needs[&amp;#034;RadarChart`&amp;#034;];&#xD;
     RadarChart[{{3, 4, 3, 4, 2}, {4, 5, 4, 5, 3}}, &#xD;
         AxesLabel -&amp;gt; {&amp;#034;Assets&amp;#034;, &amp;#034;Reliability&amp;#034;, &amp;#034;Cost Control&amp;#034;, &#xD;
         &amp;#034;Abstenteeism&amp;#034;, &amp;#034;Revenue&amp;#034;}, &#xD;
         ChartLegends -&amp;gt; {&amp;#034;Past Year&amp;#034;, &amp;#034;Current Year&amp;#034;}, Filling -&amp;gt; Axis, &#xD;
         PlotStyle -&amp;gt; {{Gray}, {Black}}, ImageSize -&amp;gt; Medium]&#xD;
     &#xD;
![Mathematica graphics](http://i.stack.imgur.com/WUH8c.png)&#xD;
&#xD;
##Neat Examples&#xD;
&#xD;
Analyze and compare crime statistics across states.&#xD;
&#xD;
     Needs[&amp;#034;RadarChart`&amp;#034;];&#xD;
     states = EntityClass[&amp;#034;AdministrativeDivision&amp;#034;, &amp;#034;AllUSStatesPlusDC&amp;#034;];&#xD;
     stateNames = First@StringSplit[#, &amp;#034;,&amp;#034;] &amp;amp; /@ states[&amp;#034;Name&amp;#034;];&#xD;
     crimeProps = {&amp;#034;AggravatedAssaultRate&amp;#034;, &amp;#034;BurglaryRate&amp;#034;, &#xD;
         &amp;#034;ForcibleRapeRate&amp;#034;, &amp;#034;LarcenyTheftRate&amp;#034;, &#xD;
         &amp;#034;MurderNonnegligentManslaughterRate&amp;#034;, &amp;#034;PropertyCrimeRate&amp;#034;, &#xD;
         &amp;#034;RobberyRate&amp;#034;, &amp;#034;ViolentCrimeRate&amp;#034;};&#xD;
     crimeData = EntityValue[states, &#xD;
         EntityProperty[&amp;#034;AdministrativeDivision&amp;#034;, #] &amp;amp; /@ crimeProps];&#xD;
     crimeRanking = Transpose[&#xD;
         Ordering[crimeData[[All, #]]] &amp;amp; /@ Range@Length@crimeProps];&#xD;
     ds = Dataset[&#xD;
         AssociationThread[stateNames, &#xD;
             AssociationThread[crimeProps, #] &amp;amp; /@ crimeRanking]];&#xD;
     GraphicsRow[{RadarChart[ds[&amp;#034;Georgia&amp;#034;], AxesType -&amp;gt; &amp;#034;Star&amp;#034;, &#xD;
         PlotLabel -&amp;gt; Style[&amp;#034;Georgia&amp;#034;, Bold, Large], &#xD;
         Epilog -&amp;gt; {Dashed, Circle[{0, 0}, 25.5]}, ImageSize -&amp;gt; Large], &#xD;
         GraphicsGrid[&#xD;
             Partition[&#xD;
                 RadarChart[ds[#], PlotLabel -&amp;gt; #, AxesLabel -&amp;gt; None, &#xD;
                 PlotRange -&amp;gt; {0, 50}, AxesType -&amp;gt; &amp;#034;Star&amp;#034;,&#xD;
                 PlotRangePadding -&amp;gt; Full, FrameTicks -&amp;gt; None, &#xD;
                 Epilog -&amp;gt; {Dashed, Circle[{0, 0}, 25.5]}] &amp;amp; /@ stateNames, &#xD;
                 UpTo[6]], ImageSize -&amp;gt; 600]}]]&#xD;
                 &#xD;
![Mathematica graphics](http://i.stack.imgur.com/5Vk7j.png)&#xD;
&#xD;
#Installation&#xD;
&#xD;
This package should work with Mathematica &amp;gt;8 if not using associations or datasets. The package was developed using mathematica 10.&#xD;
The installation is simple: Copy the `RadarChart` package directory into a location where *Mathematica* can find it. Usually this is the `Applications` directory in your `$UserBaseDirectory`. Just evaluate&#xD;
&#xD;
    FileNameJoin[{$UserBaseDirectory, &amp;#034;Applications&amp;#034;}]&#xD;
&#xD;
to see it. If there is an old installation of the `RadarChart`, remove it. Please find detailed steps below.&#xD;
&#xD;
###Automatic Installation for *Mathematica* 9 and above&#xD;
&#xD;
We have set up [an installation script](https://raw.githubusercontent.com/catrasca/RadarChart/master/RadarChart/installer.m) that does all the steps, except deleting old installations, for you. If it finds an old installation, it will prompt you with the location and quit, so that you can remove the old installation. After removing the old files, just start it again and it will proceed through all the steps pointed out in the manual installation section. To start the installation script, simply call&#xD;
&#xD;
    Import[&amp;#034;http://tinyurl.com/ntmhkca&amp;#034;]&#xD;
&#xD;
After this, the package should be available in your mathematica instance.&#xD;
&#xD;
###Manual Installation&#xD;
&#xD;
####Removing old Installations&#xD;
&#xD;
Old installation packages can be found by simply searching directories in your `$Path`. &#xD;
&#xD;
    FileNames[&amp;#034;RadarChart&amp;#034;, $Path]&#xD;
&#xD;
Please remove old installation directories that appear after evaluating the commands above. You can use &#xD;
&#xD;
    DeleteDirectory[dir, DeleteContents -&amp;gt; True]&#xD;
&#xD;
for that, but note that on Windows this might fail, because there, some files are locked when *Mathematica* is running. In this case, close *Mathematica* and do it manually using an explorer.&#xD;
&#xD;
###Downloading, Extracting and Copying the New Version&#xD;
&#xD;
The easiest way is, to download the whole repository as zip file. Use [this master.zip](https://github.com/catrasca/RadarChart/archive/master.zip) or click the *Download ZIP* on the right side on this page.&#xD;
&#xD;
After you have downloaded the file extract it. If you have no tool for this on Windows, you could use the [free 7-Zip](http://7-zip.org/). Under Mac OSX and Linux this should work out of the box.&#xD;
&#xD;
Inside the extracted directory, you will find a subdirectory `RadarChart` which has the following structure&#xD;
&#xD;
    RadarChart/&#xD;
    ??? Documentation&#xD;
    ?   ??? English&#xD;
    ?       ??? ReferencePages&#xD;
    ?           ??? Symbols&#xD;
    ?               ??? RadarChart.nb&#xD;
    ??? Kernel&#xD;
    ?   ??? init.m&#xD;
    ??? Installer.m&#xD;
    ??? pacletInfo.m&#xD;
    ??? RadarChart.m&#xD;
&#xD;
Copy the whole `RadarChart` directory with all its content to your `Applications` folder under your `$UserBaseDiretory`. If everything is in place proceed to the next step.&#xD;
&#xD;
###Finishing the Installation&#xD;
&#xD;
To make the package works, you can simply restart *Mathematica*.&#xD;
&#xD;
##![contact team](http://i.stack.imgur.com/tCbmW.png) Contact&#xD;
&#xD;
If you find bugs or have any other questions, please [create a new issue](https://github.com/catrasca/RadarChart/issues) in the bug-tracker. &#xD;
&#xD;
&#xD;
  [1]: http://packagedata.net/&#xD;
  [2]: http://github.com/catrasca/RadarChart</description>
    <dc:creator>Diego Zviovich</dc:creator>
    <dc:date>2015-12-22T20:02:41Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1421180">
    <title>Rubi - The Rule-based Integrator for Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/1421180</link>
    <description>Two months ago, Albert Rich posted [&amp;#034;What&amp;#039;s the hardest integral Mathematica running Rubi can find?&amp;#034;](http://community.wolfram.com/groups/-/m/t/1343015) here on the Wolfram Community.&#xD;
You might have also seen that I responded in detail, and pointed out a few things that could help improve Rubi (Rule-based integrator).&#xD;
While it appears nothing really happened afterward, this is far from reality.&#xD;
Since then, Albert and I have worked closely together to make Rubi more accessible and user-friendly.&#xD;
If you would like to learn how our productive collaboration evolved, let me invite you to read [my latest blog-post](http://halirutan.de/programming/Rubi/).&#xD;
However, here, we want to share an update that should serve as an overview of what we have done to improve Rubi.&#xD;
&#xD;
First of all, Rubi has got a new home under [rulebasedintegration.org](https://rulebasedintegration.org/), and its old website will no longer be updated.&#xD;
On the new website, you will find information, installation instructions, and links to the source-code and test-suites.&#xD;
&#xD;
Secondly, we created a [Rubi Organization](https://github.com/RuleBasedIntegration) on GitHub that serves as the headquarters for all things Rubi.&#xD;
It contains all Rubi&amp;#039;s code, notebooks, and test-suites nicely structured into several repositories.&#xD;
At the moment, we provide repositories for the&#xD;
&#xD;
* loadable package files and notebook source files defining over 6700 integration rules,&#xD;
* PDF files displaying the rules in human-readable mathematical notation alongside the Mathematica code, and&#xD;
* test-suite files containing over 71000 integration problems and their solutions.&#xD;
&#xD;
The integration test files are available in the syntax used by 4 popular computer algebra systems (Mathematica, Maple, Maxima, and Axiom).&#xD;
The test-suite can be used to compare Rubi&amp;#039;s results with other symbolic integrators, including Mathematica&amp;#039;s `Integrate` function.&#xD;
&#xD;
In addition to the transition to GitHub, we recently released version 4.16.0.3 of Rubi which significantly expands the class of expressions the system can integrate.&#xD;
But the most noticeable change for users is the completely reworked display of the rules and intermediate steps Rubi uses to integrate expressions.&#xD;
Although installation, usage, and examples are given on [Rubi&amp;#039;s website](https://rulebasedintegration.org/), let me show you how easy it is to install and run Rubi 4.16.0.3 using Mathematica 11.3:&#xD;
&#xD;
The command&#xD;
&#xD;
    PacletInstall[&amp;#034;https://github.com/RuleBasedIntegration/Rubi/releases/download/4.16.0.3/Rubi-4.16.0.3.paclet&amp;#034;];&#xD;
&#xD;
installs the Rubi-4.16.0.3 paclet on your computer.&#xD;
After that, to load Rubi into Mathematica all you have to do is issue the `Get` command&#xD;
&#xD;
    &amp;lt;&amp;lt; Rubi`&#xD;
&#xD;
Then to integrate an expression with respect to a variable, use Rubi&amp;#039;s `Int` command similar to Mathematica&amp;#039;s `Integrate` command.  For example, evaluating&#xD;
&#xD;
    Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]&#xD;
&#xD;
returns the antiderivative (a.k.a. the indefinite integral)&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
Rubi&amp;#039;s unique ability to display the steps it uses to integrate expressions is a great feature of the system.&#xD;
For example, the `Steps` command&#xD;
&#xD;
    Steps@Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]&#xD;
&#xD;
displays&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
Here, in red are the rules used to integrate the expression, and in blue are the intermediate results.&#xD;
Each rule can be expanded to show the rule number, which directly corresponds to the index of the rule in `Int`&amp;#039;s list of DownValues.&#xD;
More importantly, you can see the conditions that have to be satisfied so the rule can be applied.&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
Rubi&amp;#039;s `Stats` command provides statistics about the integration. For example,&#xD;
&#xD;
    Stats[Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]]&#xD;
&#xD;
displays&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
The leaf-count size of an antiderivative is a crude measure of its complexity.&#xD;
As you can see, Rubi&amp;#039;s antiderivative for this integral has a leaf-count of 25.&#xD;
Now compare Rubi&amp;#039;s antiderivative with that produced by Mathematica 11.3 for the same integral:&#xD;
&#xD;
    Integrate[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
    LeafCount[%]&#xD;
    (*  290 *)&#xD;
&#xD;
Note that not only is Mathematica&amp;#039;s result more than 11 times the size of Rubi&amp;#039;s, it unnecessarily involves elliptic integral functions *and* the imaginary unit.&#xD;
&#xD;
Skeptics might be inclined to ask if Rubi&amp;#039;s dramatically simpler result is actually a valid antiderivative.&#xD;
Since symbolic differentiation is much easier than integration, antiderivatives can be verified correct by seeing if its derivative equals the original integrand as follows:&#xD;
&#xD;
    expr = (Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]);&#xD;
    FullSimplify[D[Int[expr, x], x] == expr]&#xD;
    FullSimplify[D[Integrate[expr, x], x] == expr]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
As you can see Mathematica easily verifies Rubi&amp;#039;s antiderivative correct, but has a hard time verifying its own antiderivative correct...&#xD;
&#xD;
Albert and I are working on publishing the program used to thoroughly test each new version of Rubi before being released.&#xD;
The test program ensures Rubi&amp;#039;s result equals the optimal antiderivative for the over 71000 problems in the test-suite.&#xD;
And yes, the optimal antiderivatives have all been verified correct by differentiation.&#xD;
&#xD;
Of course, the optimal antiderivatives stored in the test-suite are actually just the simplest ones found so far.&#xD;
If you should find a substantially simpler antiderivative than the one in the test-suite, please report it so the test-suite can be made even harder on Rubi!&#xD;
&#xD;
If all that has got you interested in joining Rubi&amp;#039;s community of users, check out its website or talk to us in our [Gitter chatroom](https://gitter.im/Rule-Based-Integration/Lobby).&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10564sSs5M.png&amp;amp;userId=11733&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=qDtIH.png&amp;amp;userId=11733&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=vQ4GR.png&amp;amp;userId=11733&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=43t8e.png&amp;amp;userId=11733&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=xjKTJ.png&amp;amp;userId=11733&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=eCoWB.png&amp;amp;userId=11733</description>
    <dc:creator>Patrick Scheibe</dc:creator>
    <dc:date>2018-08-24T02:50:37Z</dc:date>
  </item>
</rdf:RDF>

