/// <summary>
 ///   Creates a new <see cref="GridSearch{TModel, TRange, TLearner, TInput, TOutput}"/> algorithm.
 /// </summary>
 ///
 /// <typeparam name="TModel">The type of the machine learning model whose parameters should be searched.</typeparam>
 /// <typeparam name="TRange">The type that specifies how ranges of the parameter values are represented.</typeparam>
 /// <typeparam name="TLearner">The type of the learning algorithm used to learn <typeparamref name="TModel"/>.</typeparam>
 /// <typeparam name="TInput">The type of the input data. Default is double[].</typeparam>
 /// <typeparam name="TOutput">The type of the output data. Default is int.</typeparam>
 ///
 /// <param name="ranges">The range of parameters to consider during search.</param>
 /// <param name="learner">A function that can create a <typeparamref name="TModel"/> given training parameters.</param>
 /// <param name="loss">A function that can measure how far model predictions are from the expected ground-truth.</param>
 /// <param name="fit">A function that specifies how to create a new model using the teacher learning algorirhm.</param>
 /// <param name="x">The input data to be used during training.</param>
 /// <param name="y">The output data to be used during training.</param>
 ///
 /// <example>
 ///   <code source="Unit Tests\Accord.Tests.MachineLearning\GridSearchTest.cs" region="doc_learn_strongly_typed" />
 /// </example>
 ///
 /// <returns>A grid-search algorithm that has been configured with the given parameters.</returns>
 ///
 public static GridSearch <TModel, TRange, TLearner, TInput, TOutput> Create <TInput, TOutput, TRange, TModel, TLearner>(
     TRange ranges,
     CreateLearnerFromParameter <TLearner, TRange> learner,
     ComputeLoss <TOutput, TModel> loss,
     LearnNewModel <TLearner, TInput, TOutput, TModel> fit,
     TInput[] x, TOutput[] y)
     where TModel : class, ITransform <TInput, TOutput>
     where TLearner : ISupervisedLearning <TModel, TInput, TOutput>
 {
     return(GridSearch <TInput, TOutput> .Create(ranges, learner, loss, fit));
 }
Beispiel #2
0
 /// <summary>
 ///   Creates a new <see cref="GridSearch{TModel, TRange, TLearner, TInput, TOutput}"/> algorithm.
 /// </summary>
 ///
 /// <typeparam name="TInput">The type of the input data. Default is double[].</typeparam>
 /// <typeparam name="TOutput">The type of the output data. Default is int.</typeparam>
 /// <typeparam name="TModel">The type of the machine learning model whose parameters should be searched.</typeparam>
 /// <typeparam name="TLearner">The type of the learning algorithm used to learn <typeparamref name="TModel"/>.</typeparam>
 ///
 /// <param name="ranges">The range of parameters to consider during search.</param>
 /// <param name="learner">A function that can create a <typeparamref name="TModel"/> given training parameters.</param>
 /// <param name="loss">A function that can measure how far model predictions are from the expected ground-truth.</param>
 /// <param name="fit">A function that specifies how to create a new model using the teacher learning algorirhm.</param>
 /// <param name="x">The input data to be used during training.</param>
 /// <param name="y">The output data to be used during training.</param>
 /// <param name="weights">The weights of each instance in the trianing data.</param>
 ///
 /// <example>
 ///   <code source="Unit Tests\Accord.Tests.MachineLearning\GridSearchTest.cs" region="doc_create" />
 /// </example>
 ///
 /// <returns>A grid-search algorithm that has been configured with the given parameters.</returns>
 ///
 public static GridSearchResult <TModel, TInput, TOutput> Create <TInput, TOutput, TModel, TLearner>(
     GridSearchRange[] ranges,
     CreateLearnerFromParameter <TLearner, GridSearchParameterCollection> learner,
     ComputeLoss <TOutput, TModel> loss,
     LearnNewModel <TLearner, TInput, TOutput, TModel> fit,
     TInput[] x, TOutput[] y, double[] weights = null)
     where TModel : class, ITransform <TInput, TOutput>
     where TLearner : ISupervisedLearning <TModel, TInput, TOutput>
 {
     return(GridSearch <TInput, TOutput> .Create(ranges, learner, loss, fit).Learn(x, y, weights));
 }