Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def integrate(f,start,end,dx=.001): | |
x_points = np.arange(start,end,dx) | |
y_points = [f(x) for x in x_points] | |
area = dx*(sum(y_points[1:-1])+0.5*(y_points[0]+y_points[-1])) | |
# area = dx*sum(y_points) | |
return area | |
def main(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void printArray(int *A, int n){ | |
for (int i=0;i<n;i++){ std::cout<<A[i]<<' ';} | |
std::cout<<'\n'; | |
} | |
void merge(int *A, int *left, int *right, int n1, int n2){ | |
int i=0,j=0,k=0; | |
while (i<n1 && j<n2){ | |
if (left[i]<right[j]){A[k]=left[i];i++;k++;} | |
else {A[k]=right[j];j++;k++;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Huffman Encoding: Given a frequency map of signs, create a new compressed representation. | |
Algorithm: | |
1. Create a data structure for node with prob, sign, left, right pointers | |
2. Create a min heap of nodes with prob as key. For each item in frequency map; insert node(p, s, NULL, NULL) into the min heap. | |
3. while the min heap has more than 1 element: Do | |
a) pop two nodes | |
b) create a parent node with these two nodes as its children | |
c) push parent node into the min heap | |
4. The last remaining node in the min heap is the root of the Huffman Tree. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from torchvision import models | |
import torch | |
import cv2 | |
import numpy as np | |
items = ['alexnet', 'densenet121', 'densenet161', 'densenet169', 'densenet201', | |
'googlenet', 'mnasnet0_5', 'mnasnet0_75', 'mnasnet1_0', 'mnasnet1_3', | |
'mobilenet_v2', 'resnet101', 'resnet152', 'resnet18', 'resnet34', 'resnet50', | |
'shufflenet_v2_x0_5', 'shufflenet_v2_x1_0', 'shufflenet_v2_x1_5', 'shufflenet_v2_x2_0', |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demonstrates plotting ROC curve and getting AUC score | |
import numpy as np | |
def roc_curve(y_true, y_pred): | |
fpr = [] | |
tpr = [] | |
thresholds = np.arange(0.0, 1.01, .01) | |
P = sum(y_true) | |
N = len(y_true) - P |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn import datasets | |
from sklearn.model_selection import train_test_split | |
import scipy.stats | |
digits = datasets.load_digits() | |
trainX, testX, trainY, testY = train_test_split(digits.images, digits.target, test_size=.2) | |
Y_freq = {y: sum(trainY==y) for y in range(10)} |