Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
14,500
<ASSISTANT_TASK:> Python Code: import rebound import numpy as np %matplotlib inline import matplotlib import matplotlib.pyplot as plt def run_sim(a): sim = rebound.Simulation() sim.add(m=1.) sim.add(primary=sim.particles[0],m=1e-3, a=1) sim.add(primary=sim.particles[0],m=1e-3, a=a) sim.integra...
<SYSTEM_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 setup a planetary system with two Jupiter mass planets. The following function takes that system, integrates it forward in time by 10 orbits ...
14,501
<ASSISTANT_TASK:> Python Code: # Import modules import time import math import random import numpy as np import scipy import sympy import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def linear_congruential_generator(x, a, b, m): x = (a * x + b) % m u = x / m return u, x, a, b, m x0 = 3...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 9.1 Random Numbers Step2: Example Step3: Minimal standard random number generator Step4: Example Step5: Example Step6: For its visualizatio...
14,502
<ASSISTANT_TASK:> Python Code: #%% librerias import pandas as pd # Crear un dataFrame data = {'Company':['GOOG','GOOG','MSFT','MSFT','FB','FB'], 'Person':['Sam','Charlie','Amy','Vanessa','Carl','Sarah'], 'Sales':[200,120,340,124,243,350]} df = pd.DataFrame(data) df df.groupby('Company') by_comp = df.gro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Ahora ya podemos usar la funcion .groupby() para agrupar la informacion en base a los nombres de las columnas. Agrupemos la informacion por el n...
14,503
<ASSISTANT_TASK:> Python Code: %%capture --no-stderr !pip3 install kfp --upgrade import kfp.components as comp dataflow_template_op = comp.load_component_from_url( 'https://raw.githubusercontent.com/kubeflow/pipelines/1.7.0-rc.3/components/gcp/dataflow/launch_flex_template/component.yaml') help(dataflow_template_o...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2. Load the component using KFP SDK Step2: 3. Configure job parameters Step3: 4. Example pipeline that uses the component Step4: 5. Create pi...
14,504
<ASSISTANT_TASK:> Python Code: T = 3.0 # duration in seconds fs = 44100.0 # sampling rate in Hertz f0 = 440*numpy.logspace(-2, 1, T*fs, endpoint=False, base=2.0) # time-varying frequency print f0.min(), f0.max() # starts at 110 Hz, ends at 880 Hz t = numpy.linspace(0, T, T*fs, endpoint=False) x = 0.01*numpy.sin(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: Create the sweep signal Step2: Listen to the signal Step3: Segmentation Using Python List Comprehensions Step4: librosa.util.frame Step5: (T...
14,505
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cmcc', 'cmcc-cm2-vhr4', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name",...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
14,506
<ASSISTANT_TASK:> Python Code: import pandas import matplotlib.pyplot as plt import numpy as np %matplotlib inline td = pandas.read_csv('titanic_train.csv') td.info() surivors = td[td.Survived==1] dead = td[td.Survived==0] plt.figure(figsize=(13,6)) plt.hist(surivors.Fare, alpha=.5, bins=np.arange(0,300,10), label="...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data Step2: The data we care about for this hypothesis(Survived, Fare) has no NaN values so no need to modify. Step3: Hypothesis Step4: Based...
14,507
<ASSISTANT_TASK:> Python Code: %%bash # example of the input file structure and naming: a plain folder with unzipped backward and forward fastq files ls ../../data/raw/fastq/ | head -n 20 from IPython.display import Image, display img1 = Image("../../data/processed/fastqc_results/raw/quality_summary_all_samples_1.png"...
<SYSTEM_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. Quality-check your raw (and dirty) reads Step2: The two plots produced by the R-script show summary statistics for each individual test (tes...
14,508
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pyJHTDB t = np.linspace(0, 1, 64) x = np.zeros((t.shape[0], t.shape[0], 3), np.float32) x[:, :, 0] = t[np.newaxis, :] x[:, :, 1] = t[:, np.newaxis] x[:, :, 2] = .0 lJHTDB = pyJHTDB.libJHTDB() lJHTDB.initialize() #Add token auth_token = "edu....
<SYSTEM_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'm going to create a 2D grid of points, and then get the values of the velocity at those points. Step2: Since the dataset I'm gonna use is the...
14,509
<ASSISTANT_TASK:> Python Code: import urllib.request rm_site = 'http://www.repeatmasker.org' fn = 'ce10.fa.out.gz' url = '%s/genomes/ce10/RepeatMasker-rm405-db20140131/%s' % (rm_site, fn) urllib.request.urlretrieve(url, fn) import gzip import itertools fh = gzip.open(fn, 'rt') for ln in itertools.islice(fh, 10): pr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Above are the first several lines of the .out.gz file for the roundworm (C. elegans). The columns have headers, which are somewhat helpful. Mo...
14,510
<ASSISTANT_TASK:> Python Code: BUCKET='ai-analytics-solutions-kfpdemo' # CHANGE to a bucket you own import tensorflow as tf import tensorflow_hub as tfhub import os model = tf.keras.Sequential() model.add(tf.keras.Input(shape=[None,None,3])) model.add(tfhub.KerasLayer("https://tfhub.dev/google/efficientnet/b4/feature...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Embedding model for images Step2: The model on TensorFlow Hub expects images of a certain size, and provided as normalized arrays. Step3: Loa...
14,511
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import tensorflow as tf import numpy as np from datetime import date date.today() author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises" tf.__version__ np.__version__ sess = tf.InteractiveSession() x = tf.constant([True, False, False],...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: NOTE on notation Step2: Q5. Given x, return the truth value of NOT x element-wise.
14,512
<ASSISTANT_TASK:> Python Code: from urllib.request import urlretrieve urlretrieve('http://sthiele.github.io/data/queens.lp','queens.lp') urlretrieve('http://sthiele.github.io/data/facts.lp','facts.lp') from pyasp.asp import * goptions = '' soptions = ' 2' solver = Gringo4Clasp(gringo_options=goptions, clasp_options...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import the pyasp library. Step2: Create a solver object. Step3: Start the solver with some input. Step4: The result is a list of the solution...
14,513
<ASSISTANT_TASK:> Python Code: import time from collections import namedtuple import numpy as np import tensorflow as tf with open('anna.txt', 'r') as f: text=f.read() vocab = set(text) vocab_to_int = {c: i for i, c in enumerate(vocab)} int_to_vocab = dict(enumerate(vocab)) encoded = np.array([vocab_to_int[c] for ...
<SYSTEM_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'll load the text file and convert it into integers for our network to use. Here I'm creating a couple dictionaries to convert the chara...
14,514
<ASSISTANT_TASK:> Python Code: import cv2 import numpy as np from scipy import misc i = misc.ascent() import matplotlib.pyplot as plt plt.grid(False) plt.gray() plt.axis('off') plt.imshow(i) plt.show() i_transformed = np.copy(i) size_x = i_transformed.shape[0] size_y = i_transformed.shape[1] # This filter detects ed...
<SYSTEM_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, we can use the pyplot library to draw the image so we know what it looks like. Step2: The image is stored as a numpy array, so we can cre...
14,515
<ASSISTANT_TASK:> Python Code: %matplotlib inline from time import time import numpy as np import pandas as pd import random import matplotlib.pyplot as plt import matplotlib matplotlib.rc('xtick', labelsize=14) matplotlib.rc('ytick', labelsize=14) import tensorflow as tf from sklearn.model_selection import train_te...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: parameters to set Step2: generate normal data Step3: plot timeseries Step4: create NN Step5: This function actually checks for anomaly in on...
14,516
<ASSISTANT_TASK:> Python Code: def divide(numerator, denominator): result = numerator/denominator print("result = %f" % result) divide(1.0, 0) def divide1(numerator, denominator): try: result = numerator/denominator print("result = %f" % result) except: print("You can't divide by...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Why didn't we catch this SyntaxError? Step3: What do you do when you get an exception?
14,517
<ASSISTANT_TASK:> Python Code: filename = 'resultat.nc' import numpy as np import matplotlib.pyplot as plt from pylab import * import cartopy.crs as ccrs from netCDF4 import Dataset %matplotlib inline import warnings warnings.filterwarnings('ignore') data = Dataset(filename) longitude=data.variables['longitude'][:] lat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Carte en moyenne temporelle sur la totalité de l'expérience Step2: Carte en moyenne temporelle de $p_{sat}$ pour $H_2O$ Step3: Carte à $L_s$ d...
14,518
<ASSISTANT_TASK:> Python Code: import numpy as np from numba import njit arr2d = np.arange(20 * 30, dtype=float).reshape(20,30) %%timeit np.sum(arr2d) def py_sum(arr): M, N = arr.shape sum = 0.0 for i in range(M): for j in range(N): sum += arr[i,j] return sum %%timeit py_sum(arr2d) 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: ¿Impresionado? La primera vez que hemos llamado a la función, Python ha generado el código correspondiente al tipo de datos que le hemos pasado....
14,519
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 変数の概要 Step2: 変数の作成 Step3: 変数の外観と動作はテンソルに似ており、実際にデータ構造が tf.Tensor で裏付けられています。テンソルのように dtype と形状を持ち、NumPy にエクスポートできます。 Step4: ほとんどのテンソル演算は期待どおり...
14,520
<ASSISTANT_TASK:> Python Code: import numpy as np # for np.allclose() to check that S-params are similar import skrf as rf rf.stylely() # reference LC circuit made in Designer LC_designer = rf.Network('designer_capacitor_30_80MHz_simple.s2p') # scikit-rf: manually connecting networks line = rf.media.DefinedGammaZ0(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: LC Series Circuit Step2: A More Advanced Equivalent Model Step3: Pass band filter
14,521
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import tensorflow as tf import numpy as np from sklearn.metrics import confusion_matrix tf.__version__ from tensorflow.examples.tutorials.mnist import input_data data = input_data.read_data_sets("data/MNIST/", one_hot=False) print("Siz...
<SYSTEM_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 was developed using Python 3.5.2 (Anaconda) and TensorFlow version Step2: Load Data Step3: The MNIST data-set has now been loaded and con...
14,522
<ASSISTANT_TASK:> Python Code: !nvidia-smi import tensorflow as tf sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) logdir = '/root/pipeline/logs/tensorflow' import numpy as np import matplotlib.pyplot as plt import datetime from tensorflow.python.framework import ops from tensorflow.python.platform ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Multiply 2 matrices Step2: Sessions must be closed to release resources. We may use the 'with' syntax to close sessions automatically when com...
14,523
<ASSISTANT_TASK:> Python Code: numbers_str = '496,258,332,550,506,699,7,985,171,581,436,804,736,528,65,855,68,279,721,120' numbers = [int(number) for number in numbers_str.split(',')] max(numbers) sorted(numbers)[10:] threes = [] for item in numbers: if item %3 == 0: threes.append(item) sorted(threes) ...
<SYSTEM_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 following cell, complete the code with an expression that evaluates to a list of integers derived from the raw numbers in numbers_str, as...
14,524
<ASSISTANT_TASK:> Python Code: from bokeh.io import output_notebook, show from bokeh.plotting import figure import numpy as np from scipy import stats import cotede output_notebook() # Number of samples N = 3000 # True mean and standard deviation of this dataset mu, sigma = 0, 1 # Let's fix the random seed so everyone...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Synthetic data Step3: How does this dataset look like? Step4: Data Distribution Step5: We know that this dataset has a normal distribution, s...
14,525
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy import linalg from matplotlib import pyplot as plt %matplotlib inline A = np.array([[1, 0.5],[0.5, 1]]) x = np.array([1.,0.]) A = np.array([[1., 0.5,-0.1],[0.5, 1.,10.0],[2.,3.,5.]]) x = np.array([1.,0.,0.]) print("A =\n",A) print("x =",x) def power_iterati...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Matriz y vector de prueba Step3: <div id='pi' /> Step5: <div id='invpi' /> Step7: <div id='rq' /> Step8: Preguntas Step9: <div id='sp' />
14,526
<ASSISTANT_TASK:> Python Code: import pyensae from jyquickhelper import add_notebook_menu add_notebook_menu() import pyensae import pyensae.datasource pyensae.datasource.download_data("velib_vanves.zip", website = "xd") import pandas df = pandas.read_csv("velib_vanves.txt",sep="\t") df.head(n=2) from pyensae.sql imp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Mix SQLite and DataFrame Step2: As this file is small (just an example), let's see how it looks like with a DataFrame. Step3: Then we import i...
14,527
<ASSISTANT_TASK:> Python Code: organism = "E. Coli" treatment = "salt stress" todays_headline = "Python bioformaticians among top paid professionals in the country" print todays_headline print workshop_venue workshop_venue = "MSU Baroda" print workshop_venue print organism + treatment print organism + " in " + trea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here organism, treatment, todays_headline are all variable names Step2: If you try to print or anyway use variable in which you have not stored...
14,528
<ASSISTANT_TASK:> Python Code: from __future__ import division %pylab inline import numpy as np _=np.random.seed(123456) import numpy as np from scipy import stats rv = stats.beta(3,2) xsamples = rv.rvs(50) %matplotlib inline from matplotlib.pylab import subplots fig,ax = subplots() fig.set_size_inches(8,4) _=ax.hist...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: As we have seen, outside of some toy problems, it can be very difficult or Step2: Because this is simulation data, we already know that the S...
14,529
<ASSISTANT_TASK:> Python Code: from openhunt.mordorutils import * spark = get_spark() sd_file = "https://raw.githubusercontent.com/OTRF/Security-Datasets/master/datasets/atomic/windows/lateral_movement/host/empire_psexec_dcerpc_tcp_svcctl.zip" registerMordorSQLTable(spark, sd_file, "sdTable") df = spark.sql( ''' SELE...
<SYSTEM_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 & Process Security Dataset Step2: Analytic I
14,530
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import sklearn X, y = load_data() assert type(X) == np.ndarray assert type(y) == np.ndarray # fit, then predict X from sklearn.svm import SVR svr_rbf = SVR(kernel='rbf') svr_rbf.fit(X, y) predict = svr_rbf.predict(X) <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:
14,531
<ASSISTANT_TASK:> Python Code: # Import modules import math import sympy as sym import numpy as np import scipy import matplotlib.pyplot as plt import plotly import plotly.plotly as ply import plotly.figure_factory as ply_ff from IPython.display import Math from IPython.display import display # Startup plotly plotly.o...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 5.1 Numerical Differentiation Step2: Three-point centered-difference formula Step3: Three-point centered-difference formula for second derivat...
14,532
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" } # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Linear Mixed-Effect Regression in {TF Probability, R, Stan} Step3: 2 Hierarchical Linear Model Step4: 3.1 Know Thy Data Step5: Conclusions ...
14,533
<ASSISTANT_TASK:> Python Code: from astropy.io import fits import numpy as np import matplotlib.pyplot as plt from skimage import measure from astropy.visualization import astropy_mpl_style plt.style.use(astropy_mpl_style) class Blob: Class that defines a 'blob' in an image: the contour of a set of pixels w...
<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: Blob Class Step14: BlobGroup Class Step17: Find and Group Blobs Step18: Run on Preproc Data Step19: Find and Group Blobs Step20: Plot Large...
14,534
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'niwa', 'sandbox-2', 'ocean') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "emai...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
14,535
<ASSISTANT_TASK:> Python Code: %%bash if [ ! -d ./FATS ]; then git clone https://github.com/isadoranun/FATS ./FATS fi cd ./FATS; git pull origin master; %%bash cd ./FATS; git log --name-status HEAD^..HEAD; %%bash cd ./FATS; cat requirements.txt; %%bash python --version %%bash uname -srvmoio %%bash pylint --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: A.2. Requirements Step2: A.3. Python Version Step3: A.4. uname -srvmoio Step4: A.5. Pylint Version Step5: A.6. caniusepython3 version Step6:...
14,536
<ASSISTANT_TASK:> Python Code: import sys try: import docplex.cp except: if hasattr(sys, 'real_prefix'): #we are in a virtual env. !pip install docplex else: !pip install --user docplex try: import matplotlib if matplotlib.__version__ < "1.4.3": !pip install --upgrade ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Note that the more global package <i>docplex</i> contains another subpackage <i>docplex.mp</i> that is dedicated to Mathematical Programming, an...
14,537
<ASSISTANT_TASK:> Python Code: from collections import OrderedDict # For recording the model specification import pandas as pd # For file input/output import numpy as np # For vectorized math operations import statsmodels.tools.numdiff as numdiff # For numeric hessian 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: 1. Load the Swissmetro Dataset Step2: 2. Clean the dataset Step3: 3. Create an id column that ignores the repeat observations per individual S...
14,538
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function # отключим всякие предупреждения Anaconda import warnings warnings.filterwarnings('ignore') import numpy as np import pandas as pd %matplotlib inline import seaborn as sns from matplotlib import pyplot as plt plt.rcParams['figure.figsize'] =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Пример Step2: Напишем вспомогательную функцию, которая будет возвращать решетку для дальнейшей красивой визуализации. Step3: Отобразим данные....
14,539
<ASSISTANT_TASK:> Python Code: import math import numpy as np import h5py import matplotlib.pyplot as plt import scipy from PIL import Image from scipy import ndimage import tensorflow as tf from tensorflow.python.framework import ops from cnn_utils import * %matplotlib inline np.random.seed(1) # Loading the data (sig...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Run the next cell to load the "SIGNS" dataset you are going to use. Step2: As a reminder, the SIGNS dataset is a collection of 6 signs represen...
14,540
<ASSISTANT_TASK:> Python Code: import sympy as sym sym.init_printing() x, y = sym.symbols('x y') expr = 3*x**2 + sym.log(x**2 + y**2 + 1) expr expr.subs({x: 17, y: 42}).evalf() % timeit expr.subs({x: 17, y: 42}).evalf() import math f = lambda x, y: 3*x**2 + math.log(x**2 + y**2 + 1) %timeit f(17, 42) g = sym.lambdify(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: lambdify constructs string representation of python code and uses python eval to compile
14,541
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.sparse %load_ext cython p = 0.01 Nc, Na = 10000, 200 c = np.ones(Nc) a = np.ones(Na) K = np.random.random((Nc, Na)) < p %timeit K.dot(a) %timeit c.dot(K) Ksp = scipy.sparse.csr_matrix(K) %timeit scipy.sparse.csr_matrix(K) np.all(Ksp.dot(a) == K.dot(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: Setup Step2: Dense matrix vector multiplication Step3: Sparse matrix vector multiplication Step6: Sparse matrix vector multiplication using M...
14,542
<ASSISTANT_TASK:> Python Code: !ls -l corpus import os import numpy as np import sys import nltk import unicodedata from collections import Counter, namedtuple import pickle import numpy as np from copy import deepcopy %matplotlib inline def find_text_files(basedir): filepaths = [] for root, dirs, files in os....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Подключим необходимые библиотеки. Стоит выделить nltk - она используется в основном для демонстрации чего можно ожидать от ngram модели. Step2: ...
14,543
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf import random from collections import Counter import utils from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import zipfile dataset_folder_path = 'data' dataset_filename = 'text8.zip' data...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ...
14,544
<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: Create a TFX pipeline for your data with Penguin template Step2: Install required package Step3: Let's check the versions of TFX. Step4: We a...
14,545
<ASSISTANT_TASK:> Python Code: from scipy import stats import numpy as np np.random.seed(42) x = np.random.normal(0, 1, 1000) y = np.random.normal(0, 1, 1000) alpha = 0.01 s, p = stats.ks_2samp(x, y) result = (p <= alpha) <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:
14,546
<ASSISTANT_TASK:> Python Code: import numpy import pandas import statsmodels.formula.api as smf import statsmodels.stats.multicomp as multi data = pandas.read_csv('nesarc_pds.csv', low_memory=False) # S2AQ8A - HOW OFTEN DRANK ANY ALCOHOL IN LAST 12 MONTHS (99 - Unknown) # S2AQ8B - NUMBER OF DRINKS OF ANY ALCOHOL USUAL...
<SYSTEM_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 OLS regression test is run Step2: And as Prob (F-statistics) is less than 0.05, I can discard null hypothesis. Step3: Tukey's HSD post ho...
14,547
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-1', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
14,548
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import matplotlib.pyplot as plt import mne from mne import io from mne.stats import permutation_cluster_test from mne.datasets import sample print(__doc__) data_path = sample.data_path() 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: Set parameters Step2: Read epochs for the channel of interest Step3: Compute statistic Step4: Plot
14,549
<ASSISTANT_TASK:> Python Code: import logging reload(logging) log_fmt = '%(asctime)-9s %(levelname)-8s: %(message)s' logging.basicConfig(format=log_fmt) # Change to info once the notebook runs ok logging.getLogger().setLevel(logging.INFO) %pylab inline import copy import os from time import sleep from subprocess import...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Test Environment set up Step2: Support Functions Step3: Run Antutu and collect scores Step4: After running the benchmark for the specified go...
14,550
<ASSISTANT_TASK:> Python Code: import graphlab products = graphlab.SFrame('amazon_baby_subset.gl/') products products['sentiment'] products.head(10)['name'] print '# of positive reviews =', len(products[products['sentiment']==1]) print '# of negative reviews =', len(products[products['sentiment']==-1]) import json ...
<SYSTEM_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 review dataset Step2: One column of this dataset is 'sentiment', corresponding to the class label with +1 indicating a review with positiv...
14,551
<ASSISTANT_TASK:> Python Code: import jax.numpy as jnp from jax import custom_jvp @custom_jvp def f(x, y): return jnp.sin(x) * y @f.defjvp def f_jvp(primals, tangents): x, y = primals x_dot, y_dot = tangents primal_out = f(x, y) tangent_out = jnp.cos(x) * x_dot * y + jnp.sin(x) * y_dot return primal_out, 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: Custom VJPs with jax.custom_vjp Step2: Example problems Step3: Since it's written in terms of jax.numpy, it's JAX-transformable Step4: But th...
14,552
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" import matplotlib matplotlib.rcParams['text.usetex'] = True matplotlib.rcParams['pdf.fonttype'] = 42 matplotlib.rcParams['ps.fonttype'] = 42 matplotlib.rcParams['mathtext.fontset'] = 'stix' matplotlib.rcParams['font.family'] = 'STIXGeneral' from matplo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: As always, let's do imports and initialize a logger and a new bundle. Step2: Adopt system parameters from Rebassa-Mansergas+ 2019. Step3: Now ...
14,553
<ASSISTANT_TASK:> Python Code: import tensorflow.compat.v1 as tf import numpy as np import shutil print(tf.__version__) CSV_COLUMNS = ['fare_amount', 'pickuplon','pickuplat','dropofflon','dropofflat','passengers', 'key'] LABEL_COLUMN = 'fare_amount' DEFAULTS = [[0.0], [-74.0], [40.0], [-74.0], [40.7], [1.0], ['nokey']...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <h2> 1. Refactor the input </h2> Step2: <h2> 2. Refactor the way features are created. </h2> Step3: <h2> Create and train the model </h2> Step...
14,554
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import samplics from samplics.sampling import SampleSize # target coverage rates expected_coverage = { "Dakar": 0.849, "Ziguinchor": 0.809, "Diourbel": 0.682, "Saint-Louis": 0.806, "Tambacounda": 0.470, "Kaolack": 0.797, ...
<SYSTEM_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 first step is to create and object using the SampleSize class with the parameter of interest, the sample size calculation method, and the st...
14,555
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np s= APRIL--this is the cruellest month, breeding Lilacs out of the dead land, mixing Memory and desire, stirring Dull roots with spring rain. stop_words='the is' s=s.splitlines() y=[] for i in s: c=i.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: Step5: 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 ...
14,556
<ASSISTANT_TASK:> Python Code: import AngularCatalog_class as ac import ImageMask_class as imclass from astropy.io import fits from astropy.io import ascii import numpy as np import numpy.random as rand import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (10, 6) mask_from_ranges = imcl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Ways to create an ImageMask Step2: To see what the mask looks like, we generate some random points and plot them. Step3: Simple enough. Note ...
14,557
<ASSISTANT_TASK:> Python Code: %matplotlib inline from synthetic import mackey_glass import matplotlib.pyplot as plt import theano import theano.tensor as T import numpy floatX = theano.config.floatX class SimpleRNN(object): def __init__(self, input_dim, recurrent_dim): w_xh = numpy.random.normal(0, .01, (...
<SYSTEM_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 now define a class that uses scan to initialize an RNN and apply it to a sequence of data vectors. The constructor initializes the shared var...
14,558
<ASSISTANT_TASK:> Python Code: import pandas as pd import badfish as bf import matplotlib.pyplot as plt %matplotlib inline df = pd.read_csv('data/airquality.csv', index_col=0) mf = bf.MissFrame(df) dir(mf) df.isnull().sum() mf.counts() mf.counts(where = ['Ozone'],how = 'any',columns=['Solar.R','Wind','Temp']) mf....
<SYSTEM_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 to convert the Pandas dataframe to Badfish's missframe. Step2: A MissFrame converts your data to a boolean matrix where a missing cell ...
14,559
<ASSISTANT_TASK:> Python Code: def _correlate(series: pd.Series, correlation_value: int, seed: int = 0): Generates a correlated random variables from a given series. # https://stats.stackexchange.com/questions/38856/how-to-generate-correlated-random-numbers-given-means-variances-and-degree-of np.random.seed(seed)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Simulate some data Step2: These are the collinear variables introduced and their relationship with var2. Step3: Modelling Step4: Fitting a mo...
14,560
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.3,<2.4" import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() print(b.get_parameter(qualifier='ecc')) print(b.get_parameter(qualifier='ecosw', context='component')) 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: As always, let's do imports and initialize a logger and a new Bundle. Step2: Relevant Parameters Step3: Relevant Constraints Step4: Influence...
14,561
<ASSISTANT_TASK:> Python Code: debug_flag = False import datetime import glob import logging import lxml import os import six import xml import xmltodict import zipfile # paper identifier paper_identifier = "BostonGlobe" archive_identifier = "BG_20171002210239_00001" # source source_paper_folder = "/mnt/hgfs/projects...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setup - Imports Step2: Setup - working folder paths Step3: Setup - logging Step4: Setup - virtualenv jupyter kernel Step5: Setup - Initializ...
14,562
<ASSISTANT_TASK:> Python Code: import sys print("python command used for this notebook:") print(sys.executable) import tensorflow as tf print("tensorflow:", tf.__version__) from tensorflow.keras.applications.resnet50 import preprocess_input, ResNet50 model = ResNet50(weights='imagenet') from skimage.io import imread 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: The following checks that scikit-image is properly installed Step2: Optional
14,563
<ASSISTANT_TASK:> Python Code: print ("Hello" + ", World") print(10 + 4) import numpy as np # numpy モジュールのインポート import matplotlib.pyplot as plt # pyplotモジュールのインポート %matplotlib inline # 平均 x = -2, y = -2 の2変量正規分布からデータを100個サンプリングする mean = [-2,-2] cov = [[1,0],[0,1]] x1,y1 = np.random.multivariate_normal(mean, cov, 100)....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 正しく動作すれば,画面に
14,564
<ASSISTANT_TASK:> Python Code: N = 10000 ; MOD = 1000000007 ; F =[0 ] * N ; def precompute() : F[1 ] = 2 ; F[2 ] = 3 ; F[3 ] = 4 ; for i in range(4 , N ) : F[i ] =(F[i - 1 ] + F[i - 2 ] ) % MOD ;   n = 8 ; precompute() ; print(F[n ] ) ; <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:
14,565
<ASSISTANT_TASK:> Python Code: from dkrz_forms import form_widgets form_widgets.show_status('form-retrieval') from dkrz_forms import form_handler, form_widgets #please provide your last name - replacing ... below MY_LAST_NAME = "ki" form_info = form_widgets.check_and_retrieve(MY_LAST_NAME) # To be completed # tob 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: Please provide your last name Step2: Get status information related to your form based request Step3: Contact the DKRZ data managers for form ...
14,566
<ASSISTANT_TASK:> Python Code: import numpy as np import torch import pandas as pd x = load_data() px = pd.DataFrame(x.numpy()) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
14,567
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" } # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: FFJORD Step2: FFJORD bijector Step3: Next, we instantiate a base distribution Step5: We use a multi-layer perceptron to model state_derivativ...
14,568
<ASSISTANT_TASK:> Python Code: import time from collections import namedtuple import numpy as np import tensorflow as tf with open('anna.txt', 'r') as f: text=f.read() vocab = set(text) vocab_to_int = {c: i for i, c in enumerate(vocab)} int_to_vocab = dict(enumerate(vocab)) chars = np.array([vocab_to_int[c] for c ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First we'll load the text file and convert it into integers for our network to use. Step3: Now I need to split up the data into batches, and in...
14,569
<ASSISTANT_TASK:> Python Code: import numpy as np import mne from mne.datasets import sample from mne.preprocessing import ICA from mne.preprocessing import create_eog_epochs, create_ecg_epochs # getting some data ready data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Before applying artifact correction please learn about your actual artifacts Step2: Define the ICA object instance Step3: we avoid fitting ICA...
14,570
<ASSISTANT_TASK:> Python Code: lessons = { "1": "Python is part of a bigger ecosystem (example: Jupyter Notebooks).", "2": "Batteries Included refers to the well-stocked standard library.", "3": "Built-ins inside __builtins__ include the basic types such as...", "4": "__ribs__ == special names == magic ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Continue to "doodle and daydream" as you find the time. Think of ways to describe your day as a Python program. Remember the story of The Car ...
14,571
<ASSISTANT_TASK:> Python Code: import os import mne sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', 'sample_audvis_raw.fif') raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False) raw.crop(tmax=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: Background Step2: If a scalp electrode was used as reference but was not saved alongside the Step3: By default, Step4: .. KEEP THESE BLOCKS ...
14,572
<ASSISTANT_TASK:> Python Code: import pandas as pd table = pd.DataFrame(index=['Bowl 1', 'Bowl 2']) table['prior'] = 1/2, 1/2 table table['likelihood'] = 3/4, 1/2 table table['unnorm'] = table['prior'] * table['likelihood'] table prob_data = table['unnorm'].sum() prob_data table['posterior'] = table['unnorm'] / pr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now I'll add a column to represent the priors Step2: And a column for the likelihoods Step3: Here we see a difference from the previous method...
14,573
<ASSISTANT_TASK:> Python Code: %matplotlib inline import nsfg preg = nsfg.ReadFemPreg() import thinkstats2 as ts live = preg[preg.outcome == 1] wgt_cdf = ts.Cdf(live.totalwgt_lb, label = 'weight') import thinkplot as tp tp.Cdf(wgt_cdf, label = 'weight') tp.Show() import random random.random? import random thousand =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Select live births, then make a CDF of <tt>totalwgt_lb</tt>. Step2: Display the CDF. Step3: Find out how much you weighed at birth, if you can...
14,574
<ASSISTANT_TASK:> Python Code: img = mnist.train.images[2] plt.imshow(img.reshape((28, 28)), cmap='Greys_r') # Size of the encoding layer (the hidden layer) encoding_dim = 32 # feel free to change this value image_shape = mnist.train.images.shape[1] inputs_ = tf.placeholder(tf.float32, (None,image_shape), name="inputs...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We'll train an autoencoder with these images by flattening them into 784 length vectors. The images from this dataset are already normalized suc...
14,575
<ASSISTANT_TASK:> Python Code: import pandas as pd import os import sys import mimetypes import email import glob mht_files = glob.glob(os.path.join(os.path.curdir, '*.mht')) for filepath in mht_files: # get the name of the file, e.g. ./31521derp.mht -> 31521derp filename_base = os.path.split(filepath)[-1].sp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: ref Step2: the next cell parses the mht-files, splits them by content type (html, jpg, etc.) and writes the output of the chunks to the hard di...
14,576
<ASSISTANT_TASK:> Python Code: import xray ds = xray.open_dataset('https://motherlode.ucar.edu/repository/opendap/41f2b38a-4e70-4135-8ff8-dbf3d1dcbfc1/entry.das', decode_times=False) print(ds) print(ds['th']) th = ds['th'].values[0][0] print(th) print(ds['grid_type_code']) print(ds['grid_typ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Dimensions, Coordinates, Data Variables Step2: potential temperature (th) Step3: To Visualize the Data, We have to Decrypt the Projection Step...
14,577
<ASSISTANT_TASK:> Python Code: def this_and_prev(iterable): iterator = iter(iterable) prev_item = None curr_item = next(iterator) for next_item in iterator: yield (prev_item, curr_item) prev_item = curr_item curr_item = next_item yield (prev_item, curr_item) for i,j in this_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: По аналогии требуется написать функцию, которая будет возвращать текущее и следующее значения. Step2: <h2>Problem 2. SQL / Python</h2> Step3: ...
14,578
<ASSISTANT_TASK:> Python Code: !pip install lightgbm !pip install shap %tensorflow_version 1.x import lzma from google.colab import drive import numpy as np import tensorflow as tf import keras from keras import backend as K from keras.layers import Input, Dense from keras.models import Model import matplotlib.pyplot ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Importing packages and defining functions and variables Step2: Defining autoencoder model, Training and evaluation functions Step3: Mount goog...
14,579
<ASSISTANT_TASK:> Python Code: import numpy as np import tensorflow as tf with open('../sentiment_network/reviews.txt', 'r') as f: reviews = f.read() with open('../sentiment_network/labels.txt', 'r') as f: labels = f.read() reviews[:2000] from string import punctuation all_text = ''.join([c for c in reviews if...
<SYSTEM_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 preprocessing Step2: Encoding the words Step3: Encoding the labels Step4: Okay, a couple issues here. We seem to have one review with ze...
14,580
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.integrate import odeint from IPython.html.widgets import interact, fixed def lorentz_derivs(yvec, t, sigma, rho, beta): Compute the the derivatives for the Lorentz system at yvec(t). # YOUR CODE HERE...
<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: Lorenz system Step4: Write a function solve_lorenz that solves the Lorenz system above for a particular initial condition $[x(0),y(0),z(0)]$. Y...
14,581
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections # tensorflow import tensorflow as tf print('Expected TensorFlow version is v1.3.0 or higher') print('Your TensorFlow version:', tf.__version__) # data manipulati...
<SYSTEM_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) Simple Linear Regression with low-level TensorFlow Step2: Create training data Step3: Plot the training data Step4: The Model Step5: The ...
14,582
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: トレーニングループの新規作成 Step2: はじめに Step3: ミニバッチの勾配を使用してカスタムトレーニングループでトレーニングします。 Step4: トレーニングループは以下のとおりです。 Step5: メトリックの低レベルの処理 Step6: トレーニングと評価のルー...
14,583
<ASSISTANT_TASK:> Python Code: 4*2 import os # Load the os library import os # Load the request module import urllib.request # Import SSL which we need to setup for talking to the HTTPS server import ssl ssl._create_default_https_context = ssl._create_unverified_context # Create a directory os.mkdir('img_align_celeba...
<SYSTEM_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 press 'a' or 'b' to create new cells. You can also use the toolbar to create new cells. You can also use the arrow keys to move up and dow...
14,584
<ASSISTANT_TASK:> Python Code: mc_env = gym.make("MountainCar-v0") mc_n_weights, mc_feature_vec = fourier_fa.make_feature_vec( np.array([mc_env.low, mc_env.high]), n_acts=3, order=2) mc_experience = linfa.init(lmbda=0.9, ...
<SYSTEM_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 try some arbitrary thetas Step2: If the bounds of the states are [0, n], the ratio between symbolic and numeric results is $1/n^{n_{dim}-...
14,585
<ASSISTANT_TASK:> Python Code: get_ipython().magic('load_ext cellevents') get_ipython().magic('load_ext autoreload') get_ipython().magic('autoreload 2') from logcon import log from xdrive import aws, server, apps from xdrive.drive import Drive import fabric.api as fab from fabric.state import connections apps.setdebug(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configuration Step2: Setup programs and data using a free instance Step3: Download stuff via ssh Step4: All of the setup time so far has used...
14,586
<ASSISTANT_TASK:> Python Code: # imports import numpy as np import pandas as pd import os import cv2 import matplotlib.pyplot as plt import skimage.feature from tqdm import tqdm # nice progress bars %matplotlib inline # constants TRAIN_PATH = '../data/Train/' DOTTED_PATH = '../data/TrainDotted/' OUT_PATH = '../output/'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Due to the fact some images are mismatched in the training set, and will not work for this method (reference to datacanary's post), I removed th...
14,587
<ASSISTANT_TASK:> Python Code: def print1(a , n ) : for i in range(0 , n + 1 ) : print(a[i ] , end = "▁ ")  print("")  def sort(a , n ) : for i in range(n , 0 , - 1 ) : for j in range(n , n - i , - 1 ) : if(a[j ] > a[j - 1 ] ) : a[j ] , a[j - 1 ] = a[j - 1 ] , a[j ]    print1(a , n )  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:
14,588
<ASSISTANT_TASK:> Python Code: from bokeh.io import output_notebook from bokeh.plotting import * from matmodlab2 import * from numpy import * import numpy as np from plotting_helpers import create_figure output_notebook() %pycat ../matmodlab2/materials/mooney_rivlin.py from sympy import Symbol, Matrix, Rational, symb...
<SYSTEM_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 name='basic'></a> Step2: <a name='verify'></a> Step3: We now exercise the Mooney-Rivlin material model using Matmodlab
14,589
<ASSISTANT_TASK:> Python Code: # Conformal Model, Amsterdam convention. Dorst et al. p. 361 from sympy import * from galgebra.ga import Ga from galgebra.mv import * # from lt import * # from sympy import * cm3coords = (o,x,y,z,infty) = symbols('o 1 2 3 infty', real=True) cm3g = '0 0 0 0 -1, 0 1 0 0 0, 0 0 1 0 0, 0 0 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: <h4>* Create direct representations of geometric objects *</h4> Step2: <h4>* Create dual representations of geometric objects *</h4> Step3: <h...
14,590
<ASSISTANT_TASK:> Python Code: audience1_name = "" #@param {type:"string"} audience1_file_location = "" #@param {type:"string"} audience1_size = 0#@param {type:"integer"} audience2_name = "" #@param {type:"string"} audience2_file_location = "" #@param {type:"string"} audience2_size = 0 #@param {type:"integer"} audienc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import Libs and configure Plotly Step2: Mount Drive and read the Customer Match Insights CSVs Step3: Define Plot Function Step4: Define TF-ID...
14,591
<ASSISTANT_TASK:> Python Code: # Figure 1 Image(url= "http://3.bp.blogspot.com/_UpN7DfJA0j4/TJtUBWPk0SI/AAAAAAAAABY/oWPMtmqJn3k/s1600/mnist_originals.png", width=200, height=200) from __future__ import print_function # Use a function definition from future version (say 3.x from 2.7 interpreter) import matplotlib.image...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Goal Step2: In the block below, we check if we are running this notebook in the CNTK internal test machines by looking for environment variable...
14,592
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS import math from IPython.display import HTML HTML('../style/code_toggle.html') import math from matplotlib import rcParams rcParams['tex...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import section specific modules Step4: 2.5 Convolution<a id='math Step5: Figure 2.5.1 Step7: Figure 2.5.2 Step9: Figure 2.5.3
14,593
<ASSISTANT_TASK:> Python Code: # Load the software ("import the module" in python jargon) from fermi_school_like import * # Import matplotlib for plotting from matplotlib import pyplot as plt # This show the plots inline in the notebook %matplotlib inline # Define number of bins in our data n_bins = 100 # Generate bin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setup our generative process Step2: Likelihood analysis Step3: Bias Step4: The fact that the average the MLE value approaches the true value ...
14,594
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import xarray as xr import matplotlib.pyplot as plt ds = xr.tutorial.open_dataset("rasm").load() ds month_length = ds.time.dt.days_in_month month_length # Calculate the weights by grouping by 'time.season'. weights = ( month_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Open the Dataset Step2: Now for the heavy lifting
14,595
<ASSISTANT_TASK:> Python Code: import pandas as pd pd.__version__ nrg = pd.read_csv('energy_consumption.csv'); nrg.describe(include='all') nrg.head() nrg.dtypes # https://docs.python.org/3/library/functions.html#type # https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.iat.html type(nrg.iat[0,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: The rows contains the electricity used in each hour for a one year period. Step2: Both pandas and Numpy use the concept of dtypes as data types...
14,596
<ASSISTANT_TASK:> Python Code: platform = 'lendingclub' store = pd.HDFStore( '/Users/justinhsi/justin_tinkering/data_science/lendingclub/{0}_store.h5'. format(platform), append=True) loan_info = store['train_filtered_columns'] columns = loan_info.columns.values # checking dtypes to see which columns need on...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Until I figure out a good imputation method (e.g. bayes PCA), just drop columns with null still Step2: straight up out of box elastic net with ...
14,597
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-3', '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...
14,598
<ASSISTANT_TASK:> Python Code: %pylab inline import os import pickle import warnings; warnings.filterwarnings('ignore') import numpy as np import pandas as pd import pystan import scipy import seaborn as sns; sns.set_context('notebook') from Bio import SeqIO import tools # load clean, normalised, indexed data data = 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: Building the model <a id="building"></a> Step3: Stan model construction <a id="build_stan"></a> Step4: <div class="alert-danger"> Step5: Extr...
14,599
<ASSISTANT_TASK:> Python Code: def car_race_collision(n: int): return 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: