Exemplo n.º 1
0
 public TwitAnalyzer(
     ITwitIndexer twitIndexer,
     IIndexerSettings settings,
     BayesAnalyzer bayesAnalyzer,
     MachineLearningAnalyzer <LinearRegressionEstimatorProvider> linearRegressionAnalyzer,
     MachineLearningAnalyzer <RandomForestEstimatorProvider> randomForestAnalyzer)
 {
     _twitIndexer              = twitIndexer;
     _settings                 = settings;
     _bayesAnalyzer            = bayesAnalyzer;
     _linearRegressionAnalyzer = linearRegressionAnalyzer;
     _randomForestAnalyzer     = randomForestAnalyzer;
 }
Exemplo n.º 2
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddSingleton(sp =>
            {
                var nodes = new[]
                {
                    new Uri("http://40.115.48.238:9200"),
                };

                var pool = new StaticConnectionPool(nodes);

                var settings = new ConnectionSettings(pool);
                settings.BasicAuthentication("elastic", "MyPa$$w0rd123");

                return(new ElasticClient(settings));
            });

            builder.Services.AddSingleton <ITwitIndexer, ElasticTwitIndexer>();
            builder.Services.AddSingleton <IIndexerSettings>(sp => new Settings(GetConfiguration()));

            var dataSetBlob = GetBlob("datasets", "bayes-dataset.csv");

            var bayesAnalyzer = BayesAnalyzer.GetTrained(dataSetBlob);

            builder.Services.AddSingleton(bayesAnalyzer);

            var linearSvmAnalyzer = MachineLearningAnalyzer <LinearSvmEstimatorProvider>
                                    .GetTrained(dataSetBlob);

            builder.Services.AddSingleton(linearSvmAnalyzer);

            var linearRegressionAnalyzer = MachineLearningAnalyzer <LinearRegressionEstimatorProvider>
                                           .GetTrained(dataSetBlob);

            builder.Services.AddSingleton(linearRegressionAnalyzer);

            var randomForestAnalyzer = MachineLearningAnalyzer <RandomForestEstimatorProvider>
                                       .GetTrained(dataSetBlob);

            builder.Services.AddSingleton(randomForestAnalyzer);
        }