Skip to content

Instantly share code, notes, and snippets.

@accessnash
accessnash / blackjack.py
Created April 7, 2021 19:15
An implementation of Blackjack game using OOP (Udemy)
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 6 19:36:36 2021
@author: Localuser
"""
import random
@accessnash
accessnash / tic-tac-toe.py
Created April 5, 2021 15:58
A simple implementation of the Tic Tac Toe game using OOP
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 5 08:46:46 2021
@author: Localuser
"""
import random
class Player:
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
class RandomNumbers:
def __init__(self, length, *, range_min = 0, range_max = 20):
self.length = length
@accessnash
accessnash / Credit_Risk_Modeling_LGD_&_EAD_model.py
Last active December 22, 2020 19:16
Continuing from the PD model in the previous section to build the LGD and the EAD models and finally calculating the Expected loss for the loan portfolio
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 20 17:20:52 2020
@author: User
"""
#Part III - LGD & EAD Model
@accessnash
accessnash / Credit_Risk_Modeling_PD_model.py
Last active March 1, 2022 02:30
Building a PD model using loans data : Part I - data cleaning from original data set, choosing variables for building PD model and estimation ; Part II: Out-of-sample PD model validation, creating score cards from PD model and setting cut-offs for approval/rejection
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 10 19:05:13 2020
@author: User
"""
#Part I: Data cleaning, choosing variables & PD Model estimation
import numpy as np
@accessnash
accessnash / fibonacci.py
Created December 7, 2020 10:32
3 different ways of using caching for a simple computation of Fibonacci numbers. Also using lru_cache (Least recently used) in Python to limit the number of items in cache
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 7 10:35:31 2020
@author: Localuser
"""
# 1st method using a Class
class Fib:
@accessnash
accessnash / expectation-maximization.py
Created November 22, 2020 17:04
Example of fitting a Gaussian mixture model with EM algorithm
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 22 17:53:58 2020
@author: Localuser
"""
# Fitting a GMM with EM algorithm
@accessnash
accessnash / kernel_density_estimation.py
Created November 17, 2020 20:23
Non-parametric density estimation for a bimodal sample
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 17 20:58:21 2020
@author: Localuser
"""
import matplotlib.pyplot as plt
import numpy as np
@accessnash
accessnash / pareto.py
Last active November 15, 2020 22:00
Plotting PDF and CDF for a pareto distribution
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 15 17:45:00 2020
@author: User
"""
#PDF and CDF of a Pareto distribution
from scipy.stats import pareto
import matplotlib.pyplot as plt
@accessnash
accessnash / ARIMA_milk_prod.py
Created October 30, 2020 07:08
Fitting a ARIMA model on the dataset for Milk production
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 29 20:35:30 2020
@author: User
"""
import pandas as pd
import seaborn as sns