Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
9,200
<ASSISTANT_TASK:> Python Code: from bokeh.io import output_notebook, show output_notebook() import pandas as pd diamonds = pd.read_csv('./data/diamonds.csv') diamonds = diamonds.sample(n=1000) diamonds.head() from bokeh.charts import Scatter, Histogram, Bar p = Scatter(diamonds, color='cut', x='carat', y='price', tit...
<SYSTEM_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 data Step2: 1) Colors autoselection Step3: Now... you don't have to get stuck with the default palette. Bokeh comes with a pre-built list...
9,201
<ASSISTANT_TASK:> Python Code: grammar = S -> NP VP NP -> DET[GEN=?x] NOM[GEN=?x] NOM[GEN=?x] -> ADJ NOM[GEN=?x] | N[GEN=?x] ADJ -> "schöne" | "kluge" | "dicke" DET[GEN=mask,KAS=nom] -> "der" DET[GEN=fem,KAS=dat] -> "der" DET[GEN=fem,KAS=nom] -> "die" DET[GEN=fem,KAS=akk] -> "die" DET[GEN=neut,KAS=nom] -> "das" DET[GE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Übungsblatt 7 Step3: Aufgabe 2 &nbsp;&nbsp;&nbsp; CFG Step5: Hausaufgaben Step6: Aufgabe 8 &nbsp;&nbsp;&nbsp; Adverben und Verbzweitstellung
9,202
<ASSISTANT_TASK:> Python Code: import hgvs.location import hgvs.posedit start = hgvs.location.BaseOffsetPosition(base=200,offset=-6,datum=hgvs.location.Datum.CDS_START) start, str(start) end = hgvs.location.BaseOffsetPosition(base=22,datum=hgvs.location.Datum.CDS_END) end, str(end) iv = hgvs.location.Interval(start=sta...
<SYSTEM_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. Make an edit object Step2: 3. Make the variant Step3: Important
9,203
<ASSISTANT_TASK:> Python Code: import numpy; print('numpy:\t', numpy.__version__, sep='\t') import scipy; print('scipy:\t', scipy.__version__, sep='\t') import matplotlib; print('matplotlib:', matplotlib.__version__, sep='\t') import sklearn; print('scikit-learn:', sklearn.__version__, sep='\t') from skle...
<SYSTEM_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 load some data. Step2: Benchmark classificator by ml-benchmarks
9,204
<ASSISTANT_TASK:> Python Code: # Authors: Denis Engemann <denis.engemann@gmail.com> # Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # License: BSD (3-clause) import matplotlib.pyplot as plt import mne from mne.viz import plot_evoked_topo from mne.datasets import sample print(__doc__) data_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: Set parameters Step2: Show topography for two different conditions
9,205
<ASSISTANT_TASK:> Python Code: from __future__ import division %matplotlib inline import matplotlib.pyplot as plt import numpy as np def ndft(x, f, N): non-equispaced discrete Fourier transform k = -(N // 2) + np.arange(N) return np.dot(f, np.exp(2j * np.pi * k * x[:, np.newaxis])) x = -0.5 + np.random.ra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: We want to solve the following Step3: Let's try evaluating this on some sinusoidal data, with a frequency of 10 cycles per unit time Step4: As...
9,206
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot pyplot.rcParams['image.cmap'] = 'jet' import numpy as np x0 = -1.4 y0 = 0.5 x = [x0] # The algorithm starts at x0, y0 y = [y0] eta = 0.1 # step size multiplier precision = 0.00001 def f(x,y): f1 = x**2/2-y**2/4+3 f2 = 2*x+1-np.exp(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Stochastic gradient descent (SGD) Step2: We now write an SGD code for this problem. The training_data is a list of tuples (x, y) representing t...
9,207
<ASSISTANT_TASK:> Python Code: from sympy import * from geom_util import * from sympy.vector import CoordSys3D N = CoordSys3D('N') alpha1, alpha2, alpha3 = symbols("alpha_1 alpha_2 alpha_3", real = True, positive=True) init_printing() %matplotlib inline %reload_ext autoreload %autoreload 2 %aimport geom_util H1=symbol...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lame params Step2: Metric tensor Step3: ${\displaystyle \hat{G}=\sum_{i,j} g_{ij}\vec{R}^i\vec{R}^j}$ Step4: Christoffel symbols Step5: Grad...
9,208
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np from sklearn.ensemble import GradientBoostingClassifier from sklearn import cross_validation, metrics from sklearn.grid_search import GridSearchCV import matplotlib.pylab as plt %matplotlib inline from matplotlib.pylab import rcParams rcParams['figur...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load Data Step2: Define a function for modeling and cross-validation Step3: Baseline Model Step4: GBM Models Step5: So we got 60 as the opti...
9,209
<ASSISTANT_TASK:> Python Code: import jax import jax.numpy as jnp import numpy as np from matplotlib import pyplot as plt # Check connected accelerators. Depending on what runtime you're connected to, # this will show a single CPU/GPU, or 8 TPU cores (jf_2x2 aka JellyDonut). # You can start a TPU runtime via : "Connect...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Randomness Step2: jnp vs. np Step3: grad() Step4: vmap() Step5: jit() Step6: pmap() Step7: pytrees
9,210
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.0,<2.1" %matplotlib inline import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() times1 = np.linspace(0,1,201) times2 = np.linspace(90,91,201) b.add_dataset('lc', 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: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details. Step2: Now we'll create empty lc...
9,211
<ASSISTANT_TASK:> Python Code: %matplotlib inline from caffe2.proto import caffe2_pb2 import numpy as np import skimage.io import skimage.transform from matplotlib import pyplot import os from caffe2.python import core, workspace, models import urllib2 print("Required modules imported.") # Configuration --- Change to y...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the block below we're loading the mean file (if it exists) and the image and then pre-processing the image for ingestion into a Caffe2 convol...
9,212
<ASSISTANT_TASK:> Python Code: from sklearn.metrics import accuracy_score, precision_score,\ recall_score, f1_score ground_truth = [1,0,1,0,0,1,1,1,1,0] chunker1 = [1,1,1,0,1,0,1,1,1,1] chunker2 = [1,0,1,0,0,0,0,0,1,0] chunker3 = [0,0,0,0,0,1,1,1,1,0] def evaluate(chunker): print( "Accurac...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Betrachten Sie folgende Daten. Es handelt sich um ein vereinfachtes Tagging-Schema fürs Chunking, bei dem nur zwischen „Teil einer NP“ (1) und „...
9,213
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt unbiasedCVs = np.genfromtxt('NVT_monitor/COLVAR',comments='#'); biasedCVs = np.genfromtxt('MetaD/COLVAR',comments='#'); unbiasedCVsHOT = np.genfromtxt('NVT_monitor/hot/COLVAR',comments='#'); %matplotlib inline fig = plt.figure(figsize=(6...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting biased and unbiased CVS Step2: Plotting contour plot of biased FES
9,214
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import astropy.io.fits as pyfits import numpy as np import astropy.visualization as viz import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 10.0) targdir = 'a1835_xmm/' imagefile = targdir+'P0098010101M2U009IMAG...
<SYSTEM_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 Photons Came From the Cluster? Step2: Estimating the background Step3: First, let's visualize the background region by masking out ev...
9,215
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() racine = NoeudTri("un") # noeud tri n'est pas encore défini racine.insere ("unite") racine.insere ("deux") print(racine) from pyensae.graphhelper import draw_diagram img = draw_diagram( blockdiag { 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: Q1 Step3: Q5
9,216
<ASSISTANT_TASK:> Python Code: from poppy.creatures import PoppyHumanoid poppy = PoppyHumanoid(simulator='vrep') %pylab inline # the class time is used to set the time object to be the simulated time in V-REP and not the default python time import time as real_time class time: def __init__(self,robot): sel...
<SYSTEM_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 need a primitive to run the force apply to poppy's chest. Step2: To start and stop the force primitive Step3: Prepared poppy for experimen...
9,217
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import load_iris import numpy as np iris = load_iris() X = iris.data.astype(np.float32) y = iris.target from sklearn.model_selection import train_test_split X_fold1, X_fold2, y_fold1, y_fold2 = train_test_split( X, y, random_state=37, train_size=0.5 ) import cv...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Split the data into two equally sized parts Step2: Instantiate the classifier Step3: Train the classifier on the first fold, then predict the ...
9,218
<ASSISTANT_TASK:> Python Code: from PIL import Image img = Image.open('eye.png') img = img.convert("L") # grayscale img # same as display(img) # define function flip() # open 'eye.png', convert to grayscale, flip, and display # define getpixel, region3x3, avg, and blur functions img = Image.open('pcb.png') img = 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: Flip Step2: Blur Step3: Denoise Step4: Generic filter Step5: Blur refactored Step6: Denoise refactored Step7: Edges Step8: Sharpen
9,219
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import scipy as sp import scipy.fftpack as scfft from SimISR.utilFunctions import makesumrule,MakePulseDataRepLPC,spect2acf,acf2spect,CenteredLagProduct from SimISR.IonoContainer import IonoContainer,MakeTestIonoclass from ISRSpectrum.ISR...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set up Step2: IS Spectra Step3: White Noise Step4: Shaped Noise Step5: Window Function Step6: Full ISR Data Creation and Estimator Step7: ...
9,220
<ASSISTANT_TASK:> Python Code:: from sklearn.metrics import confusion_matrix from sklearn.preprocessing import normalize import seaborn as sns cm = confusion_matrix(target, pred) normed_confusion_matrix = normalize(cm, axis = 1, norm = 'l1') cm_df = pd.DataFrame(normed_confusion_matrix,index, columns) sns.heatmap(cm_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:
9,221
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division % matplotlib inline import warnings warnings.filterwarnings('ignore') import math import numpy as np from thinkbayes2 import Pmf, Cdf, Suite, Joint import thinkplot class Euro(Suite): Represents hypotheses about the probability of heads...
<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: The Euro problem Step4: If we know the coin is fair, we can evaluate the likelihood of the data directly. Step5: If we cheat an pretend that t...
9,222
<ASSISTANT_TASK:> Python Code: # Run this cell before trying examples import numpy as np import matplotlib.pyplot as plt %matplotlib inline # Numpy arrays are classes import numpy as np a = np.array([0, 1, 6, 8, 12]) print(a.__class__) print(type(a)) # We want to operate on the array: try numpy cumulative sum 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: Intro to Python OOP Step2: Example Step3: Example Step4: There's a few things here which I haven't introduced, but all will become clear in t...
9,223
<ASSISTANT_TASK:> Python Code: import graphviz import matplotlib.pyplot as plt import numpy as np import pandas as pd import sklearn.datasets import sklearn.tree plt.rcParams["figure.figsize"] = [17, 10] # features X = [ [0, 0], [1, 1] ] # targets Y = [ 0, 1 ] classifier = sklea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Decision trees are directed graphs beginning with one node and branching to many. They are a hierarchical data structure that represent data by ...
9,224
<ASSISTANT_TASK:> Python Code: !pip install google-cloud-automl !apt-get install libmagickwand-dev !pip install pillow !pip install --upgrade protobuf !pip install --upgrade google-cloud-videointelligence import sys import os import json import math from google.colab import auth from google.colab import files import 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: You might have to restart your runtime to load these packages. Step2: Next, create a new GCP account (if you don't have one already), and creat...
9,225
<ASSISTANT_TASK:> Python Code: # Copyright 2018 The TensorFlow Hub Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 如何使用 TF-Hub 解决 Kaggle 上的问题 Step2: 由于本教程将使用 Kaggle 中的数据集,因此需要为您的 Kaggle 帐号创建 API 令牌,并将其上传到 Colab 环境。 Step3: 开始 Step4: 注:本竞赛的任务不是对整个评论进行评分,而是对评...
9,226
<ASSISTANT_TASK:> Python Code: import os import zipfile import shutil import csv import bcolz os.environ["KERAS_BACKEND"] = "theano" import keras import numpy as np from keras.utils.data_utils import get_file from keras.models import load_model from keras.layers.normalization import BatchNormalization from keras.layers...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data structure Step2: VGG16() setup boilerplate Step3: Load in data with generators Step4: Finetuning the model Step5: New model architectur...
9,227
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup import time, os, json import numpy as np import skimage.io import matplotlib.pyplot as plt from cs231n.classifiers.pretrained_cnn import PretrainedCNN from cs231n.data_utils import load_tiny_imagenet from cs231n.image_utils import blur_image, deprocess_image %ma...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Introducing TinyImageNet Step2: TinyImageNet-100-A classes Step3: Visualize Examples Step4: Pretrained model Step5: Pretrained model perform...
9,228
<ASSISTANT_TASK:> Python Code: %matplotlib inline import os import sys import matplotlib.pyplot as plt sys.path.insert(1, os.path.join(os.getcwd(), '../../')) from glassure.core.calc import calculate_fr, calculate_sq, optimize_sq, calculate_gr from glassure.core.utility import extrapolate_to_zero_poly, convert_density_...
<SYSTEM_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. Effect on S(Q) Step2: The two plots clearly show that the optimization on a not extrapolated S(Q) results in an artificial lower intensity o...
9,229
<ASSISTANT_TASK:> Python Code: print(__doc__) import sys from skopt.plots import plot_objective from skopt import forest_minimize import numpy as np np.random.seed(123) import matplotlib.pyplot as plt # Here we define a function that we evaluate. def funny_func(x): s = 0 for i in range(len(x)): s += (x...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Objective function Step2: Optimisation using decision trees Step3: Partial dependence plot Step4: It is possible to change the location of th...
9,230
<ASSISTANT_TASK:> Python Code: from ipyleaflet import Map, basemaps, basemap_to_tiles center = (52.204793, 360.121558) m = Map( layers=(basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, "2018-11-12"), ), center=center, zoom=4 ) m from ipyleaflet import Marker, Icon icon = Icon(icon_url='https://lea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Layers Step2: Heatmap layer Step3: Velocity Step4: Controls Step5: Clean
9,231
<ASSISTANT_TASK:> Python Code: L=json.loads(file('../json/L.json','r').read()) M=json.loads(file('../json/M.json','r').read()) N=json.loads(file('../json/N.json','r').read()) import requests AP={} for c in M: if c not in AP:AP[c]={} for i in range(len(L[c])): AP[c][N[c][i]]=L[c][i] baseurl='https://www...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: record schedules for 2 weeks, then augment count with weekly flight numbers. Step2: good dates Step3: Save
9,232
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cccr-iitm', 'sandbox-3', 'land') # 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...
9,233
<ASSISTANT_TASK:> Python Code: %load_ext sql %sql mysql://steinam:steinam@localhost/sommer_2015 %%sql %sql select count(*) as AnzahlFahrten from fahrten %sql select k.kd_id, k.`kd_firma`, k.`kd_plz`, count(a.Au_ID) as AnzAuftrag, count(f.f_id) as AnzFahrt, sum(ts.ts_strecke) as SumStrecke from kun...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Sommer 2015 Step2: Warum geht kein Join ?? Step3: Der Ansatz mit Join funktioniert in dieser Form nicht, da spätestens beim 2. Join die Firma ...
9,234
<ASSISTANT_TASK:> Python Code: __author__ = 'Nick Dingwall' from average_precision_post_code import * precision_scores = np.mean( [1.00, 1.00, 1.00, 0.67, 0.75, 0.60, 0.67, 0.71, 0.62, 0.56, 0.50]) print("Mean precision: {:4.4f}".format(precision_scores)) %matplotlib inline ranked_predictions = [1,1,0,1,0,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TL;DR Interpolated average precision is a common metric for classification tasks. However, interpolating linearly between operating points, as i...
9,235
<ASSISTANT_TASK:> Python Code: #import the necessary packages import pandas import nltk from nltk import word_tokenize import string #read the Music Reviews corpus into a Pandas dataframe df = pandas.read_csv("../Data/BDHSI2016_music_reviews.csv", encoding='utf-8', sep = '\t') #view the dataframe df #first create a ne...
<SYSTEM_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 next step is to create a new column in our dataset that contains tokenized words with all the pre-processing steps. Step2: Pre-processing i...
9,236
<ASSISTANT_TASK:> Python Code: # Pure python modules and jupyter notebook functionality # first you should import the third-party python modules which you'll use later on # the first line enables that figures are shown inline, directly in the notebook %pylab inline import os import datetime as dt import pandas as pd fr...
<SYSTEM_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 Shyft Environment Step2: 2. Configuration of a SHyFT calibration Step3: Now that we have the initial state, we'll run the calibration (thi...
9,237
<ASSISTANT_TASK:> Python Code: import copy # open the file you have downloaded # these files are organized file = open("amazon.txt") # this returns an array with one entry for each line ni the file lines = file.readlines() print len(lines) # Note: the format of the snap files is to list a node (identified by a unique ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Next, let's find if there exists clusters(connected components) Step2: Visualization Step3: Power Law Property Step4: Directed Graphs
9,238
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function import numpy as np import matplotlib.pyplot as plt import simtk.openmm as mm from msmbuilder.decomposition import tICA, PCA def propagate(n_steps=10000): "Simulate some dynamics" system = mm.System() system.addParticle(...
<SYSTEM_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, let's use OpenMM to run some dynamics on the 3D potential energy function Step2: Okay, let's run the dynamics. The first plot below sho...
9,239
<ASSISTANT_TASK:> Python Code: from allensdk.core.cell_types_cache import CellTypesCache # Instantiate the CellTypesCache instance. The manifest_file argument # tells it where to store the manifest, which is a JSON file that tracks # file paths. If you supply a relative path (like this), it will go # into your curren...
<SYSTEM_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 data_set variable is an NwbDataSet instance, which has some methods we can use to access the injected current stimulus waveform and the volt...
9,240
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import division import os import sys import tensorflow as tf import skimage.io as io import numpy as np sys.path.append("/home/aakash-sinha/Documents/Tensorflow/tf-image-segmentation/") sys.path.append("/home/aakash-sinha/Documents/Tensorflow/models/slim...
<SYSTEM_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 display the look up table with mapping from class number to the name of the PASCAL VOC class Step2: Now, let's create a contour for our s...
9,241
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np def tokenize(s, stop_words=None, punctuation='`~!@#$%^&*()_-+={[}]|\:;"<,>.?/}\t'): Split a string into a list of words, removing punctuation and stop words. w = [] for line in s.splitlines(): #uses 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: Step3: Word counting Step4: Write a function count_words that takes a list of words and returns a dictionary where the keys in the dictionary are the ...
9,242
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.3,<2.4" import phoebe print(phoebe.mpi.enabled) print(phoebe.mpi.mode) phoebe.mpi_on() print(phoebe.mpi.enabled) print(phoebe.mpi.mode) print(phoebe.mpi.myrank) print(phoebe.mpi.nprocs) print(phoebe.mpi.within_mpirun) <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: MPI Modes Step2: PHOEBE determines whether the current script is running within an MPI environment by checking for environment variables set by...
9,243
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image(filename='pagerank1.jpeg') import numpy as np # Adjacency matrix # m1 = [ 0, 0, 0] # [0.5, 0, 0] # [0.5, 1, 1] m1 = np.matrix([[0, 0, 0],[0.5, 0, 0],[0.5, 1, 1]]) beta = 0.7 # r = beta * m1 * r + ((1-beta)/N) def r_p(r): return beta...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Suppose we compute PageRank with a β of 0.7, and we introduce the additional constraint that the sum of the PageRanks of the three pages must be...
9,244
<ASSISTANT_TASK:> Python Code: import nexradaws conn = nexradaws.NexradAwsInterface() years = conn.get_avail_years() print(years) months = conn.get_avail_months('2013') print(months) days = conn.get_avail_days('2013','05') print(days) radars = conn.get_avail_radars('2013','05','31') print(radars) availscans = conn...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Query methods Step2: Get available months in a year Step3: Get available days in a given year and month Step4: Get available radars in a give...
9,245
<ASSISTANT_TASK:> Python Code: import os import numpy as np from astropy.table import QTable os.listdir() planet_table = QTable.read('Planets.csv', format='ascii.csv') planet_table print(planet_table) planet_table.rename_column('col2', 'ecc') print(planet_table) planet_table['Name'] planet_table['Name'][0] planet_ta...
<SYSTEM_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 AstroPy package - QTable Step2: Renaming columns Step3: Sorting Step4: Masking Step5: Adding a column to the Table Step6: Saving a tabl...
9,246
<ASSISTANT_TASK:> Python Code: import dx import datetime as dt import pandas as pd import seaborn as sns; sns.set() r = dx.constant_short_rate('r', 0.01) me_1 = dx.market_environment('me', dt.datetime(2015, 1, 1)) me_1.add_constant('initial_value', 100.) # starting value of simulated processes me_1.add_constant('vo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Risk Factor Models Step2: We then define a market environment containing the major parameter specifications needed, Step3: Next, the model obj...
9,247
<ASSISTANT_TASK:> Python Code: %matplotlib inline import configparser import os import requests from tqdm import tqdm import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy import sparse, stats, spatial import scipy.sparse.linalg from sklearn import preprocessing, decomposition import librosa...
<SYSTEM_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. Parsing example Step2: 2. Determine different genres Step3: 3. Create vector of genres for each movie and a dataframe Step4: Observe the r...
9,248
<ASSISTANT_TASK:> Python Code: targets = ['ENSG00000069696', 'ENSG00000144285'] targets_string = ', '.join('"{0}"'.format(t) for t in targets) url = 'https://www.targetvalidation.org/api/latest/public/association/filter' headers = {"Accept": "application/json"} # There may be an easier way of building these parameters...
<SYSTEM_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 the API call with our list of targets to find the associations. Set facets to true. Step2: Print out all the json returned just for refere...
9,249
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.sparse import csr_matrix arr = np.random.rand(4, 4) M = csr_matrix(arr) result = M.A.diagonal(0) <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:
9,250
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' 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_fields = ['seas...
<SYSTEM_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...
9,251
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('kc_house_data_small.gl/') import numpy as np # note this allows us to refer to numpy as np instead (train_and_validation, test) = sales.random_split(.8, seed=1) # initial train/test split (train, validation) = train_and_validation.random_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: Load in house sales data Step2: Import useful functions from previous notebooks Step3: We will also need the normalize_features() function fro...
9,252
<ASSISTANT_TASK:> Python Code: import mesh.patch as patch import mesh.boundary as bnd import numpy as np g = patch.Grid2d(16, 16, ng=2) print(g) bc = bnd.BC(xlb="periodic", xrb="periodic", ylb="reflect", yrb="outflow") print(bc) d = patch.CellCenterData2d(g) d.register_var("a", bc) d.create() print(d) a = d.get_var("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: Grids Step2: Data is stored as an ArrayIndexer object, which makes it easy to implement differencing on the entire array. Step3: Running Step4...
9,253
<ASSISTANT_TASK:> Python Code: traj = pt.Trajectory('step5_production.dcd', '../step3_pbcsetup.xplor.ext.psf') print(traj) goo = pt.rdf(traj, solvent_mask=':TIP3@OH2', solute_mask=':TIP3@OH2', bin_spacing=0.05, maximum=8.) goh1 = pt.rdf(traj, solvent_mask=':TIP3@OH2', solute_mask=':TIP3@H1', bin_spacing=0.05, maximu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Calculate the water-water radial distribution function. In statistical mechanics, the radial distribution function, (or pair correlation functio...
9,254
<ASSISTANT_TASK:> Python Code: import espressomd import espressomd.magnetostatics import espressomd.magnetostatic_extensions espressomd.assert_features('DIPOLES', 'LENNARD_JONES') import numpy as np # Lennard-Jones parameters LJ_SIGMA = 1. LJ_EPSILON = 1. LJ_CUT = 2**(1. / 6.) * LJ_SIGMA # Particles N_PART = 700 # Are...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: and set up the simulation parameters where we introduce a new dimensionless parameter Step2: Now we set up the system. As in part I, the orien...
9,255
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline #generate some random numbers with values between -0.5 and 0.5, which we'll call "noise" noise = (np.random.rand(11)-0.5) noise #plot simple relationship y=2x with this noise added x = np.arange(11) plt.plot(x,2*x+noise...
<SYSTEM_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 is usually called "least-squares" fitting Step2: Overfitting Step3: General rule of thumb Step4: Weighted Least Squares Step5: Oops wha...
9,256
<ASSISTANT_TASK:> Python Code: class Set: def __init__(self): self.mKey = None self.mLeft = None self.mRight = None self.mHeight = 0 def isEmpty(self): return self.mKey is None Set.isEmpty = isEmpty Set.__bool__ = isEmpty def __bool__(self): return self.mKey is not Non...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Given an ordered binary tree $t$, the expression $t.\texttt{isEmpty}()$ checks whether $t$ is the empty tree. Step2: Given an ordered binary tr...
9,257
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' 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_fields = ['seas...
<SYSTEM_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...
9,258
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import dateutil.parser import datetime from urllib.request import urlopen, Request import simplejson as json def extract_reference_time(API_data_loc): Find reference time that corresponds to most complete forecast. ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Planet OS API Demo for Model Comparison Step2: Let's choose a location near Oahu, Hawaii, to make use of the regional SWAN model we have availa...
9,259
<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: Regression Project Step2: Exercise 2 Step3: Modeling
9,260
<ASSISTANT_TASK:> Python Code: from regraph import NXGraph, NXHierarchy, Rule from regraph import plot_graph, plot_instance, plot_rule %matplotlib inline # Define graph G g = NXGraph() g.add_nodes_from(["protein", "binding", "region", "compound"]) g.add_edges_from([("region", "protein"), ("protein", "binding"), ("regi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Creating and modifying a hierarchy object Step2: The method get_graph returns the graph object corresponding to the provided graph id. Step3...
9,261
<ASSISTANT_TASK:> Python Code: import hamnonlineng as hnle letters = 'abcde' resonant = [hnle.Monomial(1, 'aabbEEC'), hnle.Monomial(1,'abddEEC')] op_sum = hnle.operator_sum(letters) sine_exp = ( hnle.sin_terms(op_sum, 3) +hnle.sin_terms(op_sum, 5) +hnle.sin_terms(op_sum, 7) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Try to solve (takes around a minute) Step2: Remove constraints on terms of the form $\hat{a}^2\hat{b}^2\dots$ or $\hat{a}\hat{b}\dots$ or those...
9,262
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np np.random.seed(1) df = pd.DataFrame({ 'A' : ['one', 'one', 'two', 'three'] * 6, 'B' : ['A', 'B', 'C'] * 8, 'C' : ['foo', 'foo', 'foo', 'bar', 'bar', 'bar'] * 4, 'D' : np.random.randn(24), 'E' : np.ran...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
9,263
<ASSISTANT_TASK:> Python Code: ## Read in the Training Data and Instantiating the Photo-z Algorithm %matplotlib inline from astropy.table import Table import numpy as np import matplotlib.pyplot as plt #data = Table.read('GTR-ADM-QSO-ir-testhighz_findbw_lup_2016_starclean.fits') #JT PATH ON TRITON to training set after...
<SYSTEM_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 we are running on separate test data, we don't need to do a train_test_split here. But we will scale the data. Need to remember to scale...
9,264
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
9,265
<ASSISTANT_TASK:> Python Code: %pylab inline import numpy as np from timeit import default_timer as timer def mandel(x, y, max_iters): Given the real and imaginary parts of a complex number, determine if it is a candidate for membership in the Mandelbrot set given a fixed number of iterations. c = ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: The mandel function performs the Mandelbrot set calculation for a given (x,y) position on the imaginary plane. It returns the number of iteratio...
9,266
<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: 使用 int16 激活值进行训练后整数量化 Step2: 检查 16x8 量化模式是否可用 Step3: 训练并导出模型 Step4: 在此示例中,您只对模型进行了一个周期的训练,因此只训练到约 96% 的准确率。 Step5: 将其写入 .tflite 文件: Step6: ...
9,267
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'dwd', 'sandbox-2', 'land') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "email"...
<SYSTEM_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...
9,268
<ASSISTANT_TASK:> Python Code: # Import all libraries needed for the tutorial # General syntax to import specific functions in a library: ##from (library) import (specific library function) from pandas import DataFrame, read_csv # General syntax to import a library but no functions: ##import (library) as (give the li...
<SYSTEM_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 Data Step2: To merge these two lists together we will use the zip function. Step3: We are basically done creating the data set. We now ...
9,269
<ASSISTANT_TASK:> Python Code: import pyConTextNLP.pyConTextGraph as pyConText import pyConTextNLP.itemData as itemData import networkx as nx reports = [ IMPRESSION: Evaluation limited by lack of IV contrast; however, no evidence of bowel obstruction or mass identified within the abdomen or pelvis. Non-speci...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step7: pyConTextGraph contains the bulk of the pyConTextNLP functionality, including basic class definitions such as the ConTextMarkup class that repre...
9,270
<ASSISTANT_TASK:> Python Code: import datetime from collections import Counter start = datetime.date(2001, 1, 1) end = datetime.date(2100, 1, 1) - datetime.timedelta(days=1) d = start anarchy_dates = [] delta = datetime.timedelta(days=1) while d <= end: if d.day * d.month == d.year % 100: anarchy_dates.appe...
<SYSTEM_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 attacks will happen between the beginning of 2001 and the end of 2099 Step2: What year will see the most vandalism? Step3: The least?...
9,271
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as pyplot from km3net.kernels import QuadraticDifferenceSparse, PurgingSparse import km3net.util as util window_width = 1500 N,x,y,z,ct = util.get_real_input_data("sample1.txt") print ("Read", N, "hits from file") context, cc...
<SYSTEM_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 initialize the GPU, and instantiate the Python interfaces to the GPU codes to get the GPU kernels compiled. Step2: The next step is to ...
9,272
<ASSISTANT_TASK:> Python Code: import pymongo from pymongo import MongoClient import datetime import re from pymongo import InsertOne, DeleteOne, ReplaceOne import datetime client = MongoClient() client = MongoClient('mongodb://localhost:27017/') db = client.homework2 users = db.users movies = db.movies movieList = mo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Tasks Step2: 1. Display all occupations Step3: 2. Chose an occupation and select all users with this occupation. Only show user information an...
9,273
<ASSISTANT_TASK:> Python Code: #Obtén el cuadrado de 1 #Obtén el cuadrado de 2 #Obtén el cuadrado de 3 #Obtén el cuadrado de 4 #Obtén el cuadrado de 5 #Obtén el cuadrado de 6 #Obtén el cuadrado de 7 #Obtén el cuadrado de 8 #Obtén el cuadrado de 9 #Obtén el cuadrado de 10 for numero in range(1,21): cuadrado = numer...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Yo creo que el punto está entendido... Es tedioso estar escribiendo lo mismo 20 veces. Ahora imagina que no tienes que hacer esto 20 veces, sino...
9,274
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings('ignore') %matplotlib inline %pylab inline import pandas as pd print(pd.__version__) import tensorflow as tf tf.logging.set_verbosity(tf.logging.ERROR) print(tf.__version__) import keras print(keras.__version__) df = pd.read_csv('./insurance-custom...
<SYSTEM_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 Step Step2: Second Step Step3: Look at all the different shapes for different kilometers per year
9,275
<ASSISTANT_TASK:> Python Code: import pymysql import os import csv ALL_WIKI_AGGREGATION_QUERY = SELECT timestamp AS month, SUM(weighted_sum) AS weighted_sum, SUM(LOG(weighted_sum)) AS weighted_log_sum, SUM(prediction = "Stub") AS stub_n, SUM(prediction = "Start") AS start_n, SUM(prediction = "C") AS c_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: Step3: Queries Step6: Database connection management object
9,276
<ASSISTANT_TASK:> Python Code: from scipy import stats as ss print(ss.expon.cdf(12, scale=36)) print(ss.binom.pmf(2, p=1 / 36, n=12)) print(ss.binom.pmf(2, p=1 / (3 * 365), n=365)) print(ss.poisson.pmf(2, mu=1 / 3)) print(ss.poisson.pmf(1, mu=1 / 3)) ss.binom? result = ss.expon.ppf(0.99, scale = 24 * 60 / 2) days = 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: 1.2 Answer Step2: 1.3 Answer Step3: 1.4 Answer Step4: 1.7 Answer Step5: 2. CLT Theory (4 Points) Step6: 3.1 Answer Step7: 3.2 Answer Step8...
9,277
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display def soliton(x, t, c, a): Return phi(x, t) for a soliton wave with constants c and a. return (0.5)*c*((1/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: Step2: Using interact for animation with data Step3: To create an animation of a soliton propagating in time, we are going to precompute the soliton d...
9,278
<ASSISTANT_TASK:> Python Code: import geopandas path = geopandas.datasets.get_path('naturalearth_lowres') df = geopandas.read_file(path) # Add a column we'll use later df['gdp_pp'] = df['gdp_md_est'] / df['pop_est'] boroughs = geopandas.read_file(geopandas.datasets.get_path('nybb')).to_crs(epsg='4326') injurious_collis...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting with Geoplot Step2: Geoplot can re-project data into any of the map projections provided by Step3: If you want to use size as a visua...
9,279
<ASSISTANT_TASK:> Python Code: def rk2(x_0, y_0, f, step=0.001, k_max=None, method='improved_euler'): r Two-stage Runge-Kutta method for solving first-order ODE. The function computes `k_max` iterations from the initial conditions `x_0` and `y_0` with steps of size `step`. It yields a total of `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: Runge-Kutta methods Step3: Four-stage Runge-Kutta methods implementation Step4: Examples Step5: As we can see from the figure above, the solu...
9,280
<ASSISTANT_TASK:> Python Code: !pip install git+https://github.com/openai/baselines >/dev/null !pip install gym >/dev/null import numpy as np import random import gym from gym.utils import seeding from gym import spaces def state_name_to_int(state): state_name_map = { 'S': 0, 'A': 1, 'B': 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: Step2: Environment Step3: Try out Environment Step4: Baseline Step5: Train model Step6: Visualizing Results Step7: Enjoy model Step8: Evaluation
9,281
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import seaborn as sns from scipy import integrate import math as m def integrand(x, a): return 1.0/(x**2 + a**2) def integral_approx(a): # Use the args keyword argument to feed extra arguments to your integrand...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Indefinite integrals Step2: Integral 1 Step3: Integral 2 Step4: Integral 3 Step5: Integral 4 Step6: Integral 5
9,282
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import collections import matplotlib import matplotlib.pyplot as plt %matplotlib inline # import seaborn as sns # sns.set_style("whitegrid", {'axes.grid' : False}) train_categorical_iter=pd.read_csv("../data/train_categorical.csv",chunksize=100000,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Observations
9,283
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nerc', 'ukesm1-0-ll', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name",...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
9,284
<ASSISTANT_TASK:> Python Code: fig = plt.figure(figsize=(12,4)) df = pd.read_csv('rtntop.csv').set_index('date') cols = [c for c in df.columns if 'rtn' in c] for i, c in enumerate(cols): ax = plt.subplot(130+(1+i)) df[['bhreturn',c]].plot(ax=ax) ax.legend().set_visible(False) ax.set_ylabel('Return').set...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Q-learned trading performance Step2: Random trading performance Step3: alpha & gamma
9,285
<ASSISTANT_TASK:> Python Code: # Everyone should know how to create (or "declare") a string by now var = 'This is a string' alphabet = 'abcdefghijklmnopqrstuvwxyz' # We can get only the first element of the alphabet # Note that a is the 0th character in the string first_letter = alphabet[0] print(first_letter) # To ge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Indexing strings Step2: This is very close to what we did last week when we looked at for statements Step3: Question - How would you get the l...
9,286
<ASSISTANT_TASK:> Python Code: def diferencia_atras(f, x_0, x_1): pendiente = (f(x_0) - f(x_1))/(x_0 - x_1) return pendiente def raiz(f, a, b): c = b - f(b)/diferencia_atras(f, a, b) return b, c def secante(f, x_0, x_1): print("{0:s} \t {1:15s} \t {2:15s} \t {3:15s}".format('i', 'x anterior', 'x 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: Implementación no vectorizada Step2: Ejemplo 2 Step3: Ejemplo 3
9,287
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) img = mnist.train.images[2] plt.imshow(img.reshape((28, 28)), cmap='...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Below I'm plotting an example image from the MNIST dataset. These are 28x28 grayscale images of handwritten digits. Step2: We'll train an autoe...
9,288
<ASSISTANT_TASK:> Python Code: # Importing pergola modules used import sys # We need to set the path to run this notebook directly from ipython notebook my_path_to_modules = "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/" sys.path.append(my_path_to_modules) from pergola import jaaba_par...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data can be easily export to a csv file. Step2: We can also load the data into an IntData object. Step3: IntData objects Step4: Basic data ou...
9,289
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'ukesm1-0-mmh', 'ocean') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
9,290
<ASSISTANT_TASK:> Python Code: %matplotlib inline %reload_ext autoreload %autoreload 2 from fastai.conv_learner import * PATH = "data/cifar10/" os.makedirs(PATH, exist_ok=True) classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck') stats = (np.array([ 0.4914 , 0.48216, 0.44653]), ...
<SYSTEM_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 get the data via Step2: Look at dem der data Step3: Fully Connected Model Step4: From this notebook by K.Turgutlu. Step5: The goal i...
9,291
<ASSISTANT_TASK:> Python Code: import datetime import collections import getpass import json import os import yaml import pandas import pymysql select_stmt_base = "select id, deactivated, group_id, created_at, notes from pids where created_at < '{}'" if os.path.exists("../conf/db.yml"): print("Using conf/db.yml 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: Define SQL Query Step2: Get Connection & Credentials Step3: Running Querying
9,292
<ASSISTANT_TASK:> Python Code: import numpy as np N = 30000 x = np.zeros(N) y = np.zeros(N) z = np.zeros(N) x1 = np.empty_like(x) y1 = np.empty_like(y) z1 = np.empty_like(z) # Sierpinski triangle iterative functions def f1(x,y,z,x1,y1,z1,c): x1[c] = 1.0/2.0*x[c] y1[c] = 1.0/2.0*y[c] z1[c] = 1.0/2.0*z[c] de...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now we turn separate coordinate array into triplets. Step2: Zoom in a little
9,293
<ASSISTANT_TASK:> Python Code: measurements = [ {'city': 'Dubai', 'temperature': 33.}, {'city': 'London', 'temperature': 12.}, {'city': 'San Francisco', 'temperature': 18.}, ] from sklearn.feature_extraction import DictVectorizer vec = DictVectorizer() tf_measurements = vec.fit_transform(measurements) tf_me...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Unsupervised Clustering using K-Means Step2: Supervised Classification using Decision Trees Step3: Now, we use a DecisionTree to learn a model...
9,294
<ASSISTANT_TASK:> Python Code: try: import tinygp except ImportError: !pip install -q tinygp from jax.config import config config.update("jax_enable_x64", True) import numpy as np import matplotlib.pyplot as plt from statsmodels.datasets import co2 data = co2.load_pandas().data t = 2000 + (np.array(data.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: Data Step2: Kernel Step3: Model fitting Step4: Using our loss function defined above, we'll run a gradient based optimization routine from sc...
9,295
<ASSISTANT_TASK:> Python Code: from lightning import Lightning from numpy import random, arange, asarray, corrcoef, argsort, array import networkx as nx from sklearn import datasets lgn = Lightning(ipython=True, host='http://public.lightning-viz.org') mat = random.randn(10,10) lgn.matrix(mat) mat = random.randn(10,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: Connect to server Step2: <hr> Simple matrix Step3: <hr> Different shapes Step4: <hr> Colors Step5: <hr> Labels Step6: You can also turn on ...
9,296
<ASSISTANT_TASK:> Python Code: import loader as support #support library to read mnist files into memory import gaussian_classifier as gf import time %pylab inline X_train, Y_train = support.loadmnist('data/train-images-idx3-ubyte', 'data/train-labels-idx1-ubyte') X_test, Y_test = support.loadmnist('data/t10k-images-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: As you can see the we have 60,000 training examples with 784 features. Let's see how long it takes to train and predict on this high dimensional...
9,297
<ASSISTANT_TASK:> Python Code: from flow.scenarios.loop import LoopScenario name = "ring_example" from flow.core.params import VehicleParams vehicles = VehicleParams() from flow.controllers.car_following_models import IDMController from flow.controllers.routing_controllers import ContinuousRouter vehicles.add("hum...
<SYSTEM_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 scenario, as well as all other scenarios in Flow, is parametrized by the following arguments Step2: 2.2 VehicleParams Step3: Once this ob...
9,298
<ASSISTANT_TASK:> Python Code: print(dir(bool)) def f(): x = 1 print(x) x = 2 f() print(x) x = 2 a = [x**2 for x in range(10)] print(a) print(x) import math import numpy print(math.pi, numpy.pi) # don't do this at home math.pi = 2 print(math.pi, numpy.pi) class MyClass: A simple example class i = 12...
<SYSTEM_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 note about scopes and namespaces Step2: List-comprehensions (and all other comprehensions) have their own scope Step3: Note Step5: The attr...
9,299
<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: tf.distribute.Strategy with Training Loops Step2: Download the fashion mnist dataset Step3: Create a strategy to distribute the variables and ...