Giter Site home page Giter Site logo

aks43725 / cand Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 2.41 MB

A Python package for generating candidate models for multi-model inference

License: MIT License

Python 100.00%
python genetic-algorithm simulated-annealing variable-selection regularization-paths

cand's Introduction

cand

This repository provides three methods to generate candidate models for multi-model inference under the linear model settings.

Methods to generate candidate models

  • The genetic algorithm (GA) described in [1].
  • The simulated annealing (SA) algorithm introduced in [2].
  • The union of distinct models on the regularization paths (RPs) of the Lasso, SCAD and MCP.

Specific settings of the implementation are described in [1].

The GA has been shown to outperform the SA and the RP in several multi-model inference tools.

References

  • [1] Cheng, C.W. and Cheng, G. (2019+). "Enhancing Multi-model Inference with Natural Selection." (Under review)
  • [2] Nevo, D. and Ritov, Y. (2017), "Identifying a Minimal Class of Models for High-dimensional Data," Journal of Machine Learning Research, 18, 1-29.

Installation

To install this package using command line:

git clone https://github.com/aks43725/cand.git
cd cand
python setup.py install

Usage

Import necessary packages and read the riboflavin dataset.

import numpy as np
import scipy as sp
import pandas as pd
import cand

ribflv = pd.read_csv('data/riboflavin.csv', index_col=0).T
y = ribflv['q_RIBFLV']
X = ribflv.drop(['q_RIBFLV'], axis=1)
n, d = X.shape

np.random.seed(570)

Implement the GA and prepare model sizes for the SA:

models_GA = cand.GA(X, y)
models_GA.fit()
print('Model sizes:\n{}'.format(models_GA.models.sum(axis=1)))
print('Fitness values:\n{}'.format(models_GA.fitness))

Implement the SA to search for good models of sizes appeared in the last GA generation:

count = np.bincount(models_GA.generations['model_size'][-1])
SA_sizes = np.nonzero(count)[0]
models_SA = cand.SA(X, y)
models_SA.fit(SA_sizes)
print('Model sizes:\n{}'.format(models_SA.models.sum(axis=1)))
print('GIC values:\n{}'.format(models_SA.ic))

Implement the RP:

models_RP = cand.RP(X, y)
models_RP.fit()
print('Model sizes:\n{}'.format(models_RP.models.sum(axis=1)))
print('GIC values:\n{}'.format(cand.GIC(X, y, models_RP.models, 'PLIC', n_jobs=-1)))

cand's People

Contributors

aks43725 avatar

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.