Skip to content

Instantly share code, notes, and snippets.

View anujonthemove's full-sized avatar
Working

Anuj Khandelwal anujonthemove

Working
View GitHub Profile
@anujonthemove
anujonthemove / commit-emojis.md
Created June 11, 2023 04:33 — forked from georgekrax/commit-emojis.md
List of emojis for GitHub commit messages
Emoji Purpose MD Markup Prefix
📄 Generic message :page_facing_up:
📐 Improve the format / structure of the code / files :triangular_ruler: [IMPROVE]:
Improve performance :zap: [IMPROVE]:
🚀 Improve something (anything) :rocket: [IMPROVE]:
📝 Write docs :memo: [PROD]:
💡 New idea
@anujonthemove
anujonthemove / get_classification_report.py
Last active June 8, 2021 11:12 — forked from fclesio/get_classification_report.py
Scikit Learn Classification Report in Dataframe
def get_classification_report(y_test, y_pred):
'''Source: https://stackoverflow.com/questions/39662398/scikit-learn-output-metrics-classification-report-into-csv-tab-delimited-format'''
from sklearn import metrics
report = metrics.classification_report(y_test, y_pred, output_dict=True)
df_classification_report = pd.DataFrame(report).transpose()
df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False)
return df_classification_report
@anujonthemove
anujonthemove / backgroundAveraging.py
Created May 24, 2020 13:03 — forked from TheSalarKhan/backgroundAveraging.py
Background Averaging (Background Subtraction) in Python+OpenCV
import numpy as np
import cv2
class BackGroundSubtractor:
# When constructing background subtractor, we
# take in two arguments:
# 1) alpha: The background learning factor, its value should
# be between 0 and 1. The higher the value, the more quickly
# your program learns the changes in the background. Therefore,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anujonthemove
anujonthemove / gd_simple.py
Created July 1, 2018 14:27 — forked from DominicBreuker/gd_simple.py
Simple example of gradient descent in tensorflow
import tensorflow as tf
x = tf.Variable(2, name='x', dtype=tf.float32)
log_x = tf.log(x)
log_x_squared = tf.square(log_x)
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(log_x_squared)
init = tf.initialize_all_variables()
@anujonthemove
anujonthemove / validate_credit_card.js
Created January 2, 2017 16:47 — forked from DiegoSalazar/validate_credit_card.js
Luhn algorithm in Javascript. Check valid credit card numbers
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@anujonthemove
anujonthemove / cv_median.cpp
Created July 19, 2016 18:25 — forked from heisters/cv_median.cpp
Find the median of a single channel using OpenCv
namespace cv {
// calculates the median value of a single channel
// based on https://github.com/arnaudgelas/OpenCVExamples/blob/master/cvMat/Statistics/Median/Median.cpp
double median( cv::Mat channel )
{
double m = (channel.rows*channel.cols) / 2;
int bin = 0;
double med = -1.0;
int histSize = 256;