日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > java >内容正文

java

Java机器学习,第2部分

發(fā)布時(shí)間:2023/12/3 java 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java机器学习,第2部分 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

歡迎使用本教程的第二部分,該教程使用LightningScorer評(píng)分PMML文件。

讓我們找出其他參數(shù)是如何工作的。

初始步驟與教程的第一部分相似。

首先獲取本地副本

git clone https://github.com/sezinkarli/lightningscorer.git

并用Maven構(gòu)建

mvn clean install

并通過(guò)轉(zhuǎn)到目標(biāo)文件夾開(kāi)始

java -jar lightningscorer-uberjar-1.0.jar

現(xiàn)在,通過(guò)轉(zhuǎn)到以下步驟來(lái)確保我們的服務(wù)器已啟動(dòng)并正在運(yùn)行

http://localhost:8080/

。

服務(wù)器退貨

{ "data": "I have come here to chew bubblegum and kick ass...", "success": true }

好吧,現(xiàn)在我們可以再次踢屁股。

我將使用apache commons的http get / post方法。 首先,我們將使用其他參數(shù)來(lái)部署我們的機(jī)器學(xué)習(xí)模型。 然后,我們將檢查它是否正常工作,然后使用我們的輸入值進(jìn)行評(píng)分。 計(jì)分之后,我們將使用其他參數(shù)。

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 + "?variance=3.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

總結(jié)

以上是生活随笔為你收集整理的Java机器学习,第2部分的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。