Skip to content

Instantly share code, notes, and snippets.

View ucalyptus's full-sized avatar
🦙
Training

Sayantan Das ucalyptus

🦙
Training
View GitHub Profile
card reports age income share expenditure owner selfemp dependents months majorcards active
yes 0 37.66667 4.52 0.03326991 124.9833 yes no 3 54 1 12
yes 0 33.25 2.42 0.0052169420000000005 9.854167 no no 3 34 1 13
yes 0 33.66667 4.5 0.0041555559999999995 15.0 yes no 4 58 1 5
yes 0 30.5 2.54 0.06521378 137.8692 no no 0 25 1 7
yes 0 32.16667 9.7867 0.06705059 546.5033 yes no 2 64 1 5
yes 0 23.25 2.5 0.0444384 91.99667 no no 0 54 1 1
yes 0 27.91667 3.96 0.01257576 40.83333 no no 2 7 1 5
yes 0 29.16667 2.37 0.07643376 150.79 yes no 0 77 1 3
yes 0 37.0 3.8 0.2456279 777.8217 yes no 0 97 1 6
import argparse
import os
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms
import numpy as np
from sklearn import metrics, preprocessing
from sklearn.preprocessing import MinMaxScaler
from sklearn.decomposition import PCA
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, accuracy_score, classification_report, cohen_kappa_score
from operator import truediv
from plotly.offline import init_notebook_mode
import matplotlib.pyplot as plt
import scipy.io as sio
class PAM(Layer):
def __init__(self,
gamma_initializer=tf.zeros_initializer(),
gamma_regularizer=None,
gamma_constraint=None,
**kwargs):
super(PAM, self).__init__(**kwargs)
self.gamma_initializer = gamma_initializer
self.gamma_regularizer = gamma_regularizer
self.gamma_constraint = gamma_constraint
@ucalyptus
ucalyptus / install.md
Last active February 5, 2020 11:01
Ctags and Vim Installation

sudo apt-get update

sudo apt-get install vim

sudo apt-get install exuberant-ctags

@ucalyptus
ucalyptus / MSD.py
Created February 4, 2020 07:09
Original Implementation of Mean Spectral Divergence
def cal_mean_spectral_divergence(band_subset):
    """
    Spectral Divergence is defined as the symmetrical KL divergence (D_KLS) of two bands probability distribution.
    We use Mean SD (MSD) to quantify the redundancy among a band set.
    B_i and B_j should be a gray histagram.
    SD = D_KL(B_i||B_j) + D_KL(B_j||B_i)
    MSD = 2/n*(n-1) * sum(ID_ij)
    Ref:
@ucalyptus
ucalyptus / first-cell.txt
Created January 31, 2020 10:13
Inputs for julia-base.ipynb first cell for installation of Julia,IJulia,Flux
!curl -sSL "https://julialang-s3.julialang.org/bin/linux/x64/1.3/julia-1.3.1-linux-x86_64.tar.gz" -o julia.tar.gz
!tar -xzf julia.tar.gz -C /usr --strip-components 1
!rm -rf julia.tar.gz*
!julia -e 'using Pkg; pkg"add IJulia; add Flux; precompile"'
@ucalyptus
ucalyptus / julia-base.ipynb
Created January 31, 2020 09:59
Upload this at colab.research.google.com/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ucalyptus
ucalyptus / RMSE_iteratively.md
Last active July 26, 2019 06:28
NEVER store RMSE again

RMSE(t) = sqrt((t/t-1)RMSE(t-1)^2 + (1/t)(y_true(t) - y_pred(t))^2)

where t is the number of observations

Courtesy

Modification

Treat (1/t) as alpha

@ucalyptus
ucalyptus / FAQ.md
Created July 10, 2019 11:02
Some questions I believe I should have their answers documented.

Which is better rMSE or MAE?

This depends on your loss function. In many circumstances it makes sense to give more weight to points further away from the mean--that is, being off by 10 is more than twice as bad as being off by 5. In such cases RMSE is a more appropriate measure of error. If being off by ten is just twice as bad as being off by 5, then MAE is more appropriate. In any case, it doesn't make sense to compare RMSE and MAE to each other