@Test @SuppressWarnings("unchecked") void explainServiceTest() { List<PredictInput> inputs = singletonList(createInput(40)); List<PredictOutput> outputs = (List<PredictOutput>) resource.predict(inputs).getBody(); assertNotNull(outputs); assertEquals(1, outputs.size()); PredictOutput output = outputs.get(0); assertNotNull(output.getResult()); assertNotNull(output.getModelIdentifier()); Map<String, Object> result = output.getResult(); assertTrue(result.containsKey("Should the driver be suspended?")); assertEquals("Yes", result.get("Should the driver be suspended?")); assertTrue(result.containsKey("Fine")); Map<String, Object> expectedFine = new HashMap<>(); expectedFine.put("Points", BigDecimal.valueOf(7)); expectedFine.put("Amount", BigDecimal.valueOf(1000)); assertEquals(expectedFine.get("Points"), ((Map<String, Object>)result.get("Fine")).get("Points")); assertEquals(expectedFine.get("Amount"), ((Map<String, Object>)result.get("Fine")).get("Amount")); }
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> predict(List<PredictInput> inputs) { try { return ResponseEntity.ok(explainabilityService.processRequest(application, inputs)); } catch (Exception e) { LOGGER.warn("An Exception occurred processing the predict request", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage()); } }
SpringBootExplainableResource { @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> predict(List<PredictInput> inputs) { try { return ResponseEntity.ok(explainabilityService.processRequest(application, inputs)); } catch (Exception e) { LOGGER.warn("An Exception occurred processing the predict request", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage()); } } }
SpringBootExplainableResource { @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> predict(List<PredictInput> inputs) { try { return ResponseEntity.ok(explainabilityService.processRequest(application, inputs)); } catch (Exception e) { LOGGER.warn("An Exception occurred processing the predict request", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage()); } } @Autowired  SpringBootExplainableResource(Application application); }
SpringBootExplainableResource { @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> predict(List<PredictInput> inputs) { try { return ResponseEntity.ok(explainabilityService.processRequest(application, inputs)); } catch (Exception e) { LOGGER.warn("An Exception occurred processing the predict request", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage()); } } @Autowired  SpringBootExplainableResource(Application application); @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> predict(List<PredictInput> inputs); }
SpringBootExplainableResource { @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> predict(List<PredictInput> inputs) { try { return ResponseEntity.ok(explainabilityService.processRequest(application, inputs)); } catch (Exception e) { LOGGER.warn("An Exception occurred processing the predict request", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage()); } } @Autowired  SpringBootExplainableResource(Application application); @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> predict(List<PredictInput> inputs);  }