Skip to content

Instantly share code, notes, and snippets.

View chkoar's full-sized avatar
💭
I may be slow to respond.

Christos Aridas chkoar

💭
I may be slow to respond.
  • localhost
View GitHub Profile
@chkoar
chkoar / make_sampler.py
Last active April 1, 2018 23:32
Factory function to construct any imbalanced-learn sampler in one line https://github.com/scikit-learn-contrib/imbalanced-learn
import sys
from imblearn.combine import *
from imblearn.over_sampling import *
from imblearn.under_sampling import *
def make_sampler(cls, **kwargs):
_ = sys.modules[__name__]
return getattr(_, cls)().set_params(**kwargs)
# example
@chkoar
chkoar / test_stationarity.py
Created December 7, 2017 13:53
test_stationarity
def test_stationarity(timeseries):
import matplotlib.pyplot as plt
from statsmodels.tsa.stattools import adfuller
#Determing rolling statistics
rolmean = pd.rolling_mean(timeseries, window=12)
rolstd = pd.rolling_std(timeseries, window=12)
#Plot rolling statistics:
orig = plt.plot(timeseries, color='blue',label='Original')
@chkoar
chkoar / savable_classifier.py
Created March 30, 2018 09:28
Savable Classifier
import uuid
from pathlib import Path
from sklearn.base import BaseEstimator, ClassifierMixin, clone
from sklearn.datasets import make_classification
from sklearn.externals import joblib
from sklearn.feature_selection import SelectPercentile
from sklearn.model_selection import cross_val_score
from sklearn.pipeline import make_pipeline
from sklearn.svm import LinearSVC
@chkoar
chkoar / pandasx.py
Created April 12, 2018 09:31
Custom function to add skewness and kurtosis in descriptive stats to a pandas dataframe
import pandas as pd
def describex(data):
data = pd.DataFrame(data)
stats = data.describe()
skewness = data.skew()
kurtosis = data.kurtosis()
skewness_df = pd.DataFrame({'skewness':skewness}).T
kurtosis_df = pd.DataFrame({'kurtosis':kurtosis}).T
return stats.append([kurtosis_df,skewness_df])
@chkoar
chkoar / uuid.py
Created May 14, 2018 09:09
Shortcut function to generate reproducible version 4 Universally Unique IDentifiers (UUIDs)
def uuid(seed=None):
"""
Shortcut function to generate reproducible version 4
Universally Unique IDentifiers (UUIDs).
"""
import uuid
import random
rd = random.Random()
@chkoar
chkoar / _.py
Last active May 5, 2019 18:46
Synthetic data generation without class
import numpy as np
from imblearn.over_sampling import SMOTE
def generate_data(X, ratio=1.0, resampler=None, random_state=None):
y = [1] * X.shape[0]
n_samples = X.shape[0]
n_features = X.shape[1]
@chkoar
chkoar / keybase.md
Created June 19, 2019 14:04
keybase.md

Keybase proof

I hereby claim:

  • I am chkoar on github.
  • I am chkoar (https://keybase.io/chkoar) on keybase.
  • I have a public key ASAbSg2GwCBc-h7NJdDMAFb7ak2LQoMFgacgQZQFSZQfDgo

To claim this, I am signing this object:

@chkoar
chkoar / get_windows_key.vbs
Created July 22, 2019 13:10
Get your original Windows 10 product key
Option Explicit
Dim objshell,path,DigitalID, Result
Set objshell = CreateObject("WScript.Shell")
'Set registry key path
Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
'Registry key value
DigitalID = objshell.RegRead(Path & "DigitalProductId")
Dim ProductName,ProductID,ProductKey,ProductData
'Get ProductName, ProductID, ProductKey
ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName")
@chkoar
chkoar / readme.md
Created September 10, 2019 08:34
Handcrafted features for computer vision

SIFT GLOH Spin Image HoG Textons RIFT

@chkoar
chkoar / _.py
Created September 10, 2019 08:36
Get the methods of an object
import inspect
class MySuperObject(object):
def __init__(self):
self.a = 1
self.b = 2
def compute(self):
print("Foo")