Skip to content

Instantly share code, notes, and snippets.

View chienhsiang-hung's full-sized avatar

洪健翔 Hung, Chien-Hsiang chienhsiang-hung

View GitHub Profile
import numpy as np
from sklearn.model_selection import KFold
from sklearn.model_selection._split import _BaseKFold, indexable, _num_samples
from sklearn.utils.validation import _deprecate_positional_args
# modified code for group gaps; source
# https://github.com/getgaurav2/scikit-learn/blob/d4a3af5cc9da3a76f0266932644b884c99724c57/sklearn/model_selection/_split.py#L2243
class PurgedGroupTimeSeriesSplit(_BaseKFold):
"""Time Series cross-validator variant with non-overlapping groups.
@chienhsiang-hung
chienhsiang-hung / KeepScreenActive.ps1
Created September 25, 2024 08:31
This will Keep Screen Active by pressing `F13` every 1 min until you click the OK below.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# start creating UI
$form = New-Object System.Windows.Forms.Form
$form.Text = 'Keep Screen Active'
$form.Size = New-Object System.Drawing.Size(300, 150)
$form.StartPosition = 'CenterScreen'
# add OK button
@chienhsiang-hung
chienhsiang-hung / tuple and list, and str concat.ipynb
Created March 9, 2023 04:33
iterate through list and tuple / How To Efficiently Concatenate Strings In Python
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.
@chienhsiang-hung
chienhsiang-hung / heapq.ipynb
Created November 14, 2022 09:29
Heap data structure is mainly used to represent a priority queue. In Python, it is available using the “heapq” module. The property of this data structure in Python is that each time the smallest heap element is popped(min-heap).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chienhsiang-hung
chienhsiang-hung / Simple Topological Sorting (DAG).py
Created November 7, 2022 10:01
Simple Topological Sorting (DAG).py
from collections import defaultdict
class Graph:
def __init__(self, vertices):
'''
@vertices: number of vertices
'''
self.graph = defaultdict(list) # adjacency list
self.V = vertices
import logging
import requests
from requests.adapters import HTTPAdapter, Retry
logging.basicConfig(level=logging.DEBUG)
session = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[502, 503, 504])
session.mount('http://', HTTPAdapter(max_retries=retries))