Skip to content

Instantly share code, notes, and snippets.

@nmayorov
nmayorov / discrete_bvp.ipynb
Last active November 30, 2015 16:34
Solving a discrete boundary-value problem in scipy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / feature_selection_rf.py
Created November 30, 2015 21:30
Feature selection for RF
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_diabetes, load_boston
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import cross_val_score
from sklearn.feature_selection import (SelectKBest, MutualInfoSelector,
f_classif, f_regression)
from sklearn.pipeline import make_pipeline
@nmayorov
nmayorov / feature_selection_rfe.py
Created November 30, 2015 22:30
RFE vs. MutualInfoSelector
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import load_digits
from sklearn.feature_selection import RFE, MutualInfoSelector
from sklearn.preprocessing import minmax_scale
from sklearn.svm import LinearSVC
from sklearn.model_selection import cross_val_score
digits = load_digits()
X = minmax_scale(digits.data)
@nmayorov
nmayorov / fs_communities_and_crimes.py
Created December 1, 2015 23:09
Feature selection on Communities and Crime dataset
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from sklearn.preprocessing import Imputer
from sklearn.feature_selection import (
SelectKBest, MutualInfoSelector, f_regression)
from sklearn.linear_model import RidgeCV
from sklearn.model_selection import cross_val_score
data = pd.read_csv('communities.data', header=None)
@nmayorov
nmayorov / hyp1f1_decimal.py
Created January 24, 2016 10:13
Compute hyp1f1 using Taylor series with help of Python' Decimal class
from decimal import Decimal, getcontext
import numpy as np
from math import isfinite
EPS = np.finfo(float).eps
class ComplexDecimal(object):
def __init__(self, real, imag):
@nmayorov
nmayorov / solve_bvp_demo.ipynb
Last active November 17, 2023 19:56
Exampled of using solve_bvp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / bvp_benchmarks.ipynb
Created April 21, 2016 17:29
Qualitative benchmarks for solve_bvp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / problem7.ipynb
Created April 24, 2016 00:16
Solving a hard BVP with continuation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / j_cash_bench.ipynb
Last active April 26, 2016 21:57
J. Cash BVP problems
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / bvp_benchmarks.py
Created June 10, 2016 18:58
FIxed BVP benchmarks
from __future__ import division, absolute_import, print_function
import inspect
import numpy as np
from numpy.testing import assert_, assert_allclose
from scipy import linalg, interpolate, special
from scipy.integrate import solve_bvp