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
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/prep/migrate_user_details_v2.py
from app.bq_service import BigQueryService if __name__ == "__main__": bq_service = BigQueryService() bq_service.migrate_populate_user_details_table_v2() print("MIGRATION SUCCESSFUL!")
202
15.916667
55
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/prep/assign_user_ids.py
from pprint import pprint from app import seek_confirmation # DATA_DIR from app.decorators.datetime_decorators import logstamp from app.decorators.number_decorators import fmt_n from app.bq_service import BigQueryService if __name__ == "__main__": bq_service = BigQueryService() print("----------------------...
1,192
30.394737
97
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/prep/migrate_daily_bot_probabilities.py
from app.bq_service import BigQueryService if __name__ == "__main__": bq_service = BigQueryService() bq_service.migrate_daily_bot_probabilities_table() print("MIGRATION SUCCESSFUL!")
201
15.833333
54
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/prep/migrate_user_screen_names.py
from app.bq_service import BigQueryService if __name__ == "__main__": bq_service = BigQueryService() bq_service.migrate_populate_user_screen_names_table() print("MIGRATION SUCCESSFUL!")
204
16.083333
57
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/prep/migrate_retweets_v2.py
from app.decorators.datetime_decorators import logstamp from app.bq_service import BigQueryService if __name__ == "__main__": bq_service = BigQueryService() print(logstamp()) bq_service.migrate_populate_retweets_table_v2() print(logstamp()) print("MIGRATION SUCCESSFUL!")
298
18.933333
55
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/k_days/reporter.py
import os from pandas import DataFrame from app import DATA_DIR from app.retweet_graphs_v2.graph_storage import GraphStorage from app.retweet_graphs_v2.k_days.generator import DateRangeGenerator if __name__ == "__main__": gen = DateRangeGenerator() reports = [] for date_range in gen.date_ranges: ...
962
32.206897
125
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/k_days/classifier.py
import os #import time import gc from dotenv import load_dotenv from app import APP_ENV, server_sleep from app.retweet_graphs_v2.graph_storage import GraphStorage from app.retweet_graphs_v2.k_days.generator import DateRangeGenerator from app.botcode_v2.classifier import NetworkClassifier as BotClassifier from app.bq...
2,646
36.814286
116
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/k_days/grapher.py
from app import server_sleep from app.bq_service import BigQueryService from app.retweet_graphs_v2.retweet_grapher import RetweetGrapher from app.retweet_graphs_v2.k_days.generator import DateRangeGenerator if __name__ == "__main__": gen = DateRangeGenerator() bq_service = BigQueryService() for date_r...
930
26.382353
90
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/k_days/download_classifications.py
import os from app.retweet_graphs_v2.graph_storage import GraphStorage from app.retweet_graphs_v2.k_days.generator import DateRangeGenerator from app.botcode_v2.classifier import NetworkClassifier as BotClassifier if __name__ == "__main__": gen = DateRangeGenerator() for date_range in gen.date_ranges: ...
950
31.793103
90
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs_v2/k_days/generator.py
import os from datetime import datetime, timedelta from pprint import pprint from dotenv import load_dotenv from app import seek_confirmation from app.decorators.datetime_decorators import dt_to_date load_dotenv() START_DATE = os.getenv("START_DATE", default="2020-01-01") # the first period will start on this day ...
2,759
31.857143
121
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs/bq_weekly_graph_loader.py
from app.retweet_graphs.bq_weekly_grapher import BigQueryWeeklyRetweetGrapher if __name__ == "__main__": storage_service = BigQueryWeeklyRetweetGrapher.init_storage_service() graph = storage_service.load_graph() # will print a memory profile... storage_service.report(graph) # will print graph size
317
25.5
77
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs/base_grapher.py
import os from datetime import datetime import time from dotenv import load_dotenv from networkx import DiGraph from app import APP_ENV, DATA_DIR, SERVER_NAME, SERVER_DASHBOARD_URL from app.decorators.number_decorators import fmt_n from app.retweet_graphs.graph_storage_service import GraphStorageService from app.ema...
3,651
31.607143
111
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs/graph_storage_service.py
import os import json import pickle from memory_profiler import profile from pandas import DataFrame from networkx import write_gpickle, read_gpickle from app import APP_ENV, DATA_DIR, seek_confirmation from app.decorators.datetime_decorators import logstamp from app.decorators.number_decorators import fmt_n from ap...
6,245
32.945652
135
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs/bq_retweet_grapher.py
import os from networkx import DiGraph from memory_profiler import profile from dotenv import load_dotenv from app.decorators.datetime_decorators import logstamp from app.decorators.number_decorators import fmt_n from app.friend_graphs.bq_grapher import BigQueryGrapher load_dotenv() USERS_LIMIT = int(os.getenv("US...
3,131
37.666667
187
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs/bq_weekly_graph_bot_classifier.py
import os from conftest import compile_mock_rt_graph from app import APP_ENV, seek_confirmation from app.retweet_graphs.bq_weekly_grapher import BigQueryWeeklyRetweetGrapher from app.botcode_v2.classifier import NetworkClassifier as BotClassifier, DRY_RUN if __name__ == "__main__": storage_service = BigQueryWeek...
2,424
43.090909
146
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs/bq_base_grapher.py
from retweet_graphs.base_grapher import BaseGrapher, USERS_LIMIT, BATCH_SIZE from app.bq_service import BigQueryService class BigQueryBaseGrapher(BaseGrapher): def __init__(self, users_limit=USERS_LIMIT, batch_size=BATCH_SIZE, storage_service=None, bq_service=None): super().__init__(users_limit=users_lim...
704
29.652174
110
py
tweet-analysis-2020
tweet-analysis-2020-main/app/retweet_graphs/bq_weekly_grapher.py
import os from dotenv import load_dotenv from networkx import DiGraph from memory_profiler import profile from app import DATA_DIR, seek_confirmation from app.decorators.datetime_decorators import dt_to_s, logstamp, dt_to_date from app.decorators.number_decorators import fmt_n from app.bq_service import BigQueryServ...
5,019
33.62069
226
py
tweet-analysis-2020
tweet-analysis-2020-main/app/botometer/sampler.py
import os from functools import cached_property from botometer import Botometer from dotenv import load_dotenv from app import seek_confirmation, server_sleep from app.bq_service import BigQueryService, generate_timestamp from app.twitter_service import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET load_...
7,292
35.10396
137
py
tweet-analysis-2020
tweet-analysis-2020-main/start/follower_network/helper_follower_network_crawler.py
#Use this code to download tweets that contain a given keyword # -*- coding: UTF-8 -*- from twython import Twython from datetime import datetime, timedelta import numpy as np from helper_twitter_api import * import sqlite3 from operator import itemgetter import os import csv import urllib.request, urllib.parse, urllib....
8,352
35.317391
159
py
tweet-analysis-2020
tweet-analysis-2020-main/start/follower_network/follower_network_collector.py
# -*- coding: utf-8 -*- """follower_network_collector.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1T0ED71rbhiNF8HG-769aBqA0zZAJodcd """ #This notebook builds a follower network for a set of users #first import the helper functions from helpe...
3,008
39.662162
120
py
tweet-analysis-2020
tweet-analysis-2020-main/start/bot_communities/midac_bot_community_analysis_libya.py
# -*- coding: utf-8 -*- """MIDAC Bot Community Analysis Libya.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1rrTv4JkYoQx0VVVtq8leYAqh6aX1VAe8 # Bot Community Analysis Use this notebook to analyze communities in bot retweet network Data = Bot p...
8,689
32.041825
208
py
tweet-analysis-2020
tweet-analysis-2020-main/start/bot_communities/SpectralCommunities.py
import networkx as nx import numpy as np from sklearn.cluster import SpectralClustering def spectral_clustering(G,k=2): A = nx.adjacency_matrix(G.to_undirected()) clustering =SpectralClustering(n_clusters=k, eigen_solver=None, affinity='precomputed',n_init = 20) clusters = clustering.fit(A) Comm = [[] ...
913
47.105263
106
py
tweet-analysis-2020
tweet-analysis-2020-main/start/bot_communities/midac_bot_community_detection_libya.py
# -*- coding: utf-8 -*- """MIDAC Bot Community Detection Libya.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/156K2fQM_TNps7WHcdqcMU8gDVbOthIyo # Bot Community Detection Use this notebook to detect communities in bot retweet network Data = Bot ...
16,819
31.284069
283
py
tweet-analysis-2020
tweet-analysis-2020-main/start/botcode/networkClassifierHELPER.py
import math import networkx as nx from collections import defaultdict from operator import itemgetter import numpy as np import time from ioHELPER import * ##################################################################################################### ####################### BUILD RETWEET NX-(SUB)GRAPH FROM DICT...
6,747
27.837607
115
py
tweet-analysis-2020
tweet-analysis-2020-main/start/botcode/MPI_graphCut.py
################################################################################# ################################# IMPORTS ####################################### ################################################################################# ## BASIC import os import sys import math import datetime import random im...
8,155
35.410714
266
py
tweet-analysis-2020
tweet-analysis-2020-main/start/botcode/ioHELPER.py
import numpy as np from os import listdir from os.path import isfile, join import datetime import networkx as nx def readCSVFile_urls(path): file = open(path, 'r').read().split('\n') res = {} for line in file: if(len(line) > 0): temp = line.split(';') res[temp[0]] = temp[1] return res; def readCSVFile_ur...
8,254
18.939614
104
py
tweet-analysis-2020
tweet-analysis-2020-main/start/bot_impact_v2/assess_impeachment_analysis.py
# -*- coding: utf-8 -*- """Assess Impeachment Analysis.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1UZxvODJREDEIg4KuTqqIhCJ3f6psRb91 # Assess Bot Impact on Impeachment Analysis This code will let you analyze the bot impact that has been calcu...
9,005
38.156522
139
py
tweet-analysis-2020
tweet-analysis-2020-main/start/botcode_v2/ising_model_bot_detector.py
# -*- coding: utf-8 -*- """Ising Model Bot Detector.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1Ou1TXypk5YA-DxSFRi55HsNwiELue7Cl # Ising Model Bot Detection This notebook lets you detect bots in a retweet network using the Ising model algor...
6,426
31.296482
201
py
tweet-analysis-2020
tweet-analysis-2020-main/start/botcode_v2/networkClassifierHELPER.py
import math import networkx as nx from collections import defaultdict from operator import itemgetter import numpy as np import time from ioHELPER import * ##################################################################################################### ####################### BUILD RETWEET NX-(SUB)GRAPH FROM DICT...
6,741
30.069124
115
py
tweet-analysis-2020
tweet-analysis-2020-main/start/botcode_v2/ioHELPER.py
import numpy as np from os import listdir from os.path import isfile, join import datetime import networkx as nx def readCSVFile_urls(path): file = open(path, 'r').read().split('\n') res = {} for line in file: if(len(line) > 0): temp = line.split(';') res[temp[0]] = temp[1] return res; def readCSVFile_ur...
8,254
18.939614
104
py
tweet-analysis-2020
tweet-analysis-2020-main/start/bot_impact/assess_bot_impact.py
# -*- coding: utf-8 -*- """AssessBotImpact.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1idq0xOjN0spFYCQ1q6JcH6KdpPp8tlMb # Assess Bot Impact This code will calculate the mean opinion shift caused by the bots in your network. You will need t...
11,179
32.573574
237
py
tweet-analysis-2020
tweet-analysis-2020-main/start/bot_impact/assess_helper.py
import json,random,csv import numpy as np from scipy import sparse import networkx as nx import pandas as pd import matplotlib.pyplot as plt #code for helper file #create networkx graph object from node and edge list csv files def G_from_edge_list(node_filename,edge_filename): G = nx.DiGraph() data_nodes = pd...
9,150
41.170507
143
py
ball-k-means
ball-k-means-master/PythonVersion/win_kmeans++_python.py
# This version is completed by Yong Zheng(413511280@qq.com), Shuyin Xia?380835019@qq.com?, Xingxin Chen, Junkuan Wang. 2020.5.1 import ctypes import numpy as np class ball_k_means: def __init__(self, isDouble=0): self.isDouble = isDouble def fit(self, s1, k, isRing = False, detail = False, random_s...
2,550
52.145833
137
py
ball-k-means
ball-k-means-master/PythonVersion/linux_kmeans++_python.py
# This version is completed by Yong Zheng(413511280@qq.com), Shuyin Xia?380835019@qq.com?, Xingxin Chen, Junkuan Wang. 2020.5.1 import ctypes import numpy as np class ball_k_means: def __init__(self, isDouble=0): self.isDouble = isDouble def fit(self, s1, k, isRing = False, detail = False, random_s...
2,552
52.1875
137
py
lcogtgemini
lcogtgemini-master/setup.py
from setuptools import setup setup(name='lcogtgemini', author=['Curtis McCully'], author_email=['cmccully@lco.global'], version=0.1, packages=['lcogtgemini'], install_requires=['numpy', 'astropy', 'scipy'], entry_points={'console_scripts': ['reduce_gemini=lcogtgemini.main:run']})
318
30.9
79
py
lcogtgemini
lcogtgemini-master/lcogtgemini/main.py
import lcogtgemini from lcogtgemini.combine import speccombine from lcogtgemini.cosmicrays import crreject from lcogtgemini.sky import skysub from lcogtgemini.reduction import scireduce, extract from lcogtgemini.utils import get_binning, rescale1e15 from lcogtgemini.qe import make_qecorrection from lcogtgemini.waveleng...
4,228
29.644928
89
py
lcogtgemini
lcogtgemini-master/lcogtgemini/reduction.py
import numpy as np import lcogtgemini from astropy.io import fits from lcogtgemini.utils import get_binning from lcogtgemini.file_utils import getsetupname from pyraf import iraf from lcogtgemini import fixpix from lcogtgemini import fits_utils def scireduce(scifiles, rawpath): for f in scifiles: binning...
3,327
40.08642
107
py
lcogtgemini
lcogtgemini-master/lcogtgemini/wavelengths.py
import lcogtgemini from lcogtgemini import utils, file_utils, fixpix from pyraf import iraf import numpy as np from astropy.io import fits, ascii import os import time def wavesol(arcfiles, rawpath): for f in arcfiles: binning = utils.get_binning(f, rawpath) fixed_rawpath = fixpix.fixpix(f, rawpath...
5,218
38.240602
120
py
lcogtgemini
lcogtgemini-master/lcogtgemini/cosmicrays.py
import numpy as np from astropy.io import fits from astroscrappy.astroscrappy import detect_cosmics import lcogtgemini from lcogtgemini.fits_utils import tofits from lcogtgemini import fixpix def crreject(scifiles): for f in scifiles: # run lacosmicx hdu_skysub = fits.open('st' + f.replace('.txt'...
1,193
37.516129
103
py
lcogtgemini
lcogtgemini-master/lcogtgemini/fixpix.py
import os from pyraf import iraf from lcogtgemini import file_utils def fixpix(txtfile, rawpath, binning, namps): images = file_utils.get_images_from_txt_file(txtfile) for image in images: if not os.path.exists('../raw_fixpix'): iraf.mkdir('../raw_fixpix') iraf.cp(os.path.join(rawp...
751
31.695652
82
py
lcogtgemini
lcogtgemini-master/lcogtgemini/fits_utils.py
import numpy as np from astropy.io import fits def sanitizeheader(hdr): # Remove the mandatory keywords from a header so it can be copied to a new # image. hdr = hdr.copy() # Let the new data decide what these values should be for i in ['SIMPLE', 'BITPIX', 'BSCALE', 'BZERO']: if i in hdr....
4,823
31.594595
131
py
lcogtgemini
lcogtgemini-master/lcogtgemini/bpm.py
import lcogtgemini from pyraf import iraf from astropy.io import fits import numpy as np def get_bad_pixel_mask(binnings, yroi): if lcogtgemini.detector == 'Hamamatsu': if lcogtgemini.is_GS: bpm_file = 'bpm_gs.fits' else: bpm_file = 'bpm_gn.fits' bpm_hdu = fits.ope...
1,925
43.790698
91
py
lcogtgemini
lcogtgemini-master/lcogtgemini/utils.py
from astropy.io import ascii, fits import numpy as np from lcogtgemini import file_utils import os from scipy.signal import butter, lfilter import lcogtgemini def mad(d): return np.median(np.abs(np.median(d) - d)) def magtoflux(wave, mag, zp): # convert from ab mag to flambda # 3e-19 is lambda^2 / c in ...
3,053
31.147368
140
py
lcogtgemini
lcogtgemini-master/lcogtgemini/combine.py
import numpy as np import lcogtgemini from astropy.io import fits, ascii from lcogtgemini import fits_utils from lcogtgemini import file_utils from astropy.convolution import convolve, Gaussian1DKernel from lcogtgemini import utils from pyraf import iraf def find_bad_pixels(data, threshold=30.0): # Take the abs n...
4,813
40.5
120
py
lcogtgemini
lcogtgemini-master/lcogtgemini/flats.py
import lcogtgemini from lcogtgemini.utils import get_binning from lcogtgemini.file_utils import getsetupname from lcogtgemini import fits_utils from lcogtgemini import fixpix from lcogtgemini import fitting from lcogtgemini import utils import numpy as np from pyraf import iraf from astropy.io import fits import os fro...
4,882
46.872549
159
py
lcogtgemini
lcogtgemini-master/lcogtgemini/sort.py
import lcogtgemini import numpy as np from pyraf import iraf import os from glob import glob from astropy.io import fits def sort(): if not os.path.exists('raw'): iraf.mkdir('raw') fs = glob('*.fits') fs += glob('*.dat') for f in fs: iraf.mv(f, 'raw/') # Make a reduction directory ...
3,071
29.117647
72
py
lcogtgemini
lcogtgemini-master/lcogtgemini/flux_calibration.py
import os import numpy as np from astropy.io import fits, ascii from pyraf import iraf import lcogtgemini.file_utils from lcogtgemini import combine from lcogtgemini import fits_utils from lcogtgemini import file_utils from lcogtgemini import fitting from lcogtgemini import utils from lcogtgemini.file_utils import ge...
9,004
49.307263
139
py
lcogtgemini
lcogtgemini-master/lcogtgemini/fitting.py
import numpy as np from scipy import optimize from statsmodels import robust from lcogtgemini.utils import mad from matplotlib import pyplot def ncor(x, y): """Calculate the normalized correlation of two arrays""" d = np.correlate(x, x) * np.correlate(y, y) return np.correlate(x, y) / d ** 0.5 def xcor...
6,446
35.630682
132
py
lcogtgemini
lcogtgemini-master/lcogtgemini/telluric.py
import os import numpy as np from astropy.io import ascii from astropy.io import fits import lcogtgemini.file_utils from lcogtgemini import combine from lcogtgemini import fits_utils from lcogtgemini import fitting # Taken from the Berkley telluric correction # telluricWaves = [(2000., 3190.), (3216., 3420.), (5500.,...
8,487
45.895028
129
py
lcogtgemini
lcogtgemini-master/lcogtgemini/file_utils.py
import numpy as np from astropy.convolution import convolve, Gaussian1DKernel from astropy.io import fits, ascii import os from glob import glob from pyraf import iraf def getobstypes(fs): # get the type of observation for each file obstypes = [] obsclasses = [] for f in fs: obstypes.append(fi...
5,173
30.54878
101
py
lcogtgemini
lcogtgemini-master/lcogtgemini/__init__.py
#!/usr/bin/env python ''' Created on Nov 7, 2014 @author: cmccully ''' import os from pyraf import iraf iraf.cd(os.getcwd()) iraf.gemini() iraf.gmos() iraf.twodspec() iraf.apextract() iraf.onedspec() bluecut = 3450 iraf.gmos.logfile = "log.txt" iraf.gmos.mode = 'h' iraf.set(clobber='yes') iraf.set(stdimage='imtgm...
542
13.289474
32
py
lcogtgemini
lcogtgemini-master/lcogtgemini/sky.py
import lcogtgemini from pyraf import iraf def skysub(scifiles, rawpath): for f in scifiles: # sky subtraction # output has an s prefixed on the front # This step is currently quite slow for Gemini-South data iraf.unlearn(iraf.gsskysub) iraf.gsskysub('t' + f[:-4], long_sample...
490
39.916667
94
py
lcogtgemini
lcogtgemini-master/lcogtgemini/bias.py
import lcogtgemini from glob import glob from astropy.io import fits from pyraf import iraf import numpy as np def makebias(fs, obstypes, rawpath): for f in fs: if f[-10:] == '_bias.fits': iraf.cp(f, 'bias.fits') elif 'bias' in f: iraf.cp(f, './') if len(glob('bias*.fi...
1,059
38.259259
112
py
lcogtgemini
lcogtgemini-master/lcogtgemini/qe.py
import lcogtgemini import os from pyraf import iraf def make_qecorrection(arcfiles): for f in arcfiles: #read in the arcfile name with open(f) as txtfile: arcimage = txtfile.readline() # Strip off the newline character arcimage = 'g' + arcimage.split('\n')[0] ...
562
36.533333
96
py
lcogtgemini
lcogtgemini-master/lcogtgemini/extinction.py
from astropy.io import ascii, fits from lcogtgemini import fits_utils import numpy as np def correct_for_extinction(scifiles, extfile): # Read in the extinction file extinction_correction = ascii.read(extfile) # Convert the extinction to flux extinction_correction['col2'] = 10**(-0.4 * extinction_corr...
1,028
40.16
106
py
lcogtgemini
lcogtgemini-master/lcogtgemini/integration.py
import numpy as np class integrate: def __init__(self): self.trapweights = np.zeros((1, 1)) self.simp2dweights = np.zeros((1, 1)) self.simp4dweights = np.zeros((1, 1, 1, 1)) def sum4d(self, d, binx, biny): return d.sum(axis=3).sum(axis=2) / binx / biny # Define a 2D trape...
3,878
41.163043
101
py
anonymeter
anonymeter-main/src/anonymeter/__init__.py
0
0
0
py
anonymeter
anonymeter-main/src/anonymeter/neighbors/mixed_types_kneighbors.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. """Nearest neighbor search for mixed type data.""" import logging from math import fabs, isnan from typing import Dict, Li...
8,813
35.878661
106
py
anonymeter
anonymeter-main/src/anonymeter/neighbors/__init__.py
0
0
0
py
anonymeter
anonymeter-main/src/anonymeter/evaluators/linkability_evaluator.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. """Privacy evaluator that measures the linkability risk.""" import logging from typing import Dict, List, Optional, Set, T...
11,666
35.688679
117
py
anonymeter
anonymeter-main/src/anonymeter/evaluators/__init__.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. """Tools to evaluate privacy risks along the directives of the Article 29 WGP.""" from anonymeter.evaluators.inference_eva...
590
58.1
83
py
anonymeter
anonymeter-main/src/anonymeter/evaluators/inference_evaluator.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. """Privacy evaluator that measures the inference risk.""" from typing import List, Optional import numpy as np import pan...
9,078
35.757085
111
py
anonymeter
anonymeter-main/src/anonymeter/evaluators/singling_out_evaluator.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. """Privacy evaluator that measures the singling out risk.""" import logging from typing import Any, Callable, Dict, List, ...
18,133
32.273394
118
py
anonymeter
anonymeter-main/src/anonymeter/stats/__init__.py
0
0
0
py
anonymeter
anonymeter-main/src/anonymeter/stats/confidence.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. """Functions for estimating rates and errors in privacy attacks.""" import warnings from math import sqrt from typing imp...
7,791
31.60251
117
py
anonymeter
anonymeter-main/src/anonymeter/preprocessing/transformations.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. """Data pre-processing and transformations for the privacy evaluators.""" import logging from typing import List, Tuple i...
3,730
34.198113
109
py
anonymeter
anonymeter-main/src/anonymeter/preprocessing/type_detection.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. from typing import Dict, List import pandas as pd def detect_col_types(df: pd.DataFrame) -> Dict[str, List[str]]: "...
1,658
29.722222
83
py
anonymeter
anonymeter-main/src/anonymeter/preprocessing/__init__.py
0
0
0
py
anonymeter
anonymeter-main/tests/test_transformations.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. import numpy as np import pandas as pd import pytest from scipy.spatial.distance import pdist, squareform from anonymeter...
2,885
34.195122
89
py
anonymeter
anonymeter-main/tests/test_type_detection.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. import numpy as np import pandas as pd import pytest from anonymeter.preprocessing.type_detection import detect_col_types...
1,643
36.363636
111
py
anonymeter
anonymeter-main/tests/test_linkability_evaluator.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. import numpy as np import pandas as pd import pytest from anonymeter.evaluators.linkability_evaluator import LinkabilityE...
5,463
41.030769
119
py
anonymeter
anonymeter-main/tests/test_inference_evaluator.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. import numpy as np import pandas as pd import pytest from anonymeter.evaluators.inference_evaluator import InferenceEvalu...
4,103
37
118
py
anonymeter
anonymeter-main/tests/test_singling_out_evaluator.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. import numpy as np import pandas as pd import pytest from scipy import integrate from anonymeter.evaluators.singling_out_...
4,203
32.632
106
py
anonymeter
anonymeter-main/tests/test_mixed_types_kneigbors.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. import numpy as np import pandas as pd import pytest from anonymeter.neighbors.mixed_types_kneighbors import MixedTypeKNe...
2,859
35.202532
91
py
anonymeter
anonymeter-main/tests/test_confidence.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details. import numpy as np import pytest from anonymeter.stats.confidence import ( EvaluationResults, SuccessRate, bi...
5,026
29.283133
103
py
anonymeter
anonymeter-main/tests/__init__.py
0
0
0
py
anonymeter
anonymeter-main/tests/fixtures.py
# This file is part of Anonymeter and is released under BSD 3-Clause Clear License. # Copyright (c) 2022 Anonos IP LLC. # See https://github.com/statice/anonymeter/blob/main/LICENSE.md for details.. import os from typing import Optional import pandas as pd TEST_DIR_PATH = os.path.dirname(os.path.realpath(__file__))...
1,143
26.902439
105
py
DCN
DCN-master/SC_MNIST.py
# -*- coding: utf-8 -*- """ Created on Sat Aug 13 14:03:37 2016 Try out SC on MNIST @author: yang4173 """ from sklearn.cluster import SpectralClustering import scipy.io as sio from sklearn import metrics from sklearn.neighbors import kneighbors_graph from sklearn.manifold import spectral_embedding from sklearn.clust...
1,492
24.741379
94
py
DCN
DCN-master/convolutional_ae.py
"""This tutorial introduces the LeNet5 neural network architecture using Theano. LeNet5 is a convolutional neural network, good for classifying images. This tutorial shows how to build the architecture, and comes with all the hyper-parameters you need to reproduce the paper's MNIST results. This implementation simpl...
13,137
32.430025
94
py
DCN
DCN-master/dA_init.py
""" This tutorial introduces denoising auto-encoders (dA) using Theano. Denoising autoencoders are the building blocks for SdA. They are based on auto-encoders as the ones used in Bengio et al. 2007. An autoencoder takes an input x and first maps it to a hidden representation y = f_{\theta}(x) = s(Wx+b), paramete...
15,364
34.899533
98
py
DCN
DCN-master/nystrom.py
# -*- coding: utf-8 -*- """ Created on Mon Sep 5 21:53:08 2016 Perform Nystrom Spectral Clustering ref: Fowlkes, Charless, et al. "Spectral grouping using the Nystrom method." IEEE transactions on pattern analysis and machine intelligence 26.2 (2004): 214-225. @author: bo """ import numpy as np from sklearn...
2,326
27.036145
89
py
DCN
DCN-master/run_pre_mnist.py
# -*- coding: utf-8 -*- """ Created on Mon Oct 10 08:50:00 2016 Experiments on pre-processed MNIST @author: bo """ import sys import gzip import cPickle import numpy as np from sklearn import metrics from sklearn.cluster import KMeans from multi_layer_km import test_SdC from cluster_acc import acc K = 10 trials ...
2,424
27.197674
102
py
DCN
DCN-master/MC.py
# -*- coding: utf-8 -*- """ Created on Fri Aug 5 13:17:42 2016 Perform Monto-Calro simulations of: KM, SC, SNMF, DCN (deep clustering network) and NJ-DCN (non-joint, SAE + KM) The experiment with SNMF is done by saving the data files, and run SNMF with MATLAB. @author: yang4173 """ import os import numpy as np imp...
3,641
28.609756
120
py
DCN
DCN-master/load_network.py
# -*- coding: utf-8 -*- """ Created on Wed Jul 13 09:29:43 2016 @author: yang4173 This script loads a saved network, calculate the learned representation and save for future use. """ import cPickle, gzip import os, sys from multi_layer_km import SdC, load_rcv from deepclustering import load_data import numpy import...
4,673
26.333333
96
py
DCN
DCN-master/multi_layer_km.py
# -*- coding: utf-8 -*- """ @author: bo Multiple-layers Deep Clustering """ import os import sys import timeit import scipy import numpy import cPickle import gzip import theano import theano.tensor as T import matplotlib.pyplot as plt from theano.tensor.shared_randomstreams import RandomStreams from clus...
36,518
37.48156
140
py
DCN
DCN-master/run_rcv1.py
# -*- coding: utf-8 -*- """ Created on Tue Oct 11 07:45:42 2016 Experiments on RCV1-v2 @author: bo """ import sys import numpy as np import matplotlib.pyplot as plt from sklearn import metrics from sklearn.cluster import KMeans from multi_layer_km import test_SdC, load_data from cluster_acc import acc trials = 1 ...
3,493
28.116667
102
py
DCN
DCN-master/run_20News.py
# -*- coding: utf-8 -*- """ Created on Sun Oct 9 13:25:23 2016 Script to run experiments on 20Newsgroup @author: bo """ import sys import numpy as np import matplotlib.pyplot as plt from sklearn import metrics from sklearn.cluster import KMeans from sklearn.manifold import SpectralEmbedding from multi_layer_km im...
3,529
30.238938
102
py
DCN
DCN-master/simulation.py
# -*- coding: utf-8 -*- """ Created on Sun Jun 19 12:09:48 2016 @author: bo Create a toy dataset, including train_set """ import numpy as np import gzip import cPickle import matplotlib.pyplot as plt import sys from sklearn.cluster import SpectralClustering from sklearn.cluster import KMeans from sklearn import m...
6,915
30.870968
101
py
DCN
DCN-master/retrieve.py
# -*- coding: utf-8 -*- """ Created on Tue Aug 30 22:15:30 2016 retrive the saved results @author: bo """ import cPickle, gzip saved_file = 'deepclus_2_clusters.pkl.gz' with gzip.open(saved_file, 'rb') as f: content = cPickle.load(f)
243
14.25
41
py
DCN
DCN-master/cluster_acc.py
# -*- coding: utf-8 -*- """ Created on Sat Aug 27 14:31:40 2016 @author: bo """ from sklearn.utils.linear_assignment_ import linear_assignment import numpy as np def acc(ypred, y): """ Calculating the clustering accuracy. The predicted result must have the same number of clusters as the ground truth. ...
1,845
29.262295
135
py
DCN
DCN-master/run_pendigits.py
# -*- coding: utf-8 -*- """ Created on Mon Oct 3 14:48:35 2016 Perform experiments with Pendigits @author: bo """ import sys import gzip import cPickle import numpy as np from sklearn import metrics from sklearn.cluster import KMeans from sklearn.manifold import SpectralEmbedding from multi_layer_km import test_Sd...
3,133
30.656566
102
py
DCN
DCN-master/multi_layer.py
# -*- coding: utf-8 -*- """ Created on Sun Apr 24 14:27:50 2016 @author: bo Multiple-layers Deep Clustering 06/19/2016 Multi-layer autoencoder, without reconstruction, performance is not good, as expected. 06/20/2016 Multi-layer autoencoder, with reconstruction and clustering as loss, seems to give meaningful resul...
21,375
37.035587
142
py
DCN
DCN-master/get_a_init.py
# -*- coding: utf-8 -*- """ Created on Sat Feb 27 01:04:40 2016 @author: bo run and save a dA model, to initialize my deep_clus model """ import dA dA.test_dA()
164
12.75
57
py
DCN
DCN-master/run_raw_mnist.py
# -*- coding: utf-8 -*- """ Created on Sun Oct 9 21:56:33 2016 Perform experiment on Raw-MNIST data @author: bo """ import gzip import cPickle import sys import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans, metrics from multi_layer_km import test_SdC from cluster_acc import acc ...
2,758
28.042105
102
py
DCN
DCN-master/multi_layer_rbm_mmc.py
# -*- coding: utf-8 -*- """ Created on Sun Apr 24 14:27:50 2016 @author: bo Multiple-layers Deep Clustering 06/19/2016 Multi-layer autoencoder, without reconstruction, performance is not good, as expected. 06/20/2016 Multi-layer autoencoder, with reconstruction and clustering as loss, seems to give meaningful resul...
36,816
37.27131
142
py
DCN
DCN-master/mnist_loader.py
# -*- coding: utf-8 -*- """ Created on Sat Sep 3 18:03:13 2016 Modified from: https://github.com/sorki/python-mnist/blob/master/mnist/loader.py @author: bo """ import os import struct from array import array import numpy as np class MNIST(object): def __init__(self, path='.'): self.path = path ...
2,571
27.577778
80
py
DCN
DCN-master/pre_rcv1.py
# -*- coding: utf-8 -*- """ Created on Thu Aug 25 22:39:02 2016 This script is to pre-process RCV1-V2 dataset @author: bo """ from sklearn.datasets import fetch_rcv1 import scipy.io as sio import numpy import gzip, cPickle import os target_dir = '/home/bo/Data/RCV1/Processed' data_home = '/home/bo/Data' #target_dir...
2,072
23.678571
69
py
DCN
DCN-master/preprocess.py
# -*- coding: utf-8 -*- """ Created on Fri Aug 12 09:33:52 2016 Perform pre-processing on MNIST dataset @author: bo """ import os import sys import timeit import scipy.io as sio import copy import scipy import numpy import cPickle import gzip from sklearn.neighbors import kneighbors_graph from sklearn.metrics.pai...
1,348
21.483333
106
py
DCN
DCN-master/deepclustering.py
# -*- coding: utf-8 -*- """ Created on Sun Feb 7 10:38:06 2016 @author: bo """ import os import sys import timeit import numpy import cPickle import gzip import theano import theano.tensor as T from theano.tensor.shared_randomstreams import RandomStreams from sklearn import metrics from sklearn.cluster import Mini...
15,544
34.490868
124
py
DCN
DCN-master/RBMs_init.py
""" 7/11/2016 Modified from DBN.py in DeepLearningTutorials. The purpose of this script is to perform layerwise pretraining using RBM, and save the trained network for later use. The fine-tuning part is thus removed. """ import os import sys import timeit from six.moves import cPickle import numpy import theano impo...
18,012
38.158696
100
py