Update README and CONTRIBUTING. Add build badges.
This commit is contained in:
msdmkats 2018-10-05 15:49:08 +03:00 коммит произвёл Sergey B. Berezin
Родитель 03e3d0fa8c
Коммит e2d811cd05
2 изменённых файлов: 141 добавлений и 54 удалений

Просмотреть файл

@ -4,12 +4,10 @@ Welcome, and thank you for your interest in contributing to Infer.NET!
Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
the rights to use your contribution. For details, visit https://github.com/dotnet/home/blob/master/guidance/net-foundation-contribution-license-agreement.pdf.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
This project has adopted the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).

189
README.md
Просмотреть файл

@ -1,19 +1,69 @@
# Infer.NET
**Infer.NET** is a framework for running Bayesian inference in graphical models. It can also be used for probabilistic programming.
One can use Infer.NET to solve many different kinds of machine learning problems - from standard problems like [classification](https://microsoft.github.io/Infer.NET/userguide/docs/Infer.NET%20Learners%20-%20Bayes%20Point%20Machine%20classifiers),
[recommendation](https://microsoft.github.io/Infer.NET/userguide/docs/Infer.NET%20Learners%20%20Matchbox%20recommender) or [clustering](https://microsoft.github.io/Infer.NET/userguide/docs/Mixture%20of%20Gaussians%20tutorial) through to [customised solutions to domain-specific problems](https://microsoft.github.io/Infer.NET/userguide/docs/Click%20through%20model%20sample).
One can use Infer.NET to solve many different kinds of machine learning problems - from standard problems like [classification](https://dotnet.github.io/infer/userguide/Learners/Bayes%20Point%20Machine%20classifiers.html),
[recommendation](https://dotnet.github.io/infer/userguide/Learners/Matchbox%20recommender.html) or [clustering](https://dotnet.github.io/infer/userguide/Mixture%20of%20Gaussians%20tutorial.html) through to [customised solutions to domain-specific problems](https://dotnet.github.io/infer/userguide/Click%20through%20model%20sample.html).
**Infer.NET** has been used in a wide variety of domains including information retrieval, bioinformatics, epidemiology, vision,
and many others.
# Contents
## Contents
- [Structure of repository](#structure-of-repository)
- [Build and test](#build-and-test)
- [Build Status](#build-status)
- [Installation](#installation)
- [Documentation](#documentation)
- [Structure of Repository](#structure-of-repository)
- [Build and Test](#build-and-test)
- [Windows](##windows)
- [Linux](##linux)
- [Linux and macOS](##linux-and-macos)
- [Contributing](#contributing)
- [License](#license)
- [.NET Foundation](#.net-foundation)
# Structure of repository
## Build Status
| | Debug | Release |
|:---|----------------:|------------------:|
|**Windows**|[![Win Debug](https://msrcambridge.visualstudio.com/Infer.NET/_apis/build/status/Nightly%20Windows%20Debug)](https://msrcambridge.visualstudio.com/Infer.NET/_build/latest?definitionId=135)|[![Win Release](https://msrcambridge.visualstudio.com/Infer.NET/_apis/build/status/Nightly%20Windows%20Release)](https://msrcambridge.visualstudio.com/Infer.NET/_build/latest?definitionId=134)|
|**Linux**|[![Linux Debug](https://msrcambridge.visualstudio.com/Infer.NET/_apis/build/status/Nightly%20Linux%20Debug)](https://msrcambridge.visualstudio.com/Infer.NET/_build/latest?definitionId=137)|[![Linux Release](https://msrcambridge.visualstudio.com/Infer.NET/_apis/build/status/Nightly%20Linux%20Release)](https://msrcambridge.visualstudio.com/Infer.NET/_build/latest?definitionId=136)|
|**macOS**|[![macOS Debug](https://msrcambridge.visualstudio.com/Infer.NET/_apis/build/status/Nightly%20macOS%20Debug)](https://msrcambridge.visualstudio.com/Infer.NET/_build/latest?definitionId=139)|[![macOS Release](https://msrcambridge.visualstudio.com/Infer.NET/_apis/build/status/Nightly%20macOS%20Release)](https://msrcambridge.visualstudio.com/Infer.NET/_build/latest?definitionId=138)|
## Installation
Infer.NET runs on Windows, Linux, and macOS - any platform where [.NET Core 2.0](https://github.com/dotnet/core) is available.
First ensure you have installed [.NET Core 2.0](https://www.microsoft.com/net/download/dotnet-core/2.0). Infer.NET also works on the .NET Framework 4.6.1 and above.
Once you have an app, you can install the Infer.NET NuGet package(s) from the .NET Core CLI using:
```
dotnet add package Microsoft.ML.Probabilistic
dotnet add package Microsoft.ML.Probabilistic.Compiler
dotnet add package Microsoft.ML.Probabilistic.Learners
```
or from the NuGet package manager:
```powershell
Install-Package Microsoft.ML.Probabilistic
Install-Package Microsoft.ML.Probabilistic.Compiler
Install-Package Microsoft.ML.Probabilistic.Learners
Install-Package Microsoft.ML.Probabilistic.Visualizers.Windows
```
Or alternatively you can add the Microsoft.ML.Probabilistic.* package(s) from within Visual Studio's NuGet package manager or via [Paket](https://github.com/fsprojects/Paket).
There currently are [four maintained Infer.NET nuget packages](https://www.nuget.org/packages?q=Microsoft.ML.Probabilistic):
1. `Microsoft.ML.Probabilistic` contains classes and methods needed to execute the inference code.
1. `Microsoft.ML.Probabilistic.Compiler` contains the Infer.NET Compiler, which takes model descriptions written using the Infer.NET API and converts them into inference code. It also contains utilities for the visualization of the generated code.
1. `Microsoft.ML.Probabilistic.Learners` contains complete machine learning applications including a classifier and a recommender system.
1. `Microsoft.ML.Probabilistic.Visualizers.Windows` contains an alternative .NET Framework and Windows specific set of visualization tools for exploring and analyzing models.
## Documentation
Documentation can be found on the [Infer.NET website](https://dotnet.github.io/infer/userguide/).
## Structure of Repository
* The Visual Studio solution `Infer2.sln` in the root of the repository contains all Infer.NET components, unit tests and sample programs from the folders described below.
@ -37,15 +87,19 @@ and many others.
* `MontyHall` - an Infer.NET implementation of the Monty Hall problem, along with a graphical user interface.
* `MotifFinder` - an Infer.NET implementation of a simple model for finding motifs in nucleotide sequences, which constitutes an important problem in bioinformatics.
* `FSharpWrapper` is a wrapper project that hides some of the generic constructs in the Infer.NET API allowing simpler calls to the Infer.NET API from standard F#.
* `IronPythonWrapper` contains wrapper for calling Infer.NET from the [IronPython](https://ironpython.net/) programming language and tests for the wrapper. Please refer to [README.md](IronPythonWrapper/README.md) for more information.
* `Learners` folder contains Visual Studio projects for complete machine learning applications including classification and recommendation. You can read more about Learners [here](https://microsoft.github.io/Infer.NET/userguide/docs/Infer.NET%20Learners.md).
* `Learners` folder contains Visual Studio projects for complete machine learning applications including classification and recommendation. You can read more about Learners [here](https://dotnet.github.io/infer/userguide/Infer.NET%20Learners.html).
* `Runtime` - is a C# project with classes and methods needed to execute the inference code.
* `Tutorials` contains [Examples Browser](https://microsoft.github.io/Infer.NET/userguide/docs/The%20Example%20Browser.md) project with simple examples that provide a step-by-step introduction to Infer.NET.
* `Tutorials` contains [Examples Browser](https://dotnet.github.io/infer/userguide/The%20examples%20browser.html) project with simple examples that provide a step-by-step introduction to Infer.NET.
* `Visualizers/Windows` contains an alternative .NET Framework and Windows specific set of visualization tools for exploring and analyzing the code generated by the `Compiler`.
* `test/`
@ -59,73 +113,91 @@ and many others.
* `Learners` folder contains the unit tests and the test application for `Learners` (see above).
* `docs` folder contains the scripts for bulding API documentation and for updating https://microsoft.github.io/Infer.NET. Please refer to [README.md](docs/README.md) for more details.
* `build` folder contains the YAML definitions for the Continuous Integration builds and the specification files for the nuget packages.
# Build and Test
* `docs` folder contains the scripts for bulding API documentation and for updating https://dotnet.github.io/infer. Please refer to [README.md](docs/README.md) for more details.
Infer.NET is cross platform and supports .NET Framework 4.5.2 and Mono 5.0. Unit tests are written using the [XUnit](https://xunit.github.io/) framework.
## Build and Test
## Windows
Infer.NET is cross platform and supports .NET Framework 4.6.1, .NET Core 2.0, and Mono 5.0. Unit tests are written using the [XUnit](https://xunit.github.io/) framework.
### Prerequisites
All of the Infer.NET libraries target .NET Standard 2.0. Projects that produce executables (including test projects) mostly target .NET Framework 4.6.1, .NET Core 2.0, or both depending on build configuration:
| Configurations | Targeted Frameworks |
|:---|---:|
| Debug, Release | both .NET Framework 4.6.1 and .NET Core 2.0 |
| DebugFull, ReleaseFull | .NET Framework 4.6.1 only |
| DebugCore, ReleaseCore | .NET Core 2.0 only |
### Windows
#### Prerequisites
**Visual Studio 2017.**
If you don't have Visual Studio 2017, you can install the free [Visual Studio 2015/2017 Community](http://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx).
If you don't have Visual Studio 2017, you can install the free [Visual Studio 2017 Community](http://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx).
### Build and test
#### Build and test
You can load `Infer2.sln` solution located in the root of repository into Visual Studio and build all libraries and samples.
**NB!** The solution has a number of build configurations that allows building either for all supported frameworks simultaneously or only for a specific one, but in order for Visual Studio to behave correctly, the solution needs to be closed and re-opened after switching between such configurations.
Unit tests are available in `Test Explorer` window. Normally you should see tests from 3 projects: `Tests`, `PublicTests` and `LearnersTest`. Note, that some of the tests are categorized, and those falling in the `OpenBug` or `BadTest` categories are not supposed to succeed.
## Linux
### Linux and macOS
Almost all components of Infer.NET run on Mono and/or .net core 2.0 except some visualizations in `Compiler` project and sample applications that use WPF.
All components of Infer.NET and almost all sample projects run on .NET Core 2.0 and/or Mono except sample applications that use WPF.
### Prerequisites
#### Prerequisites
1. **[Mono and MSBuild](https://www.mono-project.com/download/stable/#download-lin)** (version 5.0 and higher)
1. **[.NET Core 2.0 SDK](https://www.microsoft.com/net/download/linux-package-manager/ubuntu18-04/sdk-2.1.202)**
1. **[NuGet](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools)** package manager
* **[.NET Core 2.0 SDK](https://www.microsoft.com/net/download/dotnet-core/2.0)** to build and run .NET Standard and .NET Core projects
### Build
and, optionally,
1. Restore required NuGet packages after cloning the repository. Execute the following command in the root directory of the repository:
```bash
msbuild /p:MonoSupport=true /restore Infer2.sln
```
* **[Mono](https://www.mono-project.com/download/stable/)** (version 5.0 and higher) and **[NuGet](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools)** package manager to build and run .NET Framework 4.6.1 projects that don't use WPF (there're some examples that use Win Forms and, therefore, don't run on .NET Core, but can be built and run with Mono; there's also Visualizers/Windows project mentioned above that can be built with Mono using `/p:MonoSupport=true`)
2. Then build the entire solution (or individual projects) using the following commands:
```bash
msbuild /p:MonoSupport=true Infer2.sln
```
or
```bash
msbuild /p:MonoSupport=true src/Runtime/Runtime.csproj
```
These commands set the `MonoSupport` property to `true`. It excludes code that uses WPF from build.
#### Build
### Run unit tests
To build .NET Standard libraries and .NET Core executables, run in the root of the repository either
```bash
dotnet build -c DebugCore Infer2.sln
```
to build debug assemblies, or
```bash
dotnet build -c ReleaseCore Infer2.sln
```
to build release assemblies.
The corresponding commands to build .NET Standard libraries and .NET Framework executables with Mono are
```bash
msbuild /c:DebugFull /p:MonoSupport=true /restore Infer2.sln
```
and
```bash
msbuild /c:ReleaseFull /p:MonoSupport=true /restore Infer2.sln
```
Please, expect build failure messages about exapmles that use WPF GUI. Libraries and executables that don't reference WPF should build, though.
#### Run unit tests
In order to run unit tests, build the test project and execute one of the following commands:
```bash
mono ~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe <path to net452 assembly with tests> <filter>
dotnet ~/.nuget/packages/xunit.runner.console/2.3.1/tools/netcoreapp2.0/xunit.console.dll <path to netcoreapp2.0 assembly with tests> <filter>
```
```bash
dotnet ~/.nuget/packages/xunit.runner.console/2.3.1/tools/netcoreapp2.0/xunit.console.dll <path to netcoreapp2.0 assembly with tests> <filter>
mono ~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe <path to net461 assembly with tests> <filter>
```
There are three test assemblies in the solution:
- **Infer.Tests.dll** in the folder `test/Tests`.
- **Microsoft.ML.Probabilistic.Tests.dll** in the folder `test/Tests`.
- **TestPublic.dll** in the folder `test/TestPublic`.
- **Infer.Learners.Tests.dll** in the folder `test/Learners/LearnersTests`.
- **Microsoft.ML.Probabilistic.Learners.Tests.dll** in the folder `test/Learners/LearnersTests`.
Depending on the build configuration, the assemblies will be located in the `bin/Debug` or `bin/Release` subdirectories
Depending on the build configuration and targeted framework, the assemblies will be located in the `bin/Debug<Core|Full>/<netcoreapp2.0|net461>` or `bin/Release<Core|Full>/<netcoreapp2.0|net461>` subdirectories
of the test project.
`<filter>` is a rule to chose what tests will be run. You can specify them
`<filter>` is a rule to choose what tests will be run. You can specify them
using `-trait Category=<category>` and `-notrait Category=<category>` parts
of `<filter>`. The former selects tests of
the given category, while the latter selects test that don't belong to the given
@ -146,19 +218,36 @@ _BadTest_ is a category of tests that must fail.
_OpenBug_ is a category of tests that can fail.
An example of quick testing of `Infer.Tests.dll` in `Debug` configuration after changing working directory to
An example of quick testing of `Microsoft.ML.Probabilistic.Tests.dll` in `Debug` configuration after changing working directory to
the `Tests` project looks like:
```bash
mono ~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe bin/Debug/net452/Infer.Tests.dll -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -notrait Category=CsoftModel -notrait Category=ModifiesGlobals -notrait Category=DistributedTest -notrait Category=Performance
dotnet ~/.nuget/packages/xunit.runner.console/2.3.1/tools/netcoreapp2.0/xunit.console.dll bin/DebugCore/netcoreapp2.0/Microsoft.ML.Probabilistic.Tests.dll -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -notrait Category=CsoftModel -notrait Category=ModifiesGlobals -notrait Category=DistributedTest -notrait Category=Performance
mono ~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe bin/Debug/net452/Infer.Tests.dll -trait Category=CsoftModel -trait Category=ModifiesGlobals -trait Category=DistributedTests -trait Category=Performance -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -parallel none
dotnet ~/.nuget/packages/xunit.runner.console/2.3.1/tools/netcoreapp2.0/xunit.console.dll bin/DebugCore/netcoreapp2.0/Microsoft.ML.Probabilistic.Tests.dll -trait Category=CsoftModel -trait Category=ModifiesGlobals -trait Category=DistributedTests -trait Category=Performance -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -parallel none
```
To run the same set of tests on Mono:
To run the same set of tests on .net core:
```bash
dotnet ~/.nuget/packages/xunit.runner.console/2.3.1/tools/netcoreapp2.0/xunit.console.dll bin/Debug/netcoreapp2.0/Infer.Tests.dll -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -notrait Category=CsoftModel -notrait Category=ModifiesGlobals -notrait Category=DistributedTest -notrait Category=Performance
mono ~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe bin/DebugFull/net461/Microsoft.ML.Probabilistic.Tests.dll -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -notrait Category=CsoftModel -notrait Category=ModifiesGlobals -notrait Category=DistributedTest -notrait Category=Performance
dotnet ~/.nuget/packages/xunit.runner.console/2.3.1/tools/netcoreapp2.0/xunit.console.dll bin/Debug/netcoreapp2.0/Infer.Tests.dll -trait Category=CsoftModel -trait Category=ModifiesGlobals -trait Category=DistributedTests -trait Category=Performance -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -parallel none
mono ~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe bin/DebugFull/net461/Microsoft.ML.Probabilistic.Tests.dll -trait Category=CsoftModel -trait Category=ModifiesGlobals -trait Category=DistributedTests -trait Category=Performance -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -parallel none
```
Helper scripts `monotest.sh` and `netcoretest.sh` for running unit tests on Mono and .net core respectively are located in the `test` folder.
Helper scripts `netcoretest.sh` and `monotest.sh` for running unit tests on .NET Core and Mono respectively are located in the `test` folder.
## Contributing
We welcome contributions! Please review our [contribution guide](CONTRIBUTING.md).
## License
Infer&#46;NET is licensed under the [MIT license](LICENSE.txt).
## .NET Foundation
Infer&#46;NET is a [.NET Foundation](https://www.dotnetfoundation.org/projects) project.
It's also a part of [ML.NET](https://github.com/dotnet/machinelearning) machine learning framework.
There are many .NET related projects on GitHub.
- [.NET home repo](https://github.com/Microsoft/dotnet) - links to 100s of .NET projects, from Microsoft and the community.