Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
11,000
<ASSISTANT_TASK:> Python Code: %pylab inline import pandas as pd import seaborn as sns raw_df = pd.read_csv("/home/brianb/Downloads/odsc_football_modeling_data_2.csv") df_no_week_1 = raw_df[raw_df.week > 1] ff_cols = raw_df.columns sort(ff_cols.values) raw_df[ff_cols].head() df_no_week_1[ff_cols].head() raw_df = pd...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Meet the data Step2: What columns do we have? Step3: A quick look at our data Step4: Where do we begin? Step5: What did that just do? Ste...
11,001
<ASSISTANT_TASK:> Python Code: %pylab inline import GPyOpt from numpy.random import seed import numpy as np seed(123) func = GPyOpt.objective_examples.experimentsNd.alpine1(input_dim=9) mixed_domain =[{'name': 'var1', 'type': 'continuous', 'domain': (-5,5),'dimensionality': 3}, {'name': 'var3', 'ty...
<SYSTEM_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 will use the Alpine1 function, that it is available in the benchmark of functions of the package. This function is defined for arbitrary dime...
11,002
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import numpy as np import pandas as pd import matplotlib.pyplot as plt import cellpy from cellpy import log from cellpy import cellreader from cellpy import prms from cellpy import prmreader from cellpy.utils import batch # import holoviews as hv %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: 4. Looking at the data Step2: Cycles Step3: Selecting specific cells and investigating them Step4: Let's see how the smoothing (interpolation...
11,003
<ASSISTANT_TASK:> Python Code: from __future__ import division import numpy as np import pandas as pd from scipy import stats from statsmodels.sandbox.stats.multicomp import multipletests %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns from itertools import combinations from IPython.core.inter...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Классификатор C4.5 и три его модификации Step2: Сколько статистически значимых на уровне 0.05 различий мы обнаружили? Step3: Сравнивая 4 класс...
11,004
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from sklearn import preprocessing data = load_data() df_out = pd.DataFrame(preprocessing.scale(data), index=data.index, columns=data.columns) <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:
11,005
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline data = pd.read_csv("../data/GOOG.csv").ix[:,["Date", "Open"]] data.sort_values(by="Date", inplace=True) data.reset_index(inplace=True) rate = np.zeros_like(data.Date) n = 0 m = 0 for d in data.Date:...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: For the interest rate to be used, observing the charts of LIBOR rates, I will pick a linear model, starting from 2.5% at Jan-1-2005, going to 6%...
11,006
<ASSISTANT_TASK:> Python Code: import pandas as pd import networkx as nx import community import itertools import matplotlib.pyplot as plt import numpy as np import re %matplotlib inline legacybib = pd.read_csv("ACMDL201612108240806.csv") legacybib.columns legacybib.head(3) assert 0, sum(legacybib.id.duplicated()) ...
<SYSTEM_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 loading, sanitization and massage Step2: The available data columns are Step3: A peek at the topmost data items. Step4: Does the id fiel...
11,007
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns; sns.set() import numpy as np def make_data(N, f=0.3, rseed=1): rand = np.random.RandomState(rseed) x = rand.randn(N) x[int(f * N):] += 5 return x x = make_data(1000) hist = plt.hist(x, bins=30) h...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Motivating KDE Step2: Let's plot this dataset. Step3: Or, more properly Step4: The normalization simply changes the scale on the y-axis Step5...
11,008
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display def soliton(x, t, c, a): Return phi(x, t) for a soliton wave with constants c and a. if type(x) == np.nda...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Using interact for animation with data Step3: To create an animation of a soliton propagating in time, we are going to precompute the soliton d...
11,009
<ASSISTANT_TASK:> Python Code: lc_data = pd.DataFrame.from_csv('./lc_dataframe(cleaning).csv') lc_data = lc_data.reset_index() lc_data.tail() x = lc_data['grade'] sns.distplot(x, color = 'r') plt.show() x = lc_data['sub_grade'] sns.distplot(x, color = 'g') plt.show() x = lc_data['emp_title'] plt.hist(x) plt.show() ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: V4 grade (범주형 데이터형) Step2: V5 sub_grade (범주형 데이터형) Step3: V6 emp_title (범주형 데이터형) Step4: V7 emp_length (범주형 데이터형) Step5: V8 home_ownership (...
11,010
<ASSISTANT_TASK:> Python Code: # Additional Resources 📚 import pickle import faiss def load_data(): with open('movies.pickle', 'rb') as f: data = pickle.load(f) return data data = load_data() vectors = data["vector"] names = data["name"] data faiss.MatrixStats(vectors).comments.split("\n") index = fa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Motivation 🎇 Step2: Strategies for Exact Nearest Neighbors 🧠 Step3: But It’s Not All Rainbows And Unicorns 🦄 Step4: Vector Encoding using ...
11,011
<ASSISTANT_TASK:> Python Code: %time "list(range(1000000)); print('ololo')" def my_cool_function(a, b): return a + b def my_cool_function2(a: int, b: int) -> int: return a + b def my_cool_function(a, b): return a + b my_cool_function2("foo", "bar") def main(): # here be dragons return if __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: Вопрос Step2: Заготовка для типичного скрипта на Python Step3: Модули Step4: Обработка ошибок Step5: Генерация списков (списковые включения)...
11,012
<ASSISTANT_TASK:> Python Code: # Imports import math import matplotlib.pyplot as plt plt.style.use('seaborn-darkgrid') %matplotlib inline def logistic_algo(x, max_value, min_value=1.5, c=0.85, k=0.1): Algorithm for scaling a given point's radius according to a Logistic Function. phi = c * (10**(int(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: Step2: While this procedure is written in JavaScript for use by D3.js during the simulation, an implementation in python is shown below for simplicity....
11,013
<ASSISTANT_TASK:> Python Code: #|all_multicuda #hide from fastai.vision.all import * from fastai.distributed import * from fastai.vision.models.xresnet import * from accelerate import notebook_launcher from accelerate.utils import write_basic_config #from accelerate.utils import write_basic_config #write_basic_config...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Overview Step2: We need to setup Accelerate to use all of our GPUs. We can do so quickly with write_basic_config () Step3: Next let's download...
11,014
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt a_true = 0.5 b_true = 2.0 c_true = -4.0 N = 30 xdata = np.linspace(-5, 5, N) dy = 2 ydata = a_true*xdata**2 + b_true*xdata + c_true + np.random.normal(0.0, dy, size = N) plt.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: Fitting a quadratic curve Step2: First, generate a dataset using this model using these parameters and the following characteristics Step3: No...
11,015
<ASSISTANT_TASK:> Python Code: # Import modules that contain functions we need import pandas as pd import numpy as np %matplotlib inline import matplotlib.pyplot as plt # Our data is the dichotomous key table and is defined as the word 'key'. # key is set equal to the .csv file that is read by pandas. # The .csv file 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: Step 1 - Creating a Checkpoint Step1: Pre-Questions Step2: PART 1 Step3: Use and modify the section of code below to answer questions 3-5. Step4: PA...
11,016
<ASSISTANT_TASK:> Python Code: import analysis3 as a3 reload(a3) import time def time_function(fun, *args): start = time.time(); result = fun(*args); run_time = time.time() - start; minutes = run_time / 60; print('RUN TIME: %f s (%f m)' % (run_time, minutes)); return result; token = 's275_to_ar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Timing individual functions Step2: Testing pipeline as a whole
11,017
<ASSISTANT_TASK:> Python Code: !ls ../scripts/hello-world*.py !cat ../scripts/hello-world.py !python scripts/hello-world.py import math import math x = math.cos(2 * math.pi) print(x) from math import * x = cos(2 * pi) print(x) from math import cos, pi x = cos(2 * pi) print(x) import math print(dir(math)) help(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: Jupyter Notebooks Step2: This includes the whole module and makes it available for use later in the program. For example, we can do Step3: Alt...
11,018
<ASSISTANT_TASK:> Python Code: import os import mne sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', 'sample_audvis_filt-0-40_raw.fif') raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False) events_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: Annotating bad spans of data Step2: .. sidebar Step3: Now we can confirm that the annotations are centered on the EOG events. Since Step4: Se...
11,019
<ASSISTANT_TASK:> Python Code: %matplotlib inline %load_ext metatab %load_ext autoreload %autoreload 2 %mt_lib_dir lib import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np import metatab as mt import seaborn as sns; sns.set(color_codes=True) import sqlite3 import statsmodels 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: Source Data Step2: Procedure Step3: Then, we group the dataset by valueh_group and collect all of the income values for each group. These grou...
11,020
<ASSISTANT_TASK:> Python Code: import numpy as np np.__version__ author = 'kyubyong. longinglove@nate.com' x = np.array([1, 2, 6, 4, 2, 3, 2]) out, indices = np.unique(x, return_inverse=True) print "unique elements =", out print "reconstruction indices =", indices print "reconstructed =", out[indices] x = np.array([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: Making proper sets Step2: Boolean operations Step3: Q3. Find the unique intersection of x and y. Step4: Q4. Find the unique elements of x tha...
11,021
<ASSISTANT_TASK:> Python Code: import swat conn = swat.CAS(host, port, username, password) cls = conn.read_csv('https://raw.githubusercontent.com/sassoftware/sas-viya-programming/master/data/class.csv', casout=dict(name='class', caslib='casuser')) cls out = conn.datastep.runcode(''' data bmi(ca...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now we need to get some data into our session. Step2: The datastep.runcode Action Step3: We can pull the output table DataFrame out using the ...
11,022
<ASSISTANT_TASK:> Python Code: # Run some setup code import numpy as np import matplotlib.pyplot as plt # This is a bit of magic to make matplotlib figures appear inline in the notebook # rather than in a new window. %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots plt.rcParam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load data Step2: Extract Features Step3: Train SVM on features Step4: Neural Network on image features
11,023
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'inpe', 'sandbox-2', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<SYSTEM_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...
11,024
<ASSISTANT_TASK:> Python Code: from IPython.display import Image import pandas pandas.set_option('display.precision', 4) pandas.read_csv('img/old-tagging-parts.csv').drop(['AUC, with untag', '$\Delta$ AUC, with untag'], axis=1) pandas.set_option('display.precision', 4) pandas.read_csv('img/old-tagging-parts-MC.csv')....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Old tagging Step2: MC Step3: Taggers combination Step4: Additional information Step5: Check calibration of mistag Step6: Check calibration ...
11,025
<ASSISTANT_TASK:> Python Code: Image(url="https://raw.githubusercontent.com/birdsarah/bokeh-miscellany/master/cut-off-tooltip.png", width=400, height=400) from IPython.core.display import HTML HTML( <style> div.output_subarea { overflow-x: visible; } </style> ) from bokeh.plotting import figure, ColumnDataSour...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Unfortunately Bokeh can't solve this as Bokeh can't control the CSS of the parent element, which belongs to Jupyter. This can be solved in two w...
11,026
<ASSISTANT_TASK:> Python Code: urls = ['http://www.domain.com', 'https://somedomain.com', 'http://my-domain-123.net', 'https://google.com', 'http://www.foo.com', 'https://bar-baz3.com', 'ftp://domain2.com'] import re # A complete match checking for the presence of some al...
<SYSTEM_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. Get domains (without protocols) (including extension, e.g. .com) for URLs with both http and https protocols. Step2: 3. Below is a list of l...
11,027
<ASSISTANT_TASK:> Python Code: import order as od import scinum as sn # campaign c_2017 = od.Campaign("2017_13Tev_25ns", 1, ecm=13, bx=25) # processes p_data = od.Process("data", 1, is_data=True, label="data", ) p_ttH = od.Process("ttH", 2, label=r"$t\bar{t}H$", xsecs={ 13: sn.Number(0.5071, {"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: General, Analysis-unrelated Setup Step2: Task Step3: Analysis Setup Step4: <hr /> Step5: Task Step6: <hr /> Step7: Task Step8: <hr /> Ste...
11,028
<ASSISTANT_TASK:> Python Code: import pandas as pd %matplotlib inline import numpy as np import pydotplus from pandas.tools.plotting import scatter_matrix import matplotlib.pyplot as plt from sklearn import datasets from sklearn import tree from sklearn.externals.six import StringIO from sklearn.cross_validation impor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Redo the model with a 75% - 25% training/test split and compare the results. Are they better or worse than before? Discuss why this may be. Step...
11,029
<ASSISTANT_TASK:> Python Code: from pyproj import Geod g = Geod(ellps='WGS84') lat1,lon1 = (40.7143528, -74.0059731) # New York, NY lat2,lon2 = (1.359, 103.989) # Delhi, India az12,az21,dist = g.inv(lon1,lat1,lon2,lat2) az12,az21,dist # using geograhiclib: # Compute path from 1 to 2 from geographiclib.geodesic impo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set two location for which we want compute the measurments, in this example $P_1$ Step2: Note Step3: Geodetic curve Step4: Extract Latitude a...
11,030
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from PIL import Image import numpy as np from scipy.misc import imread, imresize from imagenet_classes import class_names import os #File Path # filepath_input = "./data/run/" #input csv file path filepath_ckpt = "./ckpt/model_weight.ckpt" #weight saver check 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: file_path Step2: LSTM - Hyper Params Step3: vgg16 Step4: load_vgg16 Step5: File Info Step6: Text Reader Step7: LSTM First Layer Step8: ma...
11,031
<ASSISTANT_TASK:> Python Code: %matplotlib inline from time import time import numpy as np import matplotlib.pyplot as plt from matplotlib.offsetbox import AnnotationBbox, OffsetImage import os from sklearn.datasets import fetch_mldata # Fetch MNIST dataset and create a local copy. if os.path.exists('mnist.npz'): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Visualizing MNIST Step2: Now it's your turn to plot some random representatives from each of 10 (obviously) available classes Step3: The whole...
11,032
<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: Constructing a Text Generation Model Step2: Get the Dataset Step3: First 10 Songs Step4: Create Sequences and Labels Step5: Train a Text Gen...
11,033
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'sandbox-1', 'land') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
11,034
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy from scipy import io eeg = np.load("data/eeg_eyes_opened.npy") num_trials, num_channels, num_samples = np.shape(eeg) eeg_ts = np.squeeze(eeg[0, :, :]) import warnings warnings.simplefilter(action='ignore', category=FutureWarning) from dyconnmap.fc import 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: Static connectivity Step2: Define the frequency band we are interested to examine, in Hz Step3: Define the sampling frequency, in Hz Step5: W...
11,035
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import fredpy as fp import requests import os import matplotlib.pyplot as plt plt.style.use('classic') %matplotlib inline url = 'https://www.philadelphiafed.org/-/media/frbp/assets/surveys-and-data/survey-of-professional-forecasters/historical-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: Download forecast data from SPF Step2: Manage forecast data Step3: Download and manage data from FRED Step4: Prepare dataset and export Step5...
11,036
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as mpyplot mpyplot.plot([1,2,3,4]) mpyplot.ylabel('some numbers') mpyplot.show() mpyplot.plot([1,2,3,4], [1,4,9,16]) import matplotlib.pyplot as mpyplot mpyplot.plot([1,2,3,4], [1,4,9,16], 'ro') mpyplot.axis([0, 6, 0, 20]) mpyplot.show() seq = 'ATGGTGCATCTGACTC...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: plot() is a versatile command, and will take an arbitrary number of arguments. For example, to plot x versus y, you can issue the command Step2:...
11,037
<ASSISTANT_TASK:> Python Code: # print something print(c) # what is hello_str # reverse indexing # stepwise indexing (start:stop:step) my_dict = {'one':1, 'two':2, 'three':3} print(my_dict['one']) # how to test if certain key is in dict print('one' in my_dict) print('four' in my_dict) ### example immutable x = 10 y...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Numerical Data Types Step2: Sequence Data Types Step3: Tuple Step4: Boolean Step5: <a id='flowcontrol'/> Step9: you see Step10: Creating y...
11,038
<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: Title Step2: Resources Step3: Run the model on a single batch of data, and inspect the output Step4: Compile the model for training
11,039
<ASSISTANT_TASK:> Python Code: export CHGDISABLE=1 ~/hg/hg debugpython << 'EOS' from timeit import timeit from bindings import tracing def nop(): pass @tracing.wrapfunc def wrap(): pass @tracing.wrapfunc @tracing.meta(lambda: [("color", "blue")]) def wrap_meta(): pass def bindings(tracer=tracing.singleton): id = tr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Trace-Them-All as a Profiler Step2: The ASCII Format Step3: Annotated metadata (like perftrace) Step4: Call counts (like traceprof) Step5: T...
11,040
<ASSISTANT_TASK:> Python Code: # Load pickled data import pickle from keras.datasets import cifar10 from sklearn.model_selection import train_test_split # TODO: Fill this in based on where you saved the training and testing data #training_file = "traffic-signs-data/train.p" #validation_file = "traffic-signs-data/valid....
<SYSTEM_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: Include an exploratory visualization of the dataset Step3: Step 2 Step4: Model Architecture Step5: Train, Validate and Test th...
11,041
<ASSISTANT_TASK:> Python Code: import keras # Constants Num_Classes = Num_Classes batch_size = 4 lr = 0.01 # Helper Functions # get_batches(..) copied from utils.py # gen.flow_from_directory() is an iterator that yields batches of images # from a directory indefinitely. from keras.preprocessing import image def get_bat...
<SYSTEM_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. Basic Linear Model Step2: 2. 1-Layer Neural Network
11,042
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'sandbox-2', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributo...
<SYSTEM_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...
11,043
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import bayesloop as bl import sympy.stats as stats from tqdm import tqdm_notebook import matplotlib.pyplot as plt import seaborn as sns sns.set_color_codes() # use seaborn colors # minute-scale pricing data prices = np.array( [ 221.14 , 221.09 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Persistent random walk model Step2: Online study Step3: <div style="background-color Step4: Before any data points are passed to the study in...
11,044
<ASSISTANT_TASK:> Python Code: from nltk.grammar import DependencyGrammar from nltk.parse import ( DependencyGraph, ProjectiveDependencyParser, NonprojectiveDependencyParser, ) treebank_data = Pierre NNP 2 NMOD Vinken NNP 8 SUB , , 2 P 61 CD 5 NMOD ye...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: We can load different Dependency Grammar parsers from NLTK Step3: Dependency Version of the Penn Treebank Step5: "Using the output of zpar (li...
11,045
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' class DLProgress(tqdm): last_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: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
11,046
<ASSISTANT_TASK:> Python Code: import random import numpy as np from cs231n.data_utils import load_CIFAR10 import matplotlib.pyplot as plt from __future__ import print_function %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots plt.rcParams['image.interpolation'] = 'nearest' plt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load data Step2: Extract Features Step3: Train SVM on features Step4: Inline question 1
11,047
<ASSISTANT_TASK:> Python Code: from keras.datasets import mnist # use Keras to import pre-shuffled MNIST database (X_train, y_train), (X_test, y_test) = mnist.load_data() print("The MNIST database has a training set of %d examples." % len(X_train)) print("The MNIST database has a test set of %d examples." % len(X_test)...
<SYSTEM_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. Visualize the First Six Training Images Step2: 3. View an Image in More Detail Step3: 4. Rescale the Images by Dividing Every Pixel in Ever...
11,048
<ASSISTANT_TASK:> Python Code: friends = ['John', 'Bob', 'Mary'] stuff_to_pack = ['socks','shirt','toothbrush'] print(friends) print(stuff_to_pack) #list of integers print([1, 24, 76]) #list of strings print(['red', 'yellow', 'blue']) #mixed list print(['red', 24, 98.6]) #list with a list included print([1, [5, 6], 7]...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Square brackets surround lists, and commas separate the elements in the list Step2: Please note that there are two ways of creating an empty li...
11,049
<ASSISTANT_TASK:> Python Code: import SimpleITK as sitk import numpy as np %run update_path_to_download_script from downloaddata import fetch_data as fdata %matplotlib inline import matplotlib.pyplot as plt import gui from ipywidgets import interact, fixed def display_with_overlay( segmentation_number, slice_numbe...
<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: Utility method for display Step3: Fetch the data Step4: Derive a reference Step5: Evaluate segmentations using the reference Step6: Improved...
11,050
<ASSISTANT_TASK:> Python Code: import datetime import json import os import pprint import random import string import sys import tensorflow as tf assert 'COLAB_TPU_ADDR' in os.environ, 'ERROR: Not connected to a TPU runtime; please see the first cell in this notebook for instructions!' TPU_ADDRESS = 'grpc://' + os.envi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Secondly, prepare and import BERT modules. Step2: Thirdly, prepare for training Step3: Now, let's play!
11,051
<ASSISTANT_TASK:> Python Code: regimentNames = ['Night Riflemen', 'Jungle Scouts', 'The Dragoons', 'Midnight Revengence', 'Wily Warriors'] # create a variable for the for loop results regimentNamesCapitalized_f = [] # for every item in regimentNames for i in regimentNames: # capitalize the item and add it to regim...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Using A For Loop Step2: Using Map() Step3: Map the capitalizer function to regimentNames, convert the map into a list, and view the variable S...
11,052
<ASSISTANT_TASK:> Python Code: %%capture !pip install --upgrade trax import trax from trax import layers as tl from trax.supervised import training # Trax offers the WideResnet architecture in it's models module from trax.models.resnet import WideResnet trax.fastmath.set_backend('tensorflow-numpy') %%capture train_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: Introduction Step2: Downloading Dataset Step3: Batch Generator Step4: Model Architecture Step5: When we have our model and the data, we use ...
11,053
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'svg' import numpy as np from exact_solvers import euler from utils import riemann_tools as rt from ipywidgets import interact from ipywidgets import widgets State = euler.Primitive_State def roe_averages(q_l, q_r, gamma=1.4): 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: Approximate solvers for the Euler equations of gas dynamics Step2: An implementation of this solver for use in Clawpack can be found here. Rec...
11,054
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd %matplotlib inline import matplotlib.pyplot as plt plt.style.use('ggplot') data = pd.Series(np.random.rand(100)) actual_mean = data.mean() print('{:.3f}'.format(actual_mean)) def calc_sample_means(data, n): Make n bootstrap samples from data an...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: For examples, let's say we have an array of values and their mean. Step3: How stable is this measure? To answer this, we'll sample with replace...
11,055
<ASSISTANT_TASK:> Python Code: %matplotlib inline import os import tarfile as TAR import sys from datetime import datetime from PIL import Image import warnings import json import pickle import zipfile from math import * import numpy as np import pandas as pd from sklearn.cluster import MiniBatchKMeans import matplotli...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Most likely, the ImageHash library will be missing in a typical setup. The following cell, installs the library. Step2: Feature Extraction Step...
11,056
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.style.use('ggplot') %matplotlib inline data = pd.read_csv('american_presidents.csv', header=0, index_col=None) data data.describe() data.plot(x='order',y='height_cm', color='blue') data.plot('order', kind='hist', c...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: The standard bootstrap method Step5: The Bayesian bootstrap (with a Dirichlet prior) Step6: Test both the weighted statistic method and the we...
11,057
<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: Introduction to tensor slicing Step2: Extract tensor slices Step3: Alternatively, you can use a more Pythonic syntax. Note that tensor slices ...
11,058
<ASSISTANT_TASK:> Python Code: # Generative model mu_x = 10.0 sigma_x = 2.0 x_s = edm.Normal(mu_x, sigma_x) # Sample data produced by model n_samples = 100 samples = np.zeros(n_samples) with tf.Session() as sess: for i in range(n_samples): samples[i] = sess.run(x_s) # Descriptive statistics print('Mean: {}'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Point estimate of model parameters Step2: Posterior estimate of model parameters
11,059
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np import matplotlib.pyplot as plt import mne from mne.forward import make_forward_dipole from mne.evoked import combine_evoked from mne.simulation import simulate_evoked from nilearn.plotting import plot_anat from nilearn.datasets import load_mni152_t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's localize the N100m (using MEG only) Step2: We can also plot the result using outlines of the head and brain. Step3: Plot the result in 3...
11,060
<ASSISTANT_TASK:> Python Code: # Authors: Denis Engemann <denis.engemann@gmail.com> # Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import numpy as np import mne from mne.preprocessing import ICA from mne.preprocessing import create_ecg_epochs, create_eog_epochs from ...
<SYSTEM_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 paths and prepare raw data. Step2: 1) Fit ICA model using the FastICA algorithm. Step3: 2) identify bad components by analyzing latent s...
11,061
<ASSISTANT_TASK:> Python Code: # FUSEDWind imports from fusedwind.plant_flow.vt import GenericWindFarmTurbineLayout, WTPC, WeibullWindRoseVT, GenericWindRoseVT # Topfarm lib imports from topfarm.aep import AEP from topfarm.layout_distribution import spiral, DistributeSpiral, DistributeXY, DistributeFilledPolygon from t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading all the input data Step2: Plotting the inputs Step3: Plotting the depth Step4: The red points indicate the position of the baseline t...
11,062
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy import constants import pygmsh from MeshedFields import * with pygmsh.geo.Geometry() as geom: Lx = 0.215 Ly = 0.150 Ri = 0.002 lca = 0.005 lci = 0.001 stretch = 50.0 p1 = geom.add_point([Lx/2.0*stretch, Ly/2.0], lca) p2 =...
<SYSTEM_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 meshed screen with a central hole Step2: The z-position of all mesh points is computed to lay on a toroid with 1.625 m focal length.<b...
11,063
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf 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' dataset_name = 'Text8 Dataset' class DLProgress(tq...
<SYSTEM_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. ...
11,064
<ASSISTANT_TASK:> Python Code: x = True print(x) print(type(x)) def can_run_for_president(age): Can someone of the given age run for president in the US? # The US Constitution says you must be at least 35 years old return age >= 35 print("Can a 19-year-old run for president?", can_run_for_president(19)) 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: Step2: Rather than putting True or False directly in our code, we usually get boolean values from boolean operators. These are operators that answer y...
11,065
<ASSISTANT_TASK:> Python Code: import numpy import nibabel import os import nilearn.plotting import matplotlib.pyplot as plt from statsmodels.regression.linear_model import OLS import nipype.interfaces.fsl as fsl import scipy.stats if not 'FSLDIR' in os.environ.keys(): raise Exception('This notebook requires that 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: Set up default parameters. We use 28 subjects, which is the median sample size of the set of fMRI studies published in 2015 that were estimated...
11,066
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np def tokenize(s, stop_words=None, punctuation='`~!@#$%^&*()_-+={[}]|\:;"<,>.?/}\t'): Split a string into a list of words, removing punctuation and stop words. all_words= [] for line in s.splitlines(): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Word counting Step5: Write a function count_words that takes a list of words and returns a dictionary where the keys in the dictionary are the ...
11,067
<ASSISTANT_TASK:> Python Code:: from sklearn.tree import DecisionTreeRegressor from sklearn.metrics import mean_squared_error, mean_absolute_error, max_error, explained_variance_score, mean_absolute_percentage_error # initialise & fit Decision Tree Regressor model = DecisionTreeRegressor(criterion='squared_error', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
11,068
<ASSISTANT_TASK:> Python Code: a = pk.load(open("slide14.pkl","rb"), encoding='latin1') print("DATA = ", a) print("ONE ROW = ", a[0]) plt.rcParams['figure.figsize'] = [6,4] plt.rcParams['axes.labelsize'] = 14 plt.rcParams['xtick.labelsize'] = 14 plt.rcParams['ytick.labelsize'] = 14 plt.rcParams['legend.fontsize'] = 12...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Visualizing the data
11,069
<ASSISTANT_TASK:> Python Code: def function_plot(ω0=1, ω1=1): # Define x axis range x = np.linspace(-4*np.pi, 4*np.pi, 100) # Add labels to x and y axis plt.xlabel('$x$') plt.ylabel('$\exp(x/10) \cdot \sin(\omega_{1}x) \cdot \cos(\omega_{0}x)$') # Limit x axis between start and end point of the ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plot with sliders for $\omega_0$ and $\omega_1$ from 0 to 2 with steps of 0.25 Step2: Exercise 08.2 (multiple function plotting) Step3: Plot o...
11,070
<ASSISTANT_TASK:> Python Code: import numpy as np # Show matplotlib graphs inside the notebook. %matplotlib inline import os.path import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import plotly import plotly.offline as py py.init_notebook_mode(connected=True) import plotly.graph_objs as go import p...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2.1 Importing the data Step2: 2.2 Looking at the data Step3: Export part of the dataset as HTML files for inspection ByCity, ByCountry, Step...
11,071
<ASSISTANT_TASK:> Python Code: # Import necessary packages %matplotlib inline %config InlineBackend.figure_format = 'retina' import numpy as np import torch import helper import matplotlib.pyplot as plt ### Run this cell from torchvision import datasets, transforms # Define a transform to normalize the data transform ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now we're going to build a larger network that can solve a (formerly) difficult problem, identifying text in an image. Here we'll use the MNIST ...
11,072
<ASSISTANT_TASK:> Python Code: import pandas as pd fakedata1 = pd.DataFrame( [[ 0.862, 2.264], [ 0.694, 1.847], [ 0.184, 0.705], [ 0.41 , 1.246]], columns=['input','output']) fakedata1.plot(x='input',y='output',kind='scatter') from sklearn.model_selection import train_test_split faketr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: It is pretty clear that there is a linear trend here. If I wanted to predict what would happen if we tried the input of x=0.6, it would be a goo...
11,073
<ASSISTANT_TASK:> Python Code: !pip install dm-acme !pip install dm-acme[reverb] !pip install dm-acme[tf] !pip install dm-sonnet !git clone https://github.com/deepmind/deepmind-research.git %cd deepmind-research #@title Edit and run mjkey = REPLACE THIS LINE WITH YOUR MUJOCO LICENSE KEY .strip() mujoco_dir = "$HOME/....
<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: dm_control Step4: Machine-locked MuJoCo license. Step5: Imports Step6: Data Step7: Dataset and environment Step8: D4PG learner Step9: Trai...
11,074
<ASSISTANT_TASK:> Python Code: # Load our dependencies import pybrl as brl filename = "lorem_ipsum.pdf" # of course :P pdf_password = None language = 'english' # Let's translate the PDF file. translated = brl.translatePDF(filename, password = pdf_password, language = language) # Easy, right? # Let's explore what th...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The translatePDF method does the following
11,075
<ASSISTANT_TASK:> Python Code: import numpy as np np.random.seed(123456) # Generate 100 random patterns for class1 mu_vec1 = np.array([[0],[0]]) cov_mat1 = np.array([[3,0],[0,3]]) x1_samples = np.random.multivariate_normal(mu_vec1.ravel(), cov_mat1, 100) # Generate 100 random patterns for class2 mu_vec2 = np.array([[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: <br> Step3: <br> Step5: <br> Step6: <br> Step7: <br> Step8: <br> Step10: <br> Step11: <br>
11,076
<ASSISTANT_TASK:> Python Code: import subprocess def run_command(command): Run bash command and return the result :param str command: String representation of bash command :return: Returns a generator of output of the result of running bash command in bytes :rtype: iter command = command....
<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: Then we define two util functions. Step4: Second one is for writing string in the file. Step5: Than we define some constants for future use. S...
11,077
<ASSISTANT_TASK:> Python Code: # Uncomment these to install fedjax. # !pip install fedjax # !pip install --upgrade git+https://github.com/google/fedjax.git # !pip install tensorflow_datasets import functools import itertools import fedjax import numpy as np # We cap max sentence length to 8. train_fd, test_fd = fedjax...
<SYSTEM_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 datasets in federated learning? Step2: fedjax.FederatedData provides methods for accessing metadata about the federated dataset, like ...
11,078
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup from __future__ import print_function import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.cnn import * from cs231n.data_utils import get_CIFAR10_data from cs231n.gradient_check import eval_numerical_gradient_array, eval_numerical_gradient ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Convolutional Networks Step2: Convolution Step4: Aside Step5: Convolution Step6: Max pooling Step7: Max pooling Step8: Fast layers Step9: ...
11,079
<ASSISTANT_TASK:> Python Code: from astwro.sampledata import fits_image frame = fits_image() from astwro.pydaophot import Daophot, Allstar dp = Daophot(image=frame) al = Allstar(dir=dp.dir) res = dp.FInd(frames_av=1, frames_sum=1) print ("{} pixels analysed, sky estimate {}, {} stars found.".format(res.pixels, res.s...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Daophot object creates temporary working directory (runner directory), which is passed to Allstar constructor to share. Step2: Daophot got FITS...
11,080
<ASSISTANT_TASK:> Python Code: import numpy as np %pylab inline # Load the data as usual (here the code for Python 2.7) X = np.loadtxt('data/small_Endometrium_Uterus.csv', delimiter=',', skiprows=1, usecols=range(1, 3001)) y = np.loadtxt('data/small_Endometrium_Uterus.csv', delimiter=',', skiprows=1, usecols=[3001], ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2016-10-07 Step2: 1. L1-Regularized Logistic Regression Step3: Question Compute the cross-validated predictions of the l1-regularized logistic...
11,081
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.read_csv('olympics.csv', index_col=0, skiprows=1) for col in df.columns: if col[:2]=='01': df.rename(columns={col:'Gold'+col[4:]}, inplace=True) if col[:2]=='02': df.rename(columns={col:'Silver'+col[4:]}, inplace=True) if col[:2]=='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: Question 0 (Example) Step2: Question 1 Step3: Question 2 Step4: Question 3 Step5: Question 4 Step6: Part 2 Step7: Question 6 Step8: Quest...
11,082
<ASSISTANT_TASK:> Python Code: units = 64 embedding_dim = 64 loss = 'binary_crossentropy' def create_model(batch_size=None): x = x_in = Input(shape=(maxlen,), batch_size=batch_size, dtype=tf.int32) x = Embedding(input_dim=max_features, output_dim=embedding_dim)(x) x = Activation('linear', name='embedding_act')(x)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Replacing with quantized layers Step2: Converting a Model Automatically Step3: Quantizing a Model With AutoQKeras
11,083
<ASSISTANT_TASK:> Python Code: import mne from mne.datasets import sample from mne.preprocessing import create_ecg_epochs, create_eog_epochs # getting some data ready data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif' raw = mne.io.read_raw_fif(raw_fname, preload=True) (raw.copy(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Low frequency drifts and line noise Step2: we see high amplitude undulations in low frequencies, spanning across tens of Step3: On MEG sensors...
11,084
<ASSISTANT_TASK:> Python Code: import numpy as np import ctypes from ctypes import * import pycuda.gpuarray as gpuarray import pycuda.driver as cuda import pycuda.autoinit from pycuda.compiler import SourceModule import matplotlib.pyplot as plt import matplotlib.mlab as mlab import math import time %matplotlib inline ...
<SYSTEM_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 FFT routines Step2: Initializing Data Step3: $W$ TRANSFORM FROM AXES-0 Step4: Forward Transform Step5: Inverse Transform Step6: $W$...
11,085
<ASSISTANT_TASK:> Python Code: # Import relevant modules %matplotlib inline %load_ext autoreload %autoreload 2 import numpy as np from NPTFit import nptfit # module for performing scan from NPTFit import create_mask as cm # module for creating the mask from NPTFit import dnds_analysis # module for analysing the 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: Step 1 Step2: Step 2 Step3: This time we add a non-Poissonian template correlated with the Galactic Center Excess and also one spatially distr...
11,086
<ASSISTANT_TASK:> Python Code: import jax import jax.numpy as jnp import jax.scipy.stats as stats import matplotlib.pyplot as plt import numpy as np import blackjax %load_ext watermark %watermark -d -m -v -p jax,jaxlib,blackjax jax.devices() loc, scale = 10, 20 observed = np.random.normal(loc, scale, size=1_000) def 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: Step2: The problem Step3: HMC Step4: Set the initial state Step5: Build the kernel and inference loop Step6: BlackJAX does not provide a default in...
11,087
<ASSISTANT_TASK:> Python Code: gabr_tweets = extract_users_tweets("gabr_ibrahim", 2000) gabr_dict = dict() gabr_dict['gabr_ibrahim'] = {"content" : [], "hashtags" : [], "retweet_count": [], "favorite_count": []} for tweet in gabr_tweets: text = extract_text(tweet) hashtags = extract_hashtags(tweet) rts = t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 2 Step2: Step 3 Step3: Step 4 Step4: Let's now proceed to tokenize these tweets in addition to lemmatizing them! This will help improve ...
11,088
<ASSISTANT_TASK:> Python Code: import tangent import tensorflow as tf def f(x): a = x * x b = x * a c = a + b return c df = tangent.grad(f) df df(33) forward_df = tangent.grad(f, mode='forward') forward_df(33, dx=1) forward_df(33, dx=2) forward_df(33, dx=-1) def f(x): a = x * x * x b = a * x *...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Forward mode Step2: Hessian-vector products
11,089
<ASSISTANT_TASK:> Python Code: %load_ext sql %config SqlMagic.connect_args="{'kerberos_service_name':'impala', 'auth_mechanism':'GSSAPI'}" %sql impala://impalasrv-prod:21050/test2 %%sql select * from emp Employee_name="SCOTT" %sql select * from emp where ename=:Employee_name myResultSet=%sql select ename "Employee...
<SYSTEM_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. Connect to the target database Step2: 3. Run SQL on the target using the %%sql cell magic or %sql line magic Step3: Bind variables Step4: ...
11,090
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from dh_py_access import package_api import dh_py_access.lib.datahub as datahub import xarray as xr import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap from po_data_process import comparison_bar_chart, make_comparison_plot 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: <font color='red'>Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly ...
11,091
<ASSISTANT_TASK:> Python Code: %env CLIENT bitrepository-client-1.9-RC1 !wget -Nq "https://sbforge.org/download/attachments/25395346/${CLIENT}.zip" !unzip -quo ${CLIENT}.zip %alias bitmag ${CLIENT}/bin/bitmag.sh %l %env TESTFILE1 README.md %bitmag put-file -c integrationtest1 -f $TESTFILE1 -i $TESTFILE1 !md5sum $TEST...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Describes the tests needed to validate the GetChecksums functionality. Step2: Basic getChecksum Step3: Request the checksum of a file in the c...
11,092
<ASSISTANT_TASK:> Python Code: import os import tensorflow as tf import numpy as np from google.cloud import bigquery PROJECT = 'cloud-training-demos' # REPLACE WITH YOUR PROJECT ID BUCKET = 'cloud-training-demos-ml' # REPLACE WITH YOUR BUCKET NAME REGION = 'us-central1' # REPLACE WITH YOUR BUCKET REGION e.g. us-centra...
<SYSTEM_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 will use this helper funciton to write lists containing article ids, categories, and authors for each article in our database to local file. ...
11,093
<ASSISTANT_TASK:> Python Code: DISK_LENGTH = 272 def invert(string): return ''.join(('1' if x == '0' else '0' for x in string)) print(invert('111100001010')) def fill_disk(string): while(len(string) < DISK_LENGTH): string = string + '0' + invert(string[::-1]) return string[:DISK_LENGTH] with 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: Part Two
11,094
<ASSISTANT_TASK:> Python Code: import pandas as pd ser = pd.Series([100, 'foo', 300, 'bar', 500], ['tom', 'bob', 'nancy', 'dan', 'eric']) ser ser.index ser.loc[['nancy','bob']] ser[[4, 3, 1]] ser.iloc[2] 'bob' in ser ser ser * 2 ser[['nancy', 'eric']] ** 2 d = {'one' : pd.Series([100., 200., 300.], index=['apple', '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: <p style="font-family Step2: <p style="font-family Step3: <p style="font-family Step4: <p style="font-family Step5: <p style="font-family St...
11,095
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow import keras import numpy as np class LogisticEndpoint(keras.layers.Layer): def __init__(self, name=None): super(LogisticEndpoint, self).__init__(name=name) self.loss_fn = keras.losses.BinaryCrossentropy(from_logits=True) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Usage of endpoint layers in the Functional API Step2: Exporting an inference-only model Step3: Usage of loss endpoint layers in subclassed mod...
11,096
<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 and convert a TensorFlow model Step2: Generate data Step3: Add some noise Step4: Split our data Step5: Design a model Step6: Train t...
11,097
<ASSISTANT_TASK:> Python Code: from matplotlib import pyplot as plt %matplotlib inline import artm batch_vectorizer = artm.BatchVectorizer(data_path="school.txt", data_format="vowpal_wabbit", target_folder="school_batches", batch_size=100) batch_vectorizer = artm.BatchVectorize...
<SYSTEM_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: В следующий раз данные можно счит...
11,098
<ASSISTANT_TASK:> Python Code: %matplotlib inline # import plotting tools from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter import matplotlib as mpl # import numpy import numpy as np # import necessary landla...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Topographic grid Step2: Initalizing and running a FlowDirector Step3: The FlowDirectors are method specific, so if you want to do D8 flow dire...
11,099
<ASSISTANT_TASK:> Python Code: # @title Install !pip install --upgrade --no-cache-dir recsim # @title Imports # Generic imports import functools from gym import spaces import numpy as np import matplotlib.pyplot as plt from scipy import stats # RecSim imports from recsim import agent from recsim import document from 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: Since we're not about to do anything fancy with this environment, we will initialize it with the provided create_environment function (further d...