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
"""http://stackoverflow.com/questions/6282432/load-sparse-array-from-npy-file | |
""" | |
import random | |
import scipy.sparse as sparse | |
import scipy.io | |
import numpy as np | |
def save_sparse_matrix(filename, x): | |
x_coo = x.tocoo() | |
row = x_coo.row |
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 torch.nn.functional as F | |
from pytorch_lightning import seed_everything, LightningModule, Trainer | |
from pytorch_lightning.callbacks import EarlyStopping | |
from torch import nn, optim, rand, sum as tsum, reshape, save | |
from torch.utils.data import DataLoader, Dataset | |
SAMPLE_DIM = 21000 | |
class CustomDataset(Dataset): | |
def __init__(self, samples=42): |
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 random | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns | |
get_point = lambda: {'Type': random.choice(['Liker', 'Subscriber', 'Like & Sub']), | |
'Age': random.randint(20, 40), | |
'Gender': random.choice(['M', 'W', 'T']), | |
'MemberSince': random.randint(2010, 2020)} | |
df = pd.DataFrame([get_point() for i in range(1000)]) |