Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
4,300
<ASSISTANT_TASK:> Python Code: solution = 0 N = 0 while N < 1000: if (N % 3 == 0) or (N % 5 == 0): solution = solution + N N+=1 print solution s=0 a=1 b=1 while b < 4E6: if b % 2 ==0: s=s+b; c=a+b a=b b=c print s n=600851475143 #13195 a=2 while not a > n: if n%a: a+=1 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Q002 Step2: Q003 Step3: Q004 Step4: Q005 Step5: Q006 Step6: Q007 Step7: Q008 Step8: Q009 Step9: Q010
4,301
<ASSISTANT_TASK:> Python Code: a = [1, 2, "Hi"] # Создать список и присвоить переменной `а` этот список print(a[0], a[1], a[2]) # Обращение к элементам списка, индексация с нуля b = list() # Создать пустой список c = [] # Другой способ создать пустой список a = [0] * 10 print(a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Можно создать список из однотипных элементов заданной длины Step2: Доступ к элементам Step3: Обратите внимание, что при выведении списка таким...
4,302
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np import mne data_path = mne.datasets.opm.data_path() subject = 'OPM_sample' subjects_dir = op.join(data_path, 'subjects') raw_fname = op.join(data_path, 'MEG', 'OPM', 'OPM_SEF_raw.fif') bem_fname = op.join(subjects_dir, subject, 'bem', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Prepare data for localization Step2: Examine our coordinate alignment for source localization and compute a Step3: Perform dipole fitting Step...
4,303
<ASSISTANT_TASK:> Python Code: numero = 78277485 a = numero % 1000; a b = numero % 100; b from mpmath import mp #Librería usada para modiuficar la precision decimal de PI from math import sqrt mp.dps = 1000 #Establecer la precisión que queremos pi_1000 = mp.pi print(pi_1000) besima = str(pi_1000)[b+2] print(besima) a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Ejercicio 1 Step2: Convenimos que la posición decimal de las decimas está indicada con el 0. Step3: 2. Calcula el conjunto de los divisores na...
4,304
<ASSISTANT_TASK:> Python Code: import graphlab image_train = graphlab.SFrame('image_train_data/') image_test = graphlab.SFrame('image_test_data/') #deep_learning_model = graphlab.load_model('http://s3.amazonaws.com/GraphLab-Datasets/deeplearning/imagenet_model_iter45') #image_train['deep_features'] = deep_learning_mo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the CIFAR-10 dataset Step2: Computing deep features for our images Step3: Train a nearest-neighbors model for retrieving images using dee...
4,305
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-2', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
4,306
<ASSISTANT_TASK:> Python Code: import numpy as np from numpy import linalg as LA import itertools A = np.random.rand(3,3) M = A @ A.T D, U = LA.eigh(M) # D is returned as a vector print(M) print() M2 = U @ np.diag(D) @ np.conj(U.T) # Conjugation not always needed print(M2) M = np.random.rand(2, 3) + 1j * np.random.ra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Part 1 Step2: Singular value decomposition Step5: MPS Step6: We can compress the parity indicator into a MPS form by a sequence of SVDs, as e...
4,307
<ASSISTANT_TASK:> Python Code: from ipywidgets import interact, interactive, fixed import ipywidgets as widgets import rx rx from rx import Observable, Observer help(Observer) dir(Observer) help(Observable) class MyObserver(Observer): def on_next(self, x): print("Got: %s" % x) def on_error(self, e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Concepts Step2: Concepts Step3: Reference Step4: Filtering a Sequence Step5: Interactive Rx - Filtering Step6: Transforming a Sequence Step...
4,308
<ASSISTANT_TASK:> Python Code: markdown_str = ("The tables in this section show the standard association metrics between " "*observed* human scores and different types of machine scores. " "These results are computed on the evaluation set. `raw_trim` scores " "are truncat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Descriptive holistic score statistics Step2: Association statistics Step3: Confusion matrix Step4: Distribution of human and machine scores
4,309
<ASSISTANT_TASK:> Python Code: df = pd.DataFrame({'subject':['A', 'A', 'B', 'B'], 'treatment':['CH', 'DT', 'CH', 'DT'], 'concentration':range(4)}, columns=['subject', 'treatment', 'concentration']) df pivoted = df.pivot(index='subject', columns='treatment', valu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: A better representation might be one where the different subjects are in rows, the applied treatments are in columns and outcomes are in the dat...
4,310
<ASSISTANT_TASK:> Python Code: from nilearn.plotting import plot_anat %matplotlib inline plot_anat('/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz', dim=-1); %%bash bet /data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz \ /data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w_bet.nii.g...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example of interface Step2: ... which yields the following Step3: Using nipype, the equivalent is a bit more verbose Step4: Now we can verify...
4,311
<ASSISTANT_TASK:> Python Code: import os import sys # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install -U google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG if not os.getenv("IS_TESTING...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
4,312
<ASSISTANT_TASK:> Python Code: from bigbang.archive import Archive urls = [#"analytics", "conferences", "design", "education", "gendergap", "historic", "hot", "ietf-privacy", "ipython-dev", "ipython-user", "languages", "maps-l", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The above code reads in preprocessed email archive data. These mailing lists are from a variety of different sources Step2: Now we have process...
4,313
<ASSISTANT_TASK:> Python Code: import numpy as np def gram_linear(x): Compute Gram (kernel) matrix for a linear kernel. Args: x: A num_examples x num_features matrix of features. Returns: A num_examples x num_examples Gram matrix of examples. return x.dot(x.T) def gram_rbf(x, threshold=1.0): Comput...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step6: Demo code for "Similarity of Neural Network Representations Revisited" Step7: Tutorial Step8: Linear CKA can be computed either based on dot p...
4,314
<ASSISTANT_TASK:> Python Code: a=45 print(a) b=25 print(b) x="Hello Everybody!" print(x) Amiright=True print(Amiright) fl = 0.54 print(fl) print(a) print(b) c=a+b print(c) c=a/b print(c) c=c+a print(c) #addition print(2+2) #division or quotient print(42/42) #multiplication print(2*3) #subtraction print(2-8) #expon...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Okay, neat. Can I only make variables that hold numbers? Step2: Wait a minute, the numerical variables above are only integers...can we use dec...
4,315
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'sandbox-3', 'ocean') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "emai...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
4,316
<ASSISTANT_TASK:> Python Code: import h2o from h2o.estimators.uplift_random_forest import H2OUpliftRandomForestEstimator import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.style as style import pandas as pd h2o.init(strict_version_check=False) # max_mem_size=10 control_name = "control" treatmen...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load data Step2: Prepare data Step3: Import data to H2O Step4: Train H2O UpliftDRF model Step5: Predict and plot Uplift Score Step6: Evalua...
4,317
<ASSISTANT_TASK:> Python Code: import os import tensorflow.compat.v1 as tf tf.disable_eager_execution() import pprint assert 'COLAB_TPU_ADDR' in os.environ, 'Did you forget to switch to TPU?' tpu_address = 'grpc://' + os.environ['COLAB_TPU_ADDR'] with tf.Session(tpu_address) as sess: devices = sess.list_devices() ppr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Authentication Step2: Check imports Step3: Train and evaluate a GAN model on TPU using TF-GAN. Step4: Download the data. TensorFlow Datsets w...
4,318
<ASSISTANT_TASK:> Python Code: %%bash sudo pip freeze | grep google-cloud-bigquery==1.6.1 || \ sudo pip install google-cloud-bigquery==1.6.1 from google.cloud import bigquery import pandas as pd %%bash export PROJECT=$(gcloud config list project --format "value(core.project)") echo "Your current GCP Project Name is: ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import necessary libraries. Step2: Set environment variables so that we can use them throughout the entire lab. We will be using our project na...
4,319
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License") # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The AS...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: FlatMap Step2: Examples Step3: <table align="left" style="margin-right Step4: <table align="left" style="margin-right Step5: <table align="l...
4,320
<ASSISTANT_TASK:> Python Code: # the output of plotting commands is displayed inline within frontends, # directly below the code cell that produced it %matplotlib inline from __future__ import print_function # this python library provides generic shallow (copy) and deep copy (deepcopy) operations from copy import dee...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setting input parameters Step2: Creating SASE3 lattice Step3: Load beam file Step4: Plot beamfile Step5: Match beam file Step6: Tapering th...
4,321
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division from thinkbayes2 import Pmf, Suite from thinkbayes2 import MakeMixture from fractions import Fraction d1 = Pmf({'Red':Fraction(2), 'Blue':Fraction(4)}, label='d1 (bluish) ') d1.Print() d2 = Pmf({'Red':Fraction(4), 'Blue':Fraction(2)}, label...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: A dice problem Step2: And I'll make another Pmf to represent the random choice of one die or the other. Step3: Now I can use the Random method...
4,322
<ASSISTANT_TASK:> Python Code: import os import tensorflow as tf import numpy as np import matplotlib.pyplot as plt import sys % matplotlib notebook mnist = tf.keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data(path="mnist.npz") x_train.shape y_train.shape class GAN: def __init__(self, n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load Data Set Step2: Verify data strucutre Step3: Define model Step4: Specify Dimensions Step5: Create GAN model, define I/O , loss function...
4,323
<ASSISTANT_TASK:> Python Code: 2+2 print 2*3 print (4+6)*(2+9) # should calculate to 110 print 12.0/11.0 print(5/3) # Integer division gives a 'floor' value (rounding down, basically). print(5.0/3.0) # Dividing floats (usually) gives the expected answer. print(5.0/3) # The interpreter uses the more complex typ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Another several examples Step2: One major difference between using a calculator and doing calculations on the computer is that there are a coup...
4,324
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
4,325
<ASSISTANT_TASK:> Python Code: def gen(): for i in range(10): yield i dataset = tf.data.Dataset.from_generator(gen, tf.float32)\ .make_one_shot_iterator()\ .get_next() with tf.Session() as sess: _data = sess.run(dataset) print(_data) with tf.Session() as sess: for _ in range(10):...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: generator로 label, feature까지 출력하고 싶다면 Step2: Minibatch를 하고 싶다면 Step3: (2) TextLineDataset Step4: b'1,1,2,3,4,5,6,7,8,9' Step5: Modeling Step...
4,326
<ASSISTANT_TASK:> Python Code: # 检查你的Python版本 from sys import version_info if version_info.major != 2 and version_info.minor != 7: raise Exception('请使用Python 2.7来完成此项目') import numpy as np import pandas as pd # 数据可视化代码 from titanic_visualizations import survival_stats from IPython.display import display %matplotlib...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 从泰坦尼克号的数据样本中,我们可以看到船上每位旅客的特征 Step3: 这个例子展示了如何将泰坦尼克号的 Survived 数据从 DataFrame 移除。注意到 data(乘客数据)和 outcomes (是否存活)现在已经匹配好。这意味着对于任何乘客的 data.loc[i] 都...
4,327
<ASSISTANT_TASK:> Python Code: %%bash export PROJECT=$(gcloud config list project --format "value(core.project)") echo "Your current GCP Project Name is: "$PROJECT %%bash # Create a BigQuery dataset for feat_eng if it doesn't exist datasetexists=$(bq ls -d | grep -w feat_eng) if [ -n "$datasetexists" ]; then echo ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The source dataset Step2: Create the training data table Step3: Verify table creation Step4: Baseline Model Step5: Note, the query takes sev...
4,328
<ASSISTANT_TASK:> Python Code: from __future__ import division import pandas as pd import numpy as np import scipy as sp import scipy.stats import toyplot as tp df = pd.read_csv('free_throws.csv', names=["away", "home", "team", "player", "score"]) df["at_home"] = df["home"] == df["team"] df.head() df.groupby("at_home...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data munging Step2: Overall free throw% Step3: Aggregating to player level Step4: Individual tests Step5: Global tests Step6: Bonferroni's ...
4,329
<ASSISTANT_TASK:> Python Code: !git clone https://github.com/markriedl/easygen.git !cp easygen/*.js /usr/local/share/jupyter/nbextensions/google.colab/ !cp easygen/images/*.png /usr/local/share/jupyter/nbextensions/google.colab/ !apt-get update !apt-get install chromium-chromedriver !pip install -r easygen/requirement...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install requirements Step2: Download StyleGAN Step3: Download GPT-2 Step4: Create backend hooks for saving and loading programs Step5: Impor...
4,330
<ASSISTANT_TASK:> Python Code: for researcher in researchers: if 'Wil' in researcher.name: print 'ID:{}, name:{}'.format(researcher.id, researcher.name) print 'pre-filter:', query_list[-1].count() query_list.append(query_list[-1].exclude(researcher_id=2)) print 'post-filter:', query_list[-1].count() print ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Next, let's only keep the pleco tags Step2: Now let's keep only the tags from January of 2015 Step3: Finally, we name the latest query export_...
4,331
<ASSISTANT_TASK:> Python Code: # change these to try this notebook out BUCKET = 'cloud-training-demos-ml' PROJECT = 'cloud-training-demos' REGION = 'us-central1' import os os.environ['BUCKET'] = BUCKET os.environ['PROJECT'] = PROJECT os.environ['REGION'] = REGION os.environ['TFVERSION'] = '1.14' import tensorflow as tf...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: We will look at the titles of articles and figure out whether the article came from the New York Times, TechCrunch or GitHub. Step4: Let's do ...
4,332
<ASSISTANT_TASK:> Python Code: x, fs = librosa.load('simpleLoop.wav', sr=44100) print x.shape librosa.display.waveplot(x, fs) from IPython.display import Audio Audio(x, rate=fs) onsets = librosa.onset.onset_detect(x, fs) print onsets # frame numbers of estimated onsets S = librosa.stft(x) logS = librosa.logamplitud...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plot the signal Step2: Listen Step3: librosa.onset.onset_detect Step4: Plot the onsets on top of a spectrogram of the audio Step5: essentia....
4,333
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt # YOUR CODE HERE def hat(x,a,b): v=-1*a*x**2+b*x**4 return v assert hat(0.0, 1.0, 1.0)==0.0 assert hat(0.0, 1.0, 1.0)==0.0 assert hat(1.0, 10.0, 1.0)==-9.0 x=np.linspace(-3,3) b=1....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hat potential Step2: Plot this function over the range $x\in\left[-3,3\right]$ with $b=1.0$ and $a=5.0$ Step3: Write code that finds the two l...
4,334
<ASSISTANT_TASK:> Python Code: fifteen_factorial = 15*14*13*12*11*10*9*8*7*6*5*4*3*2*1 print(fifteen_factorial) import math print(math.factorial(15)) print("Result correct?", math.factorial(15) == fifteen_factorial) print(math.factorial(5), math.sqrt(2*math.pi)*5**(5+0.5)*math.exp(-5)) print(math.factorial(10), math....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise 2 Step2: Exercise 3 Step4: We see that the relative error decreases, whilst the absolute error grows (significantly). Step6: In late...
4,335
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from scipy.optimize import fsolve from scipy import integrate import matplotlib.pyplot as plt from clawpack import pyclaw from clawpack import riemann from clawpack.visclaw.ianimate import ianimate import matplotlib plt.style.use('seaborn-talk') from ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Our next example is something you can experiment with in your own home. Go to the kitchen sink, position the faucet over a flat part of the sin...
4,336
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline #export from exp.nb_10 import * path = datasets.untar_data(datasets.URLs.IMAGENETTE_160) tfms = [make_rgb, ResizeFixed(128), to_byte_tensor, to_float_tensor] bs = 64 il = ImageList.from_files(path, tfms=tfms) sd = SplitData.split_by_fu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Mixup Step2: French horn or tench? The right answer is 70% french horn and 30% tench ;) Step3: NB Step4: In the original article, the authors...
4,337
<ASSISTANT_TASK:> Python Code: data_in_shape = (4, 4, 4, 2) L = MaxPooling3D(pool_size=(2, 2, 2), strides=None, padding='valid', data_format='channels_last') layer_0 = Input(shape=data_in_shape) layer_1 = L(layer_0) model = Model(inputs=layer_0, outputs=layer_1) # set weights to random (use seed for reproducibility) np...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: [pooling.MaxPooling3D.1] input 4x4x4x2, pool_size=(2, 2, 2), strides=(1, 1, 1), padding='valid', data_format='channels_last' Step2: [pooling.Ma...
4,338
<ASSISTANT_TASK:> Python Code: %matplotlib inline import skrf as rf rf.stylely() # imports from scipy.constants import mil,c from skrf.media import RectangularWaveguide, Freespace from skrf.frequency import Frequency import matplotlib as mpl # plot formating mpl.rcParams['lines.linewidth'] = 2 # create frequency obje...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Conductor Loss Step2: Phase Velocity Step3: Propagation Constant
4,339
<ASSISTANT_TASK:> Python Code: import numpy as np from emo_utils import * import emoji import matplotlib.pyplot as plt %matplotlib inline X_train, Y_train = read_csv('data/train_emoji.csv') X_test, Y_test = read_csv('data/tesss.csv') maxLen = len(max(X_train, key=len).split()) index = 1 print(X_train[index], label_to...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1 - Baseline model Step2: Run the following cell to print sentences from X_train and corresponding labels from Y_train. Change index to see dif...
4,340
<ASSISTANT_TASK:> Python Code: import cvxpy as cp x = cp.Variable(pos=True) y = cp.Variable(pos=True) z = cp.Variable(pos=True) a = cp.Parameter(pos=True) b = cp.Parameter(pos=True) c = cp.Parameter() objective_fn = 1/(x*y*z) objective = cp.Minimize(objective_fn) constraints = [a*(x*y + x*z + y*z) <= b, x >= y**c] prob...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Notice the keyword argument dpp=True. The parameters must enter in the DGP problem acording to special rules, which we refer to as dpp. The DPP ...
4,341
<ASSISTANT_TASK:> Python Code: import time from collections import namedtuple import numpy as np import tensorflow as tf with open('anna.txt', 'r') as f: text=f.read() vocab = sorted(set(text)) vocab_to_int = {c: i for i, c in enumerate(vocab)} int_to_vocab = dict(enumerate(vocab)) encoded = np.array([vocab_to_int...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First we'll load the text file and convert it into integers for our network to use. Here I'm creating a couple dictionaries to convert the chara...
4,342
<ASSISTANT_TASK:> Python Code: # dogscats/ # train/ # dogs/ # cats/ # valid/ # dogs/ # cats/ # test/ # dogs/ # cats/ # sample/ # <same as for dogscats/> # Making sure python knows where to look for my utilities folder (it's in this notebook's paren...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setup matplotlib to plot inside the notebook, import NumPy, SciPy, VGG, and the appropriate Keras libraries. Step2: Vgg16 Image Recognition Exa...
4,343
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import os import tempfile import pandas as pd import tensorflow as tf import tensorflow_transform as tft from tensorflow_transform import beam as tft_beam import tfx_utils from tfx.utils import io_utils from tensorflow_metadata.proto.v0 import schema_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get the schema URI from the metadata store Step2: Get the schema that was inferred by TensorFlow Data Validation Step6: Define features and cr...
4,344
<ASSISTANT_TASK:> Python Code: ## Set up the environment import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns %matplotlib inline ## Load the data set titanic_df = pd.read_csv('titanic_data.csv') ## Let's see what the data looks like ## First let's see what the columns are. titan...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Initial Inspection of the Data Step2: An initial inspection of the data shows us that we have data for 891 passengers not all of whose ages are...
4,345
<ASSISTANT_TASK:> Python Code: class Student: count = 0 # Total number of objects created so far, it is static variable as it is declared outside def __init__(self,name,usn,marks): Constructor of class Student Input: name - name of the student : string usn - univers...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Object Oriented Programming Step2: Duck Typing and Interfaces Step3: type() - Obtaining the data type of a variable
4,346
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import pandas as pd import sys sys.path.append("../../../bayesianpy") import bayesianpy from bayesianpy.network import Builder as builder import logging import os import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Ellipse # Using the lat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Next, just a bit of setup code to load the data and setup the Jpype instance. Step2: Naive Bayes Step3: The network still needs training, so k...
4,347
<ASSISTANT_TASK:> Python Code: # Authors: Teon Brooks <teon.brooks@gmail.com> # Eric Larson <larson.eric.d@gmail.com> # # License: BSD (3-clause) from mne.report import Report from mne.datasets import sample from mne import read_evokeds from matplotlib import pyplot as plt data_path = sample.data_path() meg_pa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Do standard folder parsing (this can take a couple of minutes) Step2: Add a custom section with an evoked slider
4,348
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np #Read files: train = pd.read_csv("train.csv") test = pd.read_csv("test.csv") #Combine test and train into one file train['source']='train' test['source']='test' data = pd.concat([train, test],ignore_index=True) print train.shape, test.shape, data.sh...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading data Step2: 2. Data Cleaning Step3: 2. Feature Engineering Step4: Step2 Step5: Step 3 Step6: Step 4 Step7: Step 5 Step8: Step 6 S...
4,349
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf import utils from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import zipfile dataset_folder_path = 'data' dataset_filename = 'text8.zip' dataset_name = 'Text8 Dataset' class DLProgress(tq...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ...
4,350
<ASSISTANT_TASK:> Python Code: #@title 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TensorFlow Lattice を使った倫理のための形状制約 Step2: 必要なパッケージをインポートします。 Step3: このチュートリアルで使用されるデフォルト値です。 Step4: 事例 1 Step5: データセットを前処理します。 Step7: データをトレ...
4,351
<ASSISTANT_TASK:> Python Code: # import data from url from py2cytoscape.data.cyrest_client import CyRestClient from IPython.display import Image # Create REST client for Cytoscape cy = CyRestClient() # Reset current session for fresh start cy.session.delete() # Load a sample network network = cy.network.create_from('ht...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Global Network Analysis Step2: Density Step3: Transitivity Step4: community detection Step5: Node Analysis Step6: Degree Step7: PageRank S...
4,352
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pylab as plt import convis inp, out = convis.samples.generate_sample_data(input='random',size=(2000,20,20)) print(inp.shape) m = convis.models.LN(kernel_dim=(12,7,7),population=True) print(m.compute_loss(inp,out,dt=500)) m.set_opt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Then, you need to choose a model, eg. an LN model as well. Step2: We can have a look at how well our model is doing right now by looking Step3:...
4,353
<ASSISTANT_TASK:> Python Code: # Install additional packages !pip install -q matplotlib-venn # Import all necessary libs import json import sys import argparse import pprint import random import datetime import pandas as pd from google_auth_oauthlib.flow import InstalledAppFlow from googleapiclient import discovery fro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: API Configuration Step9: API Authentication - OAuth2.0 Flow Step10: Actual Request to the Ads Data Hub Service API Step11: Analysis 1 Step12:...
4,354
<ASSISTANT_TASK:> Python Code: # Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved. # # 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...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TF-Hub CORD-19 Swivel 埋め込みを探索する Step2: 埋め込みを分析する Step5: 埋め込みが異なる用語の意味をうまく捉えていることが分かります。それぞれの単語は所属するクラスタの他の単語に類似していますが(「コロナウイルス」は「SARS」や「MERS」と...
4,355
<ASSISTANT_TASK:> Python Code: popSize = 4 # This is the number of nodes in the network update = 'BD' # Either 'BD' or 'DB' for Birth-death or death-Birth updating respectively direction = 'undirected' # Either 'directed' or 'undirected' graphs are used stepSize = 0.05 # Step size for the probability for each link in t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now let's create the graphs, calculate the fixation probability and store it in one file per graph in the folder output. Step2: Classify graphs...
4,356
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'sandbox-2', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
4,357
<ASSISTANT_TASK:> Python Code: import turicreate as tc sf = tc.SFrame.read_csv("/Users/datalab/bigdata/cjc/w15", header=False) sf dir(sf['X1']) bow = sf['X1']._count_words() type(sf['X1']) type(bow) bow.dict_has_any_keys(['limited']) bow.dict_values()[0][:20] sf sf['bow'] = bow sf typ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Download Data Step2: Transformations Step3: Text cleaning Step4: Topic modeling Step5: pred = m.predict(another_data) Step6: Seeding the m...
4,358
<ASSISTANT_TASK:> Python Code: # Author: Eric Larson <larson.eric.d@gmail.com> # # License: BSD (3-clause) import mne from mne.datasets import sample import matplotlib.pyplot as plt print(__doc__) data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif' fwd_fname = data_path + '/MEG/sa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Compute sensitivity maps Step2: Show gain matrix a.k.a. leadfield matrix with sensitivity map
4,359
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import math v = np.array([2,1]) w = 2 * v print(w) # Plot w origin = [0], [0] plt.grid() plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0)) plt.quiver(*origin, *w, scale=10) plt.show() b = v / 2 print(b) #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The same approach is taken for scalar division. Step2: Dot Product Multiplication Step3: In Python 3.5 and later, you can also use the @ opera...
4,360
<ASSISTANT_TASK:> Python Code: # your code here current_users = ["lira", "sarah", "james", "nicole", "AJ"] new_users = ["lira", "sarah", "li", "chidi", "olympia"] for i in current_users: if i in new_users: print("You need to enter a new username") else: print("This username is available") # your code here ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2. Color probability Step2: 3. Write an if-elif-else chain that determines a person’s stage of life. Step3: 4. process_data Step4: 5. user_co...
4,361
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import math from scipy import signal from scipy import stats # check Parseval's theorem holds numerically nsamps=1000 # window w = signal.tukey(nsamps,0.1) a = np.random.normal(0,1,nsamps) * w A = np.fft.fft(a) b = (1...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Parsevals theorem when applied to discrete Fourier Transform looks like this. Step2: Furthermore by the convolution theorem Step5: Parsevals t...
4,362
<ASSISTANT_TASK:> Python Code: from google.cloud import aiplatform as vertex_ai !python -c "import tensorflow as tf; print(f'TF version: {tf.__version__}')" !python -c "import tfx; print(f'TFX version: {tfx.__version__}')" !python -c "import kfp; print(f'KFP version: {kfp.__version__}')" print(f"vertex_ai: {vertex_ai....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Validate lab package version installation Step2: Note Step3: The config.py module configures the default values for the environment specific s...
4,363
<ASSISTANT_TASK:> Python Code: from games import (GameState, Game, Fig52Game, TicTacToe, query_player, random_player, alphabeta_player, play_game, minimax_decision, alphabeta_full_search, alphabeta_search, Canvas_TicTacToe) %psource Game %psource TicTacToe game52 = Fig52Game(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: GameState namedtuple Step2: Now let's get into details of all the methods in our Game class. You have to implement these methods when you creat...
4,364
<ASSISTANT_TASK:> Python Code: from BioTechTopics import Topics from plotBokehJpnb2 import plotBokehInJpnb import time # make instance of Topics object and load the data t=Topics() t.load() # unpickles LDA, tf, and tf-idf representations, puts text data from JSON into pandas dataframe #plotBokehInJpnb(t,'antibody') s...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Section 1 Step2: Fast named entity return is possible because all NLP (TextRank, tfidf, named entity recognition) is done offline and stored in...
4,365
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csir-csiro', 'sandbox-2', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
4,366
<ASSISTANT_TASK:> Python Code: %%bash pushd /workspace/nvidia-examples/tensorrt/tftrt/examples/object_detection/ bash ../helper_scripts/install_pycocotools.sh; popd import os os.environ['CUDA_VISIBLE_DEVICES']='0' import time import logging import numpy as np import tensorflow as tf print("TensorFlow version: ", tf.__...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data Step2: TF saved model Step3: Helper functions Step4: <a id="2"></a> Step5: We employ saved_model_cli to inspect the inputs and outputs ...
4,367
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import mxnet as mx from mxnet import nd, autograd import numpy as np from collections import defaultdict mx.random.seed(1) # ctx = mx.gpu(0) ctx = mx.cpu(0) %matplotlib inline import matplotlib import matplotlib.pyplot as plt import seaborn as sns imp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Dataset Step3: Check the data real quick Step4: Preparing the data for training Step5: Long short-term memory (LSTM) RNNs Step6: Attach the ...
4,368
<ASSISTANT_TASK:> Python Code: import harness from harness import Harness from pandas import Categorical from sklearn import datasets, discriminant_analysis iris = datasets.load_iris() # Harness is just a dataframe df = Harness( data=iris['data'], index=Categorical(iris['target']), estimator=discriminant_analys...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: More Examples Step2: Build & Run Tests
4,369
<ASSISTANT_TASK:> Python Code: # Import Pandas & NumPy import pandas as pd import numpy as np # Create a tiny dataset, as a list of tuples name = ('Oslo','Copenhaguen','Helsinki','Stockholm','Reykjavik') pop = ( 647676, 583348, 626305, 917297, 121822 ) area = ( 480.76, 86.20, 715.49, 188.0, 273 ) data = [ (1000+i,n,p,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1 Creating a DataFrame Step2: Let's view the dataframe. We can print it Step3: Or we can just show it, and it will be nicely formatted. Step4:...
4,370
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import seaborn as sns import numpy as np s=[] i=0 def find_peaks(a): Find the indices of the local maxima in a sequence. # YOUR CODE HERE if a[0]>a[1]: #if the first number is bigger than the second number s.app...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Peak finding Step3: Here is a string with the first 10000 digits of $\pi$ (after the decimal). Write code to perform the following
4,371
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.style.use('ggplot') train = pd.read_csv("data/trainRF.csv") test = pd.read_csv("data/testRF.csv") train_13 = train.drop(['day','month', 'duration'], axis = 1) test_13 = test.drop(['day','month', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Implementing Random Forest Step2: Key input parameters (in addition to decision trees) Step3: Out-of-Bag Error
4,372
<ASSISTANT_TASK:> Python Code: import sys import os from itertools import count from pathlib import Path sys.path.insert(0, str(Path(os.environ['HOME'], 'git', 'skanb', 'pea-test-set'))) import utils as asvt_utils import numpy as np import matplotlib.pyplot as plt from astropy.table import Table, vstack from astropy.ti...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get acq stats data and clean Step2: Get ASVT data and make it look more like acq stats data Step3: Combine flight acqs and ASVT data Step4: C...
4,373
<ASSISTANT_TASK:> Python Code: import phoebe b = phoebe.default_binary() b.add_dataset('lc', dataset='lc01') print(b.filter(qualifier='pblum*', dataset='lc01')) print(b.get_parameter('pblum_mode')) print(b.get_parameter('pblum_component')) b.set_value('pblum_component', 'secondary') print(b.filter(qualifier='pblum*', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the default mode, you can change which of the stars you'd like to provide the luminosity. By default, this is the primary component. To pro...
4,374
<ASSISTANT_TASK:> Python Code: %matplotlib inline from pymc3 import * import numpy as np import matplotlib.pyplot as plt size = 200 true_intercept = 1 true_slope = 2 x = np.linspace(0, 1, size) # y = a + b*x true_regression_line = true_intercept + true_slope * x # add noise y = true_regression_line + np.random.normal...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Generating data Step2: Estimating the model Step3: This should be fairly readable for people who know probabilistic programming. However, woul...
4,375
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib import matplotlib.pyplot as plt fngs_ts = np.load('/home/eric/cmp/fngs/outputs/ts_roi/pp264-2mm/sub-0025864_ses-1_bold_pp264-2mm.npy') cpac_ts = np.load('/home/eric/cmp/cpac/pipeline_HCPtest/sub-0025864_ses-1/roi_timeseries/_scan_res...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Things to Note
4,376
<ASSISTANT_TASK:> Python Code: import sys import os import inspect # add the path to opengrid to sys.path script_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) sys.path.append(os.path.join(script_dir, os.pardir, os.pardir)) from opengrid.library import houseprint from opengrid.library i...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create a tmpo session, and enter debug mode to get more output. Step2: Add a sensor and token to start tracking the data for this given sensor....
4,377
<ASSISTANT_TASK:> Python Code: from pylab import * # numpy, matplotlib, plt from bregman.suite import * # Bregman audio feature extraction library from soundscapeecology import * # 2D time-frequency shift-invariant convolutive matrix factorization %matplotlib inline rcParams['figure.figsize'] = (15.0, 9.0) sound_path ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <h2>Example audio</h2> Step2: <h2>Spectrum Analysis Parameters</h2> Step3: <h2>SoundscapeEcology Toolkit</h2>
4,378
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS from IPython.display import HTML from ipywidgets import interact HTML('../style/code_toggle.html') def FS_coeffs(x, m, func, T=2.0*np.pi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import section specific modules Step3: 2.3. Fourier Series<a id='math Step4: That should be good enough for our purposes here. Next we create ...
4,379
<ASSISTANT_TASK:> Python Code: from dx import * import time from pylab import plt plt.style.use('seaborn') %matplotlib inline # constant short rate r = constant_short_rate('r', 0.02) # market environments me_gbm = market_environment('gbm', dt.datetime(2015, 1, 1)) # geometric Brownian motion me_gbm.add_constant('initi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Single Risk Factor Step2: American Put Option Step3: Large Portfolio Step4: Sequential Valuation Step5: The call of the get_values method to...
4,380
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-2', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
4,381
<ASSISTANT_TASK:> Python Code: #@title 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 勾配ブースティング木 Step2: 特徴量の説明については、前のチュートリアルをご覧ください。 Step3: 入力パイプラインを構築する Step4: モデルをトレーニングする Step5: パフォーマンスの理由により、データがメモリに収まる場合は、tf.estimator.Bo...
4,382
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np np.random.seed(10) a = tf.constant(np.random.rand(50, 100, 512)) def g(a): return tf.expand_dims(a, 2) result = g(a.__copy__()) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
4,383
<ASSISTANT_TASK:> Python Code: print cobra.__version__ model_iEK = cobra.io.load_json_model("iEK1020.json") print "# of reactions", len(model_iEK.reactions) print "# of metabolites", len(model_iEK.metabolites) print "# of genes", len(model_iEK.genes) # for react in model_iEK_before.reactions: # if react not in mod...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: What you need to run this notebook... Step2: Check default media condition Step3: Check FBA solution Step4: Check Mass Balance Step5: Most o...
4,384
<ASSISTANT_TASK:> Python Code: import os from datetime import datetime import numpy as np import pandas as pd import sklearn as sk from sklearn.externals import joblib from sklearn.preprocessing import LabelEncoder from sklearn.grid_search import GridSearchCV import xgboost as xgb def check_NaN_Values_in_df(df): #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2. Re-Import the Check NaN Function from Part 2 Step2: 3. Loading in the Data from Part 3 Step3: 4. Getting a training dataset Step4: 5. Trai...
4,385
<ASSISTANT_TASK:> Python Code: # built-in python modules import os import inspect # scientific python add-ons import numpy as np import pandas as pd # plotting stuff # first line makes the plots appear in the notebook %matplotlib inline import matplotlib.pyplot as plt import matplotlib as mpl # finally, we import the ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load TMY data Step2: The file handling above looks complicated because we're trying to account for the many different ways that people will run...
4,386
<ASSISTANT_TASK:> Python Code: import os, sys from matplotlib import pyplot as plt %matplotlib inline import time import numpy as np import pickle import pandas import gzip sys.path.append("..") import cca_core def _plot_helper(arr, xlabel, ylabel): plt.plot(arr, lw=2.0) plt.xlabel(xlabel) plt.ylabel(ylabel...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the introduction tutorial, we looked at a simple way of thinking of neural network representations (neurons as activation vectors and layers ...
4,387
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr> # Eric Larson <larson.eric.d@gmail.com> # License: BSD (3-clause) import os.path as op import numpy as np from scipy import stats as stats import mne from mne import spatial_src_connectivity from mne.stats import spatio_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Compute statistic Step3: Visualize the clusters
4,388
<ASSISTANT_TASK:> Python Code: import statsmodels.formula.api as smf import pandas as pd import numpy as np import scipy as sp # Create some example data cs= [12, 14, 16, 18] # classes of carbons ds = [0, 1, 2, 3] # classes of double bonds df = pd.DataFrame({'RT': np.random.uniform(low=0.1, high=15, size=1000), '...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create Example Datasets Step2: Create OLS output Step3: Access results attributes Step4: There are two $R^2$ values that you can get from the...
4,389
<ASSISTANT_TASK:> Python Code: from __future__ import division import math import rasterio # This notebook explores a single 4 band (blue, green, red, NIR) PlanetScope scene in a UTM projection. image_file = "example.tif" satdat = rasterio.open(image_file) # Minimum bounding box in projected units print(satdat.bounds)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Basic details Step2: Bands Step3: Because we know we're look at a PlanetScope 4-band analytic satellite image, we can define the bands by thei...
4,390
<ASSISTANT_TASK:> Python Code: def sort(L): n = len(L) if n < 2: return L L1, L2 = L[:n//2], L[n//2:] return merge(sort(L1), sort(L2)) def merge(L1, L2): if L1 == []: return L2 if L2 == []: return L1 x1, *R1 = L1 x2, *R2 = L2 if x1 <= x2: return [x1] ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We still need to specify how two sorted lists $L_1$ and $L_2$ are merged in a way that the resulting Step2: Testing Step3: We import the class...
4,391
<ASSISTANT_TASK:> Python Code: #@title 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Simple TFX Pipeline for Vertex Pipelines Step2: Restart the runtime Step3: Check the package versions. Step4: Set up variables Step5: Set gc...
4,392
<ASSISTANT_TASK:> Python Code: using JuMP m = Model() # Definig variable Classes = ["A", "B", "C"] Shift = ["R", "O"] @variable(m, x[Classes, Shift] >= 0) # Define Constraints @constraints m begin 2x["B","R"] + 3x["C","R"] <= 40 2x["B","O"] + 3x["C","O"] <= 35 3x["A","R"] + x["B","R"] + 3x["C","R"] + x["...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: PART A Step2: Change Kernel to Python
4,393
<ASSISTANT_TASK:> Python Code: # # When the cursor is in this cell hit "shift enter" to execute the python code here # x=3 # x is assigned an integer value of 3 y=2.4 # y is assigned a floating point value of 2.4 print("x and y are:", x, 'and',y) z=x+y print("The value of z is:", z) aList = [1,2,9,4,7] print("W...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Like most programming languages you can operate on these values using unary and binary operators, like so Step2: Tuples and Lists Step3: The d...
4,394
<ASSISTANT_TASK:> Python Code: %pylab inline %matplotlib inline import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') import shogun as sg import numpy as np # use scipy for generating samples from scipy.stats import laplace, norm def sample_gaussian_vs_laplace(n=220, mu=0.0, sigma2=1, b=np.sqrt(0.5))...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Some Formal Basics (skip if you just want code examples) Step2: Now how to compare these two sets of samples? Clearly, a t-test would be a bad ...
4,395
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np from numpy import pi %matplotlib inline from pyqg import sqg_model # create the model object year = 1. m = sqg_model.SQGModel(L=2.*pi,nx=512, tmax = 26.005, beta = 0., Nb = 1., H = 1., rek = 0., rd = None, dt = 0.005, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Surface quasi-geostrophy (SQG) is a relatively simple model that describes surface intensified flows due to buoyancy. One of it's advantages is ...
4,396
<ASSISTANT_TASK:> Python Code: # NBVAL_IGNORE_OUTPUT import numpy as np import matplotlib.pyplot as plot import math as mt import matplotlib.ticker as mticker from mpl_toolkits.axes_grid1 import make_axes_locatable from matplotlib import cm # NBVAL_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: From Devito's library of examples we import the following structures Step2: The mesh parameters that we choose define the domain $\Omega_{0}$ p...
4,397
<ASSISTANT_TASK:> Python Code: from dkrz_forms import form_widgets form_widgets.show_status('form-generation') from dkrz_forms import form_widgets form_widgets.create_form() from dkrz_forms import form_widgets form_widgets.show_status('form-retrieval') MY_LAST_NAME = "testsuite" # e.gl MY_LAST_NAME = "schulz" #--...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create a data form Step2: Retrieve your DKRZ data form Step3: Please provide your last name
4,398
<ASSISTANT_TASK:> Python Code: def number_to_words(n): Given a number n between 1-1000 inclusive return a list of words for the number. _1={1:' ',2:"-"} _9={1:"one",2:"two",3:"three",4:"four",5:'five',6:'six',7:'seven',8:"eight",9:'nine',0:'',11:'and'} _100={0:'',1:'ten',2:"twenty",3:'thirty',4:'forty',...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Project Euler Step2: Now write a set of assert tests for your number_to_words function that verifies that it is working as expected. Step4: No...
4,399
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csiro-bom', 'access-1-0', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name",...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...