Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
GH-540: Add an Example for BaumWelchLearning(TDistribution, TObservat…
Browse files Browse the repository at this point in the history
…ion, TOptions) Class
  • Loading branch information
cesarsouza committed Jun 18, 2017
1 parent bfe5e2c commit 9140baf
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 47 deletions.
1 change: 1 addition & 0 deletions Sources/Accord.Statistics/Accord.Statistics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
<Compile Include="Models\Markov\Learning\Base\BaseHiddenMarkovModelLearning.cs" />
<Compile Include="Models\Markov\Learning\Base\BaseViterbiLearning`1.cs" />
<Compile Include="Models\Markov\Learning\Base\BaseBaumWelchLearning`3.cs" />
<Compile Include="Models\Markov\Learning\BaumWelchLearning`3.cs" />
<Compile Include="Models\Markov\Learning\BaumWelchLearning`2.cs" />
<Compile Include="Models\Markov\Learning\HiddenMarkovClassifierLearning`2.cs" />
<Compile Include="Models\Markov\Learning\Base\BaseMaximumLikelihoodLearning`2.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,6 @@ namespace Accord.Statistics.Models.Markov.Learning
using Accord.MachineLearning;
using Accord.Statistics.Models.Markov.Topology;

/// <summary>
/// Baum-Welch learning algorithms for learning Hidden Markov Models.
/// </summary>
///
/// <typeparam name="TDistribution">The type of the emission distributions in the model.</typeparam>
/// <typeparam name="TObservation">The type of the observations (i.e. int for a discrete model).</typeparam>
/// <typeparam name="TOptions">The type of fitting options accepted by this distribution.</typeparam>
///
public class BaumWelchLearning<TDistribution, TObservation, TOptions> :
BaseBaumWelchLearningOptions<HiddenMarkovModel<TDistribution, TObservation>, TDistribution, TObservation, TOptions>,
IConvergenceLearning
where TDistribution : IFittableDistribution<TObservation, TOptions>
where TOptions : class, IFittingOptions, new()
{

/// <summary>
/// Initializes a new instance of the <see cref="BaumWelchLearning{TDistribution, TObservation, TOptions}"/> class.
/// </summary>
///
public BaumWelchLearning()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BaumWelchLearning{TDistribution, TObservation, TOptions}"/> class.
/// </summary>
///
/// <param name="model">The model to be learned.</param>
///
public BaumWelchLearning(HiddenMarkovModel<TDistribution, TObservation> model)
: base(model)
{
}

/// <summary>
/// Creates an instance of the model to be learned. Inheritors of this abstract
/// class must define this method so new models can be created from the training data.
/// </summary>
///
protected override HiddenMarkovModel<TDistribution, TObservation> Create()
{
return new HiddenMarkovModel<TDistribution, TObservation>(Topology, Emissions);
}

}

/// <summary>
/// Baum-Welch learning algorithm for <see cref="HiddenMarkovModel{TDistribution}">
/// arbitrary-density (generic) Hidden Markov Models</see>.
Expand Down Expand Up @@ -184,7 +138,7 @@ protected override HiddenMarkovModel<TDistribution, TObservation> Create()
/// <seealso cref="HiddenMarkovModel"/>
/// <seealso cref="HiddenMarkovModel{TDistribution, TObservation}"/>
/// <seealso cref="BaumWelchLearning"/>
/// <seealso cref="BaumWelchLearning{TDistribution, TObservation}"/>
/// <seealso cref="BaumWelchLearning{TDistribution, TObservation, TOptions}"/>
///
/// <typeparam name="TDistribution">The type of the emission distributions in the model.</typeparam>
/// <typeparam name="TObservation">The type of the observations (i.e. int for a discrete model).</typeparam>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Accord Statistics Library
// The Accord.NET Framework
// http://accord-framework.net
//
// Copyright © César Souza, 2009-2017
// cesarsouza at gmail.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//

namespace Accord.Statistics.Models.Markov.Learning
{
using Accord.Statistics.Models.Markov;
using Accord.Statistics.Distributions;
using Accord.Statistics.Distributions.Fitting;

/// <summary>
/// Baum-Welch learning algorithms for learning Hidden Markov Models.
/// </summary>
///
/// <typeparam name="TDistribution">The type of the emission distributions in the model.</typeparam>
/// <typeparam name="TObservation">The type of the observations (i.e. int for a discrete model).</typeparam>
/// <typeparam name="TOptions">The type of fitting options accepted by this distribution.</typeparam>
///
/// <remarks>
/// Please see the <see cref="BaumWelchLearning{TDistribution, TObservation}"/> documentation page for
/// the actual documentation of this class, including examples.
/// </remarks>
///
public class BaumWelchLearning<TDistribution, TObservation, TOptions> :
BaseBaumWelchLearningOptions<HiddenMarkovModel<TDistribution, TObservation>, TDistribution, TObservation, TOptions>,
IConvergenceLearning
where TDistribution : IFittableDistribution<TObservation, TOptions>
where TOptions : class, IFittingOptions, new()
{

/// <summary>
/// Initializes a new instance of the <see cref="BaumWelchLearning{TDistribution, TObservation, TOptions}"/> class.
/// </summary>
///
public BaumWelchLearning()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BaumWelchLearning{TDistribution, TObservation, TOptions}"/> class.
/// </summary>
///
/// <param name="model">The model to be learned.</param>
///
public BaumWelchLearning(HiddenMarkovModel<TDistribution, TObservation> model)
: base(model)
{
}

/// <summary>
/// Creates an instance of the model to be learned. Inheritors of this abstract
/// class must define this method so new models can be created from the training data.
/// </summary>
///
protected override HiddenMarkovModel<TDistribution, TObservation> Create()
{
return new HiddenMarkovModel<TDistribution, TObservation>(Topology, Emissions);
}

}
}

0 comments on commit 9140baf

Please sign in to comment.