网站建设宣传的目的,做房产网站需要了解什么,客户管理系统网站模板下载,高端网站建设费用情况机器学习java您搜索了某种导出机器学习模型的方法#xff0c;以便可以将它们用于评估数据#xff0c;并且可以将它们导出为PMML格式。 您实际上是在Java生态系统中工作的#xff0c;但没有动机为它编写PMML库或rest api。 然后#xff0c;我将向您推荐LightningScorer 以便可以将它们用于评估数据并且可以将它们导出为PMML格式。 您实际上是在Java生态系统中工作的但没有动机为它编写PMML库或rest api。 然后我将向您推荐LightningScorer 这是我的附带项目。 让我们带您参观部署和评分机器学习模型的过程。 首先获取本地副本 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方法。 首先我们将部署我们的机器学习模型。 然后我们将检查它是否安全无害然后使用我们的输入值对其进行评分。 我们将使用经过UCI机器学习存储库中虹膜数据集训练的决策树。 我们将发送4个参数萼片长度和宽度以及花瓣长度和宽度并且模型会将其分类为3个值之一。 final String url http://localhost:8080/model/;
final String modelId test1;//http://dmg.org/pmml/pmml_examples/KNIME_PMML_4.1_Examples/single_iris_dectree.xml
File pmmlFile new File(/tmp/single_iris_dectree.xml);CloseableHttpClient client HttpClients.createDefault();//first we will deploy our pmml file
HttpPost deployPost new HttpPost(url modelId);
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);
// response is {data:true,success:true}
deployPost.releaseConnection();//now we check the model
HttpGet httpGet new HttpGet(url ids);
response client.execute(httpGet);
String getAllModelsResponse IOUtils.toString(response.getEntity().getContent(), Charset.forName(UTF-8));
System.out.println(getAllModelsResponse);
// response is {data:[test1],success:true}
httpGet.releaseConnection();// lets score our deployed mode with parameters below
HttpPost scorePost new HttpPost(url modelId /score);
StringEntity params new StringEntity({ \fields\: {\sepal_length\:4.5, \sepal_width\:3.5, \petal_length\:3.5, \petal_width\:1 } } );
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);
//response is{data:{result:{class:Iris-versicolor}},success:true}
scorePost.releaseConnection();client.close();翻译自: https://www.javacodegeeks.com/2018/05/machine-learning-in-java-part-1.html机器学习java