Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
8,300
<ASSISTANT_TASK:> Python Code: import requests import json import pandas as pd from pandas.io.json import json_normalize import copy from datetime import datetime import plotly import plotly.graph_objs as go from plotly import tools plotly.__version__ plotly.offline.init_notebook_mode(connected=True) headers={'User-Age...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step 1 Step1: Pagecounts Step2: Get pagecounts of en.wikipedia.org through mobile. Step3: Pageview Step4: Get page viewcounts of en.wikipedia.org th...
8,301
<ASSISTANT_TASK:> Python Code: weeks = ['150815','150822','150829','150919','150926', '151003','151024','151121','151212','151219', '160130','160206','160227','160305','160312', '160326','160409','160416','160430','160507', '160514','160521','160611','160618','160625'] urls = ['''htt...
<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: Reading it in and taking a look. Step2: Time is in four hour intervals (generally). The time listed is when a particular time interval ends. En...
8,302
<ASSISTANT_TASK:> Python Code: import requests from BeautifulSoup import * url = "http://www.bloomberg.com/quote/SPX:IND" response = requests.get(url) page = response.text soup = BeautifulSoup(page) soup.findAll('h1') index_name = soup.findAll('h1', attrs={'class': 'name'}) print(index_name) print(index_name[0].text...
<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: If you check use the Inspect element feature from Google Chrome, you will see that the name of the index is inside an &lt;h1&gt; tag which has a...
8,303
<ASSISTANT_TASK:> Python Code: model = Model() NUM_LAYERS=2 INPUT_DIM=50 HIDDEN_DIM=10 builder = LSTMBuilder(NUM_LAYERS, INPUT_DIM, HIDDEN_DIM, model) # or: # builder = SimpleRNNBuilder(NUM_LAYERS, INPUT_DIM, HIDDEN_DIM, model) s0 = builder.initial_state() x1 = vecInput(INPUT_DIM) s1=s0.add_input(x1) y1 = s1.output() ...
<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: Note that when we create the builder, it adds the internal RNN parameters to the model. Step2: If our LSTM/RNN was one layer deep, y2 would be ...
8,304
<ASSISTANT_TASK:> Python Code: grammar1 = S -> NP VP NP -> DET N DET -> "der" | "die" | "das" N -> "Mann" | "Frau" | "Buch" VP -> V NP NP V -> "gibt" | "schenkt" test_sentences = [ "der Mann gibt der Frau das Buch" ] import nltk from IPython.display import display import sys def test_gram...
<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: Übungsblatt 4 Step2: Sammeln Sie Sätze, die als grammatisch erkannt werden sollten, am besten in einer Liste. Step3: Die folgende Funktion kan...
8,305
<ASSISTANT_TASK:> Python Code: import keras from keras.layers import Concatenate,Dense,Embedding rnn_num_units = 64 embedding_size = 16 #Let's create layers for our recurrent network #Note: we create layers but we don't "apply" them yet embed_x = Embedding(n_tokens,embedding_size) # an embedding layer that converts cha...
<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: II. RNN Step2: III. Sampling
8,306
<ASSISTANT_TASK:> Python Code: %matplotlib inline import colour from colour.plotting import * colour.filter_warnings(True, False) colour_plotting_defaults() # Plotting the visible spectrum. visible_spectrum_plot() from pprint import pprint import colour.colorimetry as colorimetry pprint(colorimetry.__all__) import co...
<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 spectrum is defined as the display or specification of the monochromatic components of the radiation considered. <a name="back_reference_3">...
8,307
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ipsl', 'ipsl-cm6a-lr', 'seaice') # 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: 2...
8,308
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pandas as pd %matplotlib inline # http://scikit-learn.org/stable/auto_examples/plot_digits_pipe.html#example-plot-digits-pipe-py import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model, decomposition, d...
<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 previous weeks we have covered preprocessing our data, dimensionality reduction, and last week looked at supervised learning. This week we wi...
8,309
<ASSISTANT_TASK:> Python Code: import random def inicializarMatrizNueva(filas,columnas,valorMaximoNumero): matriz = [] for i in range(filas): fil = [] for j in range(columnas): a = random.randrange(valorMaximoNumero) fil.append(a) matriz.append(fil) matr...
<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: Matriz de prueba Step2: Ejecutar y tomar las dos primeras filas para verificar si sí funciona el algoritmo Step3: Se guarda el archivo en $HOM...
8,310
<ASSISTANT_TASK:> Python Code: x = np.random.RandomState(0).uniform(-5, 5, 20) #x = np.random.uniform(-5, 5, 20) y = x*np.sin(x) #y += np.random.normal(0,0.5,y.size) y += np.random.RandomState(34).normal(0,0.5,y.size) x_star = np.linspace(-5,5,500) #Define the basic kernels k1 = SqExp(0.45,2) k2 = RQ(0.5,2,3) k3 = Ex...
<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: Define the Test Set Step2: Train the Model Step3: Regression Step4: Optimize Hyperparameters Step5: array([ 1.47895967, 3.99711988, 0.1629...
8,311
<ASSISTANT_TASK:> Python Code: # import the modules import sys import GPy import csv import numpy as np import cPickle as pickle import scipy.stats as stats import sklearn.metrics as metrics from matplotlib import pyplot as plt %matplotlib notebook # function to compute reconstruction error def reconstructionError(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: Plotting and Analysis Functions Step2: Data Loading
8,312
<ASSISTANT_TASK:> Python Code: import tempfile from typing import List import equinox as eqx # https://github.com/patrick-kidger/equinox import jax import jax.numpy as jnp import optax # https://github.com/deepmind/optax import pysr # https://github.com/MilesCranmer/PySR import sympy # Note that PySR, which we use f...
<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 for a bunch of helpers. We'll use these in a moment; skip over them for now. Step2: Okay, let's get started.
8,313
<ASSISTANT_TASK:> Python Code: %pylab notebook Sbase = 100e6 # [VA] Vp0 = 230e3 # [V] Vs0 = 115e3 # [V] Rc_pu = 100.0 Xm_pu = 20.0 Req_pu = 0.015 Xeq_pu = 0.06 Sload = 80e6 # [VA] PF = 0.8 Vls_a = Vs0 Ils_a = Sload / (sqrt(3)*Vls_a) print('Ils_a = {:.0f} A'.format(Ils_a)) Vls_base = Vs0 Ils_base_a = 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: Description Step2: (a) Step3: The base apparent power is $S_\text{base} = 100\,MVA$ , and the base line voltage on the secondary side is $V_{L...
8,314
<ASSISTANT_TASK:> Python Code: import glob import pandas as pd samples = { 'train':{}, 'test':{} } files = glob.glob('20news-bydate-*/talk.politics*/*') for s in samples.keys(): for c in ['guns', 'mideast', 'misc']: samples[s][c] = samples[s].get(c, len(filter(lambda x: s in x and c in x, files))) 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: Model Step2: Testing Step3: Because I don't want to re-run the training & testing everything time I come back to this project, we will save th...
8,315
<ASSISTANT_TASK:> Python Code: #importing some useful packages import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import cv2 %matplotlib inline #reading in an image image = mpimg.imread('images/solidWhiteRight.jpg') #printing out some stats and plotting print('This image is:', type(ima...
<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: Read in an Image Step10: Ideas for Lane Detection Pipeline Step11: Test Images Step12: Build a Lane Finding Pipeline Step13: Test on Videos ...
8,316
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import fetch_lfw_people # Importamos mediante una de las dos alternativas # 1ª alternativa devuelve las imagenes en RGB pero con sus # respectivos tres valores faces = fetch_lfw_people(color = True) positive_patches = faces.images positive_patches.shape %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: Realizamos algunos imports necesarios Step2: Antes de nada, vamos a realizar una pequeña muestra de los resultados obtenidos con una única imag...
8,317
<ASSISTANT_TASK:> Python Code: %matplotlib inline from time import time, sleep import numpy as np import matplotlib.pyplot as plt from IPython import display import pandas as pd from time import time from tqdm import tqdm # (re-)load layers %run homework_modules.ipynb # Generate some data N = 500 X1 = np.random.randn...
<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: Framework Step2: Toy example Step3: Define a logistic regression for debugging. Step4: Start with batch_size = 1000 to make sure every step l...
8,318
<ASSISTANT_TASK:> Python Code: import pandas as pd import statsmodels.api as sm from sklearn.cross_validation import train_test_split import math import numpy as np import matplotlib.pyplot as plt gdf = pd.read_csv("./CSV/merged.csv") df1 = gdf[['AIRLINE_ID','ORIGIN', 'DEST', 'DEP_TIME','ARR_TIME','DEP_DELAY','ARR_DE...
<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. Extract Data Step2: 3. Select Data Step3: Afterwards, we filter by the important airports (ATL, DFW, JFK, LAX and ORD) Step4: 4. Sample Da...
8,319
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import math import timeit import matplotlib.pyplot as plt %matplotlib inline from cs231n.data_utils import load_CIFAR10 def get_CIFAR10_data(num_training=49000, num_validation=1000, num_test=10000): Load the CIFAR-10 dataset from disk 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: What's this TensorFlow business? Step2: Example Model Step3: TensorFlow supports many other layer types, loss functions, and optimizers - you ...
8,320
<ASSISTANT_TASK:> Python Code: s3 = boto3.client('s3') s3.list_buckets() def create_s3_bucket(bucketname): Quick method to create bucket with exception handling s3 = boto3.resource('s3') exists = True bucket = s3.Bucket(bucketname) try: s3.meta.client.head_bucket(Bucket=bucketname) excep...
<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: AWS (S3, Redshift, Kinesis) + Databricks Spark = Real-time Smart Meter Analytics Step2: Copy Postgres to S3 via Postgres dump to CSV and s3cmd ...
8,321
<ASSISTANT_TASK:> Python Code: m.group(2) m.group('first_name') import re foo_pattern = re.compile(''' ^ ([A-Za-z]+) ,[ ] ([A-Za-z]+) $ ''', re.VERBOSE) s = 'James, Mackenzie' m = re.match(foo_pattern, s) m m.groups m.group(0) m.group(1) m.group(2) foo_pattern = re.compile(''' ^ (?P<last_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: Mackenzie (first name) Step2: Regular expressions can be used to indicate if a string matches a pattern or not.
8,322
<ASSISTANT_TASK:> Python Code: # from __future__ import exam_success from __future__ import absolute_import from __future__ import print_function %matplotlib inline import sklearn import matplotlib.pyplot as plt import seaborn as sns import numpy as np import random import pandas as pd import scipy.stats as stats # Sk ...
<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: 13.765.202 lines in train.csv Step2: Per wikipedia, a value of more than 421 mm/h is considered "Extreme/large hail" Step3: We regroup the d...
8,323
<ASSISTANT_TASK:> Python Code: %matplotlib inline %load_ext autoreload %autoreload 2 import numpy as np import matplotlib.pyplot as plt n = 21 n_phases = 3 from pymks.tools import draw_microstructures from pymks.datasets import make_delta_microstructures X_delta = make_delta_microstructures(n_phases=n_phases, size=(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: Let's take a look at a few of the delta microstructures by importing draw_microstructures from pymks.tools. Step2: Using delta microstructures ...
8,324
<ASSISTANT_TASK:> Python Code: import pandas as pd data = {'spike-2': [1,2,3], 'hey spke': [4,5,6], 'spiked-in': [7,8,9], 'no': [10,11,12]} df = pd.DataFrame(data) s = 'spike' def g(df, s): spike_cols = [s for col in df.columns if s in col and s != col] for i in range(len(spike_cols)): spike_cols[i] = 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:
8,325
<ASSISTANT_TASK:> Python Code: x_train,y_train,x_valid,y_valid = get_data() train_ds,valid_ds = Dataset(x_train, y_train),Dataset(x_valid, y_valid) nh,bs = 50,512 c = y_train.max().item()+1 loss_func = F.cross_entropy data = DataBunch(*get_dls(train_ds, valid_ds, bs), c) #export def create_learner(model_func, loss_func...
<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: Annealing Step2: Let's start with a simple linear schedule going from start to end. It returns a function that takes a pos argument (going from...
8,326
<ASSISTANT_TASK:> Python Code: !ssh thauser@thauser@comet.sdsc.edu 'cd .ipython/profile_nbserver; ls -al' from IPython.lib import passwd passwd('test password') !ssh thauser@gordon.sdsc.xsede.org 'head -n 12 .ipython/profile_nbserver/ipython_notebook_config.py' import sys import time import saga # Adapted from the 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: 2. Create a self-signed certificate Step2: Not recommended Step3: Running the secured remote notebook
8,327
<ASSISTANT_TASK:> Python Code: from bookworm import * %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns sns.set_style('whitegrid') plt.rcParams['figure.figsize'] = (12,9) import pandas as pd import numpy as np book = load_book('data/raw/hp_philosophers_stone.txt') characters = extract_character_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: Visualisation with NetworkX Step2: get_interaction_df() is defined in bookworm/build_network.py, and works by searching through the provided co...
8,328
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import statsmodels.api as sm import matplotlib.pyplot as plt import requests from io import BytesIO # NBER recessions from pandas_datareader.data import DataReader from datetime import datetime usrec = DataReader('USREC', 'fred', 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: Hamilton (1989) switching model of GNP Step2: We plot the filtered and smoothed probabilities of a recession. Filtered refers to an estimate of...
8,329
<ASSISTANT_TASK:> Python Code: BATCH_SIZE = 128 EPOCHS = 10 training_images_file = 'gs://mnist-public/train-images-idx3-ubyte' training_labels_file = 'gs://mnist-public/train-labels-idx1-ubyte' validation_images_file = 'gs://mnist-public/t10k-images-idx3-ubyte' validation_labels_file = 'gs://mnist-public/t10k-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: Step2: Imports Step3: tf.data.Dataset Step4: Let's have a look at the data Step5: Keras model Step6: Train and validate the model Step7: Visualize...
8,330
<ASSISTANT_TASK:> Python Code: # Step 1: right-click the "download" link on the left # Step 2: select "copy link address" # Step 3: paste the link into the following bash command, after "wget" !wget https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh !ls # This will show us the files in our current direc...
<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 download takes awhile; it's a big distribution! Step2: This part will take awhile, depending largely on your internet connection. Go grab s...
8,331
<ASSISTANT_TASK:> Python Code: import time # We will use some np and pandas for dealing with input data. import numpy as np import pandas as pd # And of course, we need tensorflow. import tensorflow as tf from matplotlib import pyplot as plt from IPython.display import clear_output tf.__version__ tf.logging.set_verbos...
<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: Below we demonstrate both local and global model interpretability for gradient boosted trees. Step2: Interpret model Step4: Local interpretab...
8,332
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-1', 'land') # 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...
8,333
<ASSISTANT_TASK:> Python Code: !pip install keras-tuner -q from tensorflow import keras from tensorflow.keras import layers def build_model(hp): model = keras.Sequential() model.add(layers.Flatten()) model.add( layers.Dense( # Define the hyperparameter. units=hp.Int("units",...
<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: Introduction Step2: You can quickly test if the model builds successfully. Step3: There are many other types of hyperparameters as well. We ca...
8,334
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'dwd', 'sandbox-3', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<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: 2...
8,335
<ASSISTANT_TASK:> Python Code: from keras.datasets import mnist (train_images, train_labels), (test_images, test_labels) = mnist.load_data() train_images.shape len(train_labels) train_labels test_images.shape len(test_labels) test_labels from keras import models from keras import layers network = models.Sequential() ...
<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: images 是用來訓練與測試的資料,label 則為每一筆影像資料對應的正確答案,每一張手寫圖片都是 28 x 28 的灰階 Bit Map Step2: 建立準備訓練的神經網路 Step3: 上面這裡是神經網路的核心組成方式,我們在全連接層建立了兩層,由一個有 512 個神經元的...
8,336
<ASSISTANT_TASK:> Python Code: a = None if a is None: print('nulo') a = True b = False c = True print(a == b) print(a == c) print(type(1)) print(type(1.2)) print("Divisao: ",1 / 2) print("Divisao inteira: ",1 // 2) print(2 ** 3) print(25 ** (1/2)) import math print(math.sqrt(2)) print(math.log(2)) print(math.c...
<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: Boolean Step2: Números Step3: Ao dividir dois números (inteiros ou flutuantes), podemos fazer a divisão comum (/) ou divisão inteira (//), ond...
8,337
<ASSISTANT_TASK:> Python Code: # Import modules that contain functions we need import pandas as pd import numpy as np %matplotlib inline import matplotlib.pyplot as plt # Our data is a table and is defined as the word 'data'. # 'data' is set equal to the .csv file that is read by the pandas function. # The .csv file mu...
<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: This table shows the top 10 water consuming counties, the population, the amount of the population that is connected to public wa...
8,338
<ASSISTANT_TASK:> Python Code: def search(start, goal, next_states): limit = 36 while True: Path = depth_limited_search(start, goal, next_states, [start], { start }, limit) if Path is not None: return Path limit += 1 print(f'limit = {limit}') def depth_limited_search...
<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 function depth_limited_search tries to find a solution to the search problem Step2: Solving the Sliding Puzzle
8,339
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() b.add_constraint('semidetached', 'primary') b['requiv@constraint@primary'] b['requiv_max@constraint@pr...
<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: As always, let's do imports and initialize a logger and a new Bundle. Step2: Semi-Detached Systems Step3: We can view the constraint on requiv...
8,340
<ASSISTANT_TASK:> Python Code: import os from collections import Counter import matplotlib.pyplot as plt import numpy as np %matplotlib inline directory = '/home/tpin3694/Documents/' python_files = [os.path.join(root, name) for root, dirs, files in os.walk(directory) for name in files ...
<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: With the counts stored in a Counter object, lets now quickly print out the top ten libraries and their respective counts. Step2: Nothing there ...
8,341
<ASSISTANT_TASK:> Python Code: #API Key: 0c3ba2a8848c44eea6a3443a17e57448 import requests bestseller_response = requests.get('http://api.nytimes.com/svc/books/v2/lists/2009-05-10/hardcover-fiction?api-key=0c3ba2a8848c44eea6a3443a17e57448') bestseller_data = bestseller_response.json() print("The type of bestseller_data...
<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: Graded = 8/8 Step2: After writing a code that returns a result, now automating that for the various dates using a function Step3: 2) What are ...
8,342
<ASSISTANT_TASK:> Python Code: def batchnormalization(X, eps=1e-8, W=None, b=None): if X.get_shape().ndims == 4: mean = tf.reduce_mean(X, [0,1,2]) standar_desviation = tf.reduce_mean(tf.square(X-mean), [0,1,2]) X = (X - mean) / tf.sqrt(standar_desviation + eps) if W 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: Leaky Relu Step2: BCE Step3: GENERATOR AND DISCRIMINATOR FUNCTIONS Step4: Model Step5: Optimizer Step6: Sample Generator Step7: Aux functi...
8,343
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np % matplotlib inline from matplotlib import pyplot as plt data = pd.read_csv('../data/data_with_problems.csv', index_col=0) print('Our dataset has %d columns (features) and %d rows (people).' % (data.shape[1], data.shape[0])) data.head(15) data = d...
<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 dataset that will be used Step2: Let us drop the missing and duplicated values since they don't matter for now (already covered in oth...
8,344
<ASSISTANT_TASK:> Python Code: !pip install git+https://github.com/google/starthinker from starthinker.util.configuration import Configuration CONFIG = Configuration( project="", client={}, service={}, user="/content/user.json", verbose=True ) FIELDS = { 'auth_dv':'user', # Credentials used for dv. 'au...
<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. Set Configuration Step2: 3. Enter DV360 Bulk Editor Recipe Parameters Step3: 4. Execute DV360 Bulk Editor
8,345
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display from IPython.html import widgets def print_sum(a, b): Print the sum of the arguments a and b. return a+b 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: Step2: Interact basics Step3: Use the interact function to interact with the print_sum function. Step5: Write a function named print_string that prin...
8,346
<ASSISTANT_TASK:> Python Code: for i in range(9): print county_name[i] zipcode=[93210,93263,93202,93638,93620,95641,95242,95326,93201] ZipcodeList=[{ "County_N":county_name[i], "zipcode":zipcode[i] } for i in range(len(zipcode))] COUNTYZIP=pd.DataFrame(ZipcodeList, columns=["County_N", "zipcode"]) COUNTYZIP start=...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Lets extract the zipcode and precipetation data from California Department of Water Resources Step4: Crop value extract from
8,347
<ASSISTANT_TASK:> Python Code: try: import numpy as np except ImportError: raise RuntimError('This notebook requires numpy') # the baseline diet data as Python lists of tuples. FOODS = [ ("Roasted Chicken", 0.84, 0, 10), ("Spaghetti W/ Sauce", 0.78, 0, 10), ("Tomato,Red,Ripe,Raw", 0.27, 0, 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: In the next section we illustrate the range transformer with the Diet Problem, from DOcplex distributed examples. Step2: Creating a Spark sessi...
8,348
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import xarray as xr import cartopy.crs as ccrs import datetime as dt import matplotlib.pyplot as plt import matplotlib as mpl import matplotlib.gridspec as gridspec import matplotlib.dates as mdates mpl.rcParams['figure.figsize'] = 8.0, 4.0 mpl.rcPar...
<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. Load data Step2: 2.2 SST Step3: 2.3 Preprocess Step4: 3. Carry out Maximum Covariance Analysis Step5: 3.2 Postprocess Step6: 3.2.2 Extra...
8,349
<ASSISTANT_TASK:> Python Code: ## Assume that this code exists in a file named example.py def main(): print(1 + 1) if __name__ == "__main__": main() def main(): DEBUG = False #True if DEBUG: random.seed(243) print("+--------------------------------+") print("| WELCOME TO MINSWEEPER 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: The above bit of boiler-plate code is useful in a number of situations. Indeed, this is a pattern I regularly find myself using when writing scr...
8,350
<ASSISTANT_TASK:> Python Code: def NthCharacter(n ) : s = "" c = 1 while(True ) : if(c < 10 ) : s += chr(48 + c )  else : s1 = "" dup = c while(dup > 0 ) : s1 += chr(( dup % 10 ) + 48 ) dup //= 10  s1 = "". join(reversed(s1 ) ) s += s1  c += 1 if(len(s ) >= n ) : return s[n - 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:
8,351
<ASSISTANT_TASK:> Python Code: data_in_shape = (5, 5, 2) conv = Conv2D(4, (3,3), strides=(1,1), padding='valid', data_format='channels_last', dilation_rate=(1,1), activation='linear', use_bias=True) layer_0 = Input(shape=data_in_shape) layer_1 = conv(layer_0) model = Model(inputs=layer_0, ou...
<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: [convolutional.Conv2D.1] 4 3x3 filters on 5x5x2 input, strides=(1,1), padding='valid', data_format='channels_last', dilation_rate=(1,1), activat...
8,352
<ASSISTANT_TASK:> Python Code: %pylab inline # Import a Kalman filter and other useful libraries from pykalman import KalmanFilter import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy import poly1d tau = 0.1 # Set up the filter kf = KalmanFilter(n_dim_obs=1, n_dim_state=2, # position is 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: Toy example Step2: At each point in time we plot the state estimate <i>after</i> accounting for the most recent measurement, which is why we ar...
8,353
<ASSISTANT_TASK:> Python Code: a = np.array([3,4,5]) b = np.ones(3) a - b a = np.array([[1,2],[3,4]]) b = np.array([[1,2],[3,4]]) a b a * b np.dot(a,b) a = np.zeros((2,2),dtype='float') a += 5 a a *= 5 a a + a a = np.array([1,2,3]) b = np.array([4,5,6]) c = np.array([7,8,9]) np.hstack([a,b,c]) np.vstack([a,b,c]) 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: Zaskakujące może być działanie operatora *, który nie oblicza iloczynu macierzy. Odpowiada za to funkcja dot. Step2: Inne operacje dodawania i ...
8,354
<ASSISTANT_TASK:> Python Code: import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) from gensim.summarization import summarize text = "Thomas A. Anderson is a man living two lives. By day he is an " + \ "average computer programmer and by night a hacker known 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: We will try summarizing a small toy example; later we will use a larger piece of text. In reality, the text is too small, but it suffices as an ...
8,355
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.io.parsers.read_csv( 'Data/NewBalanced.csv', ) print(df.shape) print('\n') print(df.head(5)) print('\n') print(df.tail(1)) import pandas as pd from sklearn.model_selection import train_test_split from sklearn import preprocessing df = pd.io.parsers.read_cs...
<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: This file has 23 features and 10,341 data points. Clearly not all of these features are useful for training a model. For example we have date an...
8,356
<ASSISTANT_TASK:> Python Code: import os home_dir = os.environ.get('HOME') # Please enter the filename of the ztf_sim output file you would like to use. The example first determines # your home directory and then uses a relative path (useful if working on several machines with different usernames) survey_file = os.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: TransientGenerator Step2: SimulSurvey Step3: Analysing the output Step4: You can inspect the lightcurves manually. This example should return...
8,357
<ASSISTANT_TASK:> Python Code: import time import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import numpy as np from sklearn import preprocessing from sklearn.ensemble import RandomForestClassifier from sklearn.cross_validation import StratifiedShuffleSplit from sklearn.cross_validation import c...
<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> Import the dataframe and remove any features that are all zero </h2> Step2: <h2> Get mappings between sample names, file names, and sample...
8,358
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings("ignore") %matplotlib inline import sys sys.path.append("..") #Import standard pydata libs import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns filename = '../facies_vectors.csv' training_data = pd.read_csv(fi...
<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: Feature Engineering Step2: Building the model and parameter tuning
8,359
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-2', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contribut...
<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: 2...
8,360
<ASSISTANT_TASK:> Python Code: # 引用数据分析需要使用的一些包 # 数据规整化 import pandas as pd from pandas import Series,DataFrame from collections import Counter import numpy as np import re # 数据可视化 import matplotlib.pyplot as plt import seaborn as sns sns.set_style('whitegrid') %matplotlib inline # 机器学习 from sklearn.linear_model import...
<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: 我们找到的第一个人,她的全名('Name字段')叫做Astor, Mrs...
8,361
<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: The Functional API Step2: Introduction Step3: The shape of the data is set as a 784-dimensional vector. Step4: The inputs that is returned co...
8,362
<ASSISTANT_TASK:> Python Code: ymin = -4.0 ymax = 8.0 xmin = -4.0 xmax = 6.0 x0 = np.array([2.0, 1.0]) def rosenbrock(xvec): x = xvec[0] y = xvec[1] f = (1.0 - x)**2 + 100.0*(y - x**2)**2 g = np.zeros(2) g[0] = -2*(1 - x) + 200*(y - x**2)*-2*x g[1] = 200*(y - x**2) H = np.zeros((2, 2)) H...
<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 plot below show the Rosenbrock function in faded black and a blue quadratic approximation to the function about the blue dot. Step2: We now...
8,363
<ASSISTANT_TASK:> Python Code: import pickle import os if not os.path.exists('secret_twitter_credentials.pkl'): Twitter={} Twitter['Consumer Key'] = '' Twitter['Consumer Secret'] = '' Twitter['Access Token'] = '' Twitter['Access Token Secret'] = '' with open('secret_twitter_credentials.pkl','wb'...
<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 twitter package to interface with the Twitter API Step2: Example 1. Authorizing an application to access Twitter account data Step3...
8,364
<ASSISTANT_TASK:> Python Code: # http://neo4j.com/docs/developer-manual/current/cypher/#query-load-csv command = LOAD CSV WITH HEADERS FROM "https://gist.githubusercontent.com/jexp/d788e117129c3730a042/raw/1bd8c19bf8b49d9eb7149918cc11a34faf996dd8/people.tsv" AS line FIELDTERMINATOR '\t' CREATE (:Artis...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step9: http Step13: TRY ON OUR DATA Step17: http Step24: Go through and define all the nodes first, then add edges by iterating over each line? Step...
8,365
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mpi-m', 'icon-esm-lr', 'aerosol') # 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...
8,366
<ASSISTANT_TASK:> Python Code: #Drop quantitative features for which most samples take 0 or 1 for cols in quan: if train_c[cols].mean() < 0.01 or train_c[cols].mean() > 0.99: train_c.drop(cols, inplace=True, axis=1) test_c.drop(cols, inplace=True, axis=1) #For now we only use the quantitative featur...
<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 now we try a range of estimators and use GridSearch to iteratively tune their hyperparameters
8,367
<ASSISTANT_TASK:> Python Code: # Lowercase the hashtags and tweet body df['hashtags'] = df['hashtags'].str.lower() df['text'] = df['text'].str.lower() print("Total number of tweets containing hashtag 'wall' = {}".format(len(df[df['hashtags'].str.contains('wall')]))) print("Total number of tweets whose body contains 'wa...
<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 is the average twitter tenure of people who tweeted about the wall? Step2: There are a couple of users tweeting multiple times, but most t...
8,368
<ASSISTANT_TASK:> Python Code: # Librerías import pandas as pd import numpy as np from sklearn.model_selection import cross_val_score, train_test_split from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LinearRegression, RidgeCV, LassoCV, ElasticNetCV from sklearn.metrics import mean_squa...
<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: Contenido y estructura de los datos Step2: Procesamiento de datos Step3: Nota Step4: Transformación logarítmica de la variable objetivo Step...
8,369
<ASSISTANT_TASK:> Python Code: from konlpy.corpus import kolaw kolaw.fileids() c = kolaw.open('constitution.txt').read() print(c[:100]) from konlpy.corpus import kobill kobill.fileids() d = kobill.open('1809890.txt').read() print(d[:100]) x = [u"한글", {u"한글 키": [u"한글 밸류1", u"한글 밸류2"]}] print(x) from konlpy.utils import...
<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: 품사 태깅
8,370
<ASSISTANT_TASK:> Python Code: report_file = '/Users/bking/IdeaProjects/LanguageModelRNN/experiment_results/encdec_noing23_bow_200_512_04drb/encdec_noing23_bow_200_512_04drb.json' log_file = '/Users/bking/IdeaProjects/LanguageModelRNN/experiment_results/encdec_noing23_bow_200_512_04drb/encdec_noing23_bow_200_512_04drb_...
<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: Perplexity on Each Dataset Step2: Loss vs. Epoch Step3: Perplexity vs. Epoch Step4: Generations Step5: BLEU Analysis Step6: N-pairs BLEU An...
8,371
<ASSISTANT_TASK:> Python Code: x = 1 print(x) y = 2 * x print(y) !python --version def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quic...
<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 variables are shared between cells. Try executing the cell below Step2: Keyboard Shortcuts Step3: Basics of Python Step4: Basic data t...
8,372
<ASSISTANT_TASK:> Python Code: import numpy as np import pymc3 as pm import seaborn as sns import arviz as ar sns.set(font_scale=1.5) %matplotlib inline with pm.Model() as model: H = pm.Normal('H', 2.00, sigma=0.03) h = pm.Normal('h', 0.88, sigma=0.04) Q = pm.Deterministic('Q', H-h) trace = pm.sample(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: This version uses prior distributions to do all the work. H and h are both informative priors that then drive the solution to the right answer. ...
8,373
<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: Install TensorFlow for C Step2: Linker Step3: If you extract the TensorFlow C library to a non-system directory, such as Step4: Compile Step5...
8,374
<ASSISTANT_TASK:> Python Code: %matplotlib inline from jyquickhelper import add_notebook_menu add_notebook_menu() def rendement(x, n, r): return x*(1+r)**n rendement(1, 2, 0.02) rendement(1, 3, 0.02) def decompose_mensualite(K,M,p): i = K * ((1+p)**(1.0/12)-1) return M-i, i decompose_mensualite(180000, 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: Après chaque question, on vérifie sur un petit exemple que cela fonctionne comme attendu. Step2: Q2 Step3: Q3 Step4: Parfois ce calcul entre ...
8,375
<ASSISTANT_TASK:> Python Code: "Elapsed decorator." import datetime def elapsed(func): "Elapsed decorator" def _wrapper(*args, **kwargs): "Decoration function" start = datetime.datetime.now() ret = func(*args, **kwargs) print("Elapsed time", datetime.datetime.now() - start) ...
<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 former was both a Closure and a High Order Function. Did you heard about Functional Programming? Step2: The previous was the built-in "Deco...
8,376
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'ec-earth3-lr', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contri...
<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: 2...
8,377
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) img = mnist.train.images[2] plt.imshow(img.reshape((28, 28)), cmap='...
<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: Below I'm plotting an example image from the MNIST dataset. These are 28x28 grayscale images of handwritten digits. Step2: We'll train an autoe...
8,378
<ASSISTANT_TASK:> Python Code: # Install dependencies with pip. Only run this once. ! pip install -q tf-nightly git+https://github.com/google-research/neural-structural-optimization.git # Copyright 2019 Google LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in...
<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: MBB Beam (Figure 2 from paper) Step2: If desired, designs can also be converted into PIL.Image objects with the pipeline_utils.image_from_desig...
8,379
<ASSISTANT_TASK:> Python Code: import great_expectations as ge from ruamel import yaml from great_expectations.core.batch import BatchRequest from great_expectations.rule_based_profiler.rule.rule import Rule from great_expectations.rule_based_profiler.rule_based_profiler import RuleBasedProfiler, RuleBasedProfilerResul...
<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-up Step2: BatchRequests Step3: Example 1 Step4: To continue our example, we will continue building a RuleBasedProfiler using our ColumnDo...
8,380
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd df = pd.DataFrame(np.random.randint(0, 10, (3, 4)), columns=['A', 'B', 'C', 'D']) df np.cos(df * np.pi/2 ) - 1 A = pd.DataFrame(np.random.randint(0, 20, (2, 2)), columns=list('AB')) A B = pd.DataFrame(np.random.randint(0, 10, (3, 3)), columns=list(...
<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: Numpy operations Step2: Arithmetic operations Step3: The pandas arithmetic functions also have an option to fill missing values by replacing t...
8,381
<ASSISTANT_TASK:> Python Code: # Based on # https://github.com/fchollet/deep-learning-with-python-notebooks/blob/master/6.2-understanding-recurrent-neural-networks.ipynb import warnings warnings.filterwarnings('ignore') %matplotlib inline %pylab inline import matplotlib.pyplot as plt import pandas as pd import tensorfl...
<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: GRU RNNs Step2: How does this work on anything that is not a real movie review?
8,382
<ASSISTANT_TASK:> Python Code: %pylab inline from scipy import ndimage from skimage import filters, data import skimage as ski myData = uint16(ski.exposure.rescale_intensity(ski.color.rgb2gray(data.lena()),out_range='uint16')) matshow(myData, cmap = 'gray') #float64 images myData = ski.color.rgb2gray(data.lena()) ski_...
<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: Median filtering Step2: It looks like skimage's median filter is only good for uint8 data types. If its a float it will be downgraded to uint8 ...
8,383
<ASSISTANT_TASK:> Python Code: products = pd.read_csv('amazon_baby_subset.csv') products['name'][:10] print (products['sentiment'] == 1).sum() print (products['sentiment'] == -1).sum() print (products['sentiment']).count() import json with open('important_words.json') as important_words_file: important_words...
<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. listing the name of the first 10 products in the dataset. Step2: 2. counting the number of positive and negative reviews. Step3: Apply text...
8,384
<ASSISTANT_TASK:> Python Code: Functions for downloading and reading MNIST data. from __future__ import absolute_import from __future__ import division from __future__ import print_function import gzip import os import tempfile import numpy from six.moves import urllib from six.moves import xrange # pylint: disable=re...
<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: T81-558 Step2: Define CNN Step3: Training/Fitting CNN Step4: Evaluate Accuracy
8,385
<ASSISTANT_TASK:> Python Code: ### General imports %matplotlib inline import numpy as np import matplotlib.pyplot as plt from matplotlib import colors as mcolors import GPy import time ### Emukit imports from emukit.test_functions import forrester_function from emukit.core.loop.user_function import UserFunctionWrapper ...
<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 up our toy problem (1D optimisation of the forrester function) and collect 3 initial points. Step2: Fit our GP model to the observed data. ...
8,386
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import numpy as np import os from numpy import zeros_like print('Esperamos trabalhar no diretório') print(os.getcwd()) base = pd.read_csv('DOM2013.csv',sep=',') base9 = pd.read_csv('DOM2009.csv',sep=',') base.V0101=ba...
<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: MUDANÇA DA VARIÁVEL INICIAL QUE MOSTRA O ANO DE PESQUISA. Step2: DEFINIÇÃO DAS REGIÕES E TRANSFORMAÇÃO EM UMA CATEGORIA; Step3: DIVISÃO EM ZON...
8,387
<ASSISTANT_TASK:> Python Code: %matplotlib inline #%matplotlib notebook import matplotlib matplotlib.rcParams['figure.figsize'] = (9, 9) import pandas as pd url = "https://www.data.gouv.fr/fr/datasets/r/1fee314d-c278-424f-a029-a74d877eb185" df2016 = pd.read_csv(url, encoding='iso-8859-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: Informations utiles sur les données Step2: Données par agglomération Step3: Paris intra-muros Step4: Remarque Step5: Région Parisienne
8,388
<ASSISTANT_TASK:> Python Code: class MulLayer: def __init__(self): self.x = None self.y = None # 순전파시의 입력 값을 유지하기 위해 사용 def forward(self, x, y): self.x = x self.y = y out = x * y return out def backward(self, dout): dx = dout * 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: 5.5 활성화 함수 계층 구현하기 Step2: Sigmoid Step3: 5.6 Affine / Softmax 계층 구현하기 Step4: 5.6.3 softmax-with-loss 계층 Step5: 5.7 오차역전파 Step6: 학습 구현 Step7...
8,389
<ASSISTANT_TASK:> Python Code: # set the midpoint midpoint = 5 # make two empty lists lower = []; upper = [] # split the numbers into lower and upper for i in range(10): if (i < midpoint): lower.append(i) else: upper.append(i) print("lower:", lower) print("upper:", upper) print(2*(3+4)...
<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: Este pequeño script muestra algunos aspectos importantes de la sintaxis de Python. Step2: Los parentesis también se usan para pasar parámetros ...
8,390
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pylab as plt import numpy as np import sys sys.path.append('../') from pyphot import sandbox as pyphot from pyphot.svo import get_pyphot_filter as get_filter_from_svo lst = ["2MASS/2MASS.J", "2MASS/2MASS.H", "2MASS/2MASS.Ks", "HST/ACS_WFC.F475W", "HST/ACS...
<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: Quick Start Step2: Suppose one has a calibrated spectrum and wants to compute the vega magnitude throug the HST WFC3 F110W passband,
8,391
<ASSISTANT_TASK:> Python Code: import toytree import toyplot import numpy as np # a tree to use for examples url = "https://eaton-lab.org/data/Cyathophora.tre" rtre = toytree.tree(url).root(wildcard='prz') # hide tip labels rtre.draw(tip_labels=False); # get tip labels from tree tipnames = rtre.get_tip_labels() # modi...
<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: Tip label styling Step2: tip_labels_align Step3: tip_labels_colors Step4: tip_labels_style Step5: Node labels styling Step6: node_labels_st...
8,392
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-hm', 'seaice') # 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: 2...
8,393
<ASSISTANT_TASK:> Python Code: import os import mne sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', 'sample_audvis_filt-0-40_raw.fif') raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False) events_f...
<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: Annotating bad spans of data Step2: .. sidebar Step3: Now we can confirm that the annotations are centered on the EOG events. Since Step4: Se...
8,394
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pycomlink as pycml import matplotlib.pyplot as plt from tqdm import tqdm cml_list = pycml.io.examples.get_75_cmls() fig, ax = plt.subplots() for cml in cml_list: cml.plot_line(ax=ax, color='k') for cml in tqdm(cml_list): window_length = 60 threshold...
<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 CML example data Step2: Do a simple standard processing to get rain rates for each CML Step3: Do IDW interpolation of CML rain rates Step...
8,395
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv("data-readonly/IL_Building_Inventory.csv") df.columns df.head() df.tail() df.describe() df.dtypes df.groupby(["Agency Name"])["Square Footage"].sum() df["Agency Name"].value_counts() df.describe() 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: Pandas provides a number of read_* options, including read_csv, which we will use here. Step2: One of the first things we can do is examine the...
8,396
<ASSISTANT_TASK:> Python Code: # Data for manual OHE # Note: the first data point does not include any value for the optional third feature sampleOne = [(0, 'mouse'), (1, 'black')] sampleTwo = [(0, 'cat'), (1, 'tabby'), (2, 'mouse')] sampleThree = [(0, 'bear'), (1, 'black'), (2, 'salmon')] sampleDataRDD = sc.paralleli...
<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: (1b) Vetores Esparsos Step2: (1c) Atributos OHE como vetores esparsos Step4: (1d) Função de codificação OHE Step5: (1e) Aplicar OHE em uma...
8,397
<ASSISTANT_TASK:> Python Code: %matplotlib inline %reload_ext autoreload %autoreload 2 from fastai.conv_learner import * PATH = 'data/cifar10/' os.makedirs(PATH, exist_ok=True) classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck') stats = (np.array([ 0.4914 , 0.48216, 0.44653]), 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: Something changed, or I forgot something, so I have to move the data into class folders. Step2: 1. View Data Step3: I am so happy that worked....
8,398
<ASSISTANT_TASK:> Python Code: import pypot.dynamixel ports = pypot.dynamixel.get_available_ports() if not ports: raise IOError('no port found!') print 'ports found', ports using_XL320 = False my_baudrate = 1000000 for port in ports: print port try: if using_XL320: dxl_io = pypot.dynam...
<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: Protocol is not the same for XL320 servomotors, set the using_XL320 flag to True if you use them. Step2: If the code below gives you an excepti...
8,399
<ASSISTANT_TASK:> Python Code: # Authors: Olaf Hauk <olaf.hauk@mrc-cbu.cam.ac.uk> # Martin Luessi <mluessi@nmr.mgh.harvard.edu> # Alexandre Gramfort <alexandre.gramfort@inria.fr> # Nicolas P. Rougier (graph code borrowed from his matplotlib gallery) # # License: BSD-3-Clause import numpy as 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 forward solution and inverse operator Step2: Read and organise labels for cortical parcellation Step3: Compute point-spread function summ...