流行的网站开发技术,教育机构线上推广方案,家装公司起名,北京专业网站设计制作机器学习java欢迎使用本教程的第二部分#xff0c;该教程使用LightningScorer为PMML文件评分。 让我们找出其他参数是如何工作的。 初始步骤与教程的第一部分相似。 首先获取本地副本 git clone https://github.com/sezinkarli/lightningscorer.git并用Maven构建它 mvn c… 机器学习java 欢迎使用本教程的第二部分该教程使用LightningScorer为PMML文件评分。 让我们找出其他参数是如何工作的。 初始步骤与教程的第一部分相似。 首先获取本地副本 git clone https://github.com/sezinkarli/lightningscorer.git 并用Maven构建它 mvn clean install 并通过转到目标文件夹开始 java -jar lightningscorer-uberjar-1.0.jar 现在通过转到以下步骤来确保我们的服务器已启动并正在运行 http://localhost:8080/ 。 服务器退货 {
data: I have come here to chew bubblegum and kick ass...,
success: true
} 好吧现在我们可以再次踢屁股。 我将使用apache commons的http get / post方法。 首先我们将使用其他参数来部署我们的机器学习模型。 然后我们将检查它是否正常工作然后使用我们的输入值进行评分。 计分之后我们将使用其他参数。 final String url http://localhost:8080/model/;final String modelId test2;//http://dmg.org/pmml/pmml_examples/knime_pmml_examples/ElNinoPolReg.xmlFile pmmlFile new File(/tmp/ElNinoPolReg.xml);CloseableHttpClient client HttpClients.createDefault();// deployment// notice that I give a variance value as an additional parameter that I will use laterHttpPost deployPost new HttpPost(url modelId ?variance3.25);MultipartEntityBuilder builder MultipartEntityBuilder.create();builder.addBinaryBody(model, new File(pmmlFile.getAbsolutePath()), ContentType.APPLICATION_OCTET_STREAM, model);HttpEntity multipart builder.build();deployPost.setEntity(multipart);CloseableHttpResponse response client.execute(deployPost);String deployResponse IOUtils.toString(response.getEntity().getContent(), Charset.forName(UTF-8));System.out.println(deployResponse);// {data:true,success:true}deployPost.releaseConnection();// check deployed modelHttpGet httpGet new HttpGet(url ids);response client.execute(httpGet);String getAllModelsResponse IOUtils.toString(response.getEntity().getContent(), Charset.forName(UTF-8));System.out.println(getAllModelsResponse);// {data:[test1],success:true}httpGet.releaseConnection();//score deployed modelHttpPost scorePost new HttpPost(url modelId /score);StringEntity params new StringEntity({ \fields\: {\latitude\:2.5, \longitude\:11.4, \zon_winds\:3.5, \mer_winds\:3, \humidity\:31.2, \s_s_temp\:25.21 } } );scorePost.addHeader(content-type, application/json);scorePost.setEntity(params);CloseableHttpResponse response2 client.execute(scorePost);String scoreResponse IOUtils.toString(response2.getEntity().getContent(), Charset.forName(UTF-8));System.out.println(scoreResponse);// {data:{result:{airtemp:29.788226026392735}},success:true}scorePost.releaseConnection();HttpGet additionalParamGet new HttpGet(url modelId /additional);CloseableHttpResponse response3 client.execute(additionalParamGet);String additionalParamResponse IOUtils.toString(response3.getEntity().getContent(), Charset.forName(UTF-8));System.out.println(additionalParamResponse);// {data:{variance:3.25},success:true}additionalParamGet.releaseConnection();// Then you can use the variance value with your result in airtemp to calculate an interval for your scoreclient.close();翻译自: https://www.javacodegeeks.com/2018/06/machine-learning-java-part-2.html机器学习java