Giter VIP home page Giter VIP logo

titl_mars_opt's Introduction

TITL MARS OPT Python code

by Xinglong Ju ([email protected], [email protected]); Jay M. Rosenberger ([email protected]); Victoria C. P. Chen ([email protected]); Feng Liu ([email protected]).

Xinglong Ju, Jay M. Rosenberger, Victoria C. P. Chen, and Feng Liu. "TITL MARS OPT Python code". 2020. DOI

Xinglong Ju, Jay M. Rosenberger, Victoria CP Chen, and Feng Liu. "Global optimization using mixed integer quadratic programming on non-convex two-way interaction truncated linear multivariate adaptive regression splines." arXiv preprint arXiv:2006.15707 (2020). DOI

Xinglong Ju
School of Civil and Environmental Engineering, Cornell University, Ithaca, NY 14853, USA

Jay M. Rosenberger, and Victoria C. P. Chen
Department of Industrial, Manufacturing, & Systems Engineering, The University of Texas at Arlington, Arlington, TX 76019, USA

Feng Liu
Department of Anesthesia, Critical Care and Pain Medicine, Massachusetts General Hospital, Harvard Medical School, Boston, MA 02114, USA
The Picower The Picower Institute for Learning and Memory, Massachusetts Institute of Technology, Cambridge, MA 02139, USA

TITL MARS OPT is short for two-way interaction truncated linear multivariate adaptive regression splines optimization.

This python code is accompanied by "Global optimization using mixed integer quadratic programming on non-convex two-way interaction truncated linear multivariate adaptive regression splines".

Reference

[1] Xinglong Ju, and Victoria C. P. Chen. "A MARS Python version using truncated linear function." 2019. DOI

TITL MARS OPT Python code guide

Import necessary libraries

import numpy as np
import pandas as pd
import MARS
from datetime import datetime
from MARS_OPT import *
import time

This part is train the TITL MARS model.

#parameters to train the MARS model
# number of independent variables, user could change this parameter
n_variables = 2
# size of training dataset, user could change this parameter
n_points = 1000
# specify the number of candidate knots to train the MARS model, user could change this parameter
n_candidate_knots = [40, 40]
# number of maximum basis functions, user could change this parameter
n_max_basis_functions = 100
# maximum degree of interaction terms
# Must be 2 for TITL MARS
n_max_interactions = 2
# a stopping criteria, user could change this parameter
difference = 1.0e-3

# load the training X
x_original = pd.read_csv("x.dat", header=None, nrows=n_points, delim_whitespace=True)
x_original = x_original.values

# load the training Y
y_original = pd.read_csv("y.dat", header=None, nrows=n_points, delim_whitespace=True)
y_original = y_original.values

# create the MARS object
mars = MARS.MARS(n_variables=n_variables, n_points=n_points, x=x_original, y=y_original,
                 n_candidate_knots=n_candidate_knots, n_max_basis_functions=n_max_basis_functions,
                 n_max_interactions=n_max_interactions, difference=difference)
# train the TITL MARS model
mars.MARS_regress()
# save the MARS model to a file
mars.save_mars_model_to_file("TITL_MARS.mars")

TITL MARS model illustration
TITL MARS model illustration.

TITL MARS Optimization

# create the a MARS object and load the trained MARS model
mars = MARS.MARS()
mars.load_mars_model_from_file("TITL_MARS.mars")

# create a TITL MARS OPT object
mars_opt = MARS_OPT()

# find the maximum of the TITL MARS model
max1 = mars_opt.max_optimize(mars)

print(max1)
# [x1, x2, y]
# [-0.05274081296657257, 1.998290807400001, 10.084549773597132]
# find the minimum of the TITL MARS model
min1 = mars_opt.min_optimize(mars)
# [x1, x2, y]
# [0.15040898573205055, -1.9982908070000007, -8.099636884123703]
print(min1)

TITL MARS optimization result illustration
TITL MARS optimization result illustration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.