private static void SaveModelAsFile(LocalEnvironment env, TransformerChain <BinaryPredictionTransformer <Microsoft.ML.Runtime.Internal.Internallearn.IPredictorWithFeatureWeights <float> > > model) { using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write)) model.SaveTo(env, fs); Console.WriteLine("The model is saved to {0}", ModelPath); }
private static void SaveModelAsFile(LocalEnvironment env, TransformerChain <ClusteringPredictionTransformer <KMeansPredictor> > model) { using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write)) model.SaveTo(env, fs); Console.WriteLine("The model is saved to {0}", ModelPath); }
private static void PerformStep6(TransformerChain <RegressionPredictionTransformer <LinearRegressionPredictor> > trainedModel, IHostEnvironment mlContext) { byte[] bytes; using (var stream = new MemoryStream()) { trainedModel.SaveTo(mlContext, stream); bytes = stream.ToArray(); } Redis.GetDatabase(1).StringSet("tm", bytes); }