Skip to content

Instantly share code, notes, and snippets.

View shamilnabiyev's full-sized avatar

Shamil Nabiyev shamilnabiyev

View GitHub Profile
@shamilnabiyev
shamilnabiyev / pipx-setup.md
Last active May 30, 2024 12:05
Install pipx on Windows
  1. Run commands in Git Bash
    • env PIP_REQUIRE_VIRTUALENV=0 python -m pip install --user pipx
    • python -m pipx ensurepath --force
  2. Open a new Git Bash terminal
    • pipx --version
  3. If getting an error during the installation of packages using pipx
    • No Python at 'C:\Users\<username>\AppData\Local\Programs\Python\PythonX\python.exe'
    • Then remove the following folder
    • C:\Users\<username>\.local\pipx
  4. If still having the same issue
@shamilnabiyev
shamilnabiyev / vbb-sbahn-berlin.py
Last active May 5, 2024 19:34
Get Berlin S-Bahn Lines and Station IDs from VBB Verkehrsverbund Berlin-Brandenburg
import json
import requests
import pandas as pd
from itertools import chain
def get_sbahn_list(product='suburban', operator='1'):
"""
Get S-Bahn Line list from VBB Transport API
S-Bahn: product=suburban
@shamilnabiyev
shamilnabiyev / pipeline.py
Created April 9, 2023 20:14
Transfer learning with VGG and Keras [for image classification]
# Credits:
# Author: Gabriel Cassimiro
# Blog post: https://towardsdatascience.com/transfer-learning-with-vgg16-and-keras-50ea161580b4
# GitHub Repo: https://github.com/gabrielcassimiro17/object-detection
#
import tensorflow_datasets as tfds
from tensorflow.keras import layers, models
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.callbacks import EarlyStopping
@shamilnabiyev
shamilnabiyev / hyp.custom-scratch-low.yaml
Created December 12, 2022 22:21
YOLOv5 Custom hyperparameters
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
# Hyperparameters for low-augmentation COCO training from scratch
# python train.py --batch 64 --cfg yolov5n6.yaml --weights '' --data coco.yaml --img 640 --epochs 300 --linear
# See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials
lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
lrf: 0.01 # final OneCycleLR learning rate (lr0 * lrf)
momentum: 0.937 # SGD momentum/Adam beta1
weight_decay: 0.0005 # optimizer weight decay 5e-4
warmup_epochs: 3.0 # warmup epochs (fractions ok)
@shamilnabiyev
shamilnabiyev / resize-image-and-bbox.py
Last active November 17, 2022 15:50
Resize an image and bounding boxes
# Source: https://sheldonsebastian94.medium.com/resizing-image-and-bounding-boxes-for-object-detection-7b9d9463125a
import albumentations
from PIL import Image
import numpy as np
sample_img = Image.open("data/img1.jpg")
sample_arr = np.asarray(sample_img)
def resize_image(img_arr, bboxes, h, w):
@shamilnabiyev
shamilnabiyev / pypi-dependency.md
Created November 12, 2022 19:29
Find dependecies of a selected PyPi package

https://pypi.org/pypi/seaborn/0.11.2/json

@shamilnabiyev
shamilnabiyev / confusion-matrix-cross-validation.md
Last active November 2, 2022 10:43
Confusion matrix for cross validation. Results are being saved as mlflow artifacts and retrieved later for evaluation purposes.
import mlflow
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import precision_recall_fscore_support
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import StratifiedKFold
@shamilnabiyev
shamilnabiyev / hpo-optuna.md
Created October 31, 2022 18:52
Hyperparameter optimization for Random Forest Classifier using the Optuna lib
import optuna
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.metrics import classification_report
from sklearn.metrics import precision_recall_fscore_support
from sklearn.metrics import accuracy_score
@shamilnabiyev
shamilnabiyev / mlflow-autolog.md
Created October 31, 2022 18:17
MLFow with autologging and custom metrics
from sklearn.metrics import precision_recall_fscore_support
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
from sklearn.datasets import make_classification
from sklearn.metrics import accuracy_score
import mlflow
pandoc --filter pandoc-citeproc --bibliography=test.bib --citeproc -t docx -o test.docsx