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 |
|---|---|---|---|---|---|---|
Reflect | Reflect-master/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/util/text_util.py | from collections import Counter
import csv
import subprocess
from util import inflect
import pandas as pd
from statsmodels.stats.proportion import proportion_confint
infl_eng = inflect.engine()
dependency_fields = ['sentence', 'orig_sentence', 'pos_sentence',
'subj', 'verb', 'subj_pos', 'has_rel',... | 4,707 | 30.178808 | 77 | py |
Reflect | Reflect-master/util/constants.py | pad = '<pad>'
unk = '<unk>'
bos = '<bos>'
eos = '<eos>'
pad_idx = 0
unk_idx = 1
bos_idx = 2
eos_idx = 3
all = [pad, unk, bos, eos] | 132 | 11.090909 | 26 | py |
Reflect | Reflect-master/util/model_configs.py | class ModelConfig(object):
def __init__(self,
hidden_dim=1024,
embedding_dim=512,
input_dim=None,
output_dim=None,
depth=1,
hidden_dropout_rate=0.5,
input_dropout_rate=0.2,
initializer_range=None,
... | 27,929 | 24.813309 | 118 | py |
Reflect | Reflect-master/util/distill_params.py | pure_dstl_1 = {
'distill_temp' : 5.0,
'student_distill_rate' : 1.0,
'student_gold_rate' : 0.0,
'student_learning_rate' : 0.0005,
'student_decay_steps' : 10000,
'student_hold_base_rate_steps' : 1000,
'student_warmup_steps' : 10000,
'student_optimizer' : 'adam',
'teacher_learning_rate' : 0.0005,
'teacher_decay_steps' : ... | 60,330 | 27.364363 | 83 | py |
Reflect | Reflect-master/util/inflect.py | '''
inflect.py: correctly generate plurals, ordinals, indefinite articles;
convert numbers to words
Copyright (C) 2010 Paul Dyson
Based upon the Perl module Lingua::EN::Inflect by Damian Conway.
This program is free software: you can redistribute it and/or modify
it under the terms o... | 94,476 | 30.273419 | 106 | py |
Reflect | Reflect-master/util/train_params.py | radam_slw = {
'learning_rate': 0.0001,
'optimizer': 'radam',
'hold_base_rate_steps': 0
}
adam_slw = {
'learning_rate': 0.0001,
'optimizer': 'adam',
'hold_base_rate_steps': 0
}
adam_mid = {
'learning_rate': 0.0005,
'optimizer': 'adam',
'hold_base_rate_steps': 0
}
adam_midmid = {
'learning_rate': 0.0002,
'optimizer':... | 2,734 | 18.535714 | 49 | py |
Reflect | Reflect-master/util/config_util.py | from util.distill_params import DISTILL_PARAMS
from util.model_configs import GPT2Config, ModelConfig, MODEL_CONFIGS, CapsConfig, ResnetConfig
from util.train_params import TRAIN_PARAMS
class TrainParams(object):
def __init__(self, optimizer,
learning_rate=0.0001,
n_epochs=60,
... | 4,520 | 34.880952 | 95 | py |
Reflect | Reflect-master/util/models.py | from tf2_models.capnet import Capsule
from tf2_models.cnn import VanillaCNN
from tf2_models.ff import VanillaFF
from tf2_models.ff_resnet import FFResnet
from tf2_models.lm_lstm import LmLSTM, LmLSTMSharedEmb, ClassifierLSTM, LmLSTMSharedEmbV2
from tf2_models.lm_transformer import LmGPT2, LmGPT2SharedWeights, Classifie... | 1,068 | 41.76 | 113 | py |
Reflect | Reflect-master/util/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/util/tasks.py | from tasks.lm1b import Lm1B
from tasks.mnist import Mnist, AffNistTask, Svhn, Mnist40
from tasks.smallnorb import SmallNorb
from tasks.sst import ClassifySST2, LmSST2
from tasks.sv_agreement import SvAgreementLM, WordSvAgreementLM, WordSvAgreementVP
from tasks.wiki import WikiLM
TASKS = {
'sv_agreement_lm': SvAgreem... | 606 | 27.904762 | 82 | py |
Reflect | Reflect-master/distill/offline_repshare.py | import tensorflow as tf
import os
from distill.distiller import Distiller
from distill.online_distiller import OnlineDistiller
from distill.repsim_util import get_reps
from tf2_models.train_utils import ExponentialDecayWithWarmpUp
from tf2_models.trainer import OPTIMIZER_DIC
from tf2_models.utils import camel2snake
fro... | 6,270 | 42.248276 | 128 | py |
Reflect | Reflect-master/distill/repsim_util.py | import tensorflow as tf
import numpy as np
def get_reps(outputs, index=1, layer=-1, **kwargs):
"""
If Model is LSTM:
1: final_rnn_outputs,
2: hidden_activation (for all layers, including input embeddings)
reduction: None, "last", "sum"
"""
logits = outputs[0]
outputs = tf.tuple(outputs)
rep... | 3,444 | 31.5 | 110 | py |
Reflect | Reflect-master/distill/online_distiller.py | import tensorflow as tf
import os
from distill.distill_util import get_distill_scheduler
from distill.distiller import Distiller
from tf2_models.train_utils import ExponentialDecayWithWarmpUp
from tf2_models.trainer import OPTIMIZER_DIC
from tf2_models.utils import camel2snake
from inspect import isfunction
import num... | 9,001 | 43.127451 | 132 | py |
Reflect | Reflect-master/distill/model.py | class Model(object):
def apply(self, examples):
raise NotImplementedError
def update(self, loss):
raise NotImplementedError | 136 | 21.833333 | 29 | py |
Reflect | Reflect-master/distill/distill_main.py | ''' Code to apply the distillation process for a teacher and a student model.
Run:
python distill/distill_main.py \
--task=word_sv_agreement_vp \
--teacher_exp_name=small_lstm_v4_0.0001_withl2 \
--teacher_model=cl_lstm \
--teacher_config=small_lstm_v4 \
--student_exp_name=distilled0 \
--student_model=cl_gpt2 \
--stude... | 5,174 | 47.820755 | 136 | py |
Reflect | Reflect-master/distill/distill_mnist.py | ''' Code to apply the distillation process for a teacher and a student model.
Run:
python distill/distill_main.py \
--task=word_sv_agreement_vp \
--teacher_exp_name=small_lstm_v4_0.0001_withl2 \
--teacher_model=cl_lstm \
--teacher_config=small_lstm_v4 \
--student_exp_name=distilled0 \
--student_model=cl_gpt2 \
--stude... | 4,778 | 47.272727 | 136 | py |
Reflect | Reflect-master/distill/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/distill/distill_util.py | import tensorflow as tf
from tf2_models.metrics import distill_loss, sequence_distill_loss
@tf.function(experimental_relax_shapes=True)
def get_topk_mask(inputs, k):
inputs_shape = tf.shape(inputs)
inputs_shape = tf.cast(inputs_shape, dtype=tf.int64)
values, indices = tf.nn.top_k(inputs, k=k, sorted=False)
i... | 3,653 | 35.54 | 110 | py |
Reflect | Reflect-master/distill/distiller.py | import tensorflow as tf
import os
from distill.distill_util import get_distill_scheduler
from tf2_models.train_utils import ExponentialDecayWithWarmpUp
from tf2_models.trainer import OPTIMIZER_DIC
import numpy as np
class Distiller(object):
''' Pipeline for offline distillation.
'''
def __init__(self, hparams,... | 9,284 | 44.292683 | 132 | py |
Reflect | Reflect-master/tf2_models/embedding.py | import tensorflow as tf
from tf2_models.common_layers import get_initializer, shape_list
class SharedEmbeddings(tf.keras.layers.Layer):
"""Construct shared token embeddings.
"""
def __init__(self, vocab_size, hidden_size, initializer_range=None, regularizer=None, **kwargs):
super(SharedEmbeddings, self)._... | 2,633 | 38.313433 | 137 | py |
Reflect | Reflect-master/tf2_models/lm_transformer.py | import tensorflow as tf
from tf2_models.common_layers import get_initializer, shape_list
from tf2_models.embedding import SharedEmbeddings
from tf2_models.transformer_layers import Block
from tf2_models.transformers import *
class LmGPT2(tf.keras.Model):
def __init__(self, hparams, scope='lm_gpt2', *inputs, **kwargs... | 10,814 | 39.965909 | 109 | py |
Reflect | Reflect-master/tf2_models/ff.py | import tensorflow as tf
import numpy as np
class VanillaFF(tf.keras.models.Sequential):
def __init__(self, hparams, scope="cl_vff", *inputs, **kwargs):
if 'cl_token' in kwargs:
del kwargs['cl_token']
super(VanillaFF, self).__init__()
self.scope = scope
self.hparams = hparams
self.model_n... | 3,116 | 36.107143 | 92 | py |
Reflect | Reflect-master/tf2_models/common_layers.py | import tensorflow as tf
import numpy as np
from tensorflow.python.framework import tensor_shape
from tensorflow.python.util import nest
def gelu(x):
"""Gaussian Error Linear Unit.
This is a smoother version of the RELU.
Original paper: https://arxiv.org/abs/1606.08415
Args:
x: float Tensor to perform ac... | 3,398 | 34.041237 | 72 | py |
Reflect | Reflect-master/tf2_models/lm_lstm.py | import absl
import tensorflow as tf
import numpy as np
from tensorboard.compat.tensorflow_stub import tensor_shape
from tensorflow.python.util import nest
from tf2_models.common_layers import get_initializer
from tf2_models.embedding import SharedEmbeddings
from tf2_models.utils import create_init_var
class LmLSTM(tf... | 23,117 | 47.364017 | 138 | py |
Reflect | Reflect-master/tf2_models/transformers.py | import tensorflow as tf
from tf2_models.common_layers import get_initializer, shape_list
from tf2_models.embedding import SharedEmbeddings
from tf2_models.transformer_layers import Block
class GPT2(tf.keras.layers.Layer):
def __init__(self, hparams, *inputs, **kwargs):
super(GPT2, self).__init__(hparams, *input... | 16,938 | 40.619165 | 113 | py |
Reflect | Reflect-master/tf2_models/resnet.py | import tensorflow as tf
class ResnetBlock(tf.keras.layers.Layer):
def __init__(self, filters, kernel_size, activation='relu',*inputs, **kwargs):
super(ResnetBlock, self).__init__(*inputs, **kwargs)
self.filters = filters
self.kernel_size = kernel_size
self.activation = activation
self.regularizer... | 6,572 | 40.601266 | 94 | py |
Reflect | Reflect-master/tf2_models/cnn.py | import tensorflow as tf
import numpy as np
def max_out(inputs, num_units, axis=None):
shape = inputs.get_shape().as_list()
if shape[0] is None:
shape[0] = -1
if axis is None: # Assume that channel is the last dimension
axis = -1
num_channels = shape[axis]
if num_channels % num_units:
raise Valu... | 5,878 | 38.993197 | 91 | py |
Reflect | Reflect-master/tf2_models/utils.py | import tensorflow as tf
import re
from tensorboard.compat.tensorflow_stub import tensor_shape
def camel2snake(name):
return name[0].lower() + re.sub(r'(?!^)[A-Z]', lambda x: '_' + x.group(0).lower(), name[1:])
def log_summary(log_value, log_name, summary_scope):
"""Produce scalar summaries."""
with tf.compat.... | 884 | 31.777778 | 99 | py |
Reflect | Reflect-master/tf2_models/train_utils.py | import absl
import tensorflow as tf
from tensorflow.python.framework import ops
from tensorflow.python.keras.optimizer_v2.learning_rate_schedule import LearningRateSchedule
from tensorflow.python.ops import math_ops
from tensorflow.python.util.tf_export import keras_export
from tensorflow_addons.utils import keras_uti... | 17,416 | 40.568019 | 92 | py |
Reflect | Reflect-master/tf2_models/transformer_layers.py | import tensorflow as tf
from tf2_models.common_layers import get_initializer, shape_list, gelu
class Attention(tf.keras.layers.Layer):
def __init__(self, hidden_dim, n_ctx, config, regularizer, casual_masking=True, scale=False, **kwargs):
super(Attention, self).__init__(**kwargs)
self.output_attentions = c... | 6,560 | 35.049451 | 105 | py |
Reflect | Reflect-master/tf2_models/ff_resnet.py | import tensorflow as tf
class FFResnetBlock(tf.keras.layers.Layer):
def __init__(self, filters, kernel_size, activation='relu',*inputs, **kwargs):
super(FFResnetBlock, self).__init__(*inputs, **kwargs)
self.filters = filters
self.kernel_size = kernel_size
self.activation = activation
self.regular... | 6,118 | 39.256579 | 96 | py |
Reflect | Reflect-master/tf2_models/keras_callbacks.py | import tensorflow as tf
from tf2_models.utils import log_summary
class CheckpointCallback(tf.keras.callbacks.Callback):
def __init__(self, manager, ckpt):
super(CheckpointCallback, self).__init__()
self.manager = manager
self.ckpt = ckpt
def on_epoch_end(self, epoch, logs=None):
self.ckpt.step.... | 1,859 | 38.574468 | 148 | py |
Reflect | Reflect-master/tf2_models/metrics.py | import tensorflow as tf
@tf.function(experimental_relax_shapes=True)
def distill_loss(y_true, y_pred, tmp):
y_true = tf.cast(tf.squeeze(y_true), dtype=tf.float32)
scale_factor = 1.0 / (tmp*tmp)
return tf.reduce_mean(tf.compat.v2.nn.softmax_cross_entropy_with_logits(logits=y_pred / tmp,
... | 10,276 | 46.578704 | 117 | py |
Reflect | Reflect-master/tf2_models/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/tf2_models/trainer.py | import tensorflow as tf
import os
from tf2_models.keras_callbacks import CheckpointCallback, SummaryCallback
from tf2_models.train_utils import RectifiedAdam, ExponentialDecayWithWarmpUp
OPTIMIZER_DIC = {'adam': tf.keras.optimizers.Adam,
'radam': RectifiedAdam,
}
class Trainer(object)... | 3,931 | 39.536082 | 122 | py |
Reflect | Reflect-master/tfds_data/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/tfds_data/tal_agreement.py | from collections import Counter
import tensorflow as tf
import tensorflow_datasets as tfds
import os
import numpy as np
from tensorflow_datasets.core.features.text import Tokenizer
from tensorflow_datasets.core.features.text.text_encoder import write_lines_to_file, read_lines_from_file
from prep_data.build_dictionary... | 8,680 | 35.020747 | 106 | py |
Reflect | Reflect-master/tasks/task.py | import tensorflow as tf
from distill.distill_util import get_masked_probs
from distill.repsim_util import rep_loss
from util import constants
class Task(object):
def __init__(self, task_params, num_replicas_in_sync=1, builder_cls=None, name='abstract_task', data_dir='data', output_padding=False):
self.name = na... | 6,704 | 47.586957 | 142 | py |
Reflect | Reflect-master/tasks/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/tasks/sv_agreement.py | import functools
from distill.distill_util import DistillLoss, get_probs, SequenceDistillLoss, get_topk_masked_probs, get_masked_probs
from tasks.task import Task
import tensorflow as tf
from tf2_models import metrics
from tf2_models.metrics import masked_batch_perplexity, masked_perplexity, \
MaskedSequenceLoss, C... | 5,424 | 44.208333 | 163 | py |
Reflect | Reflect-master/tasks/mnist.py | from distill.distill_util import DistillLoss, get_probs
from tasks.task import Task
import tensorflow as tf
import tensorflow_datasets as tfds
from tf2_models.metrics import ClassificationLoss
from tfds_data.aff_nist import AffNist
class Mnist(Task):
def __init__(self, task_params, name='mnist', data_dir='mnist_da... | 8,663 | 37.678571 | 103 | py |
Reflect | Reflect-master/tasks/evaluations/lm_sv_agreement_eval.py | ''' Evaluate word based language models on the subject verb agreement task.
Codes adapted from:
Example Run:
python tasks/evaluations/lm_sv_agreement_eval.py \
--exp_name=lisa_fd4 \
--model_name=lm_gpt2 \
--model_config=very_big_gpt_v10 \
--train_config=adam_slow \
--prefix=offline_pure_distill_2_teacher_lm_lstm_shar... | 6,755 | 36.955056 | 135 | py |
Reflect | Reflect-master/tasks/evaluations/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/notebooks/notebook_utils.py | import tensorflow as tf
import numpy as np
import os
from tqdm import tqdm
from util import constants
from collections import Counter
from util.models import MODELS
from util.tasks import TASKS
from util.config_util import get_model_params, get_task_params, get_train_params
import matplotlib.pyplot as plt
import pandas... | 10,989 | 36.508532 | 153 | py |
Reflect | Reflect-master/notebooks/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/notebooks/calibration_util.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
import tensorflo... | 3,258 | 38.26506 | 100 | py |
Reflect | Reflect-master/notebooks/viz/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/notebooks/eval_scripts/eval_vp.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 5,193 | 28.68 | 139 | py |
Reflect | Reflect-master/notebooks/eval_scripts/eval_vp-bert.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 19,508 | 33.962366 | 137 | py |
Reflect | Reflect-master/notebooks/eval_scripts/eval_vp-ugpt.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 19,655 | 33.851064 | 139 | py |
Reflect | Reflect-master/notebooks/eval_scripts/eval_vp-lstm.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 7,129 | 32.009259 | 139 | py |
Reflect | Reflect-master/notebooks/eval_scripts/eval_full_sv_cl.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 4,451 | 29.285714 | 108 | py |
Reflect | Reflect-master/notebooks/eval_scripts/eval_lm.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 2,524 | 28.360465 | 86 | py |
Reflect | Reflect-master/notebooks/eval_scripts/eval_full_sv_cl_gpt2.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 4,517 | 29.322148 | 108 | py |
Reflect | Reflect-master/notebooks/eval_scripts/eval_full_sv_cl_bert.py | import os
import tensorflow as tf
from util import constants
from util.config_util import get_model_params, get_task_params, get_train_params
from tf2_models.trainer import Trainer
from absl import app
from absl import flags
import numpy as np
from util.models import MODELS
from util.tasks import TASKS
from notebook_ut... | 4,447 | 29.258503 | 108 | py |
Reflect | Reflect-master/prep_data/split.py | import sys
import os
import errno
import random
from util.text_util import deps_from_tsv, deps_to_tsv
def make_splits(fname, expr_dir, prop_train=0.1, prop_valid=0.01):
# for reproducibility
random.seed(42)
print('| read in the data')
data = deps_from_tsv(fname)
print('| shuffling')
random.sh... | 947 | 25.333333 | 66 | py |
Reflect | Reflect-master/prep_data/gen_bowman_logic.py | from itertools import chain
from itertools import combinations
from collections import Counter
import random
def powerset(iterable):
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))
def get_candidate_worlds(num_vars):
return powerset(set(range(num_vars)))
de... | 5,553 | 28.386243 | 77 | py |
Reflect | Reflect-master/prep_data/__init__.py | 0 | 0 | 0 | py | |
Reflect | Reflect-master/prep_data/build_dictionary.py | from util import text_util as utils
from util import constants
from sys import argv
import numpy as np
import os
def build_and_save_dic(input_file, data_dir):
worddict = {}
worddict[constants.pad] = constants.pad_idx
worddict[constants.unk] = constants.unk_idx
worddict[constants.bos] = constants.bos_i... | 969 | 26.714286 | 51 | py |
PyKrige | PyKrige-main/setup.py | # -*- coding: utf-8 -*-
"""Kriging Toolkit for Python."""
import os
import numpy as np
from Cython.Build import cythonize
from setuptools import Extension, setup
# cython extensions
CY_MODULES = [
Extension(
name=f"pykrige.{ext}",
sources=[os.path.join("src", "pykrige", *ext.split(".")) + ".pyx"],... | 634 | 27.863636 | 75 | py |
PyKrige | PyKrige-main/benchmarks/kriging_benchmarks.py | # -*- coding: utf-8 -*-
"""Benchmarks."""
from time import time
import numpy as np
from pykrige.ok import OrdinaryKriging
np.random.seed(19999)
VARIOGRAM_MODELS = ["power", "gaussian", "spherical", "exponential", "linear"]
BACKENDS = ["vectorized", "loop", "C"]
N_MOVING_WINDOW = [None, 10, 50, 100]
def make_bench... | 3,473 | 27.47541 | 88 | py |
PyKrige | PyKrige-main/examples/06_exact_values_example_1D.py | # -*- coding: utf-8 -*-
"""
Exact Values
============
PyKrige demonstration and usage
as a non-exact interpolator in 1D.
"""
import matplotlib.pyplot as plt
import numpy as np
from pykrige.ok import OrdinaryKriging
plt.style.use("ggplot")
np.random.seed(42)
x = np.linspace(0, 12.5, 50)
xpred = np.linspace(0, 12.... | 1,375 | 21.557377 | 77 | py |
PyKrige | PyKrige-main/examples/00_ordinary.py | """
Ordinary Kriging Example
========================
First we will create a 2D dataset together with the associated x, y grids.
"""
import matplotlib.pyplot as plt
import numpy as np
import pykrige.kriging_tools as kt
from pykrige.ok import OrdinaryKriging
data = np.array(
[
[0.3, 1.2, 0.47],
... | 1,840 | 30.20339 | 84 | py |
PyKrige | PyKrige-main/examples/07_regression_kriging2d.py | """
Regression kriging
------------------
An example of regression kriging
"""
import sys
from sklearn.datasets import fetch_california_housing
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.svm im... | 1,368 | 28.76087 | 81 | py |
PyKrige | PyKrige-main/examples/10_classification_kriging2d.py | """
Classification kriging
----------------------
An example of classification kriging
"""
import sys
from sklearn.datasets import fetch_california_housing
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from... | 1,566 | 29.72549 | 86 | py |
PyKrige | PyKrige-main/examples/01_universal.py | """
Universal Kriging Example
=========================
In this example we apply a regional linear trend to the kriging system.
"""
import matplotlib.pyplot as plt
import numpy as np
from pykrige.uk import UniversalKriging
data = np.array(
[
[0.3, 1.2, 0.47],
[1.9, 0.6, 0.56],
[1.1, 3.2... | 1,475 | 27.941176 | 84 | py |
PyKrige | PyKrige-main/examples/08_krige_cv.py | # -*- coding: utf-8 -*-
"""
Krige CV
--------
Searching for optimal kriging parameters with cross validation
"""
import numpy as np
from sklearn.model_selection import GridSearchCV
from pykrige.rk import Krige
# 2D Kring param opt
param_dict = {
"method": ["ordinary", "universal"],
"variogram_model": ["lin... | 1,951 | 23.708861 | 86 | py |
PyKrige | PyKrige-main/examples/02_kriging3D.py | """
Three-Dimensional Kriging Example
=================================
"""
import numpy as np
from matplotlib import pyplot as plt
from pykrige.ok3d import OrdinaryKriging3D
from pykrige.uk3d import UniversalKriging3D
data = np.array(
[
[0.1, 0.1, 0.3, 0.9],
[0.2, 0.1, 0.4, 0.8],
[0.1, ... | 3,514 | 32.47619 | 85 | py |
PyKrige | PyKrige-main/examples/05_kriging_1D.py | """
1D Kriging
==========
An example of 1D kriging with PyKrige
"""
import matplotlib.pyplot as plt
import numpy as np
from pykrige import OrdinaryKriging
plt.style.use("ggplot")
# fmt: off
# Data taken from
# https://blog.dominodatalab.com/fitting-gaussian-process-models-python/
X, y = np.array([
[-5.01, 1.06... | 2,626 | 36 | 79 | py |
PyKrige | PyKrige-main/examples/04_krige_geometric.py | # -*- coding: utf-8 -*-
"""
Geometric example
=================
A small example script showing the usage of the 'geographic' coordinates type
for ordinary kriging on a sphere.
"""
import numpy as np
from matplotlib import pyplot as plt
from pykrige.ok import OrdinaryKriging
# Make this example reproducible:
np.rand... | 2,636 | 31.555556 | 79 | py |
PyKrige | PyKrige-main/examples/03_gstools_covmodel.py | # -*- coding: utf-8 -*-
"""
GSTools Interface
=================
Example how to use the PyKrige routines with a GSTools CovModel.
"""
import gstools as gs
import numpy as np
from matplotlib import pyplot as plt
from pykrige.ok import OrdinaryKriging
# conditioning data
data = np.array(
[
[0.3, 1.2, 0.47],... | 844 | 23.852941 | 87 | py |
PyKrige | PyKrige-main/src/pykrige/ok.py | # coding: utf-8
"""
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Contains class OrdinaryKriging, which provides easy access to
2D Ordinary Kriging.
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in
Hydrogeol... | 42,554 | 40.679726 | 88 | py |
PyKrige | PyKrige-main/src/pykrige/compat_gstools.py | # coding: utf-8
# pylint: disable= invalid-name, unused-import
"""For GSTools compatibility."""
# gstools
try:
import gstools as gs
GSTOOLS_INSTALLED = True
GSTOOLS_VERSION = list(map(int, gs.__version__.split(".")[:2]))
except ImportError:
gs = None
GSTOOLS_INSTALLED = False
GSTOOLS_VERSION ... | 1,062 | 27.72973 | 85 | py |
PyKrige | PyKrige-main/src/pykrige/uk.py | # coding: utf-8
"""
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Contains class UniversalKriging, provides greater control over 2D kriging by
utilizing drift terms.
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications... | 56,799 | 41.706767 | 87 | py |
PyKrige | PyKrige-main/src/pykrige/core.py | # coding: utf-8
"""
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Methods used by multiple classes.
References
----------
[1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in Hydrogeology,
(Cambridge University Press, 1997) 272 p.
[2] ... | 30,289 | 33.538198 | 88 | py |
PyKrige | PyKrige-main/src/pykrige/uk3d.py | # coding: utf-8
"""
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Contains class UniversalKriging3D.
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in
Hydrogeology, (Cambridge University Press, 1997) 272 p.
.... | 49,151 | 41.852659 | 88 | py |
PyKrige | PyKrige-main/src/pykrige/ok3d.py | # coding: utf-8
"""
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Contains class OrdinaryKriging3D.
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in
Hydrogeology, (Cambridge University Press, 1997) 272 p.
..... | 39,816 | 41.676313 | 88 | py |
PyKrige | PyKrige-main/src/pykrige/rk.py | # coding: utf-8
"""Regression Kriging."""
from pykrige.compat import Krige, check_sklearn_model, validate_sklearn
validate_sklearn()
from sklearn.metrics import r2_score
from sklearn.svm import SVR
class RegressionKriging:
"""
An implementation of Regression-Kriging.
As described here:
https://en.w... | 5,982 | 30.994652 | 86 | py |
PyKrige | PyKrige-main/src/pykrige/variogram_models.py | # coding: utf-8
"""
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Function definitions for variogram models. In each function, m is a list of
defining parameters and d is an array of the distance values at which to
calculate the variogram model.
Referen... | 2,092 | 24.52439 | 83 | py |
PyKrige | PyKrige-main/src/pykrige/ck.py | # coding: utf-8
"""Classification Kriging."""
import numpy as np
from pykrige.compat import Krige, check_sklearn_model, validate_sklearn
validate_sklearn()
from scipy.linalg import helmert
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import OneHotEncoder
from sklearn.svm import SVC
class C... | 9,458 | 31.393836 | 106 | py |
PyKrige | PyKrige-main/src/pykrige/__init__.py | """
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Kriging toolkit for Python.
ok: Contains class OrdinaryKriging, which is a convenience class for easy
access to 2D ordinary kriging.
uk: Contains class UniversalKriging, which provides more control o... | 2,389 | 35.212121 | 76 | py |
PyKrige | PyKrige-main/src/pykrige/compat.py | # coding: utf-8
# pylint: disable= invalid-name, unused-import
"""For compatibility."""
from pykrige.ok import OrdinaryKriging
from pykrige.ok3d import OrdinaryKriging3D
from pykrige.uk import UniversalKriging
from pykrige.uk3d import UniversalKriging3D
# sklearn
try:
# keep train_test_split here for backward com... | 9,889 | 31.11039 | 88 | py |
PyKrige | PyKrige-main/src/pykrige/kriging_tools.py | # coding: utf-8
"""
PyKrige
=======
Code by Benjamin S. Murphy and the PyKrige Developers
bscott.murphy@gmail.com
Summary
-------
Methods for reading/writing ASCII grid files.
Copyright (c) 2015-2020, PyKrige Developers
"""
import datetime
import io
import os
import warnings
import numpy as np
def write_asc_grid(... | 15,629 | 32.612903 | 88 | py |
PyKrige | PyKrige-main/src/pykrige/lib/__init__.py | __all__ = ["cok", "lapack", "variogram_models"]
| 48 | 23.5 | 47 | py |
PyKrige | PyKrige-main/tests/test_core.py | """
Testing code.
Updated BSM February 2017
"""
import os
import sys
import numpy as np
import pytest
from numpy.testing import assert_allclose
from pytest import approx
from scipy.spatial.distance import cdist
from pykrige import core
from pykrige import kriging_tools as kt
from pykrige import variogram_models
from ... | 96,612 | 31.344493 | 88 | py |
PyKrige | PyKrige-main/tests/test_api.py | from itertools import product
import numpy as np
import pytest
from pykrige.compat import Krige, threed_krige
def _method_and_vergiogram():
method = ["ordinary", "universal", "ordinary3d", "universal3d"]
variogram_model = ["linear", "power", "gaussian", "spherical", "exponential"]
return product(method,... | 1,394 | 28.0625 | 81 | py |
PyKrige | PyKrige-main/tests/test_classification_krige.py | from itertools import product
import numpy as np
import pytest
from pykrige.ck import ClassificationKriging
try:
from sklearn.datasets import fetch_california_housing
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.preprocessing im... | 3,274 | 31.107843 | 85 | py |
PyKrige | PyKrige-main/tests/test_regression_krige.py | from itertools import product
import numpy as np
import pytest
from pykrige.rk import RegressionKriging
try:
from sklearn.datasets import fetch_california_housing
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import ElasticNet, Lasso, LinearRegression
from sklearn.model... | 3,107 | 30.08 | 85 | py |
PyKrige | PyKrige-main/docs/source/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# PyKrige documentation build configuration file, created by
# sphinx-quickstart on Wed Mar 1 18:34:53 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# au... | 11,242 | 30.940341 | 88 | py |
PyKrige | PyKrige-main/docs/source/sphinxext/github_link.py | # Adapted from scikit learn
import inspect
import os
import subprocess
import sys
from functools import partial
from operator import attrgetter
REVISION_CMD = "git rev-parse --short HEAD"
def _get_git_revision():
try:
revision = subprocess.check_output(REVISION_CMD.split()).strip()
except (subproces... | 2,645 | 29.767442 | 85 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/constants.py | num_initial_random_draws = 5
num_gradient_updates = 1000 | 56 | 27.5 | 28 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/benchmark_example.py | import logging
from functools import partial
import numpy as np
import matplotlib.pyplot as plt
from blackbox import BlackboxOffline
from blackbox.load_utils import evaluation_split_from_task
from optimizer.benchmark import benchmark
from optimizer.gaussian_process import GP
from optimizer.random_search import RS
fro... | 1,894 | 27.283582 | 76 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/__init__.py | 0 | 0 | 0 | py | |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/misc/artificial_data.py | import numpy as np
def artificial_task1(
input_dim: int = 2,
num_train_examples: int = 10000,
num_tasks: int = 5,
seed: int = 0,
):
# blackboxes are quadratic functions whose centers are sampled in a ball around [0.5, ..., 0.5]
np.random.seed(seed)
centers = (np.random.rand... | 1,709 | 31.884615 | 112 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/misc/__init__.py | import random
import numpy as np
import torch
def set_seed(seed: int):
torch.manual_seed(seed)
np.random.seed(seed)
random.seed(seed)
| 149 | 12.636364 | 27 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/prior/mlp_pytorch.py | import tempfile
import uuid
from pathlib import Path
from typing import Optional, Tuple
from sklearn.preprocessing import StandardScaler
from constants import num_gradient_updates
import numpy as np
from tqdm import tqdm
import torch
from torch import nn
from torch.utils.data import Dataset, DataLoader, TensorDatase... | 6,805 | 36.191257 | 126 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/prior/benchmark.py | import numpy as np
import pandas as pd
from blackbox.load_utils import evaluation_split_from_task, tasks
from optimizer.normalization_transforms import from_string
from prior.mlp_pytorch import ParametricPrior
from prior.mlp_sklearn import ParametricPriorSklearn
normalization = "gaussian"
rows = []
#tasks = [
# '... | 1,360 | 26.22 | 88 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/prior/mlp_sklearn.py | import numpy as np
from sklearn.neural_network import MLPRegressor
from sklearn.preprocessing import StandardScaler
from constants import num_gradient_updates
from prior import Prior
class ParametricPriorSklearn(Prior):
def __init__(
self,
X_train: np.array,
y_train: np.array,... | 2,161 | 29.450704 | 101 | py |
A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning | A-Quantile-based-Approach-for-Hyperparameter-Transfer-Learning-master/src/prior/unit_prior.py | from typing import Tuple
import numpy as np
from prior import Prior
class UnitPrior(Prior):
def __init__(
self,
X_train: np.array,
y_train: np.array
):
super(UnitPrior, self).__init__(
X_train=X_train,
y_train=y_train,
)
def pre... | 453 | 22.894737 | 74 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.