Skip to content

Instantly share code, notes, and snippets.

View minesh1291's full-sized avatar
๐Ÿš–
On The Journey to Neverland

Minesh A. Jethva minesh1291

๐Ÿš–
On The Journey to Neverland
View GitHub Profile
@minesh1291
minesh1291 / subprocess_with_logger.py
Created September 7, 2019 07:32 — forked from CMCDragonkai/subprocess_with_logger.py
Run subprocess while connecting STDERR to Python logging system #python
import io
import subprocess
import threading
import logging
def subprocess_with_logger(logger, check=False, *args, **kwargs):
def log_stream(pipe, logger):
# by default stderr will be a binary stream
# we wrap it into a text stream
@minesh1291
minesh1291 / python_subprocess_run_argparse_nargs.md
Created September 7, 2019 07:32 — forked from CMCDragonkai/python_subprocess_run_argparse_nargs.md
Python `subprocess.run` and `argparse` nargs (multi-value options) is tricky

Python subprocess.run and argparse nargs (multi-value options) is tricky

If you have a Python program that uses argparse nargs to specify multi-value options then you need to make sure that each value is its own parameter.

import subprocess

subprocess.run(
    [
 'command',
@minesh1291
minesh1291 / mnist_prep_norm_z_score_cnn.py
Created September 7, 2019 07:33 — forked from CMCDragonkai/mnist_prep_norm_z_score_cnn.py
MNIST Data Preparation - Normalisation to Z-Score for CNNs #python
import os
import itertools
import numpy as np
import keras.utils as utils
from pathlib import Path
from mnist import MNIST
def chunk_gen(size, iterable):
it = iter(iterable)
@minesh1291
minesh1291 / population_variance_stddev_sample_variance_stddev.md
Created September 7, 2019 07:33 — forked from CMCDragonkai/population_variance_stddev_sample_variance_stddev.md
Population Variance/Stddev vs Sample Variance/Stddev #python

Population Variance/Stddev vs Sample Variance/Stddev

According to: http://vortex.ihrc.fiu.edu/MET4570/members/Lectures/Lect05/m10divideby_nminus1.pdf the reason why we use n - 1 is because that ensures that the average of all sample variances of every combination of sample (with replacement) of a population is equal to the population variance!

import random
import numpy as np

def calculate_variance(population):
@minesh1291
minesh1291 / likelihood_ratio_test.py
Created November 5, 2019 15:53 — forked from rnowling/likelihood_ratio_test.py
Likelihood-Ratio Test with scikit-learn and scipy
"""
Copyright 2017 Ronald J. Nowling
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@minesh1291
minesh1291 / sklearn_doc.py
Created January 17, 2020 07:27 — forked from jakevdp/sklearn_doc.py
Scikit-learn Documentation Template
"""
This file has an example function, with a documentation string which should
serve as a template for scikit-learn docstrings.
"""
def sklearn_template(X, y, a=1, flag=True, f=None, **kwargs):
"""This is where a short one-line description goes
This is where a longer, multi-line description goes. It's not
required, but might be helpful if more information is needed.
@minesh1291
minesh1291 / linkedin_scraper.py
Created January 22, 2020 09:36 — forked from scrapehero/linkedin_scraper.py
Python script to scrape a company details from a public company page on LinkedIn.com. Written as part of How to Scrape educational post - https://www.scrapehero.com/tutorial-scraping-linkedin-for-public-company-data/
from lxml import html
import csv, os, json
import requests
from exceptions import ValueError
from time import sleep
def linkedin_companies_parser(url):
for i in range(5):
try:
@minesh1291
minesh1291 / pad_packed_demo.py
Created February 12, 2020 13:55 — forked from HarshTrivedi/pad_packed_demo.py
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
#
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
@minesh1291
minesh1291 / GDrive.py
Created March 29, 2020 17:53 — forked from rajarsheem/GDrive.py
Python terminal client for Google Drive for easy uploading, deleting, listing, sharing files or folders. (See usage in the comment)
from __future__ import print_function
import sys
import io
import pip
import httplib2
import os
from mimetypes import MimeTypes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.