RegularizerBuilder.java

  1. package org.drip.learning.regularization;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

  5. /*!
  6.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  7.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  8.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  9.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  11.  * Copyright (C) 2015 Lakshmi Krishnamurthy
  12.  *
  13.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  14.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  15.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  16.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  17.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  18.  *      and computational support.
  19.  *  
  20.  *      https://lakshmidrip.github.io/DROP/
  21.  *  
  22.  *  DROP is composed of three modules:
  23.  *  
  24.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  25.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  26.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  27.  *
  28.  *  DROP Product Core implements libraries for the following:
  29.  *  - Fixed Income Analytics
  30.  *  - Loan Analytics
  31.  *  - Transaction Cost Analytics
  32.  *
  33.  *  DROP Portfolio Core implements libraries for the following:
  34.  *  - Asset Allocation Analytics
  35.  *  - Asset Liability Management Analytics
  36.  *  - Capital Estimation Analytics
  37.  *  - Exposure Analytics
  38.  *  - Margin Analytics
  39.  *  - XVA Analytics
  40.  *
  41.  *  DROP Computational Core implements libraries for the following:
  42.  *  - Algorithm Support
  43.  *  - Computation Support
  44.  *  - Function Analysis
  45.  *  - Model Validation
  46.  *  - Numerical Analysis
  47.  *  - Numerical Optimizer
  48.  *  - Spline Builder
  49.  *  - Statistical Learning
  50.  *
  51.  *  Documentation for DROP is Spread Over:
  52.  *
  53.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  54.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  55.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  56.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  57.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  58.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  59.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  60.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  61.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  62.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  63.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  64.  *
  65.  *  Licensed under the Apache License, Version 2.0 (the "License");
  66.  *      you may not use this file except in compliance with the License.
  67.  *  
  68.  *  You may obtain a copy of the License at
  69.  *      http://www.apache.org/licenses/LICENSE-2.0
  70.  *  
  71.  *  Unless required by applicable law or agreed to in writing, software
  72.  *      distributed under the License is distributed on an "AS IS" BASIS,
  73.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  74.  *  
  75.  *  See the License for the specific language governing permissions and
  76.  *      limitations under the License.
  77.  */

  78. /**
  79.  * <i>RegularizerBuilder</i> constructs Custom Regularizers for the different Normed Learner Function Types.
  80.  * The References are:
  81.  *  
  82.  * <br><br>
  83.  * <ul>
  84.  *  <li>
  85.  *      Alon, N., S. Ben-David, N. Cesa Bianchi, and D. Haussler (1997): Scale-sensitive Dimensions, Uniform
  86.  *          Convergence, and Learnability <i>Journal of Association of Computational Machinery</i> <b>44
  87.  *          (4)</b> 615-631
  88.  *  </li>
  89.  *  <li>
  90.  *      Anthony, M., and P. L. Bartlett (1999): <i>Artificial Neural Network Learning - Theoretical
  91.  *          Foundations</i> <b>Cambridge University Press</b> Cambridge, UK
  92.  *  </li>
  93.  *  <li>
  94.  *      Kearns, M. J., R. E. Schapire, and L. M. Sellie (1994): <i>Towards Efficient Agnostic Learning</i>
  95.  *          Machine Learning <b>17 (2)</b> 115-141
  96.  *  </li>
  97.  *  <li>
  98.  *      Lee, W. S., P. L. Bartlett, and R. C. Williamson (1998): The Importance of Convexity in Learning with
  99.  *          Squared Loss <i>IEEE Transactions on Information Theory</i> <b>44</b> 1974-1980
  100.  *  </li>
  101.  *  <li>
  102.  *      Vapnik, V. N. (1998): <i>Statistical learning Theory</i> <b>Wiley</b> New York
  103.  *  </li>
  104.  * </ul>
  105.  *
  106.  *  <br><br>
  107.  *  <ul>
  108.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  109.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/StatisticalLearningLibrary.md">Statistical Learning</a></li>
  110.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/learning">Agnostic Learning Bounds under Empirical Loss Minimization Schemes</a></li>
  111.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/learning/regularization">Statistical Learning Empirical Loss Regularizer</a></li>
  112.  *  </ul>
  113.  *
  114.  * @author Lakshmi Krishnamurthy
  115.  */

  116. public class RegularizerBuilder {

  117.     /**
  118.      * Construct an Instance of R^1 Combinatorial To R^1 Continuous Regularizer
  119.      *
  120.      * @param funcRegularizerR1ToR1 The R^1 To R^1 Regularizer Function
  121.      * @param funcSpaceR1ToR1 The R^1 Combinatorial To R^1 Continuous Learner Function Space
  122.      * @param dblLambda The Regularization Lambda
  123.      *
  124.      * @return The R^1 Combinatorial To R^1 Continuous Regularizer Instance
  125.      */

  126.     public static final org.drip.learning.regularization.RegularizerR1ToR1 R1CombinatorialToR1Continuous (
  127.         final org.drip.function.definition.R1ToR1 funcRegularizerR1ToR1,
  128.         final org.drip.spaces.rxtor1.NormedR1CombinatorialToR1Continuous funcSpaceR1ToR1,
  129.         final double dblLambda)
  130.     {
  131.         try {
  132.             return null == funcSpaceR1ToR1 ? null : new
  133.                 org.drip.learning.regularization.RegularizerR1CombinatorialToR1Continuous
  134.                     (funcRegularizerR1ToR1, (org.drip.spaces.metric.R1Combinatorial)
  135.                         funcSpaceR1ToR1.inputMetricVectorSpace(), (org.drip.spaces.metric.R1Continuous)
  136.                             funcSpaceR1ToR1.outputMetricVectorSpace(), dblLambda);
  137.         } catch (java.lang.Exception e) {
  138.             e.printStackTrace();
  139.         }

  140.         return null;
  141.     }

  142.     /**
  143.      * Construct an Instance of R^1 Continuous To R^1 Continuous Regularizer
  144.      *
  145.      * @param funcRegularizerR1ToR1 The R^1 To R^1 Regularizer Function
  146.      * @param funcSpaceR1ToR1 The R^1 Continuous To R^1 Continuous Learner Function Space
  147.      * @param dblLambda The Regularization Lambda
  148.      *
  149.      * @return The R^1 Continuous To R^1 Continuous Regularizer Instance
  150.      */

  151.     public static final org.drip.learning.regularization.RegularizerR1ToR1 R1ContinuousToR1Continuous (
  152.         final org.drip.function.definition.R1ToR1 funcRegularizerR1ToR1,
  153.         final org.drip.spaces.rxtor1.NormedR1ContinuousToR1Continuous funcSpaceR1ToR1,
  154.         final double dblLambda)
  155.     {
  156.         try {
  157.             return null == funcSpaceR1ToR1 ? null : new
  158.                 org.drip.learning.regularization.RegularizerR1ContinuousToR1Continuous
  159.                     (funcRegularizerR1ToR1, (org.drip.spaces.metric.R1Continuous)
  160.                         funcSpaceR1ToR1.inputMetricVectorSpace(), (org.drip.spaces.metric.R1Continuous)
  161.                             funcSpaceR1ToR1.outputMetricVectorSpace(), dblLambda);
  162.         } catch (java.lang.Exception e) {
  163.             e.printStackTrace();
  164.         }

  165.         return null;
  166.     }

  167.     /**
  168.      * Construct an Instance of R^1 Combinatorial/Continuous To R^1 Continuous Regularizer
  169.      *
  170.      * @param funcRegularizerR1ToR1 The R^1 To R^1 Regularizer Function
  171.      * @param r1Input The R^1 Combinatorial/Continuous Input Space
  172.      * @param r1ContinuousOutput The R^1 Continuous Output Space
  173.      * @param dblLambda The Regularization Lambda
  174.      *
  175.      * @return The R^1 Combinatorial/Continuous To R^1 Continuous Regularizer Instance
  176.      */

  177.     public static final org.drip.learning.regularization.RegularizerR1ToR1 ToR1Continuous (
  178.         final org.drip.function.definition.R1ToR1 funcRegularizerR1ToR1,
  179.         final org.drip.spaces.metric.R1Normed r1Input,
  180.         final org.drip.spaces.metric.R1Continuous r1ContinuousOutput,
  181.         final double dblLambda)
  182.     {
  183.         if (null == r1Input) return null;

  184.         try {
  185.             if (r1Input instanceof org.drip.spaces.metric.R1Continuous)
  186.                 return new org.drip.learning.regularization.RegularizerR1ContinuousToR1Continuous
  187.                     (funcRegularizerR1ToR1, (org.drip.spaces.metric.R1Continuous) r1Input,
  188.                         r1ContinuousOutput, dblLambda);

  189.             return new org.drip.learning.regularization.RegularizerR1CombinatorialToR1Continuous
  190.                 (funcRegularizerR1ToR1, (org.drip.spaces.metric.R1Combinatorial) r1Input,
  191.                     r1ContinuousOutput, dblLambda);
  192.         } catch (java.lang.Exception e) {
  193.             e.printStackTrace();
  194.         }

  195.         return null;
  196.     }

  197.     /**
  198.      * Construct an Instance of R^d Combinatorial To R^1 Continuous Regularizer
  199.      *
  200.      * @param funcRegularizerRdToR1 The R^d To R^1 Regularizer Function
  201.      * @param funcSpaceRdToR1 The R^d Combinatorial To R^1 Continuous Learner Function Space
  202.      * @param dblLambda The Regularization Lambda
  203.      *
  204.      * @return The R^d Combinatorial To R^1 Continuous Regularizer Instance
  205.      */

  206.     public static final org.drip.learning.regularization.RegularizerRdToR1 RdCombinatorialToR1Continuous (
  207.         final org.drip.function.definition.RdToR1 funcRegularizerRdToR1,
  208.         final org.drip.spaces.rxtor1.NormedRdCombinatorialToR1Continuous funcSpaceRdToR1,
  209.         final double dblLambda)
  210.     {
  211.         try {
  212.             return null == funcSpaceRdToR1 ? null : new
  213.                 org.drip.learning.regularization.RegularizerRdCombinatorialToR1Continuous
  214.                     (funcRegularizerRdToR1, (org.drip.spaces.metric.RdCombinatorialBanach)
  215.                         funcSpaceRdToR1.inputMetricVectorSpace(), (org.drip.spaces.metric.R1Continuous)
  216.                             funcSpaceRdToR1.outputMetricVectorSpace(), dblLambda);
  217.         } catch (java.lang.Exception e) {
  218.             e.printStackTrace();
  219.         }

  220.         return null;
  221.     }

  222.     /**
  223.      * Construct an Instance of R^d Continuous To R^1 Continuous Regularizer
  224.      *
  225.      * @param funcRegularizerRdToR1 The R^d To R^1 Regularizer Function
  226.      * @param funcSpaceRdToR1 The R^d Continuous To R^1 Continuous Learner Function Space
  227.      * @param dblLambda The Regularization Lambda
  228.      *
  229.      * @return The R^d Continuous To R^1 Continuous Regularizer Instance
  230.      */

  231.     public static final org.drip.learning.regularization.RegularizerRdToR1 RdContinuousToR1Continuous (
  232.         final org.drip.function.definition.RdToR1 funcRegularizerRdToR1,
  233.         final org.drip.spaces.rxtor1.NormedRdContinuousToR1Continuous funcSpaceRdToR1,
  234.         final double dblLambda)
  235.     {
  236.         try {
  237.             return null == funcSpaceRdToR1 ? null : new
  238.                 org.drip.learning.regularization.RegularizerRdContinuousToR1Continuous
  239.                     (funcRegularizerRdToR1, (org.drip.spaces.metric.RdContinuousBanach)
  240.                         funcSpaceRdToR1.inputMetricVectorSpace(), (org.drip.spaces.metric.R1Continuous)
  241.                             funcSpaceRdToR1.outputMetricVectorSpace(), dblLambda);
  242.         } catch (java.lang.Exception e) {
  243.             e.printStackTrace();
  244.         }

  245.         return null;
  246.     }

  247.     /**
  248.      * Construct an Instance of R^d Combinatorial/Continuous To R^1 Continuous Regularizer
  249.      *
  250.      * @param funcRegularizerRdToR1 The R^d To R^1 Regularizer Function
  251.      * @param rdInput The R^d Combinatorial/Continuous Input Space
  252.      * @param r1ContinuousOutput The R^1 Continuous Output Space
  253.      * @param dblLambda The Regularization Lambda
  254.      *
  255.      * @return The R^1 Combinatorial/Continuous To R^1 Continuous Regularizer Instance
  256.      */

  257.     public static final org.drip.learning.regularization.RegularizerRdToR1 ToRdContinuous (
  258.         final org.drip.function.definition.RdToR1 funcRegularizerRdToR1,
  259.         final org.drip.spaces.metric.RdNormed rdInput,
  260.         final org.drip.spaces.metric.R1Continuous r1ContinuousOutput,
  261.         final double dblLambda)
  262.     {
  263.         if (null == rdInput) return null;

  264.         try {
  265.             if (rdInput instanceof org.drip.spaces.metric.RdContinuousBanach)
  266.                 return new org.drip.learning.regularization.RegularizerRdContinuousToR1Continuous
  267.                     (funcRegularizerRdToR1, (org.drip.spaces.metric.RdContinuousBanach) rdInput,
  268.                         r1ContinuousOutput, dblLambda);

  269.             return new org.drip.learning.regularization.RegularizerRdCombinatorialToR1Continuous
  270.                 (funcRegularizerRdToR1, (org.drip.spaces.metric.RdCombinatorialBanach) rdInput,
  271.                     r1ContinuousOutput, dblLambda);
  272.         } catch (java.lang.Exception e) {
  273.             e.printStackTrace();
  274.         }

  275.         return null;
  276.     }
  277. }