001/* 002 * Copyright (c) 2015-2020, Oracle and/or its affiliates. All rights reserved. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.tribuo.data.columnar.processors.response; 018 019import com.oracle.labs.mlrg.olcut.config.Config; 020import com.oracle.labs.mlrg.olcut.config.Configurable; 021import com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance; 022import com.oracle.labs.mlrg.olcut.provenance.Provenancable; 023import com.oracle.labs.mlrg.olcut.provenance.impl.ConfiguredObjectProvenanceImpl; 024 025/** 026 * A quartile to split data into 4 chunks. 027 */ 028public class Quartile implements Configurable, Provenancable<ConfiguredObjectProvenance> { 029 030 @Config(mandatory = true,description="The median value.") 031 private double median; 032 033 @Config(mandatory = true,description="The lower quartile value.") 034 private double lowerMedian; 035 036 @Config(mandatory = true,description="The upper quartile value.") 037 private double upperMedian; 038 039 /** 040 * Constructs a quartile with the specified values. 041 * @param median The median. 042 * @param lowerMedian The lower quartile. 043 * @param upperMedian The upper quartile. 044 */ 045 public Quartile(double median, double lowerMedian, double upperMedian) { 046 this.median = median; 047 this.lowerMedian = lowerMedian; 048 this.upperMedian = upperMedian; 049 } 050 051 /** 052 * For olcut. 053 */ 054 private Quartile() {} 055 056 /** 057 * Returns the median value. 058 * @return The median. 059 */ 060 public double getMedian() { 061 return median; 062 } 063 064 /** 065 * Returns the lower quartile value. 066 * @return The lower quartile value. 067 */ 068 public double getLowerMedian() { 069 return lowerMedian; 070 } 071 072 /** 073 * The upper quartile value. 074 * @return The upper quartile value. 075 */ 076 public double getUpperMedian() { 077 return upperMedian; 078 } 079 080 @Override 081 public String toString() { 082 return "Quartile(lowerMedian="+lowerMedian+",median="+median+",upperMedian="+upperMedian+")"; 083 } 084 085 @Override 086 public ConfiguredObjectProvenance getProvenance() { 087 return new ConfiguredObjectProvenanceImpl(this,"Quartile"); 088 } 089}