Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
3,900
<ASSISTANT_TASK:> Python Code: np.random.seed(0) data = np.random.randn(10, 10) col_sc = ColorScale() grid_map = GridHeatMap(color=data, scales={'color': col_sc}) Figure(marks=[grid_map], padding_y=0.0) x_sc, y_sc, col_sc = OrdinalScale(), OrdinalScale(reverse=True), ColorScale() grid_map = GridHeatMap(color=data, sc...
<SYSTEM_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 Heat map Step2: Heat map with axes Step3: Non Uniform Heat map Step4: Alignment of the data with respect to the grid Step5: By default...
3,901
<ASSISTANT_TASK:> Python Code: #for ronum in ranumlis: # print ronum randict = dict() othgues = [] othlow = 0 othhigh = 9 for ranez in range(10): randxz = random.randint(othlow, othhigh) othgues.append(randxz) othlow = (othlow + 10) othhigh = (othhigh + 10) #print othgues tenlis = ['zero', '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: Makes dict with keys pointing to the 10s numbers.
3,902
<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()) # Para visualização de gráficos from pylab import * %matplotlib inline import numpy as np import pandas as pd import statsmodels as st 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: Statsmodels Step2: Time-Series Analysis
3,903
<ASSISTANT_TASK:> Python Code: import tensorflow as tf lengths = [4, 3, 5, 2] def g(lengths): lengths_transposed = tf.expand_dims(lengths, 1) range = tf.range(0, 8, 1) range_row = tf.expand_dims(range, 0) mask = tf.less(range_row, lengths_transposed) result = tf.where(mask, tf.ones([4, 8]), tf.zeros...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
3,904
<ASSISTANT_TASK:> Python Code: # Copyright 2019 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
<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: Define training and evaluation functions Step5: Train and evaluate the model locally Step6: Export the model using the joblib library Step7: ...
3,905
<ASSISTANT_TASK:> Python Code: %pylab inline import seaborn as sns import warnings warnings.filterwarnings("ignore") import pandas as pd names = ['Position','I','J','H','K_s','[3.6]','[4.5]','[5.8]','[8.0]','A_v','Luminosity'] link = 'http://iopscience.iop.org/0004-637X/720/2/1374/suppdata/apj363663t2_ascii.txt' harve...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Table 2 - Photometry of Selected Candidates Step2: Data cleaning. Step3: Split [value +or- error] into separate columns Step4: Split the posi...
3,906
<ASSISTANT_TASK:> Python Code: skieval2d_periodic = pd.read_excel(SUBDIR+"ski-eval_2d_periodic_abridged.xlsx") skieval2d_periodic ax1 = skieval2d_periodic.ix[skieval2d_periodic['inch']==1].plot.area(x="m/s",y="drag",color="Red",label="1 in") ax2 = skieval2d_periodic.ix[skieval2d_periodic['inch']==2].plot.area(x="m/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: Then I can immediately make some quick plots. For instance, for each width in inch, I can plot drag or lift vs. velocity (m/s)
3,907
<ASSISTANT_TASK:> Python Code: def f(x): Function to compute the value of 5x+2 return 5*x+2 f(3) lambda x: 5*x+2 g = lambda x: 5*x+2 g(3) # Calculating Harmonic Mean using lambda function harmonic_mean = lambda x,y,z : 3/(1/x + 1/y + 1/z)**0.5 harmonic_mean(1,2,3) # Sorting a List by thr last name using lam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Elements of Functional Programming in Python Step2: Now we would compute the same expression using Lambda functions. To create a lambda express...
3,908
<ASSISTANT_TASK:> Python Code: # Import all necessary libraries, this is a configuration step for the exercise. # Please run it before the simulation code! import numpy as np import matplotlib.pyplot as plt from gll import gll from lagrange1st import lagrange1st from flux_hetero import flux # Show the plots in the Note...
<SYSTEM_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. Initialization of setup Step2: 2. Elemental Mass and Stiffness matrices Step3: 3. Flux Matrices Step4: 4. Discontinuous Galerkin Solution
3,909
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csir-csiro', 'vresm-1-0', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name",...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
3,910
<ASSISTANT_TASK:> Python Code: %run ~/Dropbox/pythonCode/LCSanalyzeblue.py t = s.galfitflag & s.lirflag & s.sizeflag & ~s.agnflag & s.sbflag galfitnogim = t & ~s.gim2dflag sum(galfitnogim) s.s.ISDSS[galfitnogim] print sum(s.s.ISDSS[galfitnogim] == -1) galfitsdssnogim = galfitnogim & (s.s.ISDSS != -1) sum(galfitsdssno...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Galaxies not in SDSS phot catalog Step2: Galaxies in SDSS but no B/T fit Step3: Download SDSS Images Step4: NSAID 69538 (244.060699, 34.2584...
3,911
<ASSISTANT_TASK:> Python Code: # Numpy, JAX, Matplotlib and h5py should all be correctly installed and on the python path. from __future__ import print_function, division, absolute_import import datetime import h5py import jax.numpy as np from jax import random from jax.experimental import optimizers from jax.config im...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Preliminaries - notes on using JAX Step2: Load the data Step3: Plot examples and statistics about the integrator RNN data. Step4: The goal of...
3,912
<ASSISTANT_TASK:> Python Code: print(__doc__) import numpy as np np.random.seed(123) import matplotlib.pyplot as plt from skopt.benchmarks import branin as _branin def branin(x, noise_level=0.): return _branin(x) + noise_level * np.random.randn() from matplotlib.colors import LogNorm def plot_branin(): fig, 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: Toy model Step2: This shows the value of the two-dimensional branin function and Step3: Note that this can take a few minutes.
3,913
<ASSISTANT_TASK:> Python Code: from dcgpy import expression_gdual_vdouble as expression from dcgpy import kernel_set_gdual_vdouble as kernel_set from pyaudi import gdual_vdouble as gdual from matplotlib import pyplot as plt import numpy as np from numpy import sin, cos from random import randint, random np.seterr(all='...
<SYSTEM_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 consider a set of differential equations in the form Step2: We define 50 random control of points where we check that the prime integral hol...
3,914
<ASSISTANT_TASK:> Python Code: bigfile = open('/Users/chengjun/百度云同步盘/Writing/OWS/ows-raw.txt', 'rb') chunkSize = 1000000 chunk = bigfile.readlines(chunkSize) print len(chunk) with open("/Users/chengjun/GitHub/cjc/data/ows_tweets_sample.txt", 'w') as f: for i in chunk: f.write(i) with open("/Users/chengj...
<SYSTEM_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. 清洗错行的情况 Step2: 问题: 第一行是变量名 Step3: 如何来处理错误换行情况? Step4: 3. 读取数据、正确分列 Step5: 4. 统计数量 Step6: 5. 清洗tweets文本 Step7: 安装twitter_text Step8: 获得...
3,915
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: カスタムレイヤー Step2: レイヤー:有用な演算の共通セット Step3: 既存のレイヤーのすべての一覧は、ドキュメントを参照してください。Dense(全結合レイヤー)、Conv2D、LSTM、BatchNormalization、Dropoutなどのたくさんのレイヤーが含まれて...
3,916
<ASSISTANT_TASK:> Python Code: import string def norm_words(words): words = words.lower().translate(None, string.punctuation) return words jeopardy["clean_question"] = jeopardy["Question"].apply(norm_words) jeopardy["clean_answer"] = jeopardy["Answer"].apply(norm_words) jeopardy.head() def norm_value(value): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Normalizing columns Step2: Answers in questions Step3: Only 0.6% of the answers appear in the questions itself. Out of this 0.6%, a sample of ...
3,917
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" } # 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 l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 階乗混合 Step2: TFP を使ってガウス分布の階乗混合を構築する Step3: tfd.Independent を使用しているところに注意してください。この「meta-distribution」は reduce_sum を、右端の reinterpreted_batch_ndi...
3,918
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame({'Date':['2019-01-01','2019-02-08','2019-02-08', '2019-03-08']}) df['Date'] = pd.to_datetime(df['Date']) df['Date'] = df['Date'].dt.strftime('%d-%b-%Y') <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:
3,919
<ASSISTANT_TASK:> Python Code: import os from dotenv import load_dotenv, find_dotenv # find .env automagically by walking up directories until it's found dotenv_path = find_dotenv() # load up the entries as environment variables load_dotenv(dotenv_path) PROJECT_DIR = os.path.dirname(dotenv_path) RAW_DATA_DIR = PROJECT...
<SYSTEM_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 some environment variables Step2: Importing pandas and matplotlib.pyplot Step3: Reading a file in Pandas
3,920
<ASSISTANT_TASK:> Python Code: import folium m = folium.Map([45, 0], zoom_start=4) folium.Marker([45, -30], popup="inline implicit popup").add_to(m) folium.CircleMarker( location=[45, -10], radius=25, fill=True, popup=folium.Popup("inline explicit Popup"), ).add_to(m) ls = folium.PolyLine( locations...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Vega Popup Step3: Fancy HTML popup Step5: You can also put any HTML code inside of a Popup, thaks to the IFrame object. Step6: Note that you ...
3,921
<ASSISTANT_TASK:> Python Code: from ipynb.fs.full.article_quality.db_monthly_stats import DBMonthlyStats, dump_aggregation import configparser config = configparser.ConfigParser() config.read('../settings.cfg') import os def write_once(path, write_to): if not os.path.exists(path): print("Writing out " + 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: Read the configuration Step2: Utility to make sure we only generate files once Step3: Dump the monthly aggregations
3,922
<ASSISTANT_TASK:> Python Code: import random def rnd(n): return [random.uniform(-1, 1) for _ in range(n)] SHOTS = 5000 x = rnd(SHOTS) y = rnd(SHOTS) def pairs(seq1, seq2): yes1, yes2, no1, no2 = [], [], [], [] for a, b in zip(seq1, seq2): if (a*a + b*b)**.5 <= 1: yes1.append(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: Now we can select coordinate pairs inside the circle Step2: We now plot the shots inside the circle in blue, outside in red Step3: We can now ...
3,923
<ASSISTANT_TASK:> Python Code: # Test here the my_auth implementation. def my_auth(username, password,required_scopes=None): An dummy authentication function. :params: username, the username :params: password, the password :params: scopes, the scope :returns: `{"sub": username, "scope": ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Authorization & securitySchemes Step3: Add user support in get_echo Step4: Test the my_auth implementation Step6: Bearer token & JWT Security...
3,924
<ASSISTANT_TASK:> Python Code: # import packages import pandas as pd # data management import matplotlib.pyplot as plt # graphics import datetime as dt # check today's date import sys # check Python version # IPython command, puts plots in notebook ...
<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: Question 0 Step3: Question 2 Step4: Question 3 Step5: Changed cell to Markdown with menu at top Step6: Question 5 Step7: Question 6 Step8:...
3,925
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import sys sys.path.append('../') import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec import seaborn as sns from hopfield import Hopfield %matplotlib inline sns.set(font_scale=2.0) prng = np.random.RandomState(see...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Dependency in how many states are added Step2: We generate two random patterns and test whether the field (h) is dependent on the initial state...
3,926
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf import matplotlib.pyplot as plt import time from tensorflow.python.client import timeline %matplotlib inline FLAGS = tf.app.flags.FLAGS ...
<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: mnist_loader Step3: Test mnist data Step4: We are generating synthetic data in this project, so all the 55000 samples can be used for training...
3,927
<ASSISTANT_TASK:> Python Code: from babi_loader import BabiDataset, pad_collate from torch.utils.data import DataLoader # There are 20 tasks, we should control which task we would like to load task_id = 1 dataset = BabiDataset( task_id ) dataloader = DataLoader(dataset, batch_size=4, shuffle=False, collate_fn=pad_colla...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 好了,现在我们导入了dataloader之后,可以尝试将每一个batch的数据打印出来看看是什么样子的 Step2: 可以看到,打印出来的都是数字索引,不是真实的文本,所以我们在输出之前,肯定需要对这些索引进行重新映射,找回原来的文本信息,我们先看一下查找表 Step3: 好了,根据...
3,928
<ASSISTANT_TASK:> Python Code: !python --version !cat ~/.keras/keras.json import numpy as np import scipy as sp import pandas as pd import matplotlib.pyplot as plt import sklearn import keras import numpy print('numpy:', numpy.__version__) import scipy print('scipy:', scipy.__version__) import matplotlib print('matp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configure Keras with tensorflow Step2: Test if everything is up&running Step3: 2. Check installeded Versions
3,929
<ASSISTANT_TASK:> Python Code: %%bash rm $(pwd)/crash-* from nipype import SelectFiles, Node, Workflow from os.path import abspath as opap from nipype.interfaces.fsl import MCFLIRT, IsotropicSmooth # Create SelectFiles node templates={'func': '{subject_id}/ses-test/func/{subject_id}_ses-test_task-fingerfootlips_bold.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: Example Crash 1 Step2: Investigating the crash Step3: nipypecli allows you to rerun the crashed node using an additional option -r. Step4: Wh...
3,930
<ASSISTANT_TASK:> Python Code: notes_file = 'synthnotes/data/note-events.parquet' pq_root_path = 'synthnotes/data/xml_extracted' pf = ParquetFile(notes_file) df = pf.to_pandas() xml_dir = 'synthnotes/data/xml_files' xml_files = os.listdir(xml_dir) ids = [int(f.split('.txt.xmi')[0]) for f in xml_files] notes = df[df.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: Get the list of ids from the processed xml files so we can select a subset of the mimic notes Step2: Select the subset of notes that we have xm...
3,931
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt data_path = 'Bike-Sharing-Dataset/hour.csv' rides = pd.read_csv(data_path) rides.head() rides[:24*10].plot(x='dteday', y='cnt') dummy_fiel...
<SYSTEM_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 and prepare the data Step2: Checking out the data Step3: Dummy variables Step4: Scaling target variables Step5: Splitting the data into...
3,932
<ASSISTANT_TASK:> Python Code: import random list10 = [] for x in range(10): list10.append(random.randrange(100)) list100 = [] for x in range(100): list100.append(random.randrange(100)) list1000 = [] for x in range(1000): list1000.append(random.randrange(100)) def sort_list(old_list): def find_new_index...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: binary sorting Step2: sort_list(list10) was 29 µs, so this one is slower Step3: sort_list() was total
3,933
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt %matplotlib inline import nengo import numpy as np import scipy.ndimage from scipy.ndimage.interpolation import rotate import matplotlib.animation as animation from matplotlib import pylab from PIL import Image import nengo.spa as spa import cPickle 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: Load the MNIST training and testing images Step2: Create array of images and rotated pairs and list of structural similarities Step3: The Netw...
3,934
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import LogNorm %matplotlib inline import seawater as sw from pyspec import spectrum as spec fni = "data/synthetic_uv.npz" uv_synthetic = np.load(fni) up = uv_synthetic['up'] # We may also want to calculate the wave...
<SYSTEM_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 random data with $\kappa^{-3}$ spectrum Step2: Compute and plot the 2D spectrum using $dx = dy = 1$ Step3: Calculating the isotropic spec...
3,935
<ASSISTANT_TASK:> Python Code: %%bash find . -name "*.c" | xargs sed -i bck "/#include<malloc\.h>/d" %%bash cat ./isis/abs/allocate.cbck from astropy import units as u, constants as const class SnickersBar(object): def __init__(self, w, h, l, weight, energy_density=2460 * u.kJ/ (100 * u.g)): self.w = u.Qu...
<SYSTEM_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 introduction to chocolate bars and classes Step2: Using cython
3,936
<ASSISTANT_TASK:> Python Code: import os import sys import numpy import itk from itk import TubeTK as ttk from itkwidgets import view PixelType = itk.F Dimension = 3 ImageType = itk.Image[PixelType, Dimension] # Read tre file TubeFileReaderType = itk.SpatialObjectReader[Dimension] tubeFileReader = TubeFileRe...
<SYSTEM_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 tubes and a reference image which provides the size, spacing, origin, and orientation for the desired output image. Step2: Visualize t...
3,937
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 from __future__ import print_function import hickle import numpy as np from pathos.multiprocessing import ProcessingPool as Pool import random import cProfile import pstats import StringIO import timeit import psutil import sys import os import time...
<SYSTEM_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, Ingest Step2: Both datasets are fit with BPZ. Step3: The data files don't appear to come with information about the native format or m...
3,938
<ASSISTANT_TASK:> Python Code: from numpy import array arr = array([1, 2, 3]) print(arr) ten = array(range(10)) matrix = array([[1,2], [3, 4]]) nested_matrix = array([matrix, matrix]) strange_array = array([[1], 2]) print('Range demo:', ten) print('Matrix demo:', matrix) print('Array of NumPy arrays:', nested_matrix) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You just have to provide array constructor of numpy module with iterable type. Step2: Types Step3: Note that typecast was made automatically S...
3,939
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import os assert os.environ["COLAB_TPU_ADDR"], "Make sure to select TPU from Edit > Notebook settings > Hardware accelerator" #!pip install -q cloud-tpu-client==0.10 https://storage.googleapis.com/tpu-pytorch/wheels/torch_xla-1.8-cp37-cp3...
<SYSTEM_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 lightning Step2: Iris Step3: CIFAR
3,940
<ASSISTANT_TASK:> Python Code: %matplotlib inline %load_ext autoreload %autoreload 2 import numpy as np import matplotlib.pyplot as plt from pymks.datasets import make_checkerboard_microstructure = make_checkerboard_microstructure(square_size=, n_squares=) from pymks.tools import draw_microstructures draw_microstruc...
<SYSTEM_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-Point Statistics for Checkerboard Microstructure Step2: Now let's take a look at how the microstructure looks. Step3: Compute Periodic 2-Poi...
3,941
<ASSISTANT_TASK:> Python Code: # make plots show up in notebook %matplotlib inline import pandas as pd # data package import matplotlib.pyplot as plt # pyplot module from pandas_datareader import data import datetime as dt # package to handle 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: Comment. When you run the code cell above, its output appears below it. Step2: World Bank. Step3: Comment. In the previous cell, we used t...
3,942
<ASSISTANT_TASK:> Python Code: import numpy as np data = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) weights = np.array([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5]) quantile = 0.25 ind_sorted = np.argsort(data) sorted_data = data[ind_sorted] sorted_weights = weights[ind_sorted] Sn = np.cumsum(sorted_weight...
<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: Calculating percentiles / quantiles Step3: I also found this post about equal frequency binning in Python useful.
3,943
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt from math import log, sqrt from sklearn import linear_model dtype_dict = {'bathrooms':float, 'waterfront':int, 'sqft_above':int, 'sqft_living15':float, 'grade':int, 'yr_renovated':int, 'price':float, 'bedrooms':float,...
<SYSTEM_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 data Step2: Feature engineering Step3: LASSO Step4: Calculate the RSS for best L1 on test data Step5: 2 Phase LASSO for finding a d...
3,944
<ASSISTANT_TASK:> Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG if os.environ["IS_TESTING"]: ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
3,945
<ASSISTANT_TASK:> Python Code: # Magics first (server issues) %matplotlib inline # Do below if you want interactive matplotlib plot () # %matplotlib notebook # https://ipython.org/ipython-doc/dev/config/extensions/autoreload.html %load_ext autoreload %autoreload 2 # %install_ext http://raw.github.com/jrjohansson/vers...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Importing cleaned data Step2: [Dead end] Does year predict production? Step3: Does Hours worked correlate with output?
3,946
<ASSISTANT_TASK:> Python Code: import numpy as np import pylab as pl from IEtools import * %pylab inline filename='C:/econdata/GDP_PAYEMS.csv' output = FREDcsvRead(filename) plotData = output['data'] plotType = pl.plot plotType = pl.semilogy plotScale = 10**6 plotLabel = output['name']+' [$ p.c.]' pl.figure(figsize=(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: Example Step2: Dynamic equilibrium models Step3: This uses the global fit approach. Step4: Example Step5: Dynamic equilibrium models Step6: ...
3,947
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib.pyplot as plt plt.style.use('fivethirtyeight') %matplotlib inline import statsmodels.formula.api as smf df = pd.read_csv('heights_weights_genders.csv') df.head(3) female_df = df[df['Gender'] == 'Female'] male_df = df[df['Gender'] == 'Male'] female_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: For Female Step2: For Male Step3: Function
3,948
<ASSISTANT_TASK:> Python Code: Now, to confirm, let us do a little bit of simple tests. import pandas as pd from matplotlib import pyplot as plt from matplotlib import cm as cm import numpy as np %matplotlib inline train=pd.read_csv('../train.csv') train.describe() # first take a look at the whole picture of time 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: Nice little peaks on top of the picture show a periodic component of ~10000, very close to the number of minutes in a week Step2: This has no 2...
3,949
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'svg' import matplotlib as mpl mpl.rcParams['font.size'] = 8 figsize =(8,4) mpl.rcParams['figure.figsize'] = figsize import matplotlib.pyplot as plt import numpy as np from ipywidgets import interact from ipywidgets import widgets, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Admissible regions Step2: Shocks and rarefactions Step3: The stationary wave Step4: From the rules determined above, we know that we can conn...
3,950
<ASSISTANT_TASK:> Python Code: #Advanced: Using other libs... # To support both python 2 and python 3 from __future__ import division, print_function, unicode_literals # Common imports import numpy as np import numpy.random as rnd import os # to make this notebook's output stable across runs rnd.seed(42) # To plot pret...
<SYSTEM_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 visualizing Step2: Predicting classes and class probabilities Step3: Sensitivity to training set details Step4: Regression trees...
3,951
<ASSISTANT_TASK:> Python Code: from pyspark.sql import SQLContext from pyspark.sql.types import * from datetime import datetime as _datetime, timedelta, date import boto3 import botocore import csv import os.path bucket = "telemetry-parquet" prefix = "main_summary/v4" %time dataset = sqlContext.read.load("s3://{}/{}".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: How many cores are we running on? Step2: And what do the underlying records look like? Step5: We want to incrementally update the data, re-com...
3,952
<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: Interpolation Step2: Now that Tensorflow Graphics is installed, let's import everything needed to run the demo contained in this notebook. Step...
3,953
<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...
<SYSTEM_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...
3,954
<ASSISTANT_TASK:> Python Code: import os # The Google Cloud Notebook product has specific requirements IS_GOOGLE_CLOUD_NOTEBOOK = os.path.exists("/opt/deeplearning/metadata/env_version") # Google Cloud Notebook requires dependencies to be installed with '--user' USER_FLAG = "" if IS_GOOGLE_CLOUD_NOTEBOOK: USER_FLAG...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Restart the kernel Step2: Before you begin Step3: Otherwise, set your project ID here. Step4: Authenticate your Google Cloud account Step5: ...
3,955
<ASSISTANT_TASK:> Python Code: def sum_if_3(k, m): if (m % 3 == 0) or (str(m).endswith('3')): return k + m else: return k sum_if_3(5, 18) sum_if_3(4, 7) if 'bc' in 'abcde': print("'bc'가 'abcde'의 부분문자열이다.") def sum_if_3s(k, m): if (m % 3 == 0) or ('3' in str(m)): return k + m ...
<SYSTEM_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: 다중 조건문(다중 if문) 활용 예제 Step6: 주의 Step7: 'while' 루프를 작성할 때 조건문이 언젠가는 만족되지 않아서 더 이상 루프...
3,956
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from qutip import * compl_circ = np.array([[(x + 1j*y) if x**2 + y**2 <= 1 else 0j for x in np.arange(-1,1,0.005)] for y in np.arange(-1,1,0.005)]) fig = plt.figure(figsiz...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Colors Step2: Schmidt plot Step3: As we see, for separable state the plot is a product of x and y coordinates, while for the singlet state - i...
3,957
<ASSISTANT_TASK:> Python Code: # for fast array manipulation import numpy as np # for plotting import matplotlib.pyplot as plt # for numerical ODE integration from scipy.integrate import odeint # for nonlinear equations from scipy.optimize import fsolve # to display plots in-line %matplotlib inline def sigmoid(x, a, 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: Parameter definitions Step2: For a stable limit cycle and a stable fixed point Step3: More preparation Step4: Solving and plotting Step5: Nu...
3,958
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import datetime from qutip import Qobj, identity, sigmax, sigmaz, tensor import random import qutip.logging_utils as logging logger = logging.get_logger() #Set this to None or logging.WARN for 'quiet' execution log_leve...
<SYSTEM_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 the physics Step2: Defining the time evolution parameters Step3: Set the conditions which will cause the pulse optimisation to termin...
3,959
<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 import os if not os.path.exists('utils.py'): !wget https://github.com/AllenDowney...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: On September 5, 2020, prosecutors in Mississippi dropped charges against Curtis Flowers, freeing him after 23 years of incarceration. Step2: To...
3,960
<ASSISTANT_TASK:> Python Code: import os import sys # Modify the path sys.path.append("..") import pandas as pd import yellowbrick as yb import matplotlib.pyplot as plt data = pd.read_csv("data/No-show-Issue-Comma-300k.csv") data.head() data.columns = ['Age','Gender','Appointment Registration','Appointment Date', ...
<SYSTEM_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 Medical Appointment Data Step2: Feature Analysis Step3: Rank2D Step4: Diagnostic Interpretation from Rank2D(Covariance) Step5: Diagnost...
3,961
<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) print(raw.info) info ...
<SYSTEM_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 seen in the introductory tutorial &lt;tut-overview&gt;, when a Step2: However, it is not strictly necessary to load the Step3: As you can ...
3,962
<ASSISTANT_TASK:> Python Code: rs = np.random.RandomState(seed=10) ns = 100 nf = 10 x, y_orig, coef = make_regression(n_samples=ns, n_features=nf, coef=True, noise=0.0, random_state=rs) x = pd.DataFrame(x) y = pd.Series(y_orig) n_quantiles = 3 # two-thirds of the data is truncated quantile = 100/float(n_quantiles) lowe...
<SYSTEM_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 the truncation values do not have to be the same for e.g. all left-censored observations, or all right-censored observations, as in th...
3,963
<ASSISTANT_TASK:> Python Code: from collatex import * from lxml import etree import json,re class WitnessSet: def __init__(self,witnessList): self.witnessList = witnessList def generate_json_input(self): json_input = {} witnesses = [] json_input['witnesses'] = witnesses ...
<SYSTEM_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 WitnessSet class represents all of the witnesses being collated. The generate_json_input() method returns a JSON object that is suitable for...
3,964
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt %matplotlib inline import numpy as np import tensorflow as tf from gpflow.likelihoods import MultiClass from gpflow.kernels import RBF, White from gpflow.models.svgp import SVGP from gpflow.training import AdamOptimizer from scipy.stats import mode from sci...
<SYSTEM_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 100 inducing points Step2: We'll compare three models Step3: For the SGP model we'll calcuate accuracy by simply taking the max mean...
3,965
<ASSISTANT_TASK:> Python Code: from polyglotdb import CorpusContext import polyglotdb.io as pgio corpus_root = '/mnt/e/Data/pg_tutorial' parser = pgio.inspect_mfa(corpus_root) parser.call_back = print # To show progress output with CorpusContext('pg_tutorial') as c: c.load(parser, corpus_root) with CorpusContext(...
<SYSTEM_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 import statements get the necessary classes and functions for importing, namely the CorpusContext class and Step2: Important Step3: Warnin...
3,966
<ASSISTANT_TASK:> Python Code: import os, re # Provide the directory where files are located directory = '/home/roli/FORESTs_BHAVYA/Combined_Libraries/ITS/' #directory = '/home/roli/FORESTs_BHAVYA/Combined_Libraries/16S/' # Provide a list of all the FeatureTables you will merge # Produced by QIIME2 in STEP 7 (i.e. DAD...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 2 Step2: Step 3 Step3: Step 4 Step4: Step 5 Step5: Step 6 Step6: Step 7 Step7: Step 8
3,967
<ASSISTANT_TASK:> Python Code: from poppy.creatures import PoppyErgo ergo = PoppyErgo() from poppy.creatures import PoppyErgoJr ergo = PoppyErgoJr() ergo ergo.m2 ergo.m2.present_position ergo.m2.present_temperature for m in ergo.motors: print 'Motor "{}" current position = {}'.format(m.name, m.present_position) ...
<SYSTEM_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 a PoppyErgoJr Step2: Get robot current status Step3: Turn on/off the compliancy of a motor Step4: Go to the zero position Step5: Make a ...
3,968
<ASSISTANT_TASK:> Python Code: ## House keeping tasks %reset -f # standard imports import urllib2 import os import json import StringIO import pickle # dataframe and numerical import pandas as pd import numpy as np # plotting import matplotlib.pyplot as plt %matplotlib inline #scipy from scipy import stats from scipy....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: import all required dependencies Step2: Load data from pickle Step3: RFU, zscore and p-value Step4: extract only the high binders Step5: Wha...
3,969
<ASSISTANT_TASK:> Python Code: from jupyterthemes import get_themes from jupyterthemes.stylefx import set_nb_theme themes = get_themes() set_nb_theme(themes[3]) # 1. magic for inline plot # 2. magic to print version # 3. magic so that the notebook will reload external python modules # 4. magic to enable retina (high 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: Rossman GBT Modeling Step2: We've pulled most of our configurable parameters outside into a json configuration file. In the ideal scenario, we ...
3,970
<ASSISTANT_TASK:> Python Code: document = 'Lorem Ipsum dolor sit amet' # shingle and discard the last 5 as these are just the last n<5 characters from the document shingles = [document[i:i+5] for i in range(len(document))][:-5] shingles other_document = 'Lorem Ipsum dolor sit amet is how dummy text starts' # shingle 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: As we can see these two documents are not very similar, at least in terms of their 3-gram shingle Jaccard similarity. That aside the problem wit...
3,971
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function import numpy as np import statsmodels.api as sm import pandas as pd from statsmodels.tsa.arima_process import arma_generate_sample np.random.seed(12345) arparams = np.array([.75, -.25]) maparams = np.array([.65, .35]) arparams = 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: Generate some data from an ARMA process Step2: The conventions of the arma_generate function require that we specify a 1 for the zero-lag of th...
3,972
<ASSISTANT_TASK:> Python Code: from rmgpy.chemkin import * from rmgpy.tools.canteraModel import * from IPython.display import display, Image speciesList, reactionList = loadChemkinFile('data/minimal_model/chem_annotated.inp', 'data/minimal_model/species_dictionary.txt', ...
<SYSTEM_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 species and reaction from the RMG-generated chemkin file chem_annotated.inp and species_dictionary.txt file found in your chemkin folde...
3,973
<ASSISTANT_TASK:> Python Code: import numpy as np import numpy.random as rand import matplotlib.pyplot as plt matplotlib inline mu1, mu2, mu3 = [15,20], [24,25], [38,40] cov = [[10, 0], [0, 10]] n_samples = 5000 data1 = rand.multivariate_normal(mu1, cov, n_samples) data2 = rand.multivariate_normal(mu2, cov, n_samples...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Compute mean values Step2: Compute the between-class scatter matrix $S_b$ Step4: Compute the within-class scatter matrix $S_w$ Step5: Solve t...
3,974
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import graphviz from sklearn.linear_model import LinearRegression, LogisticRegression import lingam from lingam.utils import make_dot, remove_effect, predict_adaptive_lasso from IPython.display import display_svg, SVG print([np.__version__, pd.__vers...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Indicate which variable belong to which group Step2: Load data Step3: Compute the residual when each variable of the second group on all the v...
3,975
<ASSISTANT_TASK:> Python Code: # directory where you want the spacer blasting to be done ## CHANGE THIS! workDir = "/home/nyoungb2/t/CLdb_Ecoli/DR_consensus/" import os from IPython.display import FileLinks %load_ext rpy2.ipython if not os.path.isdir(workDir): os.makedirs(workDir) # checking that CLdb is in $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: Init Step2: Creating DR consensus seqs & loading into CLdb Step3: That's it! Now, the CLdb.sqlite file contains the DR consensus sequences for...
3,976
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns sns.set(color_codes=True) np.random.seed(69572) %matplotlib inline %load_ext writeandexecute # plt.figure(figsize=(120,10)) small = (4,3) mid = (10, 8) large = (12, 8) from __future__ import abso...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Custom Functions Step2: DataFrame Value Counts Step4: Confusion Matrix Step5: Import & Explore Data Step6: Pre Processing Step7: Text Data ...
3,977
<ASSISTANT_TASK:> Python Code: from sympy import * init_printing(use_unicode=True) a0 = Symbol('a_0') e0 = Symbol('e_0') e = Symbol('e') a = Symbol('a') integrando = Rational(12,19)*((1+Rational(73,24)*e**2+Rational(37,96)*e**4) /(e*(1-e**2)*(1+Rational(121,304)*e**2))) integrando Integ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: y ahora exponenciamos Step2: Si definimos Step3: La constante $C_1$ es determinada por la condición inicial $a(e_0)=a_0$ que, luego de ser ree...
3,978
<ASSISTANT_TASK:> Python Code: foo = dict() # Create an empty dict foo['bar'] = 1 # Store an integer under the key 'bar' print(foo['bar']) # Retrieve the integer stored in 'bar' import scipy as sp import numpy as np import openpnm as op %config InlineBackend.figure_formats = ['svg'] np.random.seed(10) # Ins...
<SYSTEM_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 detailed tutorial on dictionaries can be found here. The dict does not offer much functionality aside from basic storage of arbitrary objects...
3,979
<ASSISTANT_TASK:> Python Code: from frozen_lake import FrozenLakeEnv env = FrozenLakeEnv() print(env.__doc__) # Some basic imports and setup import numpy as np, numpy.random as nr, gym np.set_printoptions(precision=3) def begin_grading(): print("\x1b[43m") def end_grading(): print("\x1b[0m") # Seed RNGs so you get the...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's look at what a random episode looks like. Step2: In the episode above, the agent falls into a hole after two timesteps. Also note the sto...
3,980
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline import os os.chdir('..') import sys sys.path.insert(0, './python') import caffe import os import h5py import shutil import tempfile import sklearn import sklearn.datasets import sklearn.linear_model import pandas as pd ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Synthesize a dataset of 10,000 4-vectors for binary classification with 2 informative features and 2 noise features. Step2: Learn and evaluate ...
3,981
<ASSISTANT_TASK:> Python Code: import ROOT from ROOT import TMVA import os ROOT.TMVA.Tools.Instance() TMVA.PyMethodBase.PyInitialize() ## For PYMVA methods TMVA.PyMethodBase.PyInitialize(); outputFile = ROOT.TFile.Open("CNN_ClassificationOutput.root", "RECREATE") factory = ROOT.TMVA.Factory("TMVA_CNN_Classification", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Declare DataLoader(s) Step2: Setup Dataset(s) Step3: Booking Methods Step4: Book Convolutional Neural Network in TMVA Step5: Book Convolutio...
3,982
<ASSISTANT_TASK:> Python Code: markers = ['Synap','Synap','VGlut1','VGlut1','VGlut2','Vglut3', 'psd','glur2','nmdar1','nr2b','gad','VGAT', 'PV','Gephyr','GABAR1','GABABR','CR1','5HT1A', 'NOS','TH','VACht','Synapo','tubuli','DAPI'] synapType = ['synap','synap','ex.pre','ex.pre',...
<SYSTEM_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 then proceeded to try to separate the resulting filtered synapses into two groups through a naive kMean method, after tranforming the synapse...
3,983
<ASSISTANT_TASK:> Python Code: # If you'd like to download it through the command line... !curl -O http://www.cs.cornell.edu/home/llee/data/convote/convote_v1.1.tar.gz # And then extract it through the command line... !tar -zxf convote_v1.1.tar.gz # glob finds files matching a certain filename pattern import glob # Gi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You can explore the files if you'd like, but we're going to get the ones from convote_v1.1/data_stage_one/development_set/. It's a bunch of text...
3,984
<ASSISTANT_TASK:> Python Code: from pyspark.sql import Row Person = Row("name", "age") print Person ali = Person("Alice", 11) print ali help(Row) import re import datetime from pyspark.sql import Row month_map = {'Jan': 1, 'Feb': 2, 'Mar':3, 'Apr':4, 'May':5, 'Jun':6, 'Jul':7, 'Aug':8, 'Sep': 9, 'Oct':10, 'Nov': 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: version 1.0.0 Step4: (1b) Configuration and Initial RDD Creation Step5: (1c) Data Cleaning Step6: Part 2 Step7: (2b) Example Step9: (2c) Ex...
3,985
<ASSISTANT_TASK:> Python Code: import pkg_resources raw_data = pd.read_csv(pkg_resources.resource_stream('deepforest', 'data/train.csv')) clean_data = raw_data.drop(["Cabin", "Name", "PassengerId", "Ticket"], axis=1) clean_data = pd.get_dummies(clean_data).fillna(-1) train, test = train_test_split(clean_data) def split...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Baseline model Step2: Deep Forest Step3: This is not very handy, not at all. We already see a lot of code duplication, and one may feel there ...
3,986
<ASSISTANT_TASK:> Python Code: #####Test Machine Learning Algorithms ip = 'Insert IP here' conn = MongoClient(ip, 27017) conn.database_names() db = conn.get_database('cleaned_data') reviews = db.get_collection('restaurant_reviews') useridlist =[] for user in users_dict.keys(): useridlist.append(user) print(useridl...
<SYSTEM_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.Create a user dataframe with the following columns Step2: 2.Create a list of unique business IDs for that user Step3: 3.Connect to the Mongo...
3,987
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import imageio import matplotlib.pyplot as plt import numpy as np import os import sys import tarfile from IPython.display import display, 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: Step3: First, we'll download the dataset to our local machine. The data consists of characters rendered in a variety of fonts on a 28x28 image. The lab...
3,988
<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 # Read in data that will be used for the calculations. # Using pandas read_csv method, we can create a data frame data = pd.read_csv("https://github.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: PART 1 Step2: Run the Code below to create a chart containing all of the Stars with Exoplantes within 100 light years! Step3: <span style="col...
3,989
<ASSISTANT_TASK:> Python Code: import pandas as pd from collections import Counter seqs = ['TCGGGGGTTTTT', 'CCGGTGACTTAC', 'ACGGGGATTTTC', 'TTGGGGACTTTT', 'AAGGGGACTTCC', 'TTGGGGACTTCC', 'TCGGGGATTCAT', 'TCGGGGATTCCT', 'TAGGGGACCTAC', 'TCGGG...
<SYSTEM_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 we have a DataFrame where we can get all the bases in each position to find the base(s) occurring most frequently. We'll create a second Da...
3,990
<ASSISTANT_TASK:> Python Code: utc = 0 sma = 1 ecc = 2 inc = 3 raan = 4 aop = 5 ma = 6 ta = 7 #fig1 = plt.figure(figsize = [15,8], facecolor='w') fig_peri = plt.figure(figsize = [15,8], facecolor='w') fig_peri_deorbit = plt.figure(figsize = [15,8], facecolor='w') fig_apo = plt.figure(figsize = [15,8], facecolor='w') 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: Plot the orbital parameters which are vary significantly between different tracking files.
3,991
<ASSISTANT_TASK:> Python Code: # Always run this first # NOTE: Do not define new basic variables in this notebook; # define them in Variables_Q.ipynb. Use this notebook # to define new expressions built from those variables. from __future__ import division # This needs to be here, even though it's in Varia...
<SYSTEM_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 set the PN order, if it is not already set. This will be used in numerous places below. This is the exponent of the largest power of ...
3,992
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import h5py import scipy from PIL import Image from scipy import ndimage from lr_utils import load_dataset %matplotlib inline # Loading the data (cat/non-cat) train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_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: 2 - Overview of the Problem set Step2: We added "_orig" at the end of image datasets (train and test) because we are going to preprocess them. ...
3,993
<ASSISTANT_TASK:> Python Code: import os import matplotlib.pyplot as plt import cv2 %matplotlib inline def readRGBImage(imagepath): image = cv2.imread(imagepath) # Height, Width, Channel (major, minor, _) = cv2.__version__.split(".") if major == '3': # version 3 is used, need to convert 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: Loading and save image Step2: Change color format Step4: Resize Step5: Crop Step6: Image processing with channels
3,994
<ASSISTANT_TASK:> Python Code: # Imports import numpy as np import pandas as pd import xarray as xr from functools import lru_cache # For function result caching # Special functions # from scipy.special import sph_harm import spherical_functions as sf import quaternion # Performance & benchmarking libraries from jobli...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exploring Wigner 3js Step2: This ends up as a relatively sparse array, since many combinations are invalid (do not follow angular momentum sele...
3,995
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt N = 100 # points per class D = 2 # dimensionality at 2 so we can eyeball it K = 3 # number of classes X = np.zeros((N*K, D)) # generate an empty matrix to hold X features y = np.zeros(N*K, dtype='int32') # switching this to int32 # for 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: TensorFlow Step2: Notice the following Step3: Predicting on a new value Step4: Digging into the DNNClassifier Step5: Exercises
3,996
<ASSISTANT_TASK:> Python Code: import riip ri = riip.RiiDataFrame() ri.catalog.head(3) ri.raw_data.loc[3].head(5) # first 5 rows for the material whose id is 3 ri.catalog.tail(3) ri.raw_data.loc[2911].head(5) # first 5 rows for the material whose id is 2912 grid_data = ri.load_grid_data(3) grid_data import matpl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: RiiDataFrame has an attribute named catalog that is a Pandas DataFrame provinding the catalog of experimental data as shown below. Step2: The e...
3,997
<ASSISTANT_TASK:> Python Code: from ctypes import cdll basics = cdll.LoadLibrary('./lib_basics.so') basics.mul(2, 5) from ctypes import c_int first = (c_int * 3)(1, 2, 3) vector3D = c_int * 3 second = vector3D(4, 5, 6) c_result = basics.dot(first, second, 3) python_result = sum(a * b for a, b in zip([1, 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: In Linux Step2: In Windows Step3: See? It's easy Step4: Say, we need to multiply 3-dimensional vectors Step5: We can create an alias for thi...
3,998
<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: <table class="tfo-notebook-buttons" align="left"> Step2: NOTE Step4: In order to feed the dataset into our model, we flatten the data, and con...
3,999
<ASSISTANT_TASK:> Python Code: !swirlcons --user:example=2 --user:rp-solver=4 #!mpirun -n 4 swirlcons %run make_plots.py %pylab inline import glob from matplotlib import image from clawpack.visclaw.JSAnimation import IPython_display from matplotlib import animation figno = 0 fname = '_plots/*fig' + str(figno) + '.pn...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Or, run code in parallel mode (command may need to be customized, depending your on MPI installation.) Step2: Create PNG files for web-browser ...