Giter VIP home page Giter VIP logo

sharplearning.examples's Introduction

SharpLearning.Examples

Build Status

SharpLearning.Examples contains code examples to show how to use the machine learning library SharpLearning

The examples are structured in a unittest project, where each test is a separate example. There are no assertions and the unit test framework is only used as an easy way of running the examples. Information about how to get started can be found in the SharpLearning wiki

An example showing how to read data, create a RegressionDecisionTreeLearner and learn a RegressionDecisionTreeModel can be seen below:

[TestMethod]
public void RegressionLearner_Learn_And_Predict()
{
    // Use StreamReader(filepath) when running from filesystem
    var parser = new CsvParser(() => new StringReader(Resources.winequality_white));
    var targetName = "quality";

    // read feature matrix (all columns except quality)
    var observations = parser.EnumerateRows(c => c != targetName)
        .ToF64Matrix();

    // read regression targets
    var targets = parser.EnumerateRows(targetName)
        .ToF64Vector();

    // create learner
    var learner = new RegressionDecisionTreeLearner(maximumTreeDepth: 5);

    // learns a RegressionDecisionTreeModel
    var model = learner.Learn(observations, targets);

    // use the model to predict the training data
    var predictions = model.Predict(observations);
}

Currently there are only examples showing general usage of the learners and models. Specific examples for the individual learner/model types is planned. However, except from different hyperparameters, the the individual learner types are used in exactly the same way. Same example as above but with a RandomForestLearner instead of a DecisionTreeLearner:

[TestMethod]
public void RegressionLearner_Learn_And_Predict()
{
    // Use StreamReader(filepath) when running from filesystem
    var parser = new CsvParser(() => new StringReader(Resources.winequality_white));
    var targetName = "quality";

    // read feature matrix (all columns except quality)
    var observations = parser.EnumerateRows(c => c != targetName)
        .ToF64Matrix();

    // read regression targets
    var targets = parser.EnumerateRows(targetName)
        .ToF64Vector();

    // create learner (RandomForest)
    var learner = new RegressionRandomForestLearner(trees: 100);

    // learns a RegressionRandomForestTreeModel
    var model = learner.Learn(observations, targets);

    // use the model to predict the training data
    var predictions = model.Predict(observations);
}

Datasets

SharpLearning.Examples contains 3 datasets in csv format for use with the examples:

MNIST_SMALL

  • mnist_small_train - 1000 observations from the original MNIST training data set
  • mnist_small_test - 1000 observations from the original MNIST test data set

The original and complete dataset can be found here: http://yann.lecun.com/exdb/mnist/

CIFAR10_SMALL

  • cifar10_train_small - 1000 observations from the original CIFAR10 training data set
  • cifar10_test_small - 1000 observations from the original CIFAR10 test data set

The original and complete dataset can be found here: https://www.cs.toronto.edu/~kriz/cifar.html

Wine Quality Data Set

  • winequality-white - the complete white wine quality dataset

The original dataset can be found here: http://archive.ics.uci.edu/ml/datasets/Wine+Quality

Installation

Installation instructions for SharpLearning are availible in the main SharpLearning repository: SharpLearning

sharplearning.examples's People

Contributors

mdabros avatar

Stargazers

 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

sharplearning.examples's Issues

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.