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
def randomize(dataset, labels): | |
permutation = np.random.permutation(labels.shape[0]) | |
shuffled_dataset = dataset[permutation,:,:] | |
shuffled_labels = labels[permutation] | |
return shuffled_dataset, shuffled_labels | |
train_dataset, train_labels = randomize(train_dataset, train_labels) | |
test_dataset, test_labels = randomize(test_dataset, test_labels) | |
valid_dataset, valid_labels = randomize(valid_dataset, valid_labels) |
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 time | |
import hashlib | |
t1 = time.time() | |
train_hashes = [hashlib.sha1(x).digest() for x in train_dataset] | |
valid_hashes = [hashlib.sha1(x).digest() for x in valid_dataset] | |
test_hashes = [hashlib.sha1(x).digest() for x in test_dataset] | |
valid_in_train = np.in1d(valid_hashes, train_hashes) |
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
def getSymbolBeforeDigit(x): | |
for i, c in enumerate(x): | |
if c.isdigit(): | |
return x[i-1] | |
pd.to_numeric(data['Толщина_перед_смоткой'].apply(lambda x: x.split(getSymbolBeforeDigit(x))[1].replace(',','.'))) |
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 matplotlib.pyplot as plt | |
import numpy as np | |
def show_images(images, cols = 1, titles = None): | |
"""Display a list of images in a single figure with matplotlib. | |
Parameters | |
--------- | |
images: List of np.arrays compatible with plt.imshow. | |
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
def resumetable(df): | |
print(f"Dataset Shape: {df.shape}") | |
summary = pd.DataFrame(df.dtypes,columns=['dtypes']) | |
summary = summary.reset_index() | |
summary['Name'] = summary['index'] | |
summary = summary[['Name','dtypes']] | |
summary['Missing'] = df.isnull().sum().values | |
summary['Uniques'] = df.nunique().values | |
summary['First Value'] = df.loc[0].values | |
summary['Second Value'] = df.loc[1].values |
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
sudo pacman -S pulseaudio-alsa |
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
xset r rate 300 50 |
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
dvc list -R --dvc-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
ARG PYTHON_VERSION=3.11.8 | |
ARG PYTHON_DISTRO=slim-bullseye | |
FROM python:${PYTHON_VERSION}-${PYTHON_DISTRO} as base-image | |
ENV PYTHONUNBUFFERED=1 \ | |
PYTHONDONTWRITEBYTECODE=1 \ | |
PIP_NO_CACHE_DIR=off \ | |
PIP_DISABLE_PIP_VERSION_CHECK=on \ | |
PIP_DEFAULT_TIMEOUT=100 \ |