/// <summary>
        /// Predicts using the specified proxy.
        /// </summary>
        /// <param name="proxy">The proxy.</param>
        /// <param name="model">The model.</param>
        /// <param name="data">The input data.</param>
        /// <returns>
        /// Predicted result.
        /// </returns>
        protected override double Predict(IMLServiceProxy proxy, MLModelConfig model,
                                          Dictionary <string, object> data)
        {
            var wrappedData = new List <Dictionary <string, object> > {
                data
            };

            return(proxy.Regress(model.ModelInstanceUId, wrappedData).FirstOrDefault());
        }
示例#2
0
        private IMLServiceProxy InitServiceProxy()
        {
            string serviceUrl = _modelConfig.ServiceUrl;

            serviceUrl.CheckArgumentNull("MLModelConfig.ServiceUrl");
            ConstructorArgument serviceUrlArg = new ConstructorArgument("serviceUrl", serviceUrl);
            ConstructorArgument apiKeyArg     = new ConstructorArgument("apiKey", ApiKey);
            IMLServiceProxy     proxy         = ClassFactory.Get <IMLServiceProxy>(serviceUrlArg, apiKeyArg);

            return(proxy);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MLModelTrainer"/> class.
        /// </summary>
        /// <param name="userConnection">The user connection.</param>
        /// <param name="modelConfig">The model configuration.</param>
        public MLModelTrainer(UserConnection userConnection, MLModelConfig modelConfig)
        {
            userConnection.CheckArgumentNull("userConnection");
            modelConfig.CheckArgumentNull("modelConfig");
            modelConfig.Id.CheckArgumentEmpty("MLModelConfig.Id");
            _userConnection = userConnection;
            _modelConfig    = modelConfig;
            _proxy          = InitServiceProxy();
            ConstructorArgument userConnectionArg = new ConstructorArgument("userConnection", _userConnection);

            _modelEventsNotifier = ClassFactory.Get <MLModelEventsNotifier>(userConnectionArg);
            _metadataGenerator   = ClassFactory.Get <IMLMetadataGenerator>();
            _queryBuilder        = ClassFactory.Get <IMLModelQueryBuilder>(userConnectionArg);
        }
        private List <ClassificationResult> QueryPrediction(Dictionary <string, object> classifyData)
        {
            var                         apiKey                = BpmonlineCloudEngine.GetAPIKey(_userConnection);
            var                         serviceUrlArg         = new ConstructorArgument("serviceUrl", ServiceUrl);
            var                         apiKeyArg             = new ConstructorArgument("apiKey", apiKey);
            IMLServiceProxy             proxy                 = ClassFactory.Get <IMLServiceProxy>(serviceUrlArg, apiKeyArg);
            List <ClassificationResult> classificationResults = null;

            try {
                classificationResults = proxy.Classify(ModelInstanceUId, classifyData);
            } catch (Exception e) {
                _log.ErrorFormat("Classification failed with error: {0}", e, e.Message);
            }
            return(classificationResults);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MLDataUploader"/> class.
 /// </summary>
 /// <param name="mlServiceProxy">The machine learning service proxy.</param>
 /// <param name="sessionId">The training session identifier.</param>
 /// <param name="loader">The loader.</param>
 public MLDataUploader(IMLServiceProxy mlServiceProxy, Guid sessionId, IMLDataLoader loader)
 {
     _mlServiceProxy = mlServiceProxy;
     _sessionId      = sessionId;
     _mlDataLoader   = loader;
 }
示例#6
0
 /// <summary>
 /// Predicts numeric value for the specified model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="dataForPrediction">The data for prediction.</param>
 /// <param name="proxy">The proxy.</param>
 /// <returns>Numeric value result.</returns>
 protected abstract List <double> Predict(MLModelConfig model,
                                          IList <Dictionary <string, object> > dataForPrediction, IMLServiceProxy proxy);
示例#7
0
 /// <summary>
 /// Predicts results for the given batch of records.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="dataList">Batch of records.</param>
 /// <param name="proxy">ML service proxy.</param>
 /// <returns>Prediction result.</returns>
 protected override List <ScoringOutput> Predict(MLModelConfig model,
                                                 IList <Dictionary <string, object> > dataList, IMLServiceProxy proxy)
 {
     return(proxy.Score(model, dataList, true));
 }
示例#8
0
 /// <summary>
 /// Predicts using the specified proxy.
 /// </summary>
 /// <param name="proxy">The proxy.</param>
 /// <param name="model">The model.</param>
 /// <param name="data">The input data.</param>
 /// <returns>
 /// Predicted result.
 /// </returns>
 protected override ScoringOutput Predict(IMLServiceProxy proxy, MLModelConfig model,
                                          Dictionary <string, object> data)
 {
     return(proxy.Score(model, data, true));
 }
 /// <summary>
 /// Predicts results for the given batch of records.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="dataForPrediction"></param>
 /// <param name="proxy">ML service proxy.</param>
 /// <returns>
 /// Prediction result.
 /// </returns>
 /// <exception cref="System.NotImplementedException"></exception>
 protected override List <double> Predict(MLModelConfig model, IList <Dictionary <string, object> > dataList,
                                          IMLServiceProxy proxy)
 {
     return(proxy.Regress(model.ModelInstanceUId, dataList));
 }
示例#10
0
 /// <summary>
 /// Predicts results for the given batch of records. Not implemented for current problem type.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="dataForPrediction"></param>
 /// <param name="proxy">ML service proxy.</param>
 /// <returns>
 /// Prediction result.
 /// </returns>
 /// <exception cref="System.NotImplementedException"></exception>
 protected override List <List <ClassificationResult> > Predict(MLModelConfig model,
                                                                IList <Dictionary <string, object> > dataForPrediction, IMLServiceProxy proxy)
 {
     throw new NotImplementedException();
 }
示例#11
0
 /// <summary>
 /// Predicts using the specified proxy.
 /// </summary>
 /// <param name="proxy">The proxy.</param>
 /// <param name="model">The model.</param>
 /// <param name="data">The input data.</param>
 /// <returns>
 /// Predicted result.
 /// </returns>
 protected override List <ClassificationResult> Predict(IMLServiceProxy proxy, MLModelConfig model,
                                                        Dictionary <string, object> data)
 {
     return(proxy.Classify(model.ModelInstanceUId, data));
 }
        /// <summary>
        /// Scores value for the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="dataForPrediction">The data for prediction.</param>
        /// <param name="proxy">The proxy.</param>
        /// <returns>
        /// Numeric value result.
        /// </returns>
        protected override List <double> Predict(MLModelConfig model,
                                                 IList <Dictionary <string, object> > dataForPrediction, IMLServiceProxy proxy)
        {
            List <ScoringOutput> predictionResults = proxy.Score(model, dataForPrediction, false);
            List <double>        scores            = predictionResults.Select(output => output.Score).ToList();

            return(scores);
        }
        /// <summary>
        /// Predicts numeric value for the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="dataForPrediction">The data for prediction.</param>
        /// <param name="proxy">The proxy.</param>
        /// <returns>
        /// Numeric value result.
        /// </returns>
        protected override List <double> Predict(MLModelConfig model,
                                                 IList <Dictionary <string, object> > dataForPrediction, IMLServiceProxy proxy)
        {
            List <double> predictionResults = proxy.Regress(model.ModelInstanceUId, dataForPrediction);

            return(predictionResults);
        }