Showing posts with label Pythoncode. Show all posts
Showing posts with label Pythoncode. Show all posts

Python: The Hodrick-Prescott filter or HP filter

This post shows how to extract trend and cyclical components from a univariate time series using the Hodrick-Prescott (HP) filter. A more realistic version is the one-sided HP filter since it uses only the information available at time t, not the full sample.

Python : Save and Load Tensorflow Keras Model

This post shows how to save and load your Keras model. The loaded model contains the same parameters (weights and biases) and the model structure as the final model you saved.

Python : Select subset using sub column numbers or names

This post shows how to select sub columns from array or dataframe using sub column numbers or names. For example, this method is useful when we want to select yields with relevant maturities (1,3,5,7,10,15,20,30 years) from full spectrum of maturities (1,2,3,4,...,28,29,30 years).

Python : Nelson-Siegel or Svensson model with fixed lambda

This post implements the period-by-period OLS estimation of the Nelson-Siegel and Svensson yield curve model with fixed lambda.

Python : Tensorflow Keras Tuner for the optimization of hyper parameters

This post shows how to use the Keras Tuner for the hyper parameter optimization. This can avoid many for-loops effectively, which are used when the grid search for hyper parameters is necessary.

Python : %run to import another folder's ipynb files

This post shows how to use %run command for importing Jupyter Notebook (ipynb) files from another folders. It is essentially to run the imported ipynb files before running a main file.

Python : Importing ipynb files (Jupyter Notebook) from an ipynb file

This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file. It will avoid occasional mistakes and save time to write redundant common codes such as importing library, declaring user-defined functions, data and its preprocessing, to name a few.

Python : Graph with segmented colors and horizontal multiple graphs

This post shows how to plot a graph with segmented colors and then uses this to draw horizontal multiple graphs.