Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
8,200
<ASSISTANT_TASK:> Python Code: from mlens.utils.dummy import OLS from mlens.parallel import Learner, Job from mlens.index import FoldIndex indexer = FoldIndex(folds=2) learner = Learner(estimator=OLS(), indexer=indexer, name='ols') import os, tempfile import numpy as np X = np.arang...
<SYSTEM_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 learner doesn't do any heavy lifting itself, it manages the creation a sub-graph Step2: Fitting the learner puts three copies of the OLS es...
8,201
<ASSISTANT_TASK:> Python Code: number={} number[0]="zero" number[1]="one" number[2]="two" number[3]="three" number[4]='four' number[5]='five' number[6]='six' number[7]='seven' number[8]='eight' number[9]='nine' number[10]='ten' number[11]='eleven' number[12]='twelve' number[13]='thirteen' number[14]='fourteen' number[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: First write a number_to_words(n) function that takes an integer n between 1 and 1000 inclusive and returns a list of words for the number as des...
8,202
<ASSISTANT_TASK:> Python Code: import numpy as np import holoviews as hv hv.extension('bokeh') # Declare some points points = hv.Points(np.random.randn(1000,2 )) # Declare points as source of selection stream selection = hv.streams.Selection1D(source=points) # Write function that uses the selection indices to slice po...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Purpose Step2: <img src='https Step3: python Step4: Renderers can also have different modes. In this case we will instantiate the renderer in...
8,203
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np wasteland = APRIL is the cruellest month, breeding Lilacs out of the dead land, mixing Memory and desire, stirring Dull roots with spring rain. def tokenize(s, stop_words=None, punctuation='`~!@#$%^&*()_-+={[}]|\...
<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: Word counting Step7: Write a function count_words that takes a list of words and returns a dictionary where the keys in the dictionary are the ...
8,204
<ASSISTANT_TASK:> Python Code: def test(element): element = element * 2 return element test(5) lst = [3,7,14,222,6] lst.reverse() print(lst) def maxi(element): element.sort() element.reverse() return element[0]# ich könnte auch element.reverse weglassen und einfach return element[-1] - gibt mir da...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Multipliziert Integers oder Floats mit 2 Step2: 1.Schreibe eine Funktion, die aus einer Liste, die grösste Zahl herauszieht. Es ist verboten mi...
8,205
<ASSISTANT_TASK:> Python Code: # Import our usual libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import os # OS-independent way to navigate the file system # Data directory is one directory up in relation to directory of this notebook data_dir_root = os.path.normpath...
<SYSTEM_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 1 Step2: Step3: Step4: Step5: Step6: Exercise 2 Step7: Step 2b Step8: Step 3 Step9: Notice that the sigmoid is never less than ...
8,206
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'thu', 'ciesm', 'atmos') # 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...
8,207
<ASSISTANT_TASK:> Python Code: import os import sys sys.path.append(os.getcwd().replace("notebooks", "cfncluster")) ## S3 input and output address. s3_input_files_address = "s3://path/to/input folder" s3_output_files_address = "s3://path/to/output folder" ## CFNCluster name your_cluster_name = "cluster_name" ## The pri...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <font color='blue'> Notice Step2: After you verified the project information, you can execute the pipeline. When the job is done, you will see ...
8,208
<ASSISTANT_TASK:> Python Code: def solve(N): return bin(sum(int(i) for i in str(N)))[2:] <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:
8,209
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function import matplotlib.pyplot as plt %matplotlib inline import scipy.stats import numpy as np from scipy.ndimage import imread import sys # import image img_orig = imread('testimg.jpg').flatten() print("$img_orig") print("shape: \t\t", img_orig....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise 1 Step2: Create a figure showing the 3 histograms (original & 2 sets of noise corrupted data – use Step4: Take a subset of P = 100 ob...
8,210
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from IPython.core.pylabtools import figsize import matplotlib.pyplot as plt figsize(12.5, 5) import pymc as pm sample_size = 100000 expected_value = lambda_ = 4.5 poi = pm.rpoisson N_samples = range(1, sample_size, 100) for k in range(3): 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: Step2: Looking at the above plot, it is clear that when the sample size is small, there is greater variation in the average (compare how jagged and jum...
8,211
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nasa-giss', 'giss-e2-1h', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("na...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
8,212
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns def np_fact(n): Compute n! = n*(n-1)*...*1 using Numpy. if n == 0: return 1 else: a = np.arange(1,n+1,1) b = a.cumprod(0) return b[n-1] assert np_fact(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: Step2: Factorial Step4: Write a function that computes the factorial of small numbers using a Python loop. Step5: Use the %timeit magic to time both ...
8,213
<ASSISTANT_TASK:> Python Code: from ltlcross_runner import LtlcrossRunner from IPython.display import display import pandas as pd import spot import sys spot.setup(show_default='.a') pd.options.display.float_format = '{: .0f}'.format pd.options.display.latex.multicolumn_format = 'c' import os os.environ['SPOT_HOA_TOLE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hack that alows to parse ltl3ba automata without universal branching. Step2: $\newcommand{\F}{\mathsf{F}}$ Step3: Literature Step4: Mergeable...
8,214
<ASSISTANT_TASK:> Python Code: # calculate pi import numpy as np # N : number of iterations def calc_pi(N): x = np.random.ranf(N); y = np.random.ranf(N); r = np.sqrt(x*x + y*y); c=r[ r <= 1.0 ] return 4*float((c.size))/float(N) # time the results pts = 6; N = np.logspace(1,8,num=pts); result = np.ze...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <hr style="border Step2: &nbsp; Step3: &nbsp; Step4: &nbsp; Step5: &nbsp; Step6: &nbsp; Step7: <hr style="border Step8: &nbsp; Step9: &n...
8,215
<ASSISTANT_TASK:> Python Code: import numpy as np my_vector = np.array([1, 2, 3, 4]) my_vector my_vector.shape my_vector.dtype my_matrix = np.array([[1, 2], [3, 4]]) my_matrix my_matrix.shape # Find the length of each element in bytes my_matrix.itemsize my_matrix2 = np.array([[1, 2], [3, 4]], dtype=np.int8) my_matrix2...
<SYSTEM_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 ndarray structure Step2: Array creation methods Step3: Aggregate methods (min and max) Step4: Summations Step5: Transform a 1D array int...
8,216
<ASSISTANT_TASK:> Python Code: import pandas as pd import html5lib import matplotlib.pyplot as plt %matplotlib inline csv_path='exportPivot_POP105A.csv' #SAJAT HELY CSV FILE df=pd.read_csv(csv_path) df.head() wiki_path="http://hu.wikipedia.org/wiki/Csíkszereda" df2=pd.read_html(wiki_path) df2[4] gf=df2[4] gf ef=g...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Romániai lakosság letöltése INSSE-ról Step2: Wikipédia táblázatok letöltése Step3: Ha html5llib not found hibaüzenetet kapunk, akkor egy konzo...
8,217
<ASSISTANT_TASK:> Python Code: # isntantiate a graph object G = nx.Graph() # add a single node G.add_node(1) # add multiple nodes from a list G.add_nodes_from([2,3,5]) # return lists of nodes and edges in the graph G.nodes(), G.edges() # add a single edge between 3 and 5 G.add_edge(3,5) # add multiple edges using list...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Notice that the edge list is empty, since we haven't added any edges yet. Also, because the number of edges in a graph can become very large, th...
8,218
<ASSISTANT_TASK:> Python Code: # Rather than importing everything manually, we'll make things easy # and load them all in utils.py, and just import them from there. %matplotlib inline import utils; reload(utils) from utils import * %matplotlib inline from __future__ import division,print_function import os, json fro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Introduction Step2: Linear models in keras Step3: We can use keras to create a simple linear model (Dense() - with no activation - in Keras) a...
8,219
<ASSISTANT_TASK:> Python Code: import molpx %matplotlib ipympl top = molpx._molpxdir(join='notebooks/data/ala2.pdb') MD_trajfiles = [molpx._molpxdir(join='notebooks/data/ala2.mini.xtc')] #short trajectory rama_files = [molpx._molpxdir(join='notebooks/data/ala2.mini.phi.psi.dat')] mpx_wdg_box = molpx.visualize.FES(MD_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Start from files on disk Step2: Visualize a FES and the molecular structures behind it Step3: Visualize trajectories and molecular structures ...
8,220
<ASSISTANT_TASK:> Python Code: import MessageFormatting import importlib importlib.reload(MessageFormatting) from MessageFormatting import * from timeseries.ArrayTimeSeries import ArrayTimeSeries as ts import numpy as np from scipy.stats import norm t = np.arange(0.0, 1.0, 0.01) v = norm.pdf(t, 100, 100) + 1000*np.rand...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Above is the output I'm getting- still need to discuss interpolation and also adding in the parameter for number of timeseries to find
8,221
<ASSISTANT_TASK:> Python Code: import random import gym import numpy as np from collections import deque from keras.models import Sequential from keras.layers import Dense from keras.optimizers import Adam import os # for creating directories output_dir = 'model_output/cartpole/' n_episodes = 1001 # n games we want ag...
<SYSTEM_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 hyperparameters Step2: Define class for Deep-Q-Learning agent Step3: Set other parameters (some of these should be moved to top of file)
8,222
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.ensemble import RandomForestRegressor import numpy as np import matplotlib.pyplot as plt import matplotlib plt.style.use('ggplot') plt.rc('figure',figsize=(13,13)) # Make things lo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: I want to count the number of rentals per vehicle ID in reservations.csv, appending these values as a column in vehicles.csv, in order to compar...
8,223
<ASSISTANT_TASK:> Python Code: import logging logging.root.setLevel(logging.INFO) import xcs xcs.test() from xcs import XCSAlgorithm from xcs.scenarios import MUXProblem, ScenarioObserver scenario = ScenarioObserver(MUXProblem(50000)) algorithm = XCSAlgorithm() algorithm.exploration_probability = .1 algorithm.disc...
<SYSTEM_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 we import the xcs module and run the built-in test() function. By default, the test() function runs the canonical XCS algorithm on the 11-b...
8,224
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function import numpy as np from scipy import stats import statsmodels.api as sm import matplotlib.pyplot as plt from statsmodels.sandbox.regression.predstd import wls_prediction_std from statsmodels.iolib.table import (SimpleTable, default_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: WLS Estimation Step2: WLS knowing the true variance ratio of heteroscedasticity Step3: OLS vs. WLS Step4: Compare the WLS standard errors to ...
8,225
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nasa-giss', 'sandbox-3', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name",...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
8,226
<ASSISTANT_TASK:> Python Code: import tensorflow as tf tf.TF_CPP_MIN_LOG_LEVEL = 3 # Create a constant operation. This operation is added as a node to the default graph. hello = tf.constant("hello world") # Start a TensorFlow session. sess = tf.Session() # Run the operation and get the result. print(sess.run(hello)) 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: tensors, ranks, shapes and types Step2: session Step3: variables Step4: single variable linear regression Step5: placeholders and variables ...
8,227
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-2', 'sandbox-2', 'ocnbgchem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contribut...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
8,228
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'miroc', 'miroc-es2l', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
8,229
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt n = 20 # number of datapoints in each line v1 = np.array([-13, 0.9]) # first line v2 = np.array([7, -1]) # second line sig = 1.0 seq = np.array(range(n))+1 x = np.transpose(np.array([np.ones(n), seq])) # Half of Design...
<SYSTEM_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 data Step2: EM Algorithm Step3: Division by zero should be avoided Step4: Local Minima problem Step5: What if we minimize the perpe...
8,230
<ASSISTANT_TASK:> Python Code: def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) / 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quicksort(left) + middle + quicksort(right) print quick...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Python versions Step2: Booleans Step3: more string methods can be found here Step4: List comprehensions Step5: You can make this code simple...
8,231
<ASSISTANT_TASK:> Python Code: fullbase = requests.compat.urljoin(baseurl, endpoint_datatypes) r = requests.get( fullbase, headers=custom_headers, # params={'limit':1000}, params={'limit':1000, 'datasetid':"NORMAL_DLY"}, ) r.headers r.text json.loads(r.text) fullbase = requests.compat.urljoin(baseurl, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Request 2 Step2: Request 3 Step3: Request 4 Step4: On a side note
8,232
<ASSISTANT_TASK:> Python Code: p = (4, 5, 6, 7) x, y, z, w = p # x -> 4 data = ['ACME', 50, 91.1, (2012, 12, 21)] name, _, price, date = data # name -> 'ACME', data -> (2012, 12, 21) s = 'Hello' a, b, c, d, e = s # a -> H p = (4, 5) x, y, z = p # "ValueError" def drop_first_last(grades): Drop first and last exam...
<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: 1.2 Unpacking Elements from Iterables of Arbitrary Length Step6: Discussion Step8: 1.3 Keeping the Last N Items (in list queue with deque) Ste...
8,233
<ASSISTANT_TASK:> Python Code: import git GIT_LOG_FILE = r'${REPO}/spring-petclinic' repo = git.Repo(GIT_LOG_FILE) git_bin = repo.git git_bin git_log = git_bin.execute('git log --numstat --pretty=format:"\t\t\t%h\t%at\t%aN"') git_log[:100] import pandas as pd from io import StringIO commits_raw = pd.read_csv(StringI...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: With the <tt>git_bin</tt>, we can execute almost any Git command we like directly. In our hypothetical use case, we want to retrieve some inform...
8,234
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np from mayavi import mlab import mne from mne.datasets import sample from mne.minimum_norm import read_inverse_operator, apply_inverse from mne.simulation import simulate_stc, simulate_evoked seed = 42 # parameters for inverse method method = 'sLORET...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First, we set some parameters. Step2: Load the MEG data Step3: Estimate the background noise covariance from the baseline period Step4: Gener...
8,235
<ASSISTANT_TASK:> Python Code: def generate_random_points_along_a_line (slope, intercept, num_points, abs_value, abs_noise): # randomly select x x = np.random.uniform(-abs_value, abs_value, num_points) # y = mx + b + noise y = slope*x + intercept + np.random.uniform(-abs_noise, abs_noise, num_points) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: If $N$ = num_points, then the error in fitting a line to the points (also defined as Cost, $C$) can be defined as
8,236
<ASSISTANT_TASK:> Python Code: %pylab inline import numpy as np np.random.seed(42) x = np.random.random(20) y = np.sin(2 * x) p = np.polyfit(x, y, 1) # fit a 1st-degree polynomial (i.e. a line) to the data print p # slope and intercept x_new = np.random.random(3) y_new = np.polyval(p, x_new) # evaluate the polynomi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Polynomial regression can be done with the functions polyfit Step2: Using a 1st-degree polynomial fit (that is, fitting a straight line to x an...
8,237
<ASSISTANT_TASK:> Python Code: import ee ee.Initialize() from geetools import batch p1 = ee.Geometry.Point([-71,-42]) p2 = ee.Geometry.Point([-71,-43]) p3 = ee.Geometry.Point([-71,-44]) feat1 = ee.Feature(p1.buffer(1000), {'site': 1}) feat2 = ee.Feature(p2.buffer(1000), {'site': 2}) feat3 = ee.Feature(p3.buffer(1000),...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: FeatureCollection Step2: Image Step3: Execute
8,238
<ASSISTANT_TASK:> Python Code: # import logging # logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s') # logging.root.level = logging.INFO from os import path from random import shuffle from corputil import FileCorpus, ListCorpus from corputil.utils import load_stopwords from gensim.models.word2vec 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: Training the Base Model Step2: Save model to disk. Don't finalize the model because we need to train it with new data later! Step3: Training t...
8,239
<ASSISTANT_TASK:> Python Code: !g.gisenv !g.mapset location=nc_basic_spm_grass7 mapset=user1 !g.proj -p !g.list rast rasterlist = getLayerList(type='rast') vectorlist = getLayerList(type='vect') rasterlist vectorlist !r.info elevation@PERMANENT rasterlayerinfo = rlayerInfo(map='elevation') vectorlayerinfo = vlaye...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Use of the g.mapset Step2: print projection info with g.proj Step3: list vector and raster layers with g.list Step4: use the getLayerList fun...
8,240
<ASSISTANT_TASK:> Python Code: from __future__ import division # plotting %matplotlib inline from matplotlib import pyplot as plt; import matplotlib as mpl; from mpl_toolkits.mplot3d import Axes3D # scientific import numpy as np; import sklearn as skl; import sklearn.datasets; import sklearn.cluster; import sklearn.mix...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: EECS 445 Step3: Dimensionality Reduction Step4: Example Step5: Break time!
8,241
<ASSISTANT_TASK:> Python Code: # Make sure division of integers does not round to the nearest integer from __future__ import division # Make everything in python's symbolic math package available from sympy import * # Make sure sympy functions are used in preference to numpy import sympy # Make sympy. constructions ava...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fundamental variables Step2: Derived variables Step3: The system's vector basis is given by $(\hat{\ell}, \hat{n}, \hat{\lambda})$, and will b...
8,242
<ASSISTANT_TASK:> Python Code: G = nx.read_gpickle('Synthetic Social Network.pkl') #If you are Python 2.7, read in Synthetic Social Network 27.pkl nx.draw(G) # Who are represented in the network? G.nodes(data=True) len(G.nodes()) # Who is connected to who in the network? G.edges() len(G.edges()) # Let's get a list ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Basic Network Statistics Step2: Exercise Step3: Exercise Step4: Since this is a social network of people, there'll be attributes for each ind...
8,243
<ASSISTANT_TASK:> Python Code: Image('./res/fig8_1.png') Image('./res/fig8_2.png') Image('./res/fig8_5.png') Image('./res/fig8_6.png') Image('./res/prioritized_sweeping.png') Image('./res/fig8_7.png') <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: Learning and planning are deeply integrated in the sense that they share almost all the same machinery, differing only in the source of their ex...
8,244
<ASSISTANT_TASK:> Python Code: #Configuracion para recargar módulos y librerías cada vez %reload_ext autoreload %autoreload 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: Contenido Step2: Importante Step3: 2. Librería Numpy Step4: 2.1 Array vs Matrix Step5: Desafío 1 Step6: 2.2 Indexación y Slicing Step7: Ob...
8,245
<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 import pandas as pd def extract_reference_time(API_data_loc): Find reference time that corresponds to most...
<SYSTEM_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 GEFS Step2: GEFS is a model with lots of output variables, which may also change depending of which particular output fi...
8,246
<ASSISTANT_TASK:> Python Code: def findstring(s ) : n = len(s ) s = list(s ) i = 1 while i < n - 1 : if(s[i - 1 ] == '0' and s[i + 1 ] == '0' ) : s . pop(i ) i -= 1 if i > 0 and s[i - 1 ] == '0' : i -= 1  n = len(s )  i += 1  return ' ' . join(s )  if __name__== ' __main __' : print...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
8,247
<ASSISTANT_TASK:> Python Code: # Lo primero que ejecutarás será 'Hola Jupyter' print('Hola Jupyter') variable = 50 saludo = 'Hola' # Importa matplotlib (paquete para graficar) y numpy (paquete para arreglos). # Fíjate en el la función mágica para que aparezca nuestra gráfica en la celda. %matplotlib inline import mat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Cada celda la puedes usar para escribir el código que tu quieras y si de repente se te olvida alguna función o tienes duda de si el nombre es co...
8,248
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as pl import numpy as np import shap import xgboost as xgb N = 2000 X = np.zeros((N,2)) X[:1000,0] = 1 X[:500,1] = 1 X[1000:1500,1] = 1 yA = 80 * (X[:,0] * X[:,1]) + 1e-4 * ((X[:,0] == 0) * (X[:,1] == 0)) # last term forces the creation of left split Xd = xgb.DMa...
<SYSTEM_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 Model A Step2: Create Model B Step3: SHAP Values Step4: Saabas Values Step5: mean(abs(SHAP Values)) Step6: mean(abs(Saabas Values)) ...
8,249
<ASSISTANT_TASK:> Python Code: # Packages import numpy as np from testCases import * from gc_utils import sigmoid, relu, dictionary_to_vector, vector_to_dictionary, gradients_to_vector # GRADED FUNCTION: forward_propagation def forward_propagation(x, theta): Implement the linear forward propagation (compute J...
<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: 1) How does gradient checking work? Step4: Expected Output Step6: Expected Output Step8: Expected Output Step10: Now, run backward propagati...
8,250
<ASSISTANT_TASK:> Python Code: # loading libraries and reading the data import numpy as np import pandas as pd market_df = pd.read_csv("./global_sales_data/market_fact.csv") customer_df = pd.read_csv("./global_sales_data/cust_dimen.csv") product_df = pd.read_csv("./global_sales_data/prod_dimen.csv") shipping_df = pd.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: Merging Dataframes Using pd.merge() Step2: Merging Dataframes Step3: Similary, you can merge the other dimension tables - shipping_df and orde...
8,251
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import os import numpy as np import fitsio from desitarget import desi_mask, brightmask os.environ["CSCRATCH"] = '/global/cscratch1/sd/adamyers' sourcemask = fitsio.read("$CSCRATCH/sourcemask150.fits") brightmask.plot_mask(sourcemask,lim...
<SYSTEM_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 may have to set up your $CSCRATCH environment variable so that Python can find it, e.g. Step2: These are some circular regions that could b...
8,252
<ASSISTANT_TASK:> Python Code: data.pressure[-1*24*24:].plot() # See how this compares to "normal" pressure # Plot the last 10 days data.pressure[-10*24*24:].plot() data.tail() !pwd from IPython import display display.Image('../galleries/Joaquin/joaquin.png') <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: Bermuda Weather Radar
8,253
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() %matplotlib inline # https://www.data.gouv.fr/fr/datasets/donnees-hospitalieres-relatives-a-lepidemie-de-covid-19/ from pandas import read_csv url = "https://www.data.gouv.fr/fr/datasets/r/63352e38-d353-4b54-bfd1-f1b3ee1cabd...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exposé Step2: Données départements Step3: Il faudrait aussi fusionner avec la population de chaque département. Ce sera pour une autre fois. ...
8,254
<ASSISTANT_TASK:> Python Code: fname = io.download_occultation_times(outdir='../data/') print(fname) tlefile = io.download_tle(outdir='../data') print(tlefile) times, line1, line2 = io.read_tle_file(tlefile) tstart = '2017-09-11T00:00:00' tend = '2017-09-15T00:00:00' orbits = planning.sunlight_periods(fname, tstart, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Download the NuSTAR TLE archive. Step2: Here is where we define the observing window that we want to use. Step3: We want to know how to orient...
8,255
<ASSISTANT_TASK:> Python Code: import sys sys.path.insert(0, '../') from paleopy import proxy from paleopy import analogs from paleopy.plotting import scalar_plot djsons = '../jsons/' pjsons = '../jsons/proxies' proxies = pd.read_excel('../data/ProxiesLIANZSWP.xlsx') proxies.head() for irow in proxies.index: 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: defines the folder where the JSON files are (for the datasets) and where to save the proxy JSON files Step2: instantiates a proxy instance
8,256
<ASSISTANT_TASK:> Python Code: import networkx import obonet %%time url = 'http://purl.obolibrary.org/obo/go/go-basic.obo' graph = obonet.read_obo(url) # Number of nodes len(graph) # Number of edges graph.number_of_edges() # Check if the ontology is a DAG networkx.is_directed_acyclic_graph(graph) # Retreive propertie...
<SYSTEM_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 Gene Ontology Step2: Lookup node properties Step3: Create name mappings Step4: Find parent or child relationships Step5: Find all s...
8,257
<ASSISTANT_TASK:> Python Code: import os import numpy as np import mne sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', 'sample_audvis_raw.fif') raw = mne.io.read_raw_fif(sample_data_raw_file) raw.crop(0, 60...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: What are artifacts? Step2: Low-frequency drifts Step3: Low-frequency drifts are readily removed by high-pass filtering at a fairly Step4: Her...
8,258
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import tensorflow as tf config = tf.ConfigProto() config.gpu_options.allow_growth = True import numpy as np import matplotlib.pyplot as plt learning_rate = 0.01 training_epochs = 1000 display_step = 50 train_X = np.asarray([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.5...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Macierz $A$ dla regresji liniowej wynosi Step2: Współczynniki dokładnie będą wynosiły Step3: Optymalizacja metodą iteracyjną, Step4: Tensor f...
8,259
<ASSISTANT_TASK:> Python Code: # To begin, define the prior as the probability of the car being behind door i (i=1,2,3), call this "pi". # Note that pi is uniformly distributed. p1 = ? p2 = ? p3 = ? # Next, to define the class conditional, we need three pieces of information. Supposing Monty reveals door 3, # we must ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problem 2 Step2: C Step3: D Step5: <a id='prob1ans'></a>
8,260
<ASSISTANT_TASK:> Python Code: %matplotlib inline from pandas import Series, DataFrame import pandas as pd from itertools import * import numpy as np import csv import math import matplotlib.pyplot as plt from matplotlib import pylab from scipy.signal import hilbert, chirp import scipy import networkx as nx c_dataset ...
<SYSTEM_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 the dataset 0750-0805 Step2: What is the number of different vehicles for the 15 min Step3: 15min = 900 s = 9000 ms // Step4: For eve...
8,261
<ASSISTANT_TASK:> Python Code: %%javascript IPython.keyboard_manager.command_shortcuts.add_shortcut('r', { help : 'run cell', help_index : 'zz', handler : function (event) { IPython.notebook.execute_cell(); return false; }} ); %%javascript IPython.keyboard_manager.command_shortcuts.add_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: There are a couple of points to mention about this API Step2: Likewise, to remove a shortcut, use remove_shortcut
8,262
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function, absolute_import import tensorflow as tf import numpy as np import smrt # this is our seed seed = 42 # show versions for continuity print("TensorFlow version: %s" % tf.__version__) print("NumPy version: %s" % np.__version__) print("SMRT 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: Load MNIST Step2: Demonstrate the AutoEncoder Step3: Fit and reconstruct using AutoEncoder Step4: Show reconstruction examples Step5: This l...
8,263
<ASSISTANT_TASK:> Python Code: urlre = re.compile( '(?P<url>https?://[^\s]+)' ) for page in doc : print urlre.findall( page ) urlre = re.compile( '(?P<url>https?://[^\s]+)' ) for page in doc : print urlre.findall( page.replace('\n','') ) from sgmllib import SGMLParser class URLLister(SGMLParser): def rese...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: PDF is garbage, continued Step2: Nope. Step3: Here are all the URLs in the document... Step4: Bleh. That is mostly links in the references, a...
8,264
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt %matplotlib inline import numpy as np #3.1 p = [0.2, 0.5, 0.8] n = np.arange(1, 8) for i, pi in enumerate(p): plt.plot(n, pi * (1 - pi)**(n - 1), 'o-', label='$p={}$'.format(pi), color='C{}'.format(i)) plt.axvline(x = 1/ pi, color='C{}'.format(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: 4. Prediction Intervals and Loops (19 Points + 12 EC) Step2: 5. Normal Distribution (8 Points) Step3: 5.3
8,265
<ASSISTANT_TASK:> Python Code: columns = pd.MultiIndex.from_tuples([ ('A', 'cat', 'long'), ('B', 'cat', 'long'), ('A', 'dog', 'short'), ('B', 'dog', 'short') ], names=['exp', 'animal', 'hair_length'] ) df = pd.DataFrame(np.random.randn(4, 4), columns=columns) df df.columns st...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: missing data Step2: groupby + reshaping
8,266
<ASSISTANT_TASK:> Python Code: ### Link to requirements.txt on github business.head(2) review.head(2) review.text.head(2) review_all = pd.read_csv('../../data/interim/original_csv/review.csv') # Number of reviews by date # The sharp seasonal falls are Chrismas Day and New Year's Day # The sharp seasonal spikes are 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: 3.1 Data Dictionary Step2: 3.2.4 Cleaning 'review' table Step3: 3.2.5 Cleaning 'checkin' table Step4: 3.2.6 Cleaning 'user' table Step5: 3.2...
8,267
<ASSISTANT_TASK:> Python Code: # Load relevant libraries. from os import path import pandas as pd import numpy as np import folium import glob from tqdm import tqdm import random %matplotlib inline # Load custom modules. import sys sys.path.append('..') from utils import getmedian, haversine from utils import llaToECEF...
<SYSTEM_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. Single user review Step2: 1.2 Remove the columns that you do not require Step3: 1.3 Remove location records with poor accuracy Step4: It l...
8,268
<ASSISTANT_TASK:> Python Code: import re import requests import zipfile import numpy as np import pandas as pd import matplotlib.pylab as plt import seaborn as sns import statsmodels.formula.api as sm sns.set_context('talk') pd.set_option('float_format', '{:6.2f}'.format) %matplotlib inline url = 'http://databank.worl...
<SYSTEM_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 zip file from the web and save it to your hard drive. Step2: Show contents of the zip file. Step3: Read csv-formatted data directly f...
8,269
<ASSISTANT_TASK:> Python Code: import rebound import numpy as np sim = rebound.Simulation() np.random.seed(42) #integrator options sim.integrator = "mercurius" sim.dt = 1 sim.testparticle_type = 1 #collision and boundary options sim.collision = "direct" sim.collision_resolve = "merge" sim.collision_resolve_keep_sorted...
<SYSTEM_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 choose the basic properties required for the MERCURIUS integrator to run correctly. In particular, we are Step2: Now that the preli...
8,270
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline # Plot of many regions! l1, l2 = -3.5, 3.5 resolution = 0.01 [X, Y] = np.meshgrid(np.arange(-l2,l2,resolution), np.arange(-l2,l2,resolution)) Z = X + 1j*Y def plot_complex_region(R, ax, title, cmap=plt.cm.gray, levels=...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Regiones de estabilidad más comunes para estudiar Step2: Quiz 3 Step3: 2) Aplique el método de Forward Euler para resolver el IVP hasta el tie...
8,271
<ASSISTANT_TASK:> Python Code: %matplotlib inline from statsmodels.compat import lmap import numpy as np from scipy import stats import matplotlib.pyplot as plt import statsmodels.api as sm norms = sm.robust.norms def plot_weights(support, weights_func, xlabels, xticks): fig = plt.figure(figsize=(12,8)) ax = 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: An M-estimator minimizes the function Step2: Andrew's Wave Step3: Hampel's 17A Step4: Huber's t Step5: Least Squares Step6: Ramsay's Ea St...
8,272
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import pandas as pd from time import time from joblib import Parallel, delayed import multiprocessing import time import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') from sklearn.cluster 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: loading different datasets Step2: I - Clustering Nodes Step3: 1 - Parameters Optimization Step4: Difficult to find an elbow criteria Step5: ...
8,273
<ASSISTANT_TASK:> Python Code: import time import numpy as np import copy from sklearn.linear_model import ElasticNetCV as ElasticNetCV_sk from prox_elasticnet import ElasticNetCV as ElasticNetCV_px np.random.seed(319159) from sklearn import __version__ as sklearn_version print("Using sklearn version {}.".format(sklear...
<SYSTEM_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 initialise the ElasticNetCV object for each implementation using the default parameters. This means l1_ratio = 0.5 and alpha takes 100 values...
8,274
<ASSISTANT_TASK:> Python Code: import time, array, random, copy, math import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline %config InlineBackend.figure_format = 'retina' from deap import algorithms, base, benchmarks, tools, creator random.seed(a=42) creator.create("FitnessMin", b...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: How we handle multiple -and conflictive- objectives? Step2: Planting a constant seed to always have the same results (and avoid surprises in cl...
8,275
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import prepare_EMG, prepare_outputs, prepare_data, pandas EMG_Prep = prepare_EMG.EMG_preparer() Output_Prep = prepare_outputs.output_preparer() Data_Prep = prepare_data.data_preparer() singles_1 = Data_Prep.load_singletons(1) singles_2 = Data_Prep.load_...
<SYSTEM_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 the Data Step2: Labeling the Data Step3: Preparing Input, Output 'Master' DataFrames Step4: Preprocessing, continued Step5: Explorat...
8,276
<ASSISTANT_TASK:> Python Code: import mmap with open('lorem.txt', 'r') as f: with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m: print('First 10 bytes via read :', m.read(10)) print('First 10 bytes via slice:', m[:10]) print('2nd 10 bytes via read :', m.read(10)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Writing Step2: Copying Mode Step3: Regular Expressions
8,277
<ASSISTANT_TASK:> Python Code: %pylab notebook %precision %.4g V = 120 # [V] p = 4 R1 = 2.0 # [Ohm] R2 = 2.8 # [Ohm] X1 = 2.56 # [Ohm] X2 = 2.56 # [Ohm] Xm = 60.5 # [Ohm] s = 0.025 Prot = 51 # [W] Zf = ((R2/s + X2*1j)*(Xm*1j)) / (R2/s + X2*1j + Xm*1j) Zf Zb = ((R2/(2-s) + X2*1j)*(Xm*1j)) / (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: Description Step2: SOLUTION Step3: $$Z_B = \frac{(R_2/(2-s) + jX_2)(jX_M)}{R_2/(2-s) + jX_2 + jX_M}$$ Step4: (a) Step5: (b) Step6: (c) Step...
8,278
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import, division, print_function %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns sns.set_context('poster') # sns.set_style('whitegrid') sns.set_style('darkgrid') plt.rcParams['figure.figsize'] = 12, 8 # plotsize 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: Note Step2: Notebook Extensions -- qgrid
8,279
<ASSISTANT_TASK:> Python Code: # Import biochemical model module import steps.model as smod # Create model container mdl = smod.Model() # Create chemical species A = smod.Spec('A', mdl) B = smod.Spec('B', mdl) C = smod.Spec('C', mdl) # Create reaction set container vsys = smod.Volsys('vsys', mdl) # Create reaction # 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: For complex model, we can break it down into elementary reactions, for example, the following model Step2: Setup geometry Step3: Create a rand...
8,280
<ASSISTANT_TASK:> Python Code: import os import pandas as pd import math import numpy as np from sklearn.tree import DecisionTreeClassifier headers = ["buying", "maint", "doors", "persons","lug_boot", "safety", "class"] data = pd.read_csv("car_data.csv", header=None, names=headers) data = data.sample(frac=1).reset_inde...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: No código acima, fizemos a leitura do arquivo informando que não há cabeçalho (obrigatório) e embaralhamos os dados. Step2: Um problema é que n...
8,281
<ASSISTANT_TASK:> Python Code: cos_credentials = { "apikey": "-------", "cos_hmac_keys": { "access_key_id": "------", "secret_access_key": "------" }, "endpoints": "https://cos-service.bluemix.net/endpoints", "iam_apikey_description": "------", "iam_apikey_name": "------", "iam_role_crn": "------"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Define the endpoint. Step2: Prepare model Step3: Configure docker credentials Step4: Create a config-map in the namespace you're using with t...
8,282
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline from cops_and_robots.robo_tools.fusion.softmax import SoftMax, make_regular_2D_poly poly = make_regular_2D_poly(5, max_r=2, theta=np.pi/3.1) labels = ['Interior', 'Mall Terrace Entrance', 'Heliport Facade', 'South Parking...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: NOTE Step2: As expected, our boundaries stayed the same but our probabilities are less spread out. Looking good! Step3: Great! We've successf...
8,283
<ASSISTANT_TASK:> Python Code: class IndicatorCommand: Indicator command. def __init__(self, indicator, selector): self.indicator = indicator self.selector = selector def __call__(self, music): for selection in self.selector(music): indicator = copy.copy(self.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: Class collaboration Step7: 2. Extend our music-maker Step8: 3. Initializing commands Step9: 4. Making the score
8,284
<ASSISTANT_TASK:> Python Code: # THINGS TO IMPORT # This is a baseline set of libraries I import by default if I'm rushed for time. import codecs # load UTF-8 Content import json # load JSON files import pandas as pd # Pandas handles dataframes import numpy as np ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Acquire Dee Dataset from Methods Matter Step2: Summary Statistics Step3: Cross-Tabulation Step4: Correlation Matrix Step5: Linear Regression...
8,285
<ASSISTANT_TASK:> Python Code: # Import numpy and alias to "np" import numpy as np # Import and alias to "plt" import matplotlib.pyplot as plt def planck(wavelength, temp): Return the emitted radiation from a blackbody of a given temp and wavelength Args: wavelength (float): wavelength (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: Advanced Step3: Let's also combine our plotting code into a cohesive function Step4: Now we can tie our plot function, plot_planck, to the int...
8,286
<ASSISTANT_TASK:> Python Code: import os import sys import tensorflow as tf from tensorflow.keras import layers import pandas as pd import numpy as np import cv2 import matplotlib.pyplot as plt tf.random.set_seed(123) annotation_folder = "/dataset/" if not os.path.exists(os.path.abspath(".") + annotation_folder): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Downloading the dataset Step2: Preparing the dataset Step3: Preparing hyperparameters Step7: Building a data pipeline Step8: Visualizing sam...
8,287
<ASSISTANT_TASK:> Python Code: import pandas as pd d = ({'Date': ['1/1/18','1/1/18','2/1/18','3/1/18','1/2/18','1/3/18','2/1/19','3/1/19'], 'Val': ['A','B','C','D','A','B','C','D']}) df = pd.DataFrame(data=d) def g(df): df['Date'] = pd.to_datetime(df['Date'], format='%d/%m/%y') y = df['Date'].dt.year ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
8,288
<ASSISTANT_TASK:> Python Code: import paramz, numpy as np from scipy.optimize import rosen_der, rosen x = np.array([-1,1]) class Rosen(paramz.Model): # Inherit from paramz.Model to ensure all model functionality. def __init__(self, x, name='rosen'): # Initialize the Rosen model with a numpy array `x` and name `na...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The starting position of the rosen function is set to be Step2: For paramz to understand your model there is three steps involved Step3: The ...
8,289
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' from matplotlib import rcParams rcParams["savefig.dpi"] = 100 rcParams["figure.dpi"] = 100 rcParams["figure.figsize"] = 12, 4 rcParams["font.size"] = 16 rcParams["text.usetex"] = False rcParams["font.family"] = ["sans-serif...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step5: Benchmarking our implementation Step6: <div style="background-color Step7: <div style="background-color Step8: <div style="background-color S...
8,290
<ASSISTANT_TASK:> Python Code: import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) import collections SentimentDocument = collections.namedtuple('SentimentDocument', 'words tags split sentiment') import io import re import tarfile import os.path import smart_open...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Introduction Step2: We can now proceed with loading the corpus. Step3: Here's what a single document looks like. Step4: Extract our documents...
8,291
<ASSISTANT_TASK:> Python Code: y, sr = librosa.load('audio/prelude_cmaj.wav') ipd.Audio(y, rate=sr) est_tempo, est_beats = librosa.beat.beat_track(y=y, sr=sr, bpm=120) est_beats = librosa.frames_to_time(est_beats, sr=sr) est_beats ref_beats = numpy.array([0, 0.50, 1.02, 1.53, 1.99, 2.48, 2.97, 3.43, 3.90, 4.41...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Detect Beats Step2: Load a fictional reference annotation. Step3: Plot the estimated and reference beats together. Step4: Evaluate Step5: Ex...
8,292
<ASSISTANT_TASK:> Python Code: %pylab inline import scipy.stats # Author: Jake VanderPlas # License: BSD # The figure produced by this code is published in the textbook # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) # For more information, see http://astroML.github.com # To report a bug ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Bootstrap Step2: Jackknife Step3: Hypothesis Testing Step4: Benjamini and Hochberg Method Step5: 4.7 - Comparing Distributions Step6: U tes...
8,293
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst !pip install --user google-cloud-bigquery==1.25.0 import os from google.cloud import bigquery %%bash export PROJECT=$(gcloud config list project --format "value(core.project)") echo "Your current GCP Project Name is: "$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: Note Step2: Lab Task #1 Step3: The source dataset Step4: Create the training and evaluation data tables Step5: Lab Task #3 Step6: Lab Task ...
8,294
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() def make_squares(n): squares = [i**2 for i in range(n)] def make_squares(n): squares = [i**2 for i in range(n)] print ( make_squares(2) ) s = 1 a = 0 for i in range(4): a += s s += 2 a s = 1 a = 0 for i 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: Enoncé 1 Step2: Comme il n'y a pas d'instruction return, la fonction retourne toujours None quelque chose le résultat de ce qu'elle calcule. St...
8,295
<ASSISTANT_TASK:> Python Code: from bigbang.archive import Archive urls = [#"analytics", "conferences", "design", "education", "gendergap", "historic", "hot", "ietf-privacy", "ipython-dev", "ipython-user", "languages", "maps-l", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The above code reads in preprocessed email archive data. These mailing lists are from a variety of different sources Step2: Now we have process...
8,296
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import mapp4py from mapp4py import md from lib.elasticity import rot, cubic, resize, displace, crack from mapp4py import mpi if mpi().rank!=0: with open(os.devnull, 'w') as f: sys.stdout = f; xprt = md.export_cfg(""); _ = 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: Block the output of all cores except for one Step2: Define an md.export_cfg object Step3: Asymptotic Displacement Field of Crack from Linear E...
8,297
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline np.any? def makeMPGData(filename='auto-mpg.data'): def missingIsNan(s): return np.nan if s == b'?' else float(s) data = np.loadtxt(filename, usecols=range(8), converters={3: missingIsNan}) print("Rea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: So, our linear model seems to be quite a bit better than using just the mean mpg. Step2: Which $\lambda$ value is best? Careful. What is the ...
8,298
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings('ignore') %matplotlib inline %pylab inline import matplotlib.pylab as plt import numpy as np from distutils.version import StrictVersion import sklearn print(sklearn.__version__) assert StrictVersion(sklearn.__version__ ) >= StrictVersion('0.18.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: Modell-Architektur Step2: Sigmoid Step3: Relu Step4: The classic VGG16 Architecture Step5: VGG starts with a number of convolutional blocks ...
8,299
<ASSISTANT_TASK:> Python Code: !pip install --user google-cloud-bigquery==1.25.0 # Installing the latest version of the package import tensorflow as tf print("TensorFlow version: ",tf.version.VERSION) %%bash export PROJECT=$(gcloud config list project --format "value(core.project)") echo "Your current GCP Project 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: Note Step2: The source dataset Step3: Create the training data table Step4: Verify table creation Step5: Baseline Model Step6: REMINDER Ste...