This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional, List, Dict | |
from transformers import AutoTokenizer, AutoModel | |
from torch.nn import functional as F | |
class ZeroShotLearning: | |
""" | |
Zero-Shot Learning | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
# custom warning | |
class ParentalAdvisoryWarning(UserWarning): | |
pass | |
# custom exception | |
class InputError(Exception): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Example of Wrappers | |
''' | |
from functools import wraps | |
from datetime import datetime | |
import time | |
def verbose_timeit(func): | |
@wraps(func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |