Giter Site home page Giter Site logo

dotnet / mbmlbook Goto Github PK

View Code? Open in Web Editor NEW
282.0 35.0 76.0 6.17 MB

Sample code for the Model-Based Machine Learning book.

Home Page: http://mbmlbook.com

License: MIT License

C# 99.49% HTML 0.51%
machine-learning probabilistic-graphical-models probabilistic-models probabilistic-programming

mbmlbook's Introduction

MBML Book Sample Code

Supporting code for the Model-Based Machine Learning book.

This project contains the sample code and test data for the freely-available book on model-based machine learning at http://mbmlbook.com/. The book introduces readers to how to build machine learning models for real-world problems. Each chapter tackles a different problem by defining a statistical model and demonstrating how to apply it to actual data. This repository contains the source code for these models together with the sample data - so that readers can run it on their own, re-create the results from the book and experiment with modifying the code.

Models here are created and applied using the Infer.NET framework. When targeting .NET Framework/Windows code produces visualizations using Glo.

Contents

Structure of Repository

  • The Visual Studio solution Samples.sln in the root of the repository contains a project with models for every chapter of the book and a few projects with the shared code and/or unit tests from the folders described below. Code layout in projects corresponding to the book chapters is similar and expanded only once.

  • src/

    • 1. A Murder Mystery - code by Thomas Diethe and Dmitry Kats/
    • 2. Assessing People's Skills - code by Thomas Diethe and Dmitry Kats/
      • Data - input data in ObjML format
      • DataObjects - .NET types to hold the input data
      • Experiment - types that facilitate experimentation: types for metrics, results, and, possibly, other experiment-related data structures; a type that represents a single experiment and exposes a method to run it, type(s) that store multiple experiments together for comparison, etc.
      • Models - .NET types for Infer.NET models. Have methods to construct a model and to run inference on it.
      • Views - additional Glo views needed for specific chapter. Not included in compilation when targeting .Net Core.
      • Contents.cs - static type that has constants for the name of the chapter and all the sections within the chapter
      • Program.cs
    • 3. Meeting Your Match - code by Thomas Diethe and Alexander Novikov
      • This chapter and the remaining chapters have similar layout to chapter 2.
    • 4. Uncluttering Your Inbox - code by Thomas Diethe and Dmitry Kats
    • 5. Making Recommendations - code by Yordan Zaykov and Alexander Novikov
    • 6. Understanding Asthma - code by John Guiver and Dmitry Kats
    • 7. Harnessing the Crowd - code by John Guiver and Dmitry Kats
    • MBMLCommon/ - a number of utility classes shared by different projects including
      • Outputter.cs - class that encapsulates outputting objects, so that the code for chapters can output results in a platform-agnostic way. Also exposes methods for saving outputs to .objml files.
    • MBMLViews - additional Glo views shared among the chapters.
  • test/ - projects with unit tests

Building Sample Code

Please, refer to our building guide.

Contributing

We welcome contributions! Please review our contribution guide.

License

MBML Book Sample Code is licensed under the MIT license.

.NET Foundation

MBML Book Sample Code is a .NET Foundation project. It relies on Infer.NET framework.

There are many .NET related projects on GitHub.

  • .NET home repo - links to 100s of .NET projects, from Microsoft and the community.

mbmlbook's People

Contributors

johnmwinn avatar jonathantims avatar jongalloway avatar novikov-alexander avatar terrajobst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mbmlbook's Issues

Samples targeting for .NET Core 3.0

Hi, Microsoft announced general availability of .NET Core 3 on September and described it as the future of .NET and Visual Studio 2019 being the newest version of the IDE. Will these source code samples be upgraded to target the latest version before the book is released?

It would be a shame if the code samples are broken on the new version of .NET since it has succeeded 2.1

Thanks

Exceptions thrown when running demos in Debug mode

An exception is thrown whenever I click any of the first three links in the browser window (see below). I am running Visual Studio 2017 express on Windows 10.
image
image

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=MurderMystery
  StackTrace:
   at MurderMystery.VariablesViewModel.get_DaggerOpacity() in C:\Users\martin\repos\mbmlbook\src\1. A Murder Mystery\Views\VariablesViewModel.cs:line 335
   at Microsoft.Research.Glo.Object.Property_251.GetValue(Object )
   at Microsoft.Research.Glo.Object.PropertyPart..ctor(IExpressionPart parent, ClrProperty cprop, Object defaultObj)

Cannot build sample code on mac with .NET v2.1.814

Not sure if anyone recently has tried to install the app on Mac. Following the instruction mbmlbook/BUILDING.md and I've ran the build command below

dotnet build -f netcoreapp2.1

It errors out, pasted the error message down there. I am very new to C# and have zero clue on how to fix this. Posted it here and could need some on it.

/usr/local/share/dotnet/sdk/2.1.814/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5):
error NETSDK1005: Assets file '/Users/gchu/Code/mbmlbook/src/MBMLCommon/obj/project.assets.json' doesn't have a target
for '.NETCoreApp,Version=v2.1'. Ensure that restore has run and that you have included 'netcoreapp2.1' in the TargetFrameworks
for your project.

System.Windows.Data Errors

I see a lot of these in the console when running AssessingPeoplesSkills project (see below), but not sure if it is actually affecting anything... the program seems to run fine.

System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=62400565)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=62400565); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=29593675)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=29593675); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=25269681)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=25269681); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=5503354)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=5503354); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=59434866)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=59434866); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=19545759)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=19545759); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=35563764)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=35563764); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=35876092)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=35876092); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=21777794)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=21777794); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=16901523)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=16901523); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=45904861)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=45904861); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=16441830)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=16441830); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=9774622)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=9774622); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=2733199)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=2733199); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsRecentlyModified' property not found on 'object' ''DictionaryEntryPart' (HashCode=21296519)'. BindingExpression:Path=IsRecentlyModified; DataItem='DictionaryEntryPart' (HashCode=21296519); target element is 'ListViewItem' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')

UI makes examples harder to understand.

Love the book, and the repo, but the examples have too much UI code especially for the basic examples. It takes focus away from actually learning how the varibles, properties, and engine work together because you have to slough through UI code and mentally parse whats there for machine learning and what is there for UI purposes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.