Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
10,000
<ASSISTANT_TASK:> Python Code: import os PROJECT = "cloud-training-demos" # REPLACE WITH YOUR PROJECT ID BUCKET = "cloud-training-demos-ml" # REPLACE WITH YOUR BUCKET NAME REGION = "us-central1" # REPLACE WITH YOUR BUCKET REGION e.g. us-central1 # Do not change these os.environ["PROJECT"] = PROJECT os.environ["BUCKET"]...
<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: Create raw dataset Step3: Create dataset for WALS Step4: Creating rows and columns datasets Step5: To summarize, you created the following da...
10,001
<ASSISTANT_TASK:> Python Code: a = spot.translate('a U b U c') a.show('.#') a.highlight_edges([2, 4, 5], 1) a.highlight_edge(6, 2).highlight_states((0, 1), 0) a.highlight_states([False, True, True], 5) print(a.to_str('HOA', '1')) print() print(a.to_str('HOA', '1.1')) b = spot.translate('X (F(Ga <-> b) & GF!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 # option of print_dot() can be used to display the internal number of each transition Step2: Using these numbers you can selectively hightl...
10,002
<ASSISTANT_TASK:> Python Code: import sys import pandas as pd import matplotlib.pyplot as plt import datetime as dt import numpy as np import html5lib from bs4 import BeautifulSoup import seaborn.apionly as sns ...
<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: Players selected into All-NBA teams Step2: Players Drafted Step3: Merge both data tables
10,003
<ASSISTANT_TASK:> Python Code: # A bit of setup import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots plt.rcParams['image.interpolation'] = 'nearest' plt.rcParams['image.cmap'] = 'gray' # for auto-reloading external modules # see 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: Implementing a Neural Network Step2: The neural network parameters will be stored in a dictionary (model below), where the keys are the paramet...
10,004
<ASSISTANT_TASK:> Python Code: from neon.callbacks.callbacks import Callbacks from neon.initializers import Gaussian from neon.layers import GeneralizedCost, Affine, Multicost, SingleOutputTree from neon.models import Model from neon.optimizers import GradientDescentMomentum from neon.transforms import Rectlin, Logisti...
<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 also set up the backend and load the data. Step2: Now its your turn! Set up the branch nodes and layer structure above. Some tips Step3: No...
10,005
<ASSISTANT_TASK:> Python Code: import osmdigest.pythonify as pythonify import os basedir = os.path.join("/media/disk", "OSM_Data") filename = "illinois-latest.osm.xz" tags = pythonify.Tags(os.path.join(basedir, filename)) pythonify.pickle(tags, "illinois_tags.pic.xz") os.stat("illinois_tags.pic.xz").st_size / 1024**2 ...
<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: Extract tags Step2: Load tags back in Step3: Extract nodes Step4: Extract ways and relations Step5: Load back node data and recompress Step6...
10,006
<ASSISTANT_TASK:> Python Code: ### import two datasets def reindex_xcms_by_mzrt(df): df.index = (df.loc[:,'mz'].astype('str') + ':' + df.loc[:, 'rt'].astype('str')) return df # alzheimers local_path = '/home/irockafe/Dropbox (MIT)/Alm_Lab/'\ 'projects' alzheimers_path = local_path + '/revo_healt...
<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> Looks like There aren't too many ppm m/z overlaps </h2> Step2: <h2> So, about 1/4 of the mass-matches have potential isomers in the other ...
10,007
<ASSISTANT_TASK:> Python Code: from spectral import * import spectral.io.envi as envi import numpy as np import matplotlib ls ../../data/D02_SERC img = envi.open('../../data/D02_SERC/NEON_D02_SERC_DP3_368000_4306000_reflectance.hdr', '../../data/D02_SERC/NEON_D02_SERC_DP3_368000_4306000_reflectance.dat...
<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: For this example, we will read in a reflectance tile from the site SERC (Smithsonian Ecological Research Center) since this has a variety of lan...
10,008
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup import time import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.fc_net import * from cs231n.data_utils import get_CIFAR10_data from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array from cs231n.solver impo...
<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: Dropout Step2: Dropout forward pass Step3: Dropout backward pass Step4: Fully-connected nets with Dropout Step5: Regularization experiment
10,009
<ASSISTANT_TASK:> Python Code: import dogs_vs_cats as dvc all_files = dvc.image_files() from keras.applications.nasnet import NASNetMobile from keras.preprocessing import image from keras.applications.vgg16 import preprocess_input, decode_predictions import numpy as np # https://keras.io/applications/#vgg16 model = NA...
<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: Imagenet pretrained models Step2: Imagenet 1000 classes Step3: Using pretrained CNN as feature extractors
10,010
<ASSISTANT_TASK:> Python Code: # Useful Libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy.stats import t import scipy.stats prices1 = get_pricing('TSLA', start_date = '2015-01-01', end_date = '2016-01-01', fields = 'price') returns_sample_tsla = prices1.pct_change()[1:] 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: Exercise 1 Step2: Write your hypotheses here Step3: b. Two tailed test. Step4: Exercise 2 Step5: b. Mean T-Test Step6: c. Mean p-value test...
10,011
<ASSISTANT_TASK:> Python Code: import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) p = GPIO.PWM(18, 50) p.start(2.5) p.ChangeDutyCycle(5.0) p.ChangeDutyCycle(7.0) p.ChangeDutyCycle(4.0) time.sleep(0.2) p.ChangeDutyCycle(10.0) time.sleep(0.2) p.ChangeDutyCycle(5.0) time.sleep(0.2) p.Ch...
<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 the port as a PWM port with a 50Hz frequency Step2: Start at the 0 degree position (for most motors, this is a 2.5% duty cycle). Step3: ...
10,012
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('home_data.gl/') sales.head(5) graphlab.canvas.set_target('ipynb') sales.show(view="Scatter Plot", x="sqft_living", y="price") train_data,test_data = sales.random_split(.8,seed=123) sqft_model = graphlab.linear_regression.create(train_data, targ...
<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 some house sales data Step2: Exploring the data for housing sales Step3: Create a simple regression model of sqft_living to price Step4: ...
10,013
<ASSISTANT_TASK:> Python Code: import csv import json import JobsMapResultsFilesToContainerObjs as ImageMap import DeriveFinalResultSet as drs import DataStructsHelper as DS import importlib import pandas as pd import htmltag as HT from collections import OrderedDict #import matplotlib.pyplot as plt import plotly.plotl...
<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: Rank list of images by share rates with Microsoft Image Tagging API output Step2: Generate rank list of tags by share rate.
10,014
<ASSISTANT_TASK:> Python Code:: import tensorflow as tf from tensorflow.keras.losses import MeanSquaredError y_true = [1., 0.] y_pred = [2., 3.] mse_loss = MeanSquaredError() loss = mse_loss(y_true, y_pred).numpy() <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:
10,015
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = "retina" from matplotlib import rcParams rcParams["savefig.dpi"] = 100 rcParams["figure.dpi"] = 100 rcParams["font.size"] = 20 import numpy as np import matplotlib.pyplot as plt np.random.seed(42) true_params = np.array([0.5, -2.3,...
<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 this post, I will demonstrate how you can use emcee to sample models defined using PyMC3. Step2: Then, we can code up the model in PyMC3 fol...
10,016
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('/opt/rhc') import rhc.micro as micro import rhc.async as async import logging logging.basicConfig(level=logging.DEBUG) p=micro.load_connection([ 'CONNECTION placeholder http://jsonplaceholder.typicode.com', 'RESOURCE document /posts/{id}', ]) async.wai...
<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 simple resource Step2: Define a mock for the resource Step3: Call the mocked resource Step4: What is going on here?
10,017
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pickle as pkl 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') def model_inputs(real_dim, z_dim): inputs_real = tf.placeholde...
<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 Inputs Step2: Generator network Step3: Discriminator Step4: Hyperparameters Step5: Build network Step6: Discriminator and Generator L...
10,018
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() # tutoriel_graphe noeuds = {0: 'le', 1: 'silences', 2: 'quelques', 3: '\xe9crit', 4: 'non-dits.', 5: 'Et', 6: 'risque', 7: '\xe0', 8: "qu'elle,", 9: 'parfois', 10: 'aim\xe9', 11: 'lorsque', 12: 'que', 13: 'plus', 14: 'les', ...
<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: Un graphe Step2: Partie 1 Step3: Q4 Step4: Q6 Step5: Q7 Step6: On note $d(X_1,X_2)$ la distance euclidienne entre deux points $X_1$ et $X_...
10,019
<ASSISTANT_TASK:> Python Code: img = np.random.ranf((128,128)) plt.imshow(img, cmap=plt.cm.ocean) def seed(n, shape=(8,)): global r np.random.seed(n) r = np.random.ranf(shape) seed(0) x = np.arange(0, len(r), 1) plt.plot(x, r[x], 'bo') plt.axis('tight') def noise(x): x = int(x % len(r)) return r[...
<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: value noise Step2: We can visualize r by plotting it. Step3: We can use this table to define a function noise that given an integer value x wi...
10,020
<ASSISTANT_TASK:> Python Code: # 1. open the text file infile = open('data/39.txt') # 2. read the file and assign it to the variable 'text' text = infile.read() # 3. close the text file infile.close() # 4. split the variable 'text' into distinct word strings words = text.split() # 5. define the'count_in_list' function...
<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 that we have loaded our file, we can begin to work on it. <i>Python</i> offers us a lot of pre-built tools to make the task of coding easier...
10,021
<ASSISTANT_TASK:> Python Code: import os from hiclib import mapping from mirnylib import h5dict, genome bowtie_path = '/opt/conda/bin/bowtie2' enzyme = 'DpnII' bowtie_index_path = '/home/jovyan/GENOMES/HG19_IND/hg19_chr1' fasta_path = '/home/jovyan/GENOMES/HG19_FASTA/' chrms = ['1'] genome_db ...
<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 this case, we have multiple datasets, thus we have to iterate through the list of files. Step2: <a id="filtering"></a> Step3: <a id="visual...
10,022
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.2,<2.3" %matplotlib inline import phoebe logger = phoebe.logger() b = phoebe.default_binary() b.add_dataset('lc', times=phoebe.linspace(0,1,101), dataset='lc01') print(b['ld_mode_bol@primary']) print(b['ld_func_bol@primary']) print(b['ld_func_bol@primary'].ch...
<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. See Building a System for more details. Step2: We'll just add an 'lc' da...
10,023
<ASSISTANT_TASK:> Python Code: import glob from os.path import join import os import csv import shutil import json from itertools import product from qiime2 import Artifact from qiime2.plugins import feature_classifier from q2_types.feature_data import DNAIterator from q2_feature_classifier.classifier import \ spec...
<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: File Paths and Communities Step2: Import Reference Databases Step3: Amplicon and Read Extraction Step4: Find Class Weights Step5: Classifier...
10,024
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import astropy.io.fits as pyfits import numpy as np import os import urllib import astropy.visualization as viz import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 10.0) targdir = 'a1835_xmm' if not os.path.isdi...
<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 the example data files if we don't already have them. Step2: The XMM MOS2 image Step3: imfits is a FITS object, containing multiple d...
10,025
<ASSISTANT_TASK:> Python Code: try: get_ipython().magic(u'load_ext autoreload') get_ipython().magic(u'autoreload 2') get_ipython().magic(u'matplotlib qt') except: pass import logging import matplotlib.pyplot as plt import numpy as np logging.basicConfig(format= "%(relativeCreat...
<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: Select file(s) to be processed Step2: Setup a cluster Step3: Setup some parameters Step4: Motion Correction Step5: Load memory mapped file S...
10,026
<ASSISTANT_TASK:> Python Code: # index # index1 = table.cols.date.create_index() # read the first couple of rows (like df.head) tbf = tb.open_file("/global/scratch/ryee/symbol_count/agg_count.h5", "a") table = tbf.root.count_table.read() table['count'].sum() df = DataFrame(table) df.head() df["count"].sum() cdf = Dat...
<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: naive Step2: even use pandas
10,027
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import suspect image = suspect.image.load_dicom_volume("00004_MPRAGE/i5881167.MRDC.15.img") data, wref = suspect.io.load_pfile("P75264.e02941.s00007.7") voxel_mask = suspect.image.create_mask(data, image) masked_mask = np.ma.masked_wher...
<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: Here we load the data, in this case a DICOM image set and a GE P-file. For the DICOM volume we pass a single file and the containing folder is p...
10,028
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'fio-ronm', 'sandbox-1', '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...
10,029
<ASSISTANT_TASK:> Python Code: #rootname = "/media/p/5F5B-8FCB/PROJECTS/UMAR/Data/chem/" #thumb on ubuntu rootname = "E:\\PROJECTS\\UMAR\\Data\\chem\\" #thumb on windows WQPResultsFile = rootname + "result.csv" WQPStationFile = rootname + "station.csv" SDWISFile = rootname + "SDWIS_Cache.txt" AGStationsFile = rootname ...
<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: WQP Step2: Read csv data into python. Step3: Rename columns to match with other data later. Step4: Define unneeded columns that will be dropp...
10,030
<ASSISTANT_TASK:> Python Code: from tock import * m1 = Machine([BASE, BASE, BASE, BASE], state=0, input=1) m1.set_start_state('q1') m1.add_transition('q1, &, &, & -> q2, &, $, $') m1.add_transition('q2, a, &, & -> q2, &, a, &') m1.add_transition('q2, b, &, & -> q2, &, b, &') m1.add_transition('q2, # # #, &, & -> q3, ...
<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've seen finite automata, pushdown automata, and Turing machines, but many other kinds of automata can be created by instantiating a Machine d...
10,031
<ASSISTANT_TASK:> Python Code: # Imports the functionality that we need to display YouTube videos in # a Jupyter Notebook. # You need to run this cell before you run ANY of the YouTube videos. from IPython.display import YouTubeVideo # Don't forget to watch the video in full-screen mode! YouTubeVideo("BTXyE3KLIOs"...
<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 useful numpy references Step2: Question 2 Step3: Potentially useful links Step4: Potentially useful links Step6: Assignment wrapup
10,032
<ASSISTANT_TASK:> Python Code: import numpy as np import h5py import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots plt.rcParams['image.interpolation'] = 'nearest' plt.rcParams['image.cmap'] = 'gray' %load_ext autoreload %autoreload 2 np.random.seed(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: Step2: 2 - Outline of the Assignment Step4: Expected Output Step6: Expected Output Step8: Expected Output Step10: Expected Output Step12: Expected...
10,033
<ASSISTANT_TASK:> Python Code: import os from datetime import timedelta import mne sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', 'sample_audvis_raw.fif') raw = mne.io.read_raw_fif(sample_data_raw_file, ve...
<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: ~mne.Annotations in MNE-Python are a way of storing short strings of Step2: Notice that orig_time is None, because we haven't specified it. In ...
10,034
<ASSISTANT_TASK:> Python Code: import rebound import numpy as np def setupSimulation(Nplanets): sim = rebound.Simulation() sim.integrator = "ias15" # IAS15 is the default integrator, so we don't need this line sim.add(m=1.,id=0) for i in range(1,Nbodies): sim.add(m=1e-5,x=i,vy=i**(-0.5),id=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: Now let's do a simple example where we do a short initial integration to isolate the particles that interest us for a longer simulation Step2: ...
10,035
<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: 解码用于医学成像的 DICOM 文件 Step2: 安装要求的软件包,然后重新启动运行时 Step3: 解码 DICOM 图像 Step4: 解码 DICOM 元数据和使用标记
10,036
<ASSISTANT_TASK:> Python Code: tips = sns.load_dataset("tips") sns.kdeplot(data=tips, x="total_bill") sns.kdeplot(data=tips, y="total_bill") iris = sns.load_dataset("iris") sns.kdeplot(data=iris) sns.kdeplot(data=tips, x="total_bill", bw_adjust=.2) ax= sns.kdeplot(data=tips, x="total_bill", bw_adjust=5, cut=0) sns...
<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: Flip the plot by assigning the data variable to the y axis Step2: Plot distributions for each column of a wide-form dataset Step3: Use less sm...
10,037
<ASSISTANT_TASK:> Python Code: myvars = {} with open("Twitter_keys.txt") as myfile: for line in myfile: name, var = line.partition("=")[::2] myvars[name.strip()] = var APP_KEY = myvars["APP_KEY"].rstrip() APP_SECRET = myvars["APP_SECRET"].rstrip() OAUTH_TOKEN = myvars["OAUTH_TOKEN"].rstrip() OAUTH_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: A variable save_path is created which contains the path to the folder where the tweet files in json format will be stored. The folder name is sa...
10,038
<ASSISTANT_TASK:> Python Code: from Bio import Entrez Entrez.email = "A.N.Other@example.com" from Bio import Entrez Entrez.tool = "MyLocalScript" from Bio import Entrez Entrez.email = "A.N.Other@example.com" # Always tell NCBI who you are handle = Entrez.einfo() result = handle.read() print(result) from Bio impo...
<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: <span>Bio.Entrez</span> will then use this email address with each Step2: The tool parameter will default to Biopython. Step3: Since this is a...
10,039
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt from unidecode import unidecode import time from bokeh.charts import Bar, output_file, show from bokeh.sampledata.autompg import autompg as df from bokeh.io import output_notebook, show output_notebook() jobs = pd.r...
<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: Top cities and countries posting jobs Step2: Top technologies for a given city (London, Amsterdam and San Francisco) Step3: Dumping out data t...
10,040
<ASSISTANT_TASK:> Python Code: # the output of plotting commands is displayed inline within frontends, # directly below the code cell that produced it %matplotlib inline # this python library provides generic shallow (copy) and deep copy (deepcopy) operations from copy import deepcopy import time # import from Ocelot...
<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: Layout of the corrugated structure insertion. Create Ocelot lattice <img src="4_layout.png" /> Step2: Load beam file Step3: Initialization of ...
10,041
<ASSISTANT_TASK:> Python Code: import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns sns.set_style('ticks') import functools import importlib.resources import numpy as np import os import pandas as pd pd.plotting.register_matplotlib_converters() import xarray as xr from IPython.display import 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: Helper methods for visualization Step2: 1. Define the trial Step3: Choose trial parameters Step4: 2. Load incidence forecasts Step5: 3. Simu...
10,042
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline from sklearn.preprocessing import Imputer from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split as tts from sklearn.ensemble impo...
<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: <h3>II. Preprocessing </h3> Step2: The SVM is sensitive to feature scale so the first step is to center and normalize the data. The train and t...
10,043
<ASSISTANT_TASK:> Python Code: from IPython.core.display import display, HTML from string import Template import pandas as pd import json, random HTML('<script src="lib/d3/d3.min.js"></script>') html_template = Template(''' <style> $css_text </style> <div id="graph-div"></div> <script> $js_text </script> ''') css_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: Graph Config Step2: Initial Data, Graph and Update
10,044
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np def tracePlot(chains, labels=None, truths=None): n_dim = chains.shape[2] fig, ax = plt.subplots(n_dim, 1, figsize=(8., 27.), sharex=True) ax[-1].set_xlabel('Iteration', fontsize=20.) for i in range...
<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: Defining convergence diagnostics Step2: Process samples
10,045
<ASSISTANT_TASK:> Python Code: # 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 writing, sof...
<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 to Regular Expressions Step2: Now that we have a compiled regular expression, we can see if the pattern matches another string. St...
10,046
<ASSISTANT_TASK:> Python Code: import ENESNeoTools from py2neo import Graph, Node, Relationship, authenticate authenticate("localhost:7474", ENESNeoTools.user_name, ENESNeoTools.pass_word) # connect to authenticated graph database graph = Graph("http://localhost:7474/db/data/") from neo4jrestclient.client import Grap...
<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: also rest client possible Step2: Set up a data collection graph Step3: Data servers graph setup Step4: Combine data set graph with server gra...
10,047
<ASSISTANT_TASK:> Python Code: # If we're running on Colab, install empiricaldist # https://pypi.org/project/empiricaldist/ import sys IN_COLAB = 'google.colab' in sys.modules if IN_COLAB: !pip install empiricaldist # Get utils.py from os.path import basename, exists def download(url): filename = basename(url) ...
<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 chapter introduces the Poisson process, which is a model used to describe events that occur at random intervals. Step2: The result is an o...
10,048
<ASSISTANT_TASK:> Python Code: import my_util as my_util import cluster_skill_helpers as cluster_skill_helpers from cluster_skill_helpers import * import random as rd HOME_DIR = 'd:/larc_projects/job_analytics/' SKILL_DAT = HOME_DIR + 'data/clean/skill_cluster/' SKILL_RES = HOME_DIR + 'results/' + 'skill_cluster/new/'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Steps of skill clustering Step1: First, we try it on count matrix as the matrix is already avail. Step2: There are various choices to initialize NMF i...
10,049
<ASSISTANT_TASK:> Python Code: import yaml # Set `PATH` to include the directory containing TFX CLI. PATH = %env PATH %env PATH=/home/jupyter/.local/bin:{PATH} !python -c "import tfx; print('TFX version: {}'.format(tfx.__version__))" %pip install --upgrade --user tfx==0.25.0 # Use the following command to identify th...
<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 Step2: Note Step3: CUSTOM_SERVICE_ACCOUNT - In the gcp console Click on the Navigation Menu and navigate to IAM &amp; Admin, then to Serv...
10,050
<ASSISTANT_TASK:> Python Code: import json import urllib.request as request url = 'http://www.omdbapi.com/?t=Scandal&Season=3' content = request.urlopen(url).read() data = json.loads(content.decode('UTF-8')) print(data) print(data['Episodes'][0]) print(data['Episodes'][6]['imdbRating']) ratings = [] for episode 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: We're using two params. t (for title) and Season. Change values as you wish Step2: Now let's take a look at what data we have Step3: Okay! As...
10,051
<ASSISTANT_TASK:> Python Code: import numpy as np x = np.array([[1,2,3],[4,5,6],[7,8,9]]) print x x.shape x.sum(axis=0) x.sum(axis=1) x.mean(axis=0) x.mean(axis=1) np.arange(10) np.arange(5,10) np.arange(5,10,0.5) x = np.arange(1,10).reshape(3,3) x x = np.linspace(0,5,5) x help(np.linspace) x = np.array([1,2,3]) ...
<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: Tablice typu array mają wiele przydatnych wbudowanych metod. Step2: Do tworzenia sekwencji liczbowych jako obiekty typu array należy wykorzysta...
10,052
<ASSISTANT_TASK:> Python Code: from __future__ import print_function from rdkit.Chem import AllChem from rdkit.Chem import rdChemReactions from rdkit.Chem.AllChem import ReactionFromRxnBlock, ReactionToRxnBlock from rdkit.Chem.Draw import IPythonConsole IPythonConsole.ipython_useSVG=True rxn_data = $RXN ISIS ...
<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: RDKit Enumeration Toolkit Step2: Sanitizing Reaction Blocks Step3: Preprocessing Reaction Blocks Step4: So now, this scaffold will only match...
10,053
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as pl from matplotlib import rcParams rcParams.keys() [key for key in rcParams.keys() if 'map' in key] rcParams['image.cmap'] rcParams['image.cmap'] = 'viridis' rcParams['image.interpolation'] = 'none' x = np.array([[1,2,3]...
<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: little matplotlib config trick Step2: Now, this config dictionary is huge Step3: Visualizing Multi-Dimensional Arrays Step4: Q. What is the r...
10,054
<ASSISTANT_TASK:> Python Code: import os import pandas as pd import numpy as np import scipy as sp import seaborn as sns import matplotlib.pyplot as plt import json from IPython.display import Image from IPython.core.display import HTML retval=os.chdir("..") clean_data=pd.read_pickle('./clean_data/clean_data.pkl') clea...
<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: Training and Testing Split Step2: Scaling Step3: Text Step5: Custom Feature Separator Step6: Classification Models Step7: Although tuning i...
10,055
<ASSISTANT_TASK:> Python Code: import os import numpy as np import matplotlib.pyplot as plt from matplotlib import cm from urllib.request import urlretrieve import itk from itkwidgets import compare, checkerboard dim = 2 ImageType = itk.Image[itk.F, dim] FixedImageType = ImageType MovingImageType = ImageType fixed_img...
<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: Retrieve fixed and moving images for registration Step2: Prepare images for registration Step3: Plot the MutualInformationImageToImageMetric s...
10,056
<ASSISTANT_TASK:> Python Code: from dkrz_forms import form_widgets form_widgets.show_status('form-submission') MY_LAST_NAME = "...." # e.gl MY_LAST_NAME = "schulz" #------------------------------------------------- from dkrz_forms import form_handler, form_widgets form_info = form_widgets.check_pwd(MY_LAST_NAME) sf ...
<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: Edit form information Step2: Save your form Step3: officially submit your form
10,057
<ASSISTANT_TASK:> Python Code: from nilearn import datasets # if you download these from python. haxby_dataset = datasets.fetch_haxby() # print basic information on the dataset print('First subject anatomical nifti image (3D) is at: %s' % haxby_dataset.anat[0]) print('First subject functional nifti images (4D) ar...
<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 the data Step2: The decoding Step3: Compute prediction scores using cross-validation Step4: Retrieve the discriminating weights and s...
10,058
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import tensorflow as tf import numpy as np import matplotlib.pyplot as plt %matplotlib inline from datetime import date date.today() author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises" tf.__version__ np.__version__ w = tf.Variable(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: NOTE on notation Step2: Q1. Complete this code. Step3: Q2. Complete this code. Step4: Q3-4. Complete this code. Step5: Q5-8. Complete this c...
10,059
<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='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: Network Architecture Step2: Training Step3: Denoising Step4: Checking out the performance
10,060
<ASSISTANT_TASK:> Python Code: # Versão da Linguagem Python from platform import python_version print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version()) # Imports import os import subprocess import stat import numpy as np import pandas as pd import seaborn as sns import matplotlib as mat impo...
<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: Número de veículos pertencentes a cada marca Step2: Preço médio dos veículos com base no tipo de veículo, bem como no tipo de caixa de câmbio
10,061
<ASSISTANT_TASK:> Python Code: # Load library import cv2 import numpy as np from matplotlib import pyplot as plt # Load image as grayscale image = cv2.imread('images/plane.jpg', cv2.IMREAD_GRAYSCALE) # Show image plt.imshow(image, cmap='gray'), plt.axis("off") plt.show() # Load image in color image_bgr = cv2.imread('...
<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 Image As Greyscale Step2: Load Image As RGB Step3: View Image Data
10,062
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import seaborn as sns from random import randint as rand import matplotlib.pyplot as plt %matplotlib inline from sklearn.linear_model import LinearRegression from sklearn.metrics.pairwise import euclidean_distances from scipy.linalg import svd from 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: Helper functions Step2: Experiment 1 Step3: Original Lines Step4: Rotated lines Step5: Experiment 2 Step6: Compute rotation linear transfor...
10,063
<ASSISTANT_TASK:> Python Code: %matplotlib inline from bigbang.archive import Archive from bigbang.archive import load as load_archive from bigbang.thread import Thread from bigbang.thread import Node from bigbang.utils import remove_quoted import matplotlib.pyplot as plt import datetime import pandas as pd import csv ...
<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, collect data from a public email archive. Step2: Let's check the number of threads in this mailing list corpus Step3: We can plot the ...
10,064
<ASSISTANT_TASK:> Python Code: import pandas as pd table = pd.DataFrame(index=['Bowl 1', 'Bowl 2']) table['prior'] = 1/2, 1/2 table table['likelihood'] = 3/4, 1/2 table table['unnorm'] = table['prior'] * table['likelihood'] table prob_data = table['unnorm'].sum() prob_data table['posterior'] = table['unnorm'] / 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: Now I'll add a column to represent the priors Step2: And a column for the likelihoods Step3: Here we see a difference from the previous method...
10,065
<ASSISTANT_TASK:> Python Code: %load_ext oct2py.ipython %lsmagic %%octave addpath ("~/Software/MATLAB/CO2SYS-MATLAB/src") %%octave help derivnum %%octave # Standard input for CO2SYS: # -------------------------- # Input Variables: PAR1 = 2300; % ALK PAR2 = 2000; % DIC PAR1TYPE = 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: List all avaiable magics Step2: Specify the directory where you have put the Matlab routines CO2SYS.m, errors.m, and derivnum.m. Step3: Note S...
10,066
<ASSISTANT_TASK:> Python Code: from polyglot.mapping import Embedding embeddings = Embedding.load("/home/rmyeid/polyglot_data/embeddings2/en/embeddings_pkl.tar.bz2") neighbors = embeddings.nearest_neighbors("green") neighbors embeddings.distances("green", neighbors) %matplotlib inline import matplotlib.pyplot as pl...
<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: Formats Step2: Nearest Neighbors Step3: to calculate the distance between a word and the nieghbors, we can call the distances method Step4: T...
10,067
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne import io from mne.datasets import sample from mne.minimum_norm import read_inverse_operator, source_induced_power pri...
<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
10,068
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import torch import torchvision import torch.utils.data as data from torchvision import transforms, utils import torch.nn as nn import torch.optim as optim import time %matplotlib inline import tiny_imagenet tiny_imagenet.download(".") 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: Define helper functions Step2: Network parameters Step3: Training and validation images are now in tiny-imagenet-200/train and tiny-imagenet-2...
10,069
<ASSISTANT_TASK:> Python Code: # variable assignment # https://www.digitalocean.com/community/tutorials/how-to-use-variables-in-python-3 # strings -- enclose in single or double quotes, just make sure they match # numbers # the print function # booleans # addition # subtraction # multiplication # division # etc. # cr...
<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 math Step2: Lists Step3: Dictionaries Step4: Commenting your code Step6: Type coercion
10,070
<ASSISTANT_TASK:> Python Code: import pkg_resources if pkg_resources.get_distribution('CGRtools').version.split('.')[:2] != ['4', '0']: print('WARNING. Tutorial was tested on 4.0 version of CGRtools') else: print('Welcome!') # load data for tutorial from pickle import load from traceback import format_exc with ...
<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: CGRtools has subpackage containers with data structures classes Step2: 1.1. MoleculeContainer Step3: Each structure has additional atoms attri...
10,071
<ASSISTANT_TASK:> Python Code: import pandas as pd act_train = pd.read_csv('act_train.csv') act_test = pd.read_csv('act_test.csv') people = pd.read_csv('people.csv') def prepare_acts(data, train_set=True): data = data.drop(['date', 'activity_id'], axis=1) if train_set: data = data.drop(['outcome'], ax...
<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: Preparing the Data Step2: A Random Forest Model Step3: Output
10,072
<ASSISTANT_TASK:> Python Code: # Load libraries import pandas as pd from pytz import all_timezones # Show ten time zones all_timezones[0:10] # Create datetime pd.Timestamp('2017-05-01 06:00:00', tz='Europe/London') # Create datetime date = pd.Timestamp('2017-05-01 06:00:00') # Set time zone date_in_london = date.tz...
<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: View Timezones Step2: Create Timestamp With Time Zone Step3: Create Timestamp Without Time Zone Step4: Add Time Zone Step5: Convert Time Zon...
10,073
<ASSISTANT_TASK:> Python Code: import os import ipywidgets as widgets import bqplot.pyplot as plt from bqplot import LinearScale image_path = os.path.abspath("../../data_files/trees.jpg") with open(image_path, "rb") as f: raw_image = f.read() ipyimage = widgets.Image(value=raw_image, format="jpg") ipyimage plt.fig...
<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: Using pyplot's imshow to display the image Step2: Displaying the image inside a bqplot Figure Step3: Mixing with other marks Step4: Its trait...
10,074
<ASSISTANT_TASK:> Python Code: from numpy import pi from scipy.constants import hbar # Find the power for a 3 mm diameter gaussian beam with stated intensity: r = 0.3/2 # units of cm A = pi*r**2 P = 2.5e-3 * A P*1e6 # microWatts <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: Step1: Notes from Klein et al 2011 (doi
10,075
<ASSISTANT_TASK:> Python Code: import gzip import urllib.request url = 'ftp://ftp.ncbi.nlm.nih.gov/genomes/archive/old_genbank/Eukaryotes/vertebrates_mammals/Homo_sapiens/GRCh38/non-nuclear/assembled_chromosomes/FASTA/chrMT.fa.gz' response = urllib.request.urlopen(url) print(gzip.decompress(response.read()).decode('UTF...
<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 FASTA file shown above has just one sequence in it. As we saw in the first example above, it's also possible for one FASTA file to contain...
10,076
<ASSISTANT_TASK:> Python Code: # Author: Marijn van Vliet <w.m.vanvliet@gmail.com> # # License: BSD-3-Clause import os.path as op import numpy as np from scipy.signal import welch, coherence, unit_impulse from matplotlib import pyplot as plt import mne from mne.simulation import simulate_raw, add_noise from mne.datase...
<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 Step3: Data simulation Step4: Let's simulate two timeseries and plot some basic information about them. Step5: Now we put the signals a...
10,077
<ASSISTANT_TASK:> Python Code: cmin = [0.0, 0.0] cmax = [1.0, 1.0] coo = uniform(0, 1, (7,2)) val = uniform(0, 1, coo.shape[0]) n = 100 s = linspace(0,1,n) x = array(meshgrid(s,s)).transpose([1,2,0]).copy() def plot_surface(m0): interp = mba2(cmin, cmax, [m0,m0], coo, val) error = amax(abs(val - interp(coo)...
<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 $n \times n$ regular grid of coordinates to interpolate onto. Step2: The plot_surface() function constructs MBA class with the given ini...
10,078
<ASSISTANT_TASK:> Python Code: def myXOR(x , y ) : for i in range(31 , - 1 , - 1 ) : b1 = x &(1 << i ) b2 = y &(1 << i ) b1 = min(b1 , 1 ) b2 = min(b2 , 1 ) xoredBit = 0 if(b1 & b2 ) : xoredBit = 0  else : xoredBit =(b1 b2 )  res <<= 1 ; res |= xoredBit  return res  x = 3 y = 5 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:
10,079
<ASSISTANT_TASK:> Python Code: # Copyright 2020 The Google Research Authors. # # 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 require...
<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: M-layer experiments Step2: Generate a spiral and show extrapolation Step3: Train an M-layer on multivariate polynomials such as the determinan...
10,080
<ASSISTANT_TASK:> Python Code: import sqlite3 import json DATABASE = "data.sqlite" conn = sqlite3.connect(DATABASE) cursor = conn.cursor() # For getting the maximum row id QUERY_MAX_ID = "SELECT id FROM interactions ORDER BY id DESC LIMIT 1" # Get interaction data QUERY_INTERACTION = "SELECT geneids1, geneids2, probab...
<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: Queries Step2: Step through every interaction.
10,081
<ASSISTANT_TASK:> Python Code: # this embeds plots in the notebook %matplotlib inline import numpy as np # for arrays import pylab as pl # for plotting lam_sq = np.arange(0.01,1,0.01) phi_fg = 2. P_gal = np.sin(2*phi_fg*lam_sq)/(2*phi_fg*lam_sq) + 0*1j phi_1 = 10. P_rg = 0.25*np.cos(2*phi_1*lam_sq) + 1j*0.25*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: Make a function for the Galactic foreground Step2: We're going to specify that $\phi_{\rm fg}= 2\,{\rm rad\,m^{-2}}$. We can then compute the G...
10,082
<ASSISTANT_TASK:> Python Code: # Install notebook dependencies import sys #!{sys.executable} -m pip install itk itk-ultrasound numpy matplotlib itkwidgets import itk from matplotlib import pyplot as plt from itkwidgets import view, compare SAMPLING_FREQUENCY = 40e6 # Hz SAMPLING_PERIOD = SAMPLING_FREQUENCY ** -1 # 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 RF Image Step2: The RF image represents transducer results over a certain time period with regards to the axial direction (along the beam)...
10,083
<ASSISTANT_TASK:> Python Code: import itertools import sys import bson import h5py import keras.layers import keras.models import matplotlib.pyplot import numpy import pandas import sklearn.cross_validation import sklearn.dummy import sklearn.linear_model import sklearn.metrics sys.path.insert(1, '..') import crowdastr...
<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'll just look at a small number of potential hosts for now. I'll have to do batches to scale this up and I just want to check it works for now...
10,084
<ASSISTANT_TASK:> Python Code: import pandas as pd from pydrill.client import PyDrill %matplotlib inline #Get a connection to the Apache Drill server drill = PyDrill(host='localhost', port=8047) #Get Written questions data - may take some time! stub='http://lda.data.parliament.uk'.strip('/') #We're going to have to ca...
<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 Written Questions Data for a Session Step2: We should now have all the data in a single JSON file (writtenQuestions.json). Step3: Apa...
10,085
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.special import gammaln import random from collections import Counter import string import graphviz import pygraphviz import pydot def CRP(topic, phi): ''' CRP gives the probability of topic assignment for specific vocabulary Return a 1 * j array,...
<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: B. Function construction Step2: B.2 Node Sampling Step3: B.3 Gibbs sampling -- $z_{m,n}$ Step4: B.4 Gibbs sampling -- ${\bf c}_{m}$, CRP prio...
10,086
<ASSISTANT_TASK:> Python Code: import pineapple %pip freeze import pineapple # required for all subsequent cells # Use %pip line magic to list all installed packages %pip list # Use %pip line magic to download and install a specific package %pip install unittest2 # New package is not available for import import unitte...
<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: All preinstalled packages Step2: %require examples Step3: Best practices
10,087
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-1', 'seaice') # 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: 2...
10,088
<ASSISTANT_TASK:> Python Code: import os import shogun as sg import numpy as np import matplotlib.pyplot as plt %matplotlib inline SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') doc_1 = "this is the first document" doc_2 = "document classification introduction" doc_3 = "a third document about classifica...
<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 <a href="http Step2: We will take some time off now to assign each document to a category, to ease our work later on. Since the two last do...
10,089
<ASSISTANT_TASK:> Python Code: from pynq.overlays.base import BaseOverlay base = BaseOverlay("base.bit") from pynq.lib.pmod import Grove_ADC from pynq.lib.pmod import PMOD_GROVE_G4 grove_adc = Grove_ADC(base.PMODA,PMOD_GROVE_G4) print("{} V".format(round(grove_adc.read(),4))) grove_adc.set_log_interval_ms(100) grove_...
<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. Starting logging once every 100 milliseconds Step2: 3. Try to change the input signal during the logging. Step3: 4. Plot values over time S...
10,090
<ASSISTANT_TASK:> Python Code: # Adapted from # https://github.com/keras-team/keras/blob/master/examples/addition_rnn.py import warnings warnings.filterwarnings('ignore') %matplotlib inline %pylab inline import tensorflow as tf tf.logging.set_verbosity(tf.logging.ERROR) print(tf.__version__) # let's see what compute 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: Step4: Step 1 Step5: Input is encoded as one-hot, 7 digits times 12 possibilities Step6: Same for output, but at most 4 digits Step7: Step 2 Step8: ...
10,091
<ASSISTANT_TASK:> Python Code: s clean_s = removeDelimiter(s," ",[".",",",";","_","-",":","!","?","\"",")","("]) wordlist = clean_s.split() dictionary = {} for word in wordlist: if word in dictionary: tmp = dictionary[word] dictionary[word]=tmp+1 else: dictionary[word]=1 import operator sorted_dict = sorted(dic...
<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 method in Python 3 is - Step2: These are the words that appear more than 200 times and I have excluded the really common words (greate...
10,092
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np from scipy.spatial import Delaunay from metpy.gridding.triangles import find_natural_neighbors # Create test observations, test points, and plot the triangulation and points. gx, gy = np.meshgrid(np.arange(0, 20, 4), np.arange(0, 20, 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: Since finding natural neighbors already calculates circumcenters and circumradii, return Step2: We can then use the information in tri_info lat...
10,093
<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: Composing Learning Algorithms Step3: NOTE Step5: There are a few important points about the code above. First, it keeps track of the number of...
10,094
<ASSISTANT_TASK:> Python Code: (n_transcripts_per_gene > 1e3).sum() n_transcripts_per_gene[n_transcripts_per_gene > 1e4] median_transcripts_per_gene = table1_t.median() median_transcripts_per_gene.head() sns.distplot(median_transcripts_per_gene) fig = plt.gcf() fig.savefig('median_transcripts_per_gene.png') data = med...
<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: Look at gene's median transcript count Step2: Clean data matrix to be compatible with the cluster labels and identities
10,095
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = (20,10) from sklearn import model_selection from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC from sklearn.neighbors import KNeighborsClassifier from sklearn.tree import Deci...
<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'll use all columns except Gender for this tutorial. We could use gender by converting the gender to a numeric value (e.g., 0 for Male, 1 for ...
10,096
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-3', 'seaice') # 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: 2...
10,097
<ASSISTANT_TASK:> Python Code: from proxy.http.parser import HttpParser, httpParserTypes from proxy.common.constants import HTTP_1_1 response = HttpParser(httpParserTypes.RESPONSE_PARSER) response.code = b'200' response.reason = b'OK' response.version = HTTP_1_1 print(response.build_response()) from proxy.http.respons...
<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: But, this is a painful way to construct responses. Hence, other high level abstractions are available. Step2: Notice how okResponse will alway...
10,098
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set_style("whitegrid") %matplotlib inline # True values T = 500 # Time steps sigma2_eps0 = 3 # Variance of the observation noise sigma2_eta0 = 10 # Variance...
<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 a reminder, the equations describing a system in State Space Form are the measurement equation Step2: First, we will look at the maximum a p...
10,099
<ASSISTANT_TASK:> Python Code: config = ConfigParser.RawConfigParser() config.read('synchronization.cfg') api_key = config.get('Darksky', 'api_key') geolocator = Nominatim() location = geolocator.geocode('Muntstraat 10 Leuven') latitude = location.latitude longitude = location.longitude base_url = config.get('Darksky',...
<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: URL builder Step2: Fahrenheit to Celsius Step3: Fetch JSON data from URL