Skip to content

Instantly share code, notes, and snippets.

View Proteusiq's full-sized avatar

Prayson Wilfred Daniel Proteusiq

View GitHub Profile
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from typing import Optional, List, Dict
from transformers import AutoTokenizer, AutoModel
from torch.nn import functional as F
class ZeroShotLearning:
"""
Zero-Shot Learning
...
import tempfile
import numpy as np
import torch
from torch.nn import Module
from scipy.io.wavfile import write
from playsound import playsound
# Constant Variables
from itertools import permutations
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import networkx as nx
import osmnx as ox
ox.config(log_console=True, use_cache=True)
@Proteusiq
Proteusiq / pyikea.py
Created December 26, 2020 07:06
Operations Reaserch
'''
Task: Operations Research
PYIKEA wants to maximize its profit of selling armchair, wingchair, and Lovet-table. The profit of selling armchair is 150 DKK, wingchair 100 DKK, and Lovet-table 250 DKK.
It takes:
15 planks of wood and 5 hours of labour to make one armchair
12 planks of wood and 2 hours of labour to make one wingchair
18 planks of wood and 8 hours of labour to make one Lovet-table
The store needs at least 4 of each chair, and a table. The total amount of woods pieces in storage is 450 and labour budget is of 120 hours only.
import easyocr
import requests
# API Defaults
API_URL = "https://www.tjekbil.dk/api/v2/nummerplade"
HEADERS = {"Content-Type": "application/json; charset=utf-8"}
def check_vehical(image_path: str, language: str = "en") -> dict:
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.linear_model import LogisticRegression
# assumes classification problem data split with numeric, categorical and text features
# [Salary, Bonus, Age, Gender, Descriptions Target]
@Proteusiq
Proteusiq / issues.py
Created December 10, 2020 19:01
Using customised warning and errors
import warnings
# custom warning
class ParentalAdvisoryWarning(UserWarning):
pass
# custom exception
class InputError(Exception):
'''
Example of Wrappers
'''
from functools import wraps
from datetime import datetime
import time
def verbose_timeit(func):
@wraps(func)
@Proteusiq
Proteusiq / events_change.py
Created August 23, 2020 06:11
events_change.py
# Advance Python: Tips and Tricks
# Author: Prayson W. Daniel (github.com/proteusiq)
# Objective: We want functions to be activate/executed when we experience change in X
# Note: we can run functions in threads or asynchronic to avoid blocking (if that's wanted behavior)
from events import Events