repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
enterprise_extensions
enterprise_extensions-master/enterprise_extensions/chromatic/solar_wind.py
# -*- coding: utf-8 -*- import os import numpy as np import scipy.stats as sps import scipy.special as spsf from enterprise import constants as const from enterprise.signals import (deterministic_signals, gp_signals, parameter, signal_base, utils) from .. import gp_kernels as gpk de...
13,958
35.637795
81
py
enterprise_extensions
enterprise_extensions-master/enterprise_extensions/frequentist/optimal_statistic.py
# -*- coding: utf-8 -*- import warnings import numpy as np import scipy.linalg as sl from enterprise.signals import gp_priors, signal_base, utils from enterprise_extensions import model_orfs, models # Define the output to be on a single line. def warning_on_one_line(message, category, filename, lineno, file=None, ...
17,367
38.205418
120
py
enterprise_extensions
enterprise_extensions-master/enterprise_extensions/frequentist/Fe_statistic.py
# -*- coding: utf-8 -*- import numpy as np import scipy.linalg as sl from enterprise.signals import (gp_signals, parameter, signal_base, utils, white_signals) class FeStat(object): """ Class for the Fe-statistic. :param psrs: List of `enterprise` Pulsar instances. :pa...
8,981
35.661224
118
py
enterprise_extensions
enterprise_extensions-master/enterprise_extensions/frequentist/F_statistic.py
# -*- coding: utf-8 -*- import numpy as np import scipy.special from enterprise.signals import deterministic_signals, gp_signals, signal_base from enterprise_extensions import blocks, deterministic def get_xCy(Nvec, T, sigmainv, x, y): """Get x^T C^{-1} y""" TNx = Nvec.solve(x, left_array=T) TNy = Nvec....
5,418
33.297468
112
py
enterprise_extensions
enterprise_extensions-master/enterprise_extensions/frequentist/__init__.py
0
0
0
py
enterprise_extensions
enterprise_extensions-master/enterprise_extensions/frequentist/chi_squared.py
# -*- coding: utf-8 -*- import numpy as np import scipy.linalg as sl def get_chi2(pta, xs): """Compute generalize chisq for pta: chisq = y^T (N + F phi F^T)^-1 y = y^T N^-1 y - y^T N^-1 F (F^T N^-1 F + phi^-1)^-1 F^T N^-1 y """ params = xs if isinstance(xs, dict) else pta.map_param...
1,704
29.446429
81
py
Graph-Unlearning
Graph-Unlearning-main/main.py
import logging import torch from exp.exp_graph_partition import ExpGraphPartition from exp.exp_node_edge_unlearning import ExpNodeEdgeUnlearning from exp.exp_unlearning import ExpUnlearning from exp.exp_attack_unlearning import ExpAttackUnlearning from parameter_parser import parameter_parser def config_logger(save...
1,499
27.846154
131
py
Graph-Unlearning
Graph-Unlearning-main/parameter_parser.py
import argparse def str2bool(v): if isinstance(v, bool): return v if v.lower() in ('yes', 'true', 't', 'y', '1'): return True elif v.lower() in ('no', 'false', 'f', 'n', '0'): return False else: raise argparse.ArgumentTypeError('Boolean value expected.') def parameter...
4,665
53.255814
137
py
Graph-Unlearning
Graph-Unlearning-main/config.py
RAW_DATA_PATH = 'temp_data/raw_data/' PROCESSED_DATA_PATH = 'temp_data/processed_data/' MODEL_PATH = 'temp_data/models/' ANALYSIS_PATH = 'temp_data/analysis_data/' # database name DATABASE_NAME = "unlearning_gnn"
213
29.571429
49
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/node_embedding.py
import logging import config from lib_gnn_model.graphsage.graphsage import SAGE from lib_dataset.data_store import DataStore class NodeEmbedding: def __init__(self, args, graph, data): super(NodeEmbedding, self) self.logger = logging.getLogger(__name__) self.args = args self.grap...
1,606
34.711111
103
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/__init__.py
0
0
0
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/walker.py
import itertools import math import random import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm import trange from .alias import alias_sample, create_alias_table from .utils import partition_num class RandomWalker: def __init__(self, G, p=1, q=1, use_rejection_sampling=0): ...
9,789
34.34296
136
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/classify.py
from __future__ import print_function import numpy from sklearn.metrics import f1_score, accuracy_score from sklearn.multiclass import OneVsRestClassifier from sklearn.preprocessing import MultiLabelBinarizer class TopKRanker(OneVsRestClassifier): def predict(self, X, top_k_list): probs = numpy.asarray(...
2,772
31.244186
78
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/alias.py
import numpy as np def create_alias_table(area_ratio): """ :param area_ratio: sum(area_ratio)=1 :return: accept,alias """ l = len(area_ratio) accept, alias = [0] * l, [0] * l small, large = [], [] area_ratio_ = np.array(area_ratio) * l for i, prob in enumerate(area_ratio_): ...
1,261
21.945455
59
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/utils.py
def preprocess_nxgraph(graph): node2idx = {} idx2node = [] node_size = 0 for node in graph.nodes(): node2idx[node] = node_size idx2node.append(node) node_size += 1 return idx2node, node2idx def partition_dict(vertices, workers): batch_size = (len(vertices) - 1) // worke...
1,191
23.326531
55
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/__init__.py
from .models import *
21
21
21
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/models/deepwalk.py
# -*- coding:utf-8 -*- """ Author: Weichen Shen,wcshen1994@163.com Reference: [1] Perozzi B, Al-Rfou R, Skiena S. Deepwalk: Online learning of social representations[C]//Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining. ACM, 2014: 701-710.(http://www.pe...
1,742
25.815385
272
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/models/node2vec.py
# -*- coding:utf-8 -*- """ Author: Weichen Shen,wcshen1994@163.com Reference: [1] Grover A, Leskovec J. node2vec: Scalable feature learning for networks[C]//Proceedings of the 22nd ACM SIGKDD international conference on Knowledge discovery and data mining. ACM, 2016: 855-864.(https://www.kdd.org/kdd201...
1,883
25.535211
264
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/models/sdne.py
# -*- coding:utf-8 -*- """ Author: Weichen Shen,wcshen1994@163.com Reference: [1] Wang D, Cui P, Zhu W. Structural deep network embedding[C]//Proceedings of the 22nd ACM SIGKDD international conference on Knowledge discovery and data mining. ACM, 2016: 1225-1234.(https://www.kdd.org/kdd2016/papers/file...
6,214
34.514286
252
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/models/struc2vec.py
# -*- coding:utf-8 -*- """ Author: Weichen Shen,wcshen1994@163.com Reference: [1] Ribeiro L F R, Saverese P H P, Figueiredo D R. struc2vec: Learning node representations from structural identity[C]//Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. ACM,...
14,604
32.574713
282
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/models/__init__.py
from .deepwalk import DeepWalk from .node2vec import Node2Vec from .line import LINE from .sdne import SDNE from .struc2vec import Struc2Vec __all__ = ["DeepWalk", "Node2Vec", "LINE", "SDNE", "Struc2Vec"]
207
22.111111
63
py
Graph-Unlearning
Graph-Unlearning-main/lib_node_embedding/ge/models/line.py
# -*- coding:utf-8 -*- """ Author: Weichen Shen,wcshen1994@163.com Reference: [1] Tang J, Qu M, Wang M, et al. Line: Large-scale information network embedding[C]//Proceedings of the 24th International Conference on World Wide Web. International World Wide Web Conferences Steering Committee, 2015: 1067-...
7,184
32.574766
272
py
Graph-Unlearning
Graph-Unlearning-main/lib_utils/utils.py
import os import errno import numpy as np import pandas as pd import networkx as nx import torch from scipy.sparse import coo_matrix from tqdm import tqdm def graph_reader(path): """ Function to read the graph from the path. :param path: Path to the edge list. :return graph: NetworkX object returned....
4,851
27.046243
117
py
Graph-Unlearning
Graph-Unlearning-main/lib_utils/logger.py
from texttable import Texttable def tab_printer(args): """ Function to print the logs in a nice tabular format. :param args: Parameters used for the model. """ # args = vars(args) keys = sorted(args.keys()) t = Texttable() t.add_rows([["Parameter", "Value"]] + [[k.replace("_"," ").capi...
373
30.166667
101
py
Graph-Unlearning
Graph-Unlearning-main/lib_aggregator/opt_dataset.py
from torch.utils.data import Dataset class OptDataset(Dataset): def __init__(self, posteriors, labels): self.posteriors = posteriors self.labels = labels def __getitem__(self, index): ret_posterior = {} for shard, post in self.posteriors.items(): ret_posterior[sha...
448
22.631579
51
py
Graph-Unlearning
Graph-Unlearning-main/lib_aggregator/optimal_aggregator.py
import copy import logging import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch import optim from torch.optim.lr_scheduler import MultiStepLR from torch.utils.data import DataLoader from torch_geometric.data import Data from lib_aggregator.opt_dataset import OptDataset from...
4,054
37.990385
120
py
Graph-Unlearning
Graph-Unlearning-main/lib_aggregator/aggregator.py
import logging import torch torch.cuda.empty_cache() from sklearn.metrics import f1_score import numpy as np from lib_aggregator.optimal_aggregator import OptimalAggregator from lib_dataset.data_store import DataStore class Aggregator: def __init__(self, run, target_model, data, shard_data, args): self...
2,958
35.9875
117
py
Graph-Unlearning
Graph-Unlearning-main/lib_aggregator/__init__.py
0
0
0
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/partition_lpa.py
import math import numpy as np import networkx as nx import logging import pickle from lib_graph_partition.constrained_lpa_base import ConstrainedLPABase from lib_graph_partition.partition import Partition from lib_graph_partition.constrained_lpa import ConstrainedLPA import config class PartitionLPA(Partition): ...
3,406
45.671233
210
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/constrained_kmeans.py
import logging import copy from tqdm import tqdm import numpy as np import cupy as np class ConstrainedKmeans: def __init__(self, data_feat, num_clusters, node_threshold, terminate_delta, max_iteration=20): self.logger = logging.getLogger('constrained_kmeans') self.data_feat = data_feat ...
4,038
34.743363
118
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/graph_partition.py
import logging from lib_graph_partition.partition_kmeans import PartitionKMeans from lib_graph_partition.partition_lpa import PartitionConstrainedLPA, PartitionLPA, PartitionConstrainedLPABase from lib_graph_partition.metis_partition import MetisPartition from lib_graph_partition.partition_random import PartitionRando...
1,708
42.820513
112
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/constrained_kmeans_base.py
# An implementation of ``Balanced K-Means for Clustering.'' (https://rdcu.be/cESzk) import logging import copy import numpy as np import seaborn as sns import matplotlib.pyplot as plt from munkres import Munkres from lib_graph_partition.hungarian import Hungarian from lib_graph_partition.hungarian_1 import KMMatcher ...
4,307
35.820513
118
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/metis_partition.py
import numpy as np import networkx as nx import pymetis from torch_geometric.data import ClusterData from torch_geometric.utils import from_networkx from lib_graph_partition.partition import Partition class MetisPartition(Partition): def __init__(self, args, graph, dataset): super(MetisPartition, self)._...
2,609
38.545455
170
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/constrained_lpa.py
import copy import logging from collections import defaultdict import numpy as np class ConstrainedLPA: def __init__(self, adj, num_communities, node_threshold, terminate_delta): self.logger = logging.getLogger('constrained_lpa_single') self.adj = adj self.num_nodes = adj.shape[0] ...
5,167
38.450382
104
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/partition_kmeans.py
import math import pickle import cupy as cp import numpy as np import logging from sklearn.cluster import KMeans import config from lib_graph_partition.constrained_kmeans_base import ConstrainedKmeansBase from lib_graph_partition.partition import Partition from lib_graph_partition.constrained_kmeans import Constrain...
3,881
43.62069
124
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/hungarian.py
#!/usr/bin/python """ Implementation of the Hungarian (Munkres) Algorithm using Python and NumPy References: http://www.ams.jhu.edu/~castello/362/Handouts/hungarian.pdf http://weber.ucsd.edu/~vcrawfor/hungar.pdf http://en.wikipedia.org/wiki/Hungarian_algorithm http://www.public.iastate.edu/~ddot...
19,635
40.252101
120
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/constrained_lpa_base.py
# An implementation of `` Balanced Label Propagation for Partitioning MassiveGraphs'' (https://stanford.edu/~jugander/papers/wsdm13-blp.pdf) import copy import logging from collections import defaultdict import numpy as np import cvxpy as cp from scipy.stats import linregress class ConstrainedLPABase: def __ini...
8,700
45.77957
164
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/partition_random.py
import numpy as np from lib_graph_partition.partition import Partition class PartitionRandom(Partition): def __init__(self, args, graph): super(PartitionRandom, self).__init__(args, graph) def partition(self): graph_nodes = np.array(self.graph.nodes) np.random.shuffle(graph_nodes) ...
472
28.5625
82
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/__init__.py
0
0
0
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/partition.py
import numpy as np class Partition: def __init__(self, args, graph, dataset=None): self.args = args self.graph = graph self.dataset = dataset self.partition_method = self.args['partition_method'] self.num_shards = self.args['num_shards'] self.dataset_name = self.ar...
738
26.37037
61
py
Graph-Unlearning
Graph-Unlearning-main/lib_graph_partition/hungarian_1.py
''' reference: https://www.topcoder.com/community/competitive-programming/tutorials/assignment-problem-and-hungarian-algorithm/ ''' import numpy as np #max weight assignment class KMMatcher: ## weights : nxm weight matrix (numpy , float), n <= m def __init__(self, weights): weights = np.array(weights...
3,953
31.146341
123
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/gnn_base.py
import logging import pickle import torch class GNNBase: def __init__(self): self.logger = logging.getLogger('gnn') self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # self.device = torch.device('cpu') self.model = None self.embedding_dim = 0 ...
1,482
28.078431
82
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/node_classifier.py
import logging import os import torch from sklearn.model_selection import train_test_split torch.cuda.empty_cache() import torch.nn.functional as F import torch_geometric.transforms as T from torch_geometric.datasets import Planetoid from torch_geometric.data import NeighborSampler from torch_geometric.nn.conv.gcn_co...
7,966
38.636816
114
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/__init__.py
0
0
0
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/gin/gin.py
import os import logging import torch import torch.nn.functional as F import torch_geometric.transforms as T from torch_geometric.datasets import Planetoid, Reddit from lib_gnn_model.gnn_base import GNNBase from lib_gnn_model.gin.gin_net import GINNet import config class GIN(GNNBase): def __init__(self, num_fea...
2,338
31.943662
92
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/gin/gin_net.py
import torch import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU from torch_geometric.nn import GINConv class GINNet(torch.nn.Module): def __init__(self, num_feats, num_classes): super(GINNet, self).__init__() dim = 32 nn1 = Sequential(Linear(num_feats, dim), Re...
1,558
30.18
74
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/gat/gat_net.py
import torch import torch.nn.functional as F from torch_geometric.nn import GATConv class GATNet(torch.nn.Module): def __init__(self, num_feats, num_classes, dropout=0.6): super(GATNet, self).__init__() self.dropout = dropout self.conv1 = GATConv(num_feats, 8, heads=8, dropout=self.dropou...
1,074
36.068966
117
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/gat/gat.py
import logging import os import torch import torch.nn.functional as F import torch_geometric.transforms as T from torch_geometric.datasets import Planetoid import config from lib_gnn_model.gnn_base import GNNBase from lib_gnn_model.gat.gat_net import GATNet class GAT(GNNBase): def __init__(self, num_feats, num_...
2,273
31.028169
92
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/graphsage/graphsage.py
import os import logging import torch import torch.nn.functional as F import torch_geometric.transforms as T from torch_geometric.datasets import Planetoid from torch_geometric.data import NeighborSampler from lib_gnn_model.graphsage.graphsage_net import SageNet from lib_gnn_model.gnn_base import GNNBase import confi...
4,883
39.363636
96
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/graphsage/graphsage_net.py
import torch import torch.nn.functional as F from torch_geometric.nn import SAGEConv class SageNet(torch.nn.Module): def __init__(self, in_channels, hidden_channels, out_channels): super(SageNet, self).__init__() self.num_layers = 2 self.convs = torch.nn.ModuleList() self.convs.a...
2,154
37.482143
79
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/gcn/gcn_net.py
import torch import torch.nn.functional as F from torch_geometric.nn import GCNConv class GCNNet(torch.nn.Module): def __init__(self, num_feats, num_classes): super(GCNNet, self).__init__() self.conv1 = GCNConv(num_feats, 16, cached=True, add_self_loops=False) self.conv2 = GCNConv(16, num...
781
31.583333
80
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/gcn/gcn.py
import os import logging import torch import torch.nn.functional as F import torch_geometric.transforms as T from torch_geometric.datasets import Planetoid from lib_gnn_model.gnn_base import GNNBase from lib_gnn_model.gcn.gcn_net import GCNNet import config class GCN(GNNBase): def __init__(self, num_feats, num_...
2,221
31.202899
92
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/mlp/mlp.py
import os import logging import torch import torch.nn.functional as F import torch_geometric.transforms as T from torch_geometric.datasets import Planetoid from lib_gnn_model.gnn_base import GNNBase from lib_gnn_model.mlp.mlpnet import MLPNet import config class MLP(GNNBase): def __init__(self, num_feats, num_c...
2,518
31.294872
107
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/mlp/__init__.py
0
0
0
py
Graph-Unlearning
Graph-Unlearning-main/lib_gnn_model/mlp/mlpnet.py
from torch import nn import torch.nn.functional as F class MLPNet(nn.Module): def __init__(self, input_size, num_classes): super(MLPNet, self).__init__() self.xent = nn.CrossEntropyLoss() self.layers = nn.Sequential( nn.Linear(input_size, 250), nn.Linear(250, 100),...
668
23.777778
50
py
Graph-Unlearning
Graph-Unlearning-main/exp/exp_graph_partition.py
import logging import time import torch from sklearn.model_selection import train_test_split import numpy as np from torch_geometric.data import Data import torch_geometric as tg import networkx as nx from exp.exp import Exp from lib_utils.utils import connected_component_subgraphs from lib_graph_partition.graph_part...
6,423
44.560284
155
py
Graph-Unlearning
Graph-Unlearning-main/exp/exp_attack_unlearning.py
import logging import time from collections import defaultdict import numpy as np import torch import torch_geometric as tg from torch_geometric.data import Data from scipy.spatial import distance import config from exp.exp import Exp from lib_graph_partition.graph_partition import GraphPartition from lib_gnn_model.n...
13,321
48.895131
154
py
Graph-Unlearning
Graph-Unlearning-main/exp/exp.py
import logging from lib_dataset.data_store import DataStore class Exp: def __init__(self, args): self.logger = logging.getLogger('exp') self.args = args self.data_store = DataStore(args) def load_data(self): pass
258
16.266667
46
py
Graph-Unlearning
Graph-Unlearning-main/exp/exp_node_edge_unlearning.py
import logging import pickle import time from collections import defaultdict import numpy as np import torch from torch_geometric.data import Data import config from exp.exp import Exp from lib_gnn_model.graphsage.graphsage import SAGE from lib_gnn_model.gat.gat import GAT from lib_gnn_model.gin.gin import GIN from l...
7,194
42.606061
123
py
Graph-Unlearning
Graph-Unlearning-main/exp/exp_unlearning.py
import logging import time import numpy as np from exp.exp import Exp from lib_gnn_model.graphsage.graphsage import SAGE from lib_gnn_model.gat.gat import GAT from lib_gnn_model.gin.gin import GIN from lib_gnn_model.gcn.gcn import GCN from lib_gnn_model.mlp.mlp import MLP from lib_gnn_model.node_classifier import Nod...
5,345
39.195489
132
py
Graph-Unlearning
Graph-Unlearning-main/lib_dataset/data_store.py
import os import pickle import logging import shutil import numpy as np import torch from torch_geometric.datasets import Planetoid, Coauthor import torch_geometric.transforms as T import config class DataStore: def __init__(self, args): self.logger = logging.getLogger('data_store') self.args = ...
9,583
44.421801
129
py
Graph-Unlearning
Graph-Unlearning-main/lib_dataset/__init__.py
0
0
0
py
ZINBAE
ZINBAE-master/ZINBAE.py
""" Implementation of ZINBAE model """ from time import time import numpy as np from keras.models import Model import keras.backend as K from keras.engine.topology import Layer, InputSpec from keras.layers import Dense, Input, GaussianNoise, Layer, Activation, Lambda, Multiply, BatchNormalization, Reshape, Concatenate...
10,280
39.636364
154
py
ZINBAE
ZINBAE-master/loss.py
import numpy as np import tensorflow as tf from keras import backend as K def _nan2zero(x): return tf.where(tf.is_nan(x), tf.zeros_like(x), x) def _nan2inf(x): return tf.where(tf.is_nan(x), tf.zeros_like(x)+np.inf, x) def _nelem(x): nelem = tf.reduce_sum(tf.cast(~tf.is_nan(x), tf.float32)) return tf...
4,141
30.142857
122
py
ZINBAE
ZINBAE-master/layers.py
from keras.engine.topology import Layer from keras.layers import Lambda from keras import backend as K import tensorflow as tf class ConstantDispersionLayer(Layer): ''' An identity layer which allows us to inject extra parameters such as dispersion to Keras models ''' def __init__(...
1,798
32.314815
98
py
ZINBAE
ZINBAE-master/ZINBAE0.py
""" Implementation of scDeepCluster for scRNA-seq data """ from time import time import numpy as np from keras.models import Model import keras.backend as K from keras.engine.topology import Layer, InputSpec from keras.layers import Dense, Input, GaussianNoise, Layer, Activation, Lambda, Multiply, BatchNormalization, ...
8,888
39.040541
154
py
ZINBAE
ZINBAE-master/preprocess.py
# Copyright 2017 Goekcen Eraslan # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
4,580
33.969466
112
py
incremental-ks
incremental-ks-master/IncrementalKS/Pure Python/testing_parallel_streams.py
from scipy.stats import ks_2samp from IKS import IKS import numpy as np from time import time from collections import deque initial_A = np.random.normal(loc = 0, scale = 1, size = 500) initial_B = np.random.normal(loc = 1, scale = 1, size = 500) stream_A = np.random.normal(loc = 0, scale = 1, size = 5000) stream_B =...
1,724
24.746269
85
py
incremental-ks
incremental-ks-master/IncrementalKS/Pure Python/IKS.py
from Treap import Treap from math import log class IKS: def __init__(self): self.treap = None self.n = [0, 0] @staticmethod def KSThresholdForPValue(pvalue, N): '''Threshold for KS Test given a p-value Args: pval (float): p-value. N (int): the size of the samples. Returns: ...
3,778
29.475806
199
py
incremental-ks
incremental-ks-master/IncrementalKS/Pure Python/testing_single_stream_rnd_factor.py
from scipy.stats import ks_2samp from IKS import IKS import numpy as np from time import time from itertools import chain from random import random from collections import deque initial = np.random.normal(loc = 0, scale = 1, size = 500) stream = list(chain(*[np.random.normal(loc = 1.0 * (i % 2), scale = 1, size = 50...
1,592
24.285714
104
py
incremental-ks
incremental-ks-master/IncrementalKS/Pure Python/testing_batch.py
from scipy.stats import ks_2samp from IKS import IKS import numpy as np group_A = np.random.normal(loc = 0, scale = 1, size = 100) group_B = np.random.normal(loc = 1, scale = 1, size = 100) iks = IKS() for x, y in zip(group_A, group_B): iks.Add(x, 0) iks.Add(y, 1) print(iks.KS()) print(ks_2samp(group_A, group_...
333
19.875
58
py
incremental-ks
incremental-ks-master/IncrementalKS/Pure Python/IKSSW.py
from IKS import IKS from collections import deque from random import random class IKSSW: def __init__(self, values): '''Incremental Kolmogorov-Smirnov Sliding Window. This class assumes that one window is fixed (reference window) and another slides over a stream of data. The reference window can be updated to be...
2,664
29.988372
240
py
incremental-ks
incremental-ks-master/IncrementalKS/Pure Python/Treap.py
from random import random class Treap: def __init__(self, key, value = 0): self.key = key self.value = value self.priority = random() self.size = 1 self.height = 1 self.lazy = 0 self.max_value = value self.min_value = value self.left = None self.right = None @staticmethod ...
3,699
21.02381
64
py
incremental-ks
incremental-ks-master/IncrementalKS/Python C++ Wrapper/ForgettingBuffer.py
class Node: def __init__(self, value): self.value = value self.next = None class ForgettingBuffer: def __init__(self, values): self.first = None self.last = None for val in values: if self.first == None: self.first = Node(val) self.last = self.first else: se...
930
18.808511
40
py
incremental-ks
incremental-ks-master/IncrementalKS/Python C++ Wrapper/testing_parallel_streams.py
from scipy.stats import ks_2samp from IKS import IKS import numpy as np from time import time from collections import deque initial_A = np.random.normal(loc = 0, scale = 1, size = 500) initial_B = np.random.normal(loc = 1, scale = 1, size = 500) stream_A = np.random.normal(loc = 0, scale = 1, size = 5000) stream_B =...
1,724
24.746269
85
py
incremental-ks
incremental-ks-master/IncrementalKS/Python C++ Wrapper/IKS.py
from cffi import FFI ffi = FFI() ffi.cdef(""" typedef struct { void * pointer; } IKS_WrappedPointer; IKS_WrappedPointer IKS_NewGeneratorWithSeed(unsigned seed); IKS_WrappedPointer IKS_NewGenerator(void); void IKS_DeleteGenerator(IKS_WrappedPointer pointer); IKS_WrappedPointer IKS_NewIKS(IKS_WrappedPointer gen...
4,612
30.813793
199
py
incremental-ks
incremental-ks-master/IncrementalKS/Python C++ Wrapper/testing_single_stream_rnd_factor.py
from scipy.stats import ks_2samp from IKS import IKS import numpy as np from time import time from itertools import chain from random import random from collections import deque initial = np.random.normal(loc = 0, scale = 1, size = 500) stream = list(chain(*[np.random.normal(loc = 1.0 * (i % 2), scale = 1, size = 50...
1,592
24.285714
104
py
incremental-ks
incremental-ks-master/IncrementalKS/Python C++ Wrapper/testing_batch.py
from scipy.stats import ks_2samp from IKS import IKS import numpy as np group_A = np.random.normal(loc = 0, scale = 1, size = 100) group_B = np.random.normal(loc = 1, scale = 1, size = 100) iks = IKS() for x, y in zip(group_A, group_B): iks.Add(x, 0) iks.Add(y, 1) print(iks.KS()) print(ks_2samp(group_A, group_...
333
19.875
58
py
incremental-ks
incremental-ks-master/IncrementalKS/Python C++ Wrapper/IKSSW.py
from IKS import IKS from collections import deque from random import random class IKSSW: def __init__(self, values): '''Incremental Kolmogorov-Smirnov Sliding Window. This class assumes that one window is fixed (reference window) and another slides over a stream of data. The reference window can be updated to be...
2,664
29.988372
240
py
pyterpol
pyterpol-master/grid_to_binary.py
#!/usr/bin/env python import os import argparse import numpy as np def main(): ps = argparse.ArgumentParser() ps.add_argument('--remove', action='store_true', default=False, help='Removes ascii files.') ps.add_argument('--overwrite', action='store_true', default=False, help='Overwrites binary files -- ma...
1,998
34.696429
140
py
pyterpol
pyterpol-master/__init__.py
# reads basic classes from .synthetic.makespectrum import SyntheticSpectrum from .synthetic.makespectrum import SyntheticGrid from .observed.observations import ObservedSpectrum from .fitting.interface import ObservedList from .fitting.interface import StarList from .fitting.interface import RegionList from .fitting.in...
543
37.857143
53
py
pyterpol
pyterpol-master/fitting/fitter.py
import os import nlopt import emcee # import warnings import numpy as np from scipy.optimize import fmin from scipy.optimize import fmin_slsqp try: from scipy.optimize import differential_evolution except ImportError as ex: print ex differential_evolution = None from pyterpol.synthetic.auxiliary import parl...
20,033
31.842623
114
py
pyterpol
pyterpol-master/fitting/parameter.py
# definition of parameters - here I add parameters which apply for implemented # grids. To fit additional parameters, one will have to define along with # addition of new grids, or here.. parameter_definitions=dict( teff=dict(name='teff', value=10000., vmin=6000., vmax=50000., unit='K', fitted=False, group=0, typed...
5,467
34.277419
122
py
pyterpol
pyterpol-master/fitting/__init__.py
0
0
0
py
pyterpol
pyterpol-master/fitting/interface.py
# -*- coding: utf-8 -*- import copy import corner # import sys import warnings import numpy as np import matplotlib.pyplot as plt from scipy import stats from pyterpol.synthetic.makespectrum import SyntheticGrid from pyterpol.observed.observations import ObservedSpectrum from pyterpol.fitting.parameter import Parameter...
151,519
35.127802
120
py
pyterpol
pyterpol-master/synthetic/auxiliary.py
import numpy as np import matplotlib.pyplot as plt from astropy.constants import c from scipy.interpolate import splrep from scipy.interpolate import splev from scipy.interpolate import bisplrep from scipy.interpolate import bisplev from scipy.interpolate import RectBivariateSpline from scipy.interpolate import Interpo...
10,363
24.033816
115
py
pyterpol
pyterpol-master/synthetic/makespectrum.py
import os import sys import copy import warnings import numpy as np import matplotlib.pyplot as plt from astropy.constants import c from auxiliary import is_within_interval from auxiliary import instrumental_broadening from auxiliary import interpolate_spec from auxiliary import interpolate_block_faster from auxiliary ...
45,773
34.319444
119
py
pyterpol
pyterpol-master/synthetic/defaults.py
# defaults settings - for more utility, this was transfered # to init import os, inspect curdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # DEFINITIONS OF GRIDS OF RELATIVE SPECTRA # -----------------------------------------------------------------------------------------------------...
2,466
34.242857
120
py
pyterpol
pyterpol-master/synthetic/__init__.py
2
0
0
py
pyterpol
pyterpol-master/plotting/plotting.py
import copy import matplotlib.pyplot as plt import matplotlib.gridspec as gs import numpy as np from scipy.stats import norm from pyterpol.synthetic.auxiliary import read_text_file def get_walker(db, nchain, nwalker, niter): """ Retrieves a walker from the chain. :param db: :param nchain: :param n...
9,041
22.42487
95
py
pyterpol
pyterpol-master/plotting/__init__.py
0
0
0
py
pyterpol
pyterpol-master/pyterpol_examples/Interface/output/example.py
""" This tutorial serves as demonstration of how to fit observed spectra with Pyterpol. Our observed spectra were created with the old C++ version of the code. We have three spectra of a binary consisting of primary: teff = 25000, g = 4.2, , vrot = 150, lr = 0.7, z = 1.0 secondary: teff = 18000, g = 4.2, , vrot = 50, ...
5,219
47.333333
146
py
pyterpol
pyterpol-master/pyterpol_examples/Interface/setup/example.py
""" This tutorial serves as demonstration of how to set up an Interface. Our observed spectra were created with the old C++ version of the code. We have three spectra of a binary consisting of primary: teff = 25000, g = 4.2, , vrot = 150, lr = 0.7, z = 1.0 secondary: teff = 18000, g = 4.2, , vrot = 50, lr = 0.3, z = 1....
9,099
51.601156
151
py
pyterpol
pyterpol-master/pyterpol_examples/Interface/fit/example.py
""" This tutorial serves as demonstration of how to fit observed spectra with Pyterpol. Our observed spectra were created with the old C++ version of the code. We have three spectra of a binary consisting of primary: teff = 25000, g = 4.2, , vrot = 150, lr = 0.7, z = 1.0 secondary: teff = 18000, g = 4.2, , vrot = 50, ...
8,806
45.845745
146
py
pyterpol
pyterpol-master/pyterpol_examples/SyntheticSpectrum/example.py
""" This is a tutorial script how to handle the class Synthetic Spectrum. """ import pyterpol import numpy as np import matplotlib.pyplot as plt # Load the spectrum using the library numpy wave, intens = np.loadtxt('grid.dat', unpack=True, usecols=[0,1]) # The synthetic spectrum can be created either from arrays ss =...
1,449
25.851852
92
py
pyterpol
pyterpol-master/pyterpol_examples/SyntheticGrid/example.py
""" This script serves a demonstration of the class SyntheticGrid. """ # import the library import pyterpol import matplotlib.pyplot as plt # The handling of the synthetic grid is shadowed from the user, # therefore the interaction of the user with the grid should # restrict to only few methods. # How to create a gri...
2,610
31.6375
83
py
pyterpol
pyterpol-master/pyterpol_examples/observed_spectra_fitting/v746cas/v746cas_2.py
""" V746Cas - fitting of a observed spectra. This example also show, ho we can proceed if we want to fit parameters step by step. """ import pyterpol import matplotlib.pyplot as plt def inspect_spectra(f): ifile = open(f, 'r') slist = ifile.readlines() ifile.close() for rec in slist: ifile = ...
2,974
28.455446
90
py
pyterpol
pyterpol-master/pyterpol_examples/observed_spectra_fitting/v746cas/v746cas.py
""" V746Cas - fitting of a observed spectra. This example also show, ho we can proceed if we want to fit parameters step by step. """ import pyterpol import matplotlib.pyplot as plt def inspect_spectra(f): ifile = open(f, 'r') slist = ifile.readlines() ifile.close() for rec in slist: ifile = ...
2,974
28.455446
90
py
pyterpol
pyterpol-master/pyterpol_examples/observed_spectra_fitting/v746cas_2/v746cas_2.py
""" V746Cas - fitting of a observed spectra. This example also show, ho we can proceed if we want to fit parameters step by step. """ import pyterpol import numpy as np import matplotlib.pyplot as plt def inspect_spectra(f): """ Plots all spectra. :param f: :return: """ ifile = open(f, 'r') ...
3,716
24.993007
89
py
pyterpol
pyterpol-master/pyterpol_examples/observed_spectra_fitting/v746cas_2/v746cas_eval_mcmc.py
import pyterpol # check convergence of individual parameters pyterpol.Interface.plot_convergence_mcmc('chain.dat', figname='mcmc_convergence.png') # plot covariance of radiative parameters pyterpol.Interface.plot_covariances_mcmc('chain.dat', parameters=['vrot', 'teff', 'logg'], figname='mcmc_correlations.png') # pl...
514
38.615385
123
py