ascl_id stringclasses 752
values | repo_url stringclasses 737
values | file_path stringlengths 4 194 | content large_stringlengths 1 1M | language stringclasses 29
values | license_type stringclasses 24
values | size int64 1 1M |
|---|---|---|---|---|---|---|
[ascl:1907.023] | https://github.com/seshnadathur/Revolver | python_tools/galaxycat.py | import numpy as np
import sys
import healpy as hp
import os
from astropy.io import fits
from python_tools.cosmology import Cosmology
class GalaxyCatalogue:
def __init__(self, parms, randoms=False):
if randoms:
input_file = parms.random_file
input_file_type = parms.random_file_typ... | Python | Unknown | 12,626 |
[ascl:1907.023] | https://github.com/seshnadathur/Revolver | python_tools/recon.py | from __future__ import print_function
import numpy as np
import os
import json
import sys
from scipy.fftpack import fftfreq
from python_tools.cosmology import Cosmology
import python_tools.fastmodules as fastmodules
import pyfftw
from astropy.table import Table
class Recon:
def __init__(self, cat, ran, parms):
... | Python | Unknown | 19,778 |
[ascl:1907.023] | https://github.com/seshnadathur/Revolver | python_tools/voxelvoids.py | from __future__ import print_function
import os
import sys
import numpy as np
import subprocess
import python_tools.fastmodules as fastmodules
from scipy.ndimage.filters import gaussian_filter
from python_tools.cosmology import Cosmology
class VoxelVoids:
def __init__(self, cat, ran, parms):
print("\n =... | Python | Unknown | 20,033 |
[ascl:1907.023] | https://github.com/seshnadathur/Revolver | python_tools/cosmology.py | import numpy as np
from scipy.integrate import quad
from scipy import constants
class Cosmology:
"""
Calculate background cosmological quantities for 0<z<4
"""
def __init__(self, omega_m=0.31, flat=True, omega_l=0.69, h=0.676):
c = constants.c / 1000
if flat:
omega_k = 0
... | Python | Unknown | 1,249 |
[ascl:2306.028] | https://github.com/hablabx/rfast | rfast_rpars.txt | parameter label retrieved? lin/log gauss/flat prior 1 prior 2
fAr | r"$f_{\rm Ar}$" | n | log | f | 1e-10 | 1e+0
fN2 | r"$f_{\rm N2}$" | y | log | f | 1e-10 | 1e+0
fO2 | r"$f_{\rm O2}... | Text | Unknown | 2,520 |
[ascl:2306.028] | https://github.com/hablabx/rfast | rfast_genspec.py | # import statements
import time
import shutil
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
from astropy.table import Table, Column, MaskedColumn
from astropy.io import ascii
from scipy.interpolate import interp1d
from rfast_routines import gen_spec
from rfast... | Python | Unknown | 4,777 |
[ascl:2306.028] | https://github.com/hablabx/rfast | rfast_routines.py | import lblabc_input
import math
import os
import numpy as np
from scipy import interpolate
from astropy.io import ascii
from rfast_opac_routines import opacities_read
from rfast_opac_routines import cia_read
from rfast_opac_routines import rayleigh
#
#
# flux adding routine for non-emitting, inhomogeneous, ... | Python | Unknown | 60,852 |
[ascl:2306.028] | https://github.com/hablabx/rfast | rfast_initret.py | # import statements
import sys
import os
import shutil
import numpy as np
from astropy.io import ascii
from rfast_routines import inputs
# get input script filename
if len(sys.argv) >= 3:
filename_scr = sys.argv[1] # if script name provided at command line
filename_ret = sys.argv[2]
else:
fi... | Python | Unknown | 11,010 |
[ascl:2306.028] | https://github.com/hablabx/rfast | lblabc_input.f95 | ! to compile:
! python -m numpy.f2py -c lblabc_input.f95 -m lblabc_input
!
! then in python:
! import lblabc_input
!
SUBROUTINE read_lblabc(iuabc,npg,ntg,nwn,p,tatm,wn,abc)
!
IMPLICIT NONE
!
! INTEGER, PARAMETER :: iuabc = 101
INTEGER, PARAMETER :: mxp = 20
INTEGER, PARAMETER :: mxt = 20
INTEGER, ... | Fortran | Unknown | 2,001 |
[ascl:2306.028] | https://github.com/hablabx/rfast | readme_quickstart.txt | The rfast package includes software to generate synthetic spectra of worlds (via the
rfast_gendata.py routine) and software to retrieve on spectral observations, be they
real or fake (via rfast_retrieve.py). Nearly all aspects of these utilities are managed
via the rfast_inputs.scr runscript.
To get started, a user... | Text | Unknown | 2,230 |
[ascl:2306.028] | https://github.com/hablabx/rfast | rfast_noise.py | # import statements
import time
import shutil
import sys
import numpy as np
import matplotlib.pyplot as plt
from astropy.table import Table, Column, MaskedColumn
from astropy.io import ascii
from rfast_routines import noise
from rfast_routines import inputs
# get input script filen... | Python | Unknown | 3,301 |
[ascl:2306.028] | https://github.com/hablabx/rfast | rfast_atm_routines.py | import numpy as np
import math
import time
from scipy.interpolate import interp1d
#
# set up hard-coded gas parameters
#
# inputs:
#
# bg - background gas identifier ('ar','ch4','co2','h2','he','n2','o2')
#
def set_gas_info(bg):
# number of absorbing or scattering gases
Ngas = 11 # Ar, C... | Python | Unknown | 13,500 |
[ascl:2306.028] | https://github.com/hablabx/rfast | rfast_opac_routines.py | import lblabc_input
import numpy as np
from scipy import interpolate
from astropy.io import ascii
#
#
# routine to read-in cia data
#
# inputs:
#
# species - list of strings, choosing from 'co2','h2','n2','o2',
# which will determine species included and ordering of species
# lam ... | Python | Unknown | 16,027 |
[ascl:2306.028] | https://github.com/hablabx/rfast | README.md | # rfast
A fast tool for planetary spectral forward and inverse modeling.
The readme_quickstart provides a step-by-step example of how to
generate a simulated spectrum, add noise, perform inverse modeling,
and plot results.
Software provided here expects a co-located folder named
"hires_opacities", which can be dow... | Markdown | Unknown | 421 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | .travis.yml | matrix:
include:
- language: python
sudo: false
python: '3.6'
before_install: cd python
install: pip install tox-travis numpy cython
script: tox -v
deploy:
provider: pypi
on:
tags: true
user: tpospisi
password:
secure: Pw8EcfIo4sOOiEa7Ys1bNQaIRxuOmNVCL... | YAML | null | 1,161 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | README.md | RFCDE
===
This repository provides an implementation of random forests designed
for conditional density estimation (https://arxiv.org/abs/1804.05753).
R and python packages are available. For installation details and
package-specific documentation see the subdirectories _r_ and
_python_. Both languages use a common C+... | Markdown | null | 5,762 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/README.rst | =====
RFCDE
=====
The ``RFCDE`` package implements random forests for conditional density
estimation.
Installation
------------
RFCDE is availabile from PyPI; to install use \`pip\`
.. code:: shell
pip install rfcde | reStructuredText | null | 225 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/setup.py | from setuptools import setup
from Cython.Build import cythonize
from setuptools.extension import Extension
import numpy as np
with open("README.rst", "r") as f:
README_TEXT = f.read()
ext_modules = cythonize([
Extension("rfcde.ForestWrapper",
sources=[
'src/rfcde/ForestWrapper... | Python | null | 1,776 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/tox.ini | [tox]
minversion = 2.0
envlist = py{27,36}--{linux}
[testenv]
changedir = tests
deps =
cython
numpy
pytest
statsmodels
scipy
commands = pytest --basetemp={envtmpdir} {posargs} | Config | null | 186 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/requirements.txt | Cython
pytest
numpy
statsmodels
| Text | null | 32 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/vignettes/RFCDE.ipynb | {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import rfcde\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import scipy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Motivat... | Jupyter Notebook | null | 65,883 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/vignettes/Multiple Responses.ipynb | {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/lib/python3.6/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will ... | Jupyter Notebook | null | 13,188 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/__init__.py | """Implementation of RFCDE; wraps C++ implementation."""
from .core import RFCDE
| Python | null | 81 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/ForestWrapper.cpp | /* Generated by Cython 0.29.10 */
/* BEGIN: Cython Metadata
{
"distutils": {
"depends": [
"/usr/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h",
"/usr/lib/python3.7/site-packages/numpy/core/include/numpy/ufuncobject.h",
"src/rfcde/Forest.h"
],... | C++ | null | 381,355 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Node.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef NODE_GUARD
#define NODE_GUARD
#include <algorithm>
#include <vector>
#include "Split.h"
typedef std::vector<int>::iterator ivecit;
class Node {
public:
double split_value; // value used to perform split... | C/C++ Header | null | 1,224 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Split.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef SPLIT_GUARD
#define SPLIT_GUARD
#include <vector>
typedef std::vector<int>::iterator ivecit;
class Split {
public:
int var;
int offset;
double loss_delta;
Split() : var(-1), offset(-1), loss_delt... | C/C++ Header | null | 960 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/helpers.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef HELPER_GUARD
#define HELPER_GUARD
#include <vector>
#include <algorithm>
typedef std::vector<int>::iterator ivecit;
struct SortComparator {
const double* x;
SortComparator(const double* x) { this -> ... | C/C++ Header | null | 667 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/basis_functions.py | """Functions for evaluation of orthogonal basis functions."""
# Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
import numpy as np
def evaluate_basis(responses, n_basis, basis_system):
"""Evaluates a system of basis functions.
Arguments
----------
... | Python | null | 3,364 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Node.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <random>
#include "Node.h"
#include "helpers.h"
typedef std::vector<int>::iterator ivecit;
Node::Node() {
split_value = 0.0;
loss_delta = 0.0;
split_var = -1;
le_child = NULL;
... | C++ | null | 3,686 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/weighted_quantile.py | import numpy as np
def weighted_quantile(x, weights, quantile):
"""Calculates the weighted quantile
Arguments
---------
x : numpy array
An array of values.
weights : numpy array
The weights associated with each value.
quantile : float
The quantile to be calculated.
R... | Python | null | 544 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/core.py | """Provides the RFCDE class for fitting RFCDE models."""
# Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
from warnings import warn
import numpy as np
from .basis_functions import evaluate_basis
from .kde import kde
from .weighted_quantile import weighted_quanti... | Python | null | 9,710 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/helpers.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include "helpers.h"
#include <vector>
#include <algorithm>
void sortby(ivecit begin, ivecit end, const double* x) {
std::sort(begin, end, SortComparator(x));
}
void sort_next(ivecit begin, ivecit end, const in... | C++ | null | 373 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Tree.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef TREE_GUARD
#define TREE_GUARD
#include <vector>
#include "Node.h"
class Tree {
public:
Node root;
int n_train;
std::vector<int> valid_idx;
std::vector<int> wts;
std::vector<int> starts;
std::v... | C/C++ Header | null | 4,355 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Split.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <algorithm>
#include <random>
#include "Split.h"
#include "helpers.h"
typedef std::vector<int>::iterator ivecit;
Split find_best_split(double* x_train, double* z_basis,
... | C++ | null | 4,449 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/kde.py | """Functions for weighted kernel density estimation."""
# Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
import numpy as np
import statsmodels.api as sm
def kde(responses, grid, weights, bandwidth):
"""Calculates the weighted kernel density estimate.
Arg... | Python | null | 2,021 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Tree.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <random>
#include <stdlib.h>
#include "Tree.h"
#include "Node.h"
#include "helpers.h"
void Tree::train(double* x_train, double* z_basis, int* lens,
const std::vector<int... | C++ | null | 3,762 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Forest.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef FOREST_GUARD
#define FOREST_GUARD
#include "Tree.h"
class Forest {
public:
std::vector<Tree> trees; // vector of trees in the forest
bool fit_oob;
void train(double* x_train, double* z_basis, int* ... | C/C++ Header | null | 1,203 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/src/rfcde/Forest.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <random>
#include "Forest.h"
#include "Tree.h"
void Forest::train(double* x_train, double* z_basis, int* lens, int n_train,
int n_var,
int n_basis, int n_trees, int m... | C++ | null | 2,061 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/tutorial/RFCDE-tutorial-teddy.ipynb | {
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `rfcde` package can be installed directly by cloning the Github repository:\n",
"\n",
"<code style=\"background:black;color:white\">git clone https://github.com/tpospisi/RFCDE.git </code> <br>\n",
"<code style=\"backgro... | Jupyter Notebook | null | 522,149 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/index.rst | .. include:: ../README.rst
.. toctree::
:maxdepth: 2
:hidden:
index
api
| reStructuredText | null | 86 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# RFCDE documentation build configuration file, created by
# sphinx-quickstart on Tue Feb 13 20:05:53 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# auto... | Python | null | 4,097 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/api.rst | ===============
API reference
===============
rfcde.core
==========
.. automodule:: rfcde.core
:members:
| reStructuredText | null | 110 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/searchindex.js | Search.setIndex({docnames:["api","index"],envversion:53,filenames:["api.rst","index.rst"],objects:{"rfcde.core":{RFCDE:[0,1,1,""]},"rfcde.core.RFCDE":{basis_system:[0,2,1,""],fit_oob:[0,2,1,""],forest:[0,2,1,""],min_loss_delta:[0,2,1,""],mtry:[0,2,1,""],n_basis:[0,2,1,""],n_trees:[0,2,1,""],node_size:[0,2,1,""],oob_wei... | JavaScript | null | 1,689 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_sources/index.rst.txt | .. include:: ../README.rst
.. toctree::
:maxdepth: 2
:hidden:
index
api
| Text | null | 86 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_sources/api.rst.txt | ===============
API reference
===============
rfcde.core
==========
.. automodule:: rfcde.core
:members:
| Text | null | 110 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_static/jquery.js | /*! jQuery v3.1.0 | (c) jQuery Foundation | jquery.org/license */
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?wi... | JavaScript | null | 86,351 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_static/underscore-1.3.1.js | // Underscore.js 1.3.1
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and doc... | JavaScript | null | 35,168 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_static/doctools.js | /*
* doctools.js
* ~~~~~~~~~~~
*
* Sphinx JavaScript utilities for all documentation.
*
* :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* select a different prefix for underscore
*/
$u = _.noConflict();
/**
* make the code below compati... | JavaScript | null | 9,131 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_static/underscore.js | // Underscore.js 1.3.1
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://do... | JavaScript | null | 12,140 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_static/websupport.js | /*
* websupport.js
* ~~~~~~~~~~~~~
*
* sphinx.websupport utilities for all documentation.
*
* :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
(function($) {
$.fn.autogrow = function() {
return this.each(function() {
var textarea = this;... | JavaScript | null | 25,351 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_static/searchtools.js | /*
* searchtools.js_t
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilities for the full-text search.
*
* :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* Non-minified version JS is _stemmer.js if file is provided */
/**
* Porter Stemmer
*/
va... | JavaScript | null | 25,449 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/docs/_build/html/_static/jquery-3.1.0.js | /*eslint-disable no-unused-vars*/
/*!
* jQuery JavaScript Library v3.1.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2016-07-07T21:44Z
*/
( function( global... | JavaScript | null | 263,767 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/tests/test_basis.py | import numpy as np
import rfcde
import pytest
def test_cosine_basis_is_orthonormal():
n_grid = 10000
n_basis = 31
grid = np.linspace(0, 1, n_grid)
basis = rfcde.basis_functions.cosine_basis(grid, n_basis)
norms = np.matmul(basis.T, basis) / n_grid
assert np.all(norms.diagonal() == pytest.ap... | Python | null | 1,062 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/tests/test_edge_cases.py | import numpy as np
import rfcde
import pytest
def test_node_size_is_respected():
n = 1000
x = np.random.random((n, 1))
z = np.random.random(n)
n_trees = 1
mtry = 1
n_basis = 15
for min_size in [1, 2, 3, 10, 100]:
forest = rfcde.RFCDE(n_trees=n_trees,
m... | Python | null | 508 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/tests/test_performance.py | import numpy as np
import rfcde
import pytest
def cde_loss(cdes, z_grid, true_z):
"""Calculates conditional density estimation loss on holdout data
Arguments
---------
cdes : numpy matrix
A matrix of conditional density estimates. Each column
corresponds to a grid point, each row corr... | Python | null | 1,615 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | python/tests/test_joint.py | import numpy as np
import rfcde
import pytest
def test_joint_densities_run():
n_grid = 10000
n_basis = 31
def generate_data(n):
x = np.random.random((n, 2))
z = np.random.random((n, 2))
return x, z
x_train, z_train = generate_data(1000)
x_test, z_test = generate_data(10)
... | Python | null | 821 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/README.md | RFCDE
===
The ``RFCDE`` package implements random forests for conditional density
estimation.
Installation
---
Use the `devtools` package to install from Github
```r
devtools::install_github("tpospisi/RFCDE/r")
```
If getting an issue about `R library not found for -lgfortrain`, please see the following [blog post... | Markdown | null | 440 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/src/Node.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <random>
#include "Node.h"
#include "helpers.h"
typedef std::vector<int>::iterator ivecit;
Node::Node() {
split_value = 0.0;
loss_delta = 0.0;
split_var = -1;
le_child = NULL;
... | C++ | null | 3,686 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/src/Split.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <algorithm>
#include <random>
#include "Split.h"
#include "helpers.h"
typedef std::vector<int>::iterator ivecit;
Split find_best_split(double* x_train, double* z_basis,
... | C++ | null | 4,449 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/src/helpers.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include "helpers.h"
#include <vector>
#include <algorithm>
void sortby(ivecit begin, ivecit end, const double* x) {
std::sort(begin, end, SortComparator(x));
}
void sort_next(ivecit begin, ivecit end, const in... | C++ | null | 373 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/src/Tree.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <random>
#include <stdlib.h>
#include "Tree.h"
#include "Node.h"
#include "helpers.h"
void Tree::train(double* x_train, double* z_basis, int* lens,
const std::vector<int... | C++ | null | 3,762 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/src/RcppExports.cpp | // Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <Rcpp.h>
using namespace Rcpp;
RcppExport SEXP _rcpp_module_boot_RFCDEModule();
static const R_CallMethodDef CallEntries[] = {
{"_rcpp_module_boot_RFCDEModule", (DL_FUNC) &_r... | C++ | null | 521 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/src/wrapper.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <Rcpp.h>
#include "Tree.h"
#include "Forest.h"
using namespace Rcpp;
//' @name ForestRcpp
//' @title Fit a random forest for CDE
//'
//' @description Provides a wrapper to the C++ RFCDE implementation.
/... | C++ | null | 2,042 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/src/Forest.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <random>
#include "Forest.h"
#include "Tree.h"
void Forest::train(double* x_train, double* z_basis, int* lens, int n_train,
int n_var,
int n_basis, int n_trees, int m... | C++ | null | 2,061 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/tests/testthat.R | library(testthat)
library(RFCDE)
testthat::test_check("RFCDE")
| R | null | 64 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/tests/testthat/test_lints.R | if (requireNamespace("lintr", quietly = TRUE)) {
context("Lints")
test_that("Package Style", {
lintr::expect_lint_free()
})
}
| R | null | 146 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/tests/testthat/test_edge_cases.R | context("Test edge cases")
test_that("Node size is respected", {
set.seed(32)
n <- 1000
x <- matrix(runif(n))
z <- matrix(runif(n))
n_trees <- 1
mtry <- 1
n_basis <- 15
for (min_size in c(1, 2, 3, 10, 100)) {
forest <- RFCDE(x, z, n_trees = n_trees, mtry = mtry, node_size = min_size,
... | R | null | 923 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/tests/testthat/test_performance.R | context("Test prediction performance")
test_that("Beta example performance", {
set.seed(42)
gen_data <- function(n) {
x <- matrix(runif(n * 2, 0.0, 1.0), n, 2)
z <- matrix(rbeta(n, x[, 1] + 5, x[, 2] + 5), n, 1)
return(list(x = x, z = z))
}
train_data <- gen_data(1000)
x_train <- train_data$x
... | R | null | 859 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/tests/testthat/test_type_conversion.R | context("Test type conversions")
test_that("Training works for vectors", {
set.seed(42)
n <- 100
x <- matrix(runif(n), n, 1)
z <- matrix(runif(n), n, 1)
n_trees <- 100
mtry <- 2
min_size <- 20
n_basis <- 15
expect_silent(RFCDE(x, z[, 1], n_trees = n_trees, mtry = mtry,
node_s... | R | null | 1,080 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/tests/testthat/test_loss.R | context("Loss functions")
test_that("Loss estimates match integrals", {
set.seed(42)
n_train <- 1000
n_test <- 10
n_grid <- 1000
x_train <- matrix(runif(n_train))
z_train <- matrix(rnorm(n_train, 0, x_train))
x_test <- matrix(runif(n_test))
z_test <- matrix(rnorm(n_test, 0, x_test))
n_trees <- 10... | R | null | 876 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/tests/testthat/test_basis.R | context("Test basis functions")
test_that("Cosine basis is orthonormal", {
n_grid <- 10000
n_basis <- 31
z_grid <- seq(0, 1, length.out = n_grid)
z_basis <- cosine_basis(z_grid, n_basis)
norms <- crossprod(z_basis) / n_grid
expect_equal(diag(norms), rep(1, n_basis), tol = 1e-3)
diag(norms) <- 0
expec... | R | null | 666 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/R/RFCDE.R | # Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
#' Fits a conditional density estimate random forest to training data.
#'
#' @param x_train a matrix of training covariates.
#' @param z_train a matrix of training responses.
#' @param lens length of functional data
... | R | null | 7,587 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/R/helpers.R | # Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
#' Project from [z_min, z_max] to [0, 1].
#'
#' @param z A vector of grid points to project
#' @param z_min A vector of minimum values for each dimension.
#' @param z_max A vector of maximum values for each dimension... | R | null | 455 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/R/KDE.R | # Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
#' Helper function for kernel density estimation.
#'
#' @param z_train matrix of training responses.
#' @param z_grid matrix of grid points to evaluate densities.
#' @param weights vector of weights.
#' @param bandwi... | R | null | 2,681 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/R/loss.R | # Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
#' Calculate loss for a single kernel density estimate
#'
#' @param weights A vector of weights for the training points.
#' @param z_train A matrix of training responses
#' @param z_test A test response
#' @param h A... | R | null | 2,951 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/R/RFCDE-package.R | # Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
#' RFCDE: Random Forests for Conditional Density Estimation
#'
#' Fits random forest conditional density estimates using conditional
#' density loss for splits.
#'
#' @name RFCDE-package
#' @author Taylor Pospisil
#'... | R | null | 616 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/R/RcppExports.R | # Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' @name ForestRcpp
#' @title Fit a random forest for CDE
#'
#' @description Provides a wrapper to the C++ RFCDE implementation.
#'
#' @param x_train a matrix of training covariates.
#' @param ... | R | null | 608 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/R/basis_functions.R | # Copyright Taylor Pospisil 2018.
# Distributed under MIT License (http://opensource.org/licenses/MIT)
#' Calculate basis functions for new observations
#'
#' @param z matrix whose row correspond to observations and whose
#' columns correspond to dimensions. Assumes each column has been
#' scaled to [0, 1].
#' @pa... | R | null | 4,059 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/inst/include/Forest.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef FOREST_GUARD
#define FOREST_GUARD
#include "Tree.h"
class Forest {
public:
std::vector<Tree> trees; // vector of trees in the forest
bool fit_oob;
void train(double* x_train, double* z_basis, int* ... | C/C++ Header | null | 1,203 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/inst/include/Tree.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef TREE_GUARD
#define TREE_GUARD
#include <vector>
#include "Node.h"
class Tree {
public:
Node root;
int n_train;
std::vector<int> valid_idx;
std::vector<int> wts;
std::vector<int> starts;
std::v... | C/C++ Header | null | 4,355 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/inst/include/helpers.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef HELPER_GUARD
#define HELPER_GUARD
#include <vector>
#include <algorithm>
typedef std::vector<int>::iterator ivecit;
struct SortComparator {
const double* x;
SortComparator(const double* x) { this -> ... | C/C++ Header | null | 667 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/inst/include/Split.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef SPLIT_GUARD
#define SPLIT_GUARD
#include <vector>
typedef std::vector<int>::iterator ivecit;
class Split {
public:
int var;
int offset;
double loss_delta;
Split() : var(-1), offset(-1), loss_delt... | C/C++ Header | null | 960 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | r/inst/include/Node.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef NODE_GUARD
#define NODE_GUARD
#include <algorithm>
#include <vector>
#include "Split.h"
typedef std::vector<int>::iterator ivecit;
class Node {
public:
double split_value; // value used to perform split... | C/C++ Header | null | 1,224 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Forest.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <random>
#include "Forest.h"
#include "Tree.h"
void Forest::train(double* x_train, double* z_basis, int* lens, int n_train,
int n_var,
int n_basis, int n_trees, int m... | C++ | null | 2,061 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/helpers.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include "helpers.h"
#include <vector>
#include <algorithm>
void sortby(ivecit begin, ivecit end, const double* x) {
std::sort(begin, end, SortComparator(x));
}
void sort_next(ivecit begin, ivecit end, const in... | C++ | null | 373 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/helpers.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef HELPER_GUARD
#define HELPER_GUARD
#include <vector>
#include <algorithm>
typedef std::vector<int>::iterator ivecit;
struct SortComparator {
const double* x;
SortComparator(const double* x) { this -> ... | C/C++ Header | null | 667 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Tree.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <random>
#include <stdlib.h>
#include "Tree.h"
#include "Node.h"
#include "helpers.h"
void Tree::train(double* x_train, double* z_basis, int* lens,
const std::vector<int... | C++ | null | 3,762 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Split.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef SPLIT_GUARD
#define SPLIT_GUARD
#include <vector>
typedef std::vector<int>::iterator ivecit;
class Split {
public:
int var;
int offset;
double loss_delta;
Split() : var(-1), offset(-1), loss_delt... | C/C++ Header | null | 960 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Split.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <algorithm>
#include <random>
#include "Split.h"
#include "helpers.h"
typedef std::vector<int>::iterator ivecit;
Split find_best_split(double* x_train, double* z_basis,
... | C++ | null | 4,449 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Node.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef NODE_GUARD
#define NODE_GUARD
#include <algorithm>
#include <vector>
#include "Split.h"
typedef std::vector<int>::iterator ivecit;
class Node {
public:
double split_value; // value used to perform split... | C/C++ Header | null | 1,224 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Tree.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef TREE_GUARD
#define TREE_GUARD
#include <vector>
#include "Node.h"
class Tree {
public:
Node root;
int n_train;
std::vector<int> valid_idx;
std::vector<int> wts;
std::vector<int> starts;
std::v... | C/C++ Header | null | 4,355 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Forest.h | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#ifndef FOREST_GUARD
#define FOREST_GUARD
#include "Tree.h"
class Forest {
public:
std::vector<Tree> trees; // vector of trees in the forest
bool fit_oob;
void train(double* x_train, double* z_basis, int* ... | C/C++ Header | null | 1,203 |
[ascl:2005.018] | https://github.com/lee-group-cmu/RFCDE | cpp/Node.cpp | // Copyright Taylor Pospisil 2018.
// Distributed under MIT License (http://opensource.org/licenses/MIT)
#include <vector>
#include <random>
#include "Node.h"
#include "helpers.h"
typedef std::vector<int>::iterator ivecit;
Node::Node() {
split_value = 0.0;
loss_delta = 0.0;
split_var = -1;
le_child = NULL;
... | C++ | null | 3,686 |
[ascl:2202.011] | https://github.com/AgentM-GEG/residual_feature_extraction | README.md | # RESIDUAL FEATURE EXTRACTION PIPELINE
A pipeline that carries out feature extraction of residual substructure within the residual images produced by popular galaxy structural-fitting routines such as GALFIT, GIM2D, etc. This pipeline extracts faint low surface brightness features by isolating flux-wise and area-wise s... | Markdown | MIT | 10,148 |
[ascl:2202.011] | https://github.com/AgentM-GEG/residual_feature_extraction | example/data_products/MC_run_data/gds_H.gf4608_Athresh_2.0sig_3ker.txt | 1.900000000000000000e+01
| Text | MIT | 25 |
[ascl:2202.011] | https://github.com/AgentM-GEG/residual_feature_extraction | TF_finder_CAN_v0.5/README.md | # RESIDUAL FEATURE EXTRACTION PIPELINE
A pipeline that carries out feature extraction of residual substructure within the residual images produced by popular galaxy structural-fitting routines such as GALFIT, GIM2D, etc. This pipeline extracts faint low surface brightness features by isolating flux-wise and area-wise s... | Markdown | MIT | 10,148 |
[ascl:2202.011] | https://github.com/AgentM-GEG/residual_feature_extraction | TF_finder_CAN_v0.5/TF_main_functions.py | '''
This module contains the key functions that carryout the residual feature extraction on the input
GALFIT-based image cube.
Author: Kameswara Bharadwaj Mantha
email: km4n6@mail.umkc.edu
'''
############### loading the necessary modules ###########
import numpy as np
import matplotlib.pyplot as plt
from astropy.io ... | Python | MIT | 53,275 |
[ascl:2202.011] | https://github.com/AgentM-GEG/residual_feature_extraction | TF_finder_CAN_v0.5/remove_outliers.py | import numpy as np
def removeoutliers(data, nsigma, remove='both', center='mean', niter=np.Inf, retind=False, verbose=False):
"""Strip outliers from a dataset, iterating until converged.
:INPUT:
data -- 1D numpy array. data from which to remove outliers.
nsigma -- positive number. limit definin... | Python | MIT | 3,031 |
[ascl:2202.011] | https://github.com/AgentM-GEG/residual_feature_extraction | TF_finder_CAN_v0.5/MC_Athresh_finding.py | '''
This function carries out an area threshold calculation using a MonteCarlo approach. An area threhsold is defined as the area
above which the contiguous pixel regions have a minimal chance of being caused by a spatially-correlated noise spike.
This function plays an important role in the Tidal feature finder pipel... | Python | MIT | 7,405 |
[ascl:2202.011] | https://github.com/AgentM-GEG/residual_feature_extraction | TF_finder_CAN_v0.5/Tidal_feature_finder.py | '''
This is the frontend to the Residual Feature Extraction pipeline.
A brief functioning of the pipeline:
This pipeline works on model-subtracted residual images by popular structural fitting routines (e.g., GALFIT, GIM2D, etc) to extract
faint low surface brightness features by isolating flux-wise and area-wise sign... | Python | MIT | 13,656 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.