Skip to content

Instantly share code, notes, and snippets.

View wolframalpha's full-sized avatar
💭
knobs!

Devi Prasad Khatua wolframalpha

💭
knobs!
View GitHub Profile
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup.
Get-NetFirewallRule -Name *ssh*
# There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled
# If the firewall does not exist, create one
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
import pandas as pd
import numpy as np
def calibration_error(y_true, y_prob, n_bins=5, strategy='uniform', return_expected_caliberation_error=True):
if strategy == 'quantile': # Determine bin edges by distribution of data
quantiles = np.linspace(0, 1, n_bins + 1)
bins = np.percentile(y_prob, quantiles * 100)
bins[-1] = bins[-1] + 1e-8
elif strategy == 'uniform':
bins = np.linspace(0., 1. + 1e-8, n_bins + 1)
@wolframalpha
wolframalpha / variable_transformation.py
Created November 27, 2019 06:38
Variable transformation and importance using OLS/regression
import numpy as np
import pandas as pd
import statsmodels.api as sm
transformations = {'log': np.log,
'sqrt': np.sqrt,
'sqr': lambda x: np.power(x, 2),
'cube': lambda x: np.power(x, 3),
'cubert': lambda x: np.power(x, -3),
'original': lambda x: x}
import pandas as pd
import numpy as np
def closest_node(node, nodes):
nodes = np.asarray(nodes)
dist_2 = np.sum((nodes - node)**2, axis=1)
return np.argmin(dist_2)
@wolframalpha
wolframalpha / read_shelf_data.py
Created October 16, 2019 09:54
Read Label.me xml file
from bs4 import BeautifulSoup
import pandas as pd
soup = BeautifulSoup(open('00001.xml'), 'xml')
objs = soup.find_all('object')
data = []
for obj in objs:
x = [x.get_text() for x in obj.find_all('x')]
y = [y.get_text() for y in obj.find_all('y')]
name = obj.find('name').get_text()
@wolframalpha
wolframalpha / point_in_poly.py
Created October 7, 2019 09:01
Check if a point is in the polygon
# please install shapely first by `pip install Shapely`
from shapely.geometry import Point
from shapely.geometry.polygon import Polygon
point = Point(0.5, 0.5)
polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
# this return a bool
print(polygon.contains(point))
import datetime
cf_history = [('CF_B_HST_MONTH_24', 'CF_B_HST_OS_AMOUNT_24', 'CF_B_HST_AC_DPD_24'),
('CF_B_HST_MONTH_23', 'CF_B_HST_OS_AMOUNT_23', 'CF_B_HST_AC_DPD_23'),
('CF_B_HST_MONTH_22', 'CF_B_HST_OS_AMOUNT_22', 'CF_B_HST_AC_DPD_22'),
('CF_B_HST_MONTH_21', 'CF_B_HST_OS_AMOUNT_21', 'CF_B_HST_AC_DPD_21'),
('CF_B_HST_MONTH_20', 'CF_B_HST_OS_AMOUNT_20', 'CF_B_HST_AC_DPD_20'),
('CF_B_HST_MONTH_19', 'CF_B_HST_OS_AMOUNT_19', 'CF_B_HST_AC_DPD_19'),
('CF_B_HST_MONTH_18', 'CF_B_HST_OS_AMOUNT_18', 'CF_B_HST_AC_DPD_18'),
('CF_B_HST_MONTH_17', 'CF_B_HST_OS_AMOUNT_17', 'CF_B_HST_AC_DPD_17'),
import re
def get_buckets(statuses):
status_bucket = []
for status in statuses:
dpd = re.search('(\d+) (or above )?day', status, re.IGNORECASE)
if dpd:
dpd = int(dpd.groups()[0])
if dpd <= 30:
status_bucket.append('SMA-0')
elif dpd <= 60:
@wolframalpha
wolframalpha / cannyed.py
Created June 17, 2019 12:19
use this code for canny edge detection
# %matplotlib inline
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img = cv.imread('Sample/Sample.tif')
edges = cv.Canny(img,100,200)
plt.figure(figsize=(30, 25))
# plt.subplot(121),plt.imshow(img,cmap = 'gray')
# plt.title('Original Image'), plt.xticks([]), plt.yticks([])
import time
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
from joblib import Parallel, delayed
start_time = time.time()
texts = ['anirban das', 'chitvan gupta', 'prasad devi', 'devi prasad'] * 40
names = ['anirban das', 'devi prasad'] * 6000
def match_name(params):