예제 #1
0
 /// <summary>
 /// Loads a predictor from the model stream. Returns null iff there's no predictor.
 /// </summary>
 public static IPredictor LoadPredictorOrNull(IHostEnvironment env, Stream modelStream)
 {
     Contracts.CheckValue(env, nameof(env));
     Contracts.CheckValue(modelStream, nameof(modelStream));
     using (var rep = RepositoryReader.Open(modelStream, env))
         return(LoadPredictorOrNull(env, rep));
 }
예제 #2
0
 /// <summary>
 /// Returns the <see cref="RoleMappedSchema"/> from a model stream, or <c>null</c> if there were no
 /// role mappings present.
 /// </summary>
 public static RoleMappedSchema LoadRoleMappedSchemaOrNull(IHostEnvironment env, Stream modelStream)
 {
     Contracts.CheckValue(env, nameof(env));
     env.CheckValue(modelStream, nameof(modelStream));
     using (var rep = RepositoryReader.Open(modelStream, env))
     {
         return(LoadRoleMappedSchemaOrNull(env, rep));
     }
 }
예제 #3
0
 /// <summary>
 /// Return role/column-name pairs loaded from <paramref name="modelStream"/>.
 /// </summary>
 public static IEnumerable <KeyValuePair <ColumnRole, string> > LoadRoleMappingsOrNull(IHostEnvironment env, Stream modelStream)
 {
     Contracts.CheckValue(env, nameof(env));
     env.CheckValue(modelStream, nameof(modelStream));
     using (var rep = RepositoryReader.Open(modelStream, env))
     {
         return(LoadRoleMappingsOrNull(env, rep));
     }
 }
예제 #4
0
 /// <summary>
 /// Loads all transforms from the model stream, applies them sequentially to the provided data, and returns
 /// the resulting data. If there are no transforms in the stream, or if there's no DataLoader stream at all
 /// (this can happen if the model is produced by old TL), returns the source data.
 /// If the DataLoader stream is invalid, throws.
 /// </summary>
 /// <param name="env">The host environment to use.</param>
 /// <param name="data">The starting data view.</param>
 /// <param name="modelStream">The model stream.</param>
 /// <returns>The resulting data view.</returns>
 public static IDataView LoadTransforms(IHostEnvironment env, IDataView data, Stream modelStream)
 {
     // REVIEW: Consolidate with LoadTransformChain in DataDiagnosticsCommand.
     Contracts.CheckValue(env, nameof(env));
     env.CheckValue(data, nameof(data));
     env.CheckValue(modelStream, nameof(modelStream));
     using (var rep = RepositoryReader.Open(modelStream, env))
     {
         return(LoadTransforms(env, data, rep));
     }
 }
예제 #5
0
 /// <summary>
 /// Loads and returns the loader and transforms from the specified model stream.
 /// </summary>
 /// <param name="env">The host environment to use.</param>
 /// <param name="modelStream">The model stream.</param>
 /// <param name="files">The data source to initialize the loader with.</param>
 /// <param name="extractInnerPipe">Whether to extract the transforms and loader from the wrapped CompositeDataLoader.</param>
 /// <returns>The created data view.</returns>
 public static IDataView LoadPipeline(IHostEnvironment env, Stream modelStream, IMultiStreamSource files, bool extractInnerPipe = false)
 {
     // REVIEW: Should not duplicate loading loader/transforms code. This method should call LoadLoader.
     Contracts.CheckValue(env, nameof(env));
     env.CheckValue(modelStream, nameof(modelStream));
     env.CheckValue(files, nameof(files));
     using (var rep = RepositoryReader.Open(modelStream, env))
     {
         return(LoadPipeline(env, rep, files, extractInnerPipe));
     }
 }