Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
0
<ASSISTANT_TASK:> Python Code: short_freq = (hdulist[0].header['STEPSIZE'] / (60. * 60. * 24.)) med_freq = (10. / (60. * 24.)) long_freq = 1. / 24. max_freq = 10. / 24. from scipy.signal import lombscargle short_periods = np.linspace(short_freq, med_freq, len(times)) med_periods = np.linspace(med_freq, long_freq, len(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lomb-Scargle Periodogram via scipy Step2: Lomb-Scargle Periodogram via astroML Step3: Try with more data! Step4: Try with noisy data Step5: ...
1
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns import antipackage import github.ellisonbg.misc.vizarray as va def checkerboard(size): Return a 2d checkboard of 0.0 and 1.0 as a NumPy array check = np.zeros((size,size),float) check....
<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: Checkerboard Step3: Use vizarray to visualize a checkerboard of size=20 with a block size of 10px. Step4: Use vizarray to visualize a checkerb...
2
<ASSISTANT_TASK:> Python Code: %pylab inline import sys from corner import corner sys.path.append('.') from src.mocklc import MockLC, SimulationSetup from src.blendlpf import MockLPF import src.plotting as pl lc = MockLC(SimulationSetup('M', 0.1, 0.0, 0.0, 'short_transit', cteff=5500, know_orbit=True)) lc.create(wnsi...
<SYSTEM_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 mock light curve Step2: Initialize the log posterior function Step3: Optimize Step4: Estimate the posterior Step5: Analysis Step6: ...
3
<ASSISTANT_TASK:> Python Code: df1 = pd.read_csv('listings/30042015/30042015.csv', sep = ";") df2 = pd.read_csv('listings/17072015/17072015.csv', sep = ";") df3 = pd.read_csv('listings/02102015/02102015.csv', sep = ";") df4 = pd.read_csv('listings/03012016/03012016.csv', sep = ";") df5 = pd.read_csv('listings/08122016/...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: feim un DataFrame on cada columna conté els host_id de cada scrap i de nom li posam la data de l'scrap Step2: Feim un dataframe amb l'índex del...
4
<ASSISTANT_TASK:> Python Code: !conda install -y netcdf4 from netCDF4 import Dataset, num2date, date2num from numpy import * import matplotlib.pyplot as plt %matplotlib inline from ipywidgets import interact, interactive, fixed import ipywidgets as widgets x = linspace(0, 1, 100) # generates a hundred values between...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Add to the function to allow amplitude to be varied and aadd in an additional slider to vary both f and a Step2: Climate data Step3: Plotting ...
5
<ASSISTANT_TASK:> Python Code: import numpy as np import numexpr as ne ne.set_num_threads(10); rho = np.empty((512,512,512), dtype=np.float32) rho[:] = np.random.random(rho.shape) rho_mean = rho.mean(dtype=np.float64).astype(np.float32) # Use double precision for intermediate accumulations %%timeit delta = np.exp((rh...
<SYSTEM_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 NumPy way Step2: The Numexpr way Step3: We were using 10 cores. Did our speedup come from multi-threading or loop-blocking/vectorization?...
6
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt plt.rcParams.update({'font.size': 18}) import tqdm import numpy as np import espressomd.observables import espressomd.accumulators espressomd.assert_features( ["ENGINE", "ROTATION", "MASS", "ROTATIONAL_INERTIA", "CUDA"]) ED_PARAMS = {...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise Step2: No more setup needed! We can run the simulation and plot our observables. Step4: The Mean Square Displacement of an active par...
7
<ASSISTANT_TASK:> Python Code: import xarray as xr import numpy as np import os, sys import matplotlib.pyplot as plt import cartopy import cartopy.crs as ccrs %matplotlib inline def read_data(file_name): Read netcdf file and return variables: rlat, rlon, var, px and py. # read the dataset ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Allow to display the output of plotting commands in notebook Step3: Function read_data Step5: Function main Step6: Run main
8
<ASSISTANT_TASK:> Python Code: df df=pd.read_csv(csv_path) df[(df[u'year'] <= 2016)] print pd.Timestamp.min print pd.Timestamp.max year2=[] for i in df['year']: try: year2.append(int(i[6:10])) except: year2.append(np.nan) df['year']=year2 df[(df[u'year'] <= 2016)] df = df[(df[u'reclat'] != 0.0) & (df[u'rec...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: lassuk lepesekben Step2: ugy nez ki ez a kifejezes a hibas a 2016-al. ez a zert van, mert ez az oszlop nem valos datumkent van ertelmezve. ket ...
9
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import make_regression from sklearn.cross_validation import train_test_split X, y, true_coefficient = make_regression(n_samples=80, n_features=30, n_informative=10, noise=100, coef=True, random_state=5) X_train, X_test, y_train, y_test = train_test_split(X, y, random...
<SYSTEM_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 Regression Step2: Ridge Regression (L2 penalty) Step3: Lasso (L1 penalty) Step4: Linear models for classification Step5: Multi-Class ...
10
<ASSISTANT_TASK:> Python Code: # conda install ipyrad -c bioconda # conda install toytree -c eaton-lab import pandas as pd import toytree # load the tree table from CSV tree_table = pd.read_csv( "./analysis-treeslider/test.tree_table.csv", index_col=0, ) # examine top of table tree_table.head() outfile = 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: Short Tutorial Step2: Write the trees column to a file Step3: Get Astral Step4: Run Astral Step5: Plot astral species tree
11
<ASSISTANT_TASK:> Python Code: %pylab inline from sg2lib import * gamma = 1 Sx = 2 Fs = array([[1, gamma], [0, 1]]) Fp = array([[Sx, 0], [0, 1/Sx]]) n = 10 Fsi = array([[1, gamma/n], [0, 1]]) print('Incremental deformation gradient:') print(Fsi) array_equal(matrix_power(Fsi, n), Fs) Fpi = array([[Sx**(1/n), 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: Naive concept of simultaneous deformation Step2: To divide simple shear deformation with $\gamma$=1 to n incremental steps Step3: To check tha...
12
<ASSISTANT_TASK:> Python Code: import os import mne from mne.preprocessing import (ICA, create_eog_epochs, create_ecg_epochs, corrmap) sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <div class="alert alert-info"><h4>Note</h4><p>Before applying ICA (or any artifact repair strategy), be sure to observe Step2: We can get a sum...
13
<ASSISTANT_TASK:> Python Code: # import variable setting dictionaries from dkrz data ingest tool chain # and remove __doc__ strings from dictionary (would clutter PROV graph visualizations) from provtemplates import workflow_steps from collections import MutableMapping from contextlib import suppress def delete_keys_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: Template representation variant 1 Step2: Template representation variant 2 Step3: Template representation variant 3
14
<ASSISTANT_TASK:> Python Code: training = sqlContext.read.parquet("s3://zoltanctoth-flights/training.parquet") test = sqlContext.read.parquet("s3://zoltanctoth-flights/training.parquet") test.printSchema() test.first() training.cache() test.cache() from pyspark.sql.types import DoubleType from pyspark.sql.functions 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: Generate label column for the training data Step2: Create and fit Spark ML model Step3: Predict whether the aircraft will be late Step4: Chec...
15
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib matplotlib.rcParams['figure.figsize'] = (10.0, 8.0) import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import interp1d, InterpolatedUnivariateSpline from scipy.optimize import bisect import json from functools import partial clas...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: And some more specialized dependencies Step2: Configuration for this figure. Step3: Open a chest located on a remote globus endpoint and load ...
16
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import seaborn as sns import numpy as np def find_peaks(a): Find the indices of the local maxima in a sequence. # YOUR CODE HERE #raise NotImplementedError() ind=[] #next two if checks end points if a[0]> a[1...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Peak finding Step3: Here is a string with the first 10000 digits of $\pi$ (after the decimal). Write code to perform the following
17
<ASSISTANT_TASK:> Python Code: def g(x, alpha, beta): assert alpha >= 0 and beta >= 0 return (alpha*x)/(1 + (beta * x)) def plot_cobg(x, alpha, beta): y = np.linspace(x[0],x[1],300) g_y = g(y, alpha, beta) cobweb(lambda x: g(x, alpha, beta), y, g_y) # configura gráfica interactiva interact(plot_co...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Búsqueda algebráica de puntos fijos Step2: Punto fijo oscilatorio Step3: ¿Qué pasará con infinitas iteraciones?
18
<ASSISTANT_TASK:> Python Code: import os import sys root_folder = os.path.dirname(os.getcwd()) sys.path.append(root_folder) import ResoFit from ResoFit.calibration import Calibration from ResoFit.fitresonance import FitResonance from ResoFit.experiment import Experiment from ResoFit._utilities import Layer import numpy...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Global paramters Step2: File locations Step3: Preview data using Experiment() Step4: Data Step5: Spectra Step6: Remove unwanted data points...
19
<ASSISTANT_TASK:> Python Code: #Like before, we're going to select the relevant columns from the database: connection = psycopg2.connect('dbname= threeoneone user=threeoneoneadmin password=threeoneoneadmin') cursor = connection.cursor() cursor.execute('''SELECT createddate, closeddate, borough FROM service;''') 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: Let's extract years and months again Step2: And now, we're going to filter out bad cases again. However, this time, we're going to be a bit mor...
20
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns; sns.set() # for plot styling import numpy as np import threading import time from sklearn.datasets.samples_generator import make_blobs from sklearn.cluster import KMeans import sys sys.path.append("../") from IoTPy...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Part 1 Step2: Sklearn function to generate random points Step3: Function to compute kmeans and plot clusters. Step4: Function to change the p...
21
<ASSISTANT_TASK:> Python Code: # Importando Bibliotecas import csv import matplotlib.pyplot as plt from math import sqrt from random import randrange # Definição da função que transforma um conjunto de dados inteiro em float def str_column_to_float(data): newData = [] for lines in data: aux = [float(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: Utilização da Regressão Linear e Avaliação do Algoritmo Step2: Visualização da Regressão Linear
22
<ASSISTANT_TASK:> Python Code: !rm -rf hello setup.py && mkdir hello %%file hello/hello.py #pythran export hello() def hello(): Wave hello. print("Hello from Pythran o/") %%file hello/__init__.py Hello package, featuring a Pythran kernel. from hello import hello %%file setup.py from distutils.core ...
<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: Project layout Step4: And so is the __init__.py file. Step5: The setup.py file contains the classical metadata, plus a special header. this he...
23
<ASSISTANT_TASK:> Python Code: from pylab import * t = arange(0.0, 2.0,0.01) y = sin(2*pi*t) plot(t, y) xlabel('Time (s)') ylabel('Voltage (mV)') title('The simplest one, buddies') grid(True) show() from pylab import * t = arange(0.0, 2.0,0.01) y = sin(2*pi*t) plot(t, y, color='red') xlabel('Time (s)') ylabe...
<SYSTEM_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 plot line Step2: A custom 2D plot, based on our first example.
24
<ASSISTANT_TASK:> Python Code: #Example conditional statements x = 1 y = 2 x<y #x is less than y #x is greater than y x>y #x is less-than or equal to y x<=y #x is greater-than or equal to y x>=y #Example of and operator (1<2)and(2<3) #Example of or operator (1<2)or(2>3) #Example of not operator not(1>2) x = 1 y = 2 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: If you let a and b be conditional statements (like the above statements, e.g. a = x < y), then you can combine the two together using logical op...
25
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.array([[ 0, 1, 2, 3, 4, 5], [ 5, 6, 7, 8, 9, 10], [10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25]]) result = np.diag(np.fliplr(a)) <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:
26
<ASSISTANT_TASK:> Python Code: # загрузка из файла reviews_test = pd.read_csv('data/reviews_test.csv', header=0, encoding='utf-8') reviews_train = pd.read_csv('data/reviews_train.csv', header=0, encoding='utf-8') reviews_internet = pd.read_csv('data/internet_reviews.csv', header=0, encoding='utf-8') # обучающая выборка...
<SYSTEM_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: Классификатор 5 / не 5 Step6: Cни...
27
<ASSISTANT_TASK:> Python Code: # Python // JavaScript # No output # Plain text output "Hello world" True False 42 import math math.pi dict(a=1,b=2) list(range(10)) dict(a='string', b=1, c=3.14, d=[1, 2, 3], e=dict(f=1)) # Stream output print("Just a string") # Matplotlib import matplotlib.pyplot as plt import numpy ...
<SYSTEM_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 code cells illustrate how different types of cell outputs are decoded. Step2: Primitive outputs Step3: Image outputs Step4: HTM...
28
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings('ignore') %matplotlib inline %pylab inline from distutils.version import StrictVersion import sklearn print(sklearn.__version__) assert StrictVersion(sklearn.__version__ ) >= StrictVersion('0.18.1') import tensorflow as tf tf.logging.set_verbosity(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: How does Tensorflow Low Level API look like? Step2: Interactive usage of Low Level API Step3: Calling a TensorFlow Model deployed on Google Cl...
29
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot # We have this here to trigger matplotlib's font cache stuff. # This cell is hidden from the output import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame({'A': np.linspace(1, 10, 10)}) df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here's a boring example of rendering a DataFrame, without any (visible) styles Step2: Note Step4: The row0_col2 is the identifier for that par...
30
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne import io from mne.datasets import sample print(__doc__) data_path = sample.data_path() raw_fname = data_path + '/MEG...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Show event related fields images
31
<ASSISTANT_TASK:> Python Code: #export from exp.nb_01 import * def get_data(): path = datasets.download_data(MNIST_URL, ext='.gz') with gzip.open(path, 'rb') as f: ((x_train, y_train), (x_valid, y_valid), _) = pickle.load(f, encoding='latin-1') return map(tensor, (x_train,y_train,x_valid,y_valid)) d...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Foundations version Step2: Tinker practice Step3: From pytorch docs Step4: Loss function Step5: We need squeeze() to get rid of that trailin...
32
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np import matplotlib.pyplot as plt import mne # sphinx_gallery_thumbnail_number = 9 data_path = mne.datasets.sample.data_path() fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif') evoked = mne.read_evokeds(fname, baseline=(None, 0), 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: First we read the evoked object from a file. Check out Step2: Notice that evoked is a list of Step3: Let's start with a simple one. We plot e...
33
<ASSISTANT_TASK:> Python Code: # run this cell first! fruits = {"apple":"red", "banana":"yellow", "grape":"purple"} print fruits["banana"] query = "apple" print fruits[query] print fruits[0] print fruits.keys() print fruits.values() for key in fruits: print fruits[key] del fruits["banana"] print fruits print fruit...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: There's no concept of "first element" in a dictionary, since it's unordered. (Of course, if you happened to have a key in your dictionary that w...
34
<ASSISTANT_TASK:> Python Code: # download sample files !wget -P data -nc ftp://ftp.nersc.no/nansat/test_data/obpg_l2/A2015121113500.L2_LAC.NorthNorwegianSeas.hdf !wget -P data -nc ftp://ftp.nersc.no/nansat/test_data/obpg_l2/A2015122122000.L2_LAC.NorthNorwegianSeas.hdf import numpy as np import matplotlib.pyplot as 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: Open MODIS/Aqua files with chlorophyll in the North Sea and fetch data Step2: Plot chlorophyll-a maps in swath projection Step3: Colocate data...
35
<ASSISTANT_TASK:> Python Code: import itertools # heads = True # tails = False # Initialize coins to all heads coins = [True]*100 for factor in range(100): # This will generate N zeros, then a 1. This repeats forever flip_generator = itertools.cycle([0]*factor+[1]) # This will take the first 100 items...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Classic Riddler Step2: If I would not have seen this particular tweet (https
36
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib.pyplot as plt %matplotlib inline df= pd.read_excel("NHL 2014-15.xls") !pip install xlrd df.columns.value_counts() df.head() df.columns df['Ctry'].value_counts().head(10) df['Nat'].value_counts().head(10) df['Birth City'].value_counts().head(1...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here's all of our data Step2: Here are each of the columns in the data set Step3: Let's count how many players are from each country Step4: L...
37
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt plt.style.use('seaborn-whitegrid') import numpy as np x = np.linspace(0, 10, 50) dy = 0.8 y = np.sin(x) + dy * np.random.randn(50) # yerr表示y的误差 plt.errorbar(x, y, yerr=dy, fmt='.k'); plt.errorbar(x, y, yerr=dy, fmt='o', color='black', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 这里的fmt是控制线和点外观的格式代码,并且具有与plt.plot中使用的简写相同的语法,在Simple Line Plots和Simple Scatter Plots中进行了概述。 Step2: 除了这些选项之外,还可以指定水平误差线(xerr),单面误差线和许多其他变体。有关可用选...
38
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import pandas as pd import numpy as np import pkg_resources import matplotlib.pyplot as plt import seaborn as sns import time import scipy.stats as stats from sklearn 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: Load and pre-process data sets Step2: Let's examine some rows in these datasets. Note that columns like toxicity and male are percent scores. ...
39
<ASSISTANT_TASK:> Python Code: # read raw data raw_data = pd.read_csv('/home/phoenix/Documents/session_1_data_train.csv') test_data = pd.read_csv('/home/phoenix/Documents/session_1_data_test.csv') test_data.columns = raw_data.columns raw_data.head() raw_data.label.value_counts().keys() test_data.label.value_counts().ke...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Outcomes of sprint 1 Step2: Train test split Step3: Evaluation function Step4: Objective of Sprint 3 Step5: Logistic Regression Step6: Sup...
40
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import division import numpy as np from numpy import linalg as LA k_a=0.2 k_b=0.2 k_p = 0.5 P = np.matrix([[1-k_a-k_b, k_a ,k_b, 0, 0, 0], [k_a, 1-k_a-k_b, 0, k_b, 0, 0], [k_b, 0, 1-k_a-k_b, k_a, 0, 0], [0, k_...
<SYSTEM_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 markov chain seems to be irreducible Step2: EDIT Step3: Stationary state is given by $\pi = (0.1667, 0.1667, 0.1667, 0.1667, 0.1667, 0.166...
41
<ASSISTANT_TASK:> Python Code: from reprophylo import * pj = unpickle_pj('outputs/my_project.pkpj', git=False) genera_with_porocalices = ['Cinachyrella', 'Cinachyra', 'Amphitethya', 'Fangophilina', 'Acanthotet...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 3.10.1 Updating the metadata after the tree has been built Step2: while others do not Step3: The following command will add the value 'present...
42
<ASSISTANT_TASK:> Python Code: password = input("Please enter the password:") if password == "Simsim": print("\t> Welcome to the cave") x = "Mayank" y = "TEST" if y == "TEST": print(x) if y: print("Hello World") z = None if z: print("TEST") x = 11 if x > 10: print("Hello") if x > 10.999999999999...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: if ... else statement Step2: if ...elif ... else statement Step3: Imagine that in the above program, 23 is the temperature which was read by  ...
43
<ASSISTANT_TASK:> Python Code: from sklearn import datasets iris = datasets.load_iris() X = iris.data Y = iris.target # print(iris.DESCR) from sklearn.neural_network import MLPClassifier clf = MLPClassifier(random_state=1960) clf.fit(X, Y) #clf.__dict__ def test_ws_sql_gen(pickle_data): WS_URL="https://sklearn2s...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Generate SQL Code from the Model Step2: Execute the SQL Code Step3: Scikit-learn Prediction Step4: Comparing the SQL and Scikit-learn Predict...
44
<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...
45
<ASSISTANT_TASK:> Python Code: import re import pubchempy as pcp import logging logging.getLogger('pubchempy').setLevel(logging.DEBUG) def get_substructure_cas(smiles): cas_rns = [] results = pcp.get_synonyms(smiles, 'smiles', searchtype='substructure') for result in results: for syn in result.get...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Enable debug logging to make it easier to see what is going on Step2: A function to get the CAS registry numbers for compounds with a particula...
46
<ASSISTANT_TASK:> Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage tensorflow $USER_FLAG import os if not os.g...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage and tensorflow libraries as well. Step2: Restart the kernel Step3: Before you begin Step...
47
<ASSISTANT_TASK:> Python Code: df['Age'].describe() df.groupby('Gender')['Income'].describe() df['Income'].describe() df['SchoolMajor'].value_counts() df['SchoolDegree'].value_counts() df.sort_values(by='StudentDebtOwe', ascending=False).head() df[(df['BootcampFullJobAfter']==1) & (df['BootcampLoanYesNo']==1)].he...
<SYSTEM_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. What are the maximum income for female programmers? Step2: 3. how much does a programmer make on average per year? Step3: 4. what is the mo...
48
<ASSISTANT_TASK:> Python Code: import torch import torch.nn as nn import torch.nn.functional as F # adds some efficiency from torch.utils.data import DataLoader # lets us load data in batches from torchvision import datasets, transforms import numpy as np import pandas as pd from sklearn.metrics import confus...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the MNIST dataset Step2: Load the training set Step3: Load the test set Step4: Examine a training record Step5: Calling the first recor...
49
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function %matplotlib inline #format the book import book_format book_format.set_style() import numpy as np from numpy.random import randn import matplotlib.pyplot as plt N = 5000 a = np.pi/2. + (randn(N) * 0.35) r = 50.0 + (randn(N) * 0.4) xs = ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Introduction Step2: We can see that out intuition failed us because the nonlinearity of the problem forced all of the errors to be biased in on...
50
<ASSISTANT_TASK:> Python Code: #$HIDE_INPUT$ from google.cloud import bigquery # Create a "Client" object client = bigquery.Client() # Construct a reference to the "nhtsa_traffic_fatalities" dataset dataset_ref = client.dataset("nhtsa_traffic_fatalities", project="bigquery-public-data") # API request - fetch the datase...
<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: Let's use the table to determine how the number of accidents varies with the day of the week. Since Step3: As usual, we run it as follows
51
<ASSISTANT_TASK:> Python Code: import twothirds import random N = 2000 guesses = [int(round(random.triangular(0, 100, 44), 0)) for k in range(N)] g = twothirds.TwoThirdsGame(guesses) g.two_thirds_of_the_average() g.find_winner() import string def randomword(length): A function to generate a random name: http:...
<SYSTEM_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 as assume we have the following list of random guesses Step2: Now we create a single game instance Step3: Let's find the two thirds of the...
52
<ASSISTANT_TASK:> Python Code: shopping_list = [ 'Milk', 'Eggs', 'Bread', 'Beer'] item_count = len(shopping_list) print("List: %s has %d items" % (shopping_list, item_count)) for item in shopping_list: print("I need to buy some %s " % (item)) # or with f-strings for item in shopping_list: print(f"I need to buy...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Enumerating the Items in a List Step2: 1.1 You Code Step3: Indexing Lists Step4: For Loop with Index Step5: 1.2 You Code Step6: Lists are M...
53
<ASSISTANT_TASK:> Python Code: PROJECT = "cloud-training-demos" # Replace with your PROJECT BUCKET = "cloud-training-bucket" # Replace with your BUCKET REGION = "us-central1" # Choose an available region for Cloud MLE TFVERSION = "1.14" # TF version for CMLE to use import os os.environ["BUCK...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Deploy trained model Step2: We'll now deploy our model. This will take a few minutes. Once the cell below completes, you should be able to see ...
54
<ASSISTANT_TASK:> Python Code: from keras.datasets import imdb idx = imdb.get_word_index() idx_arr = sorted(idx, key=idx.get) idx_arr[:10] idx2word = {v: k for k, v in idx.iteritems()} path = get_file('imdb_full.pkl', origin='https://s3.amazonaws.com/text-datasets/imdb_full.pkl', md5_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This is the word list Step2: ...and this is the mapping from id to word Step3: We download the reviews using code copied from keras.datasets S...
55
<ASSISTANT_TASK:> Python Code: import os import sys # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install -U google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG if not os.getenv("IS_TESTING...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
56
<ASSISTANT_TASK:> Python Code: ##Some code to run at the beginning of the file, to be able to show images in the notebook ##Don't worry about this cell #Print the plots in this screen %matplotlib inline #Be able to plot images saved in the hard drive from IPython.display import Image #Make the notebook wider from IPy...
<SYSTEM_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. Clustering Step2: 1a. Clustering with K-means Step3: 1b. Clustering with DBSCAN Step4: 1c. Hierarchical clustering Step5: 2. Imputation o...
57
<ASSISTANT_TASK:> Python Code: print("Exemplo 4.1") import numpy as np #Para vs = 12V #6i1 + 2i1 + 4(i1 - i2) = -12 #12i1 - 4i2 = -12 #3i1 - i2 = -3 #-3vx -12 + 4(i2 - i1) + 8i2 + 4i2 = 0 #vx = 2i1 #-6i1 + 16i2 - 4i1 = 12 #-10i1 + 16i2 = 12 #-5i1 + 8i2 = 6 #i0 = i2 coef = np.matrix('3 -1;-5 8') ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problema Prático 4.1 Step2: Superposição Step3: Problema Prático 4.3 Step4: Exemplo 4.4 Step5: Problema Prático 4.4 Step6: Exemplo 4.5 Step...
58
<ASSISTANT_TASK:> Python Code: %pylab inline pylab.rc("savefig", dpi=120) # set resolution of inline figures import echidna.core.spectra as spectra import echidna config = spectra.SpectraConfig.load_from_file(echidna.__echidna_base__ + "/echidna/config/example.yml") prin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Spectra creation Step2: Now we need a config file to create the spectrum from. There is an example config file in echidna/config. If we look at...
59
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'inpe', 'sandbox-1', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
60
<ASSISTANT_TASK:> Python Code: import os from gensim import utils from gensim.models import translation_matrix from gensim.models import KeyedVectors train_file = "OPUS_en_it_europarl_train_5K.txt" with utils.smart_open(train_file, "r") as f: word_pair = [tuple(utils.to_unicode(line).strip().split()) for line in 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: For this tutorial, we'll train our model using the English -> Italian word pairs from the OPUS collection. This corpus contains 5000 word pairs....
61
<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: You can see that you need to add a description first to start with Step3: Now we can confirm that the anno...
62
<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: Migrate from TPUEstimator to TPUStrategy Step2: TensorFlow 1 Step3: With those functions defined, create a tf.distribute.cluster_resolver.TPUC...
63
<ASSISTANT_TASK:> Python Code: import os IS_COLAB_BACKEND = 'COLAB_GPU' in os.environ # this is always set on Colab, the value is 0 or 1 depending on GPU presence if IS_COLAB_BACKEND: from google.colab import auth # Authenticates the Colab machine and also the TPU using your # credentials so that they can access...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Updating tensorboard_plugin_profile Step2: Enabling and testing the TPU Step3: Input data Step4: Let's take a peek at the training dataset we...
64
<ASSISTANT_TASK:> Python Code: # RUN THIS CELL to perform standard imports: import spacy nlp = spacy.load('en_core_web_sm') # Enter your code here: with open('../TextFiles/owlcreek.txt') as f: doc = nlp(f.read()) # Run this cell to verify it worked: doc[:36] len(doc) sents = [sent for sent in doc.sents] len(sent...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Create a Doc object from the file owlcreek.txt<br> Step2: 2. How many tokens are contained in the file? Step3: 3. How many sentences are co...
65
<ASSISTANT_TASK:> Python Code: import os import sys import inspect import numpy as np import datetime as dt import time import pytz import pandas as pd import pdb import tmpo #import charts from opengrid import config from opengrid.library import houseprint c=config.Config() DEV = c.get('env', 'type') == 'dev' # DEV is...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Script settings Step2: We create one big dataframe, the columns are the sensors
66
<ASSISTANT_TASK:> Python Code: import numpy as np import os import time import meshcat import meshcat.geometry as g import meshcat.transformations as tf # Create a new visualizer vis = meshcat.Visualizer() vis.open() vis.url() vis.set_object(g.Box([0.2, 0.2, 0.2])) for theta in np.linspace(0, 2 * np.pi, 200): v...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: By default, creating the Visualizer will start up a meshcat server for you in the background. The easiest way to open the visualizer is with its...
67
<ASSISTANT_TASK:> Python Code: # Let's find out the number of neighbors that individual #7 has. G.neighbors(9) # Possible Answers: sorted([n for n in G.nodes()], key=lambda x:len(G.neighbors(x)), reverse=True) sorted([(n, G.neighbors(n)) for n in G.nodes()], key=lambda x: len(x[1]), reverse=True) nx.degree_centrality...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise Step2: Approach 2 Step3: If you inspect the dictionary closely, you will find that node 19 is the one that has the highest degree cen...
68
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import seaborn as sns import scipy.stats as ss import sympy as sp sns.set_context('notebook') %matplotlib inline x = np.linspace(.01, .99, num=1e3) doppler = lambda x : np.sqrt(x * (1 - x)) * np.sin(1.2 * np.pi / (x + .05)) plt.plot(x, d...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Doppler function Step2: Derivative of Doppler function Step3: Left and right truncated exponentials Step4: Draw the densitites Step5: Kernel...
69
<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 = sorted(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...
<SYSTEM_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...
70
<ASSISTANT_TASK:> Python Code: #$HIDE_INPUT$ from google.cloud import bigquery # Create a "Client" object client = bigquery.Client() # Construct a reference to the "hacker_news" dataset dataset_ref = client.dataset("hacker_news", project="bigquery-public-data") # API request - fetch the dataset dataset = client.get_dat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Let's use the table to see which comments generated the most replies. Since Step3: Now that our query is ready, let's run it and store the res...
71
<ASSISTANT_TASK:> Python Code: import sys sys.path.insert(0, './code') # Go into the subdirectory from thinkbayes import Pmf # Grab the thinkbayes script help(Pmf) # What is this object? pmf = Pmf() # intialize the object for x in [1,2,3,4,5,6]: # for x in array pmf.Set(x, 1/6.0) # Set the frequen...
<SYSTEM_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 code builds a Pmf to represent the distribution of Step2: This is a Probability Mass Function object, which includes some pre-def...
72
<ASSISTANT_TASK:> Python Code: # Import pyoptools to load all contents from pyoptools.all import * from math import pi #Example 2.1 : Plane surfaces P1=Plane(shape=Circular(radius=(20)),reflectivity=1) P2=Plane(shape=Rectangular(size=(40,25))) P3=Plane(shape=Triangular(coord=((-15,15),(5,-20),(18,12)))) Plot3D(P1,cent...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Table of contents Step2: 2.2 Spherical surfaces <a class="anchor" id="2.2"></a> Step3: 2.3 Cylinders and cylidrical surfaces <a class="anchor"...
73
<ASSISTANT_TASK:> Python Code: # Authors: Robert Luke <mail@robertluke.net> # # License: BSD (3-clause) import os import mne from mne.preprocessing.nirs import (optical_density, temporal_derivative_distribution_repair) fnirs_data_folder = mne.datasets.fnirs_motor.data_path() fnirs_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: Import data Step2: We can see some small artifacts in the above data from movement around 40, Step3: Apply temporal derivative distribution re...
74
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csiro-bom', 'sandbox-2', '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...
75
<ASSISTANT_TASK:> Python Code: from thermostate import State, Q_, units, set_default_units p_1 = Q_(101325, 'Pa') p_1 = Q_(1.01325, 'bar') p_1 = Q_(14.7, 'psi') p_1 = Q_(1.0, 'atm') T_1 = 460*units.degR T_1 = 25*units.degC T_1 = 75*units.degF T_1 = 400*units.K Q_(101325, 'Pa') == 1.0*units.atm substance = 'water' ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Pint and Units Step2: We can use whatever units we'd like, Pint supports a wide variety of units. Step3: Another way to specify the units is t...
76
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mri', 'sandbox-2', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "ema...
<SYSTEM_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...
77
<ASSISTANT_TASK:> Python Code: import numpy as np c, v = np.loadtxt('data.csv', delimiter=',', usecols=(6,7), unpack=True) c v #选择第4列,开盘价 opening_price = np.loadtxt('data.csv', delimiter=',', usecols=(3,), unpack=True) print opening_price vwap = np.average(c, weights=v) print "VWAP =", vwap t = np.arange(len(c)) pri...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: data.csv文件是苹果公司的历史股价数据。第一列为股票代码,第二列为dd-mm-yyyy格式的日期,第三列为空,随后各列依次是开盘价(4)、最高价(5)、最低价(6)和收盘价(7),最后一列为当日的成交量(8)。 Step2: 2. 计算平均值 Step3: TWAP是Time0...
78
<ASSISTANT_TASK:> Python Code: # Execute this cell to load the notebook's style sheet, then ignore it from IPython.core.display import HTML css_file = '../../style/custom.css' HTML(open(css_file, "r").read()) # Import Libraries %matplotlib inline import numpy as np import matplotlib.pyplot as plt # Define parameters ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Computation of Green's functions and seismograms for the acoustic wave equation Step2: 2D Green's function Step3: 3D Green's function Step4: ...
79
<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: Keras 예제의 가중치 클러스터링 Step2: 클러스터링을 사용하지 않고 MNIST용 tf.keras 모델 훈련하기 Step3: 기준 모델을 평가하고 나중에 사용할 수 있도록 저장하기 Step4: 클러스터링을 사용하여 사전 훈련된 모델 미세 조정하기 ...
80
<ASSISTANT_TASK:> Python Code: import os import sys # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install -U google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG if not os.getenv("IS_TESTING...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
81
<ASSISTANT_TASK:> Python Code: __author__ = 'ATSC-301 UBC' import glob import numpy as np import matplotlib.pyplot as plt from __future__ import division from __future__ import print_function % matplotlib inline import h5py import scipy.io from mpl_toolkits.basemap import Basemap hdf5_L1B=glob.glob('_data/MODIS_L1...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Content Step2: We import h5py to read HDF5 files Step3: scipy.io for saving data in *.mat format Step4: For the map view of data, we need mpl...
82
<ASSISTANT_TASK:> Python Code: import numpy as np import os import six.moves.urllib as urllib import sys import tarfile import tensorflow as tf import zipfile from collections import defaultdict from io import StringIO from matplotlib import pyplot as plt from PIL import Image # This is needed to display the images. %...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Env setup Step2: Object detection imports Step3: Model preparation Step4: Download Model Step5: Load a (frozen) Tensorflow model into memory...
83
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import matplotlib.pyplot as plt import numpy as np from ipywidgets import widgets from ipywidgets import interact, interactive, fixed from IPython.display import display,HTML,clear_output import os HTML('''<script>code_show=true;function code_toggle() {if (code_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: Definition and proxy for usefull functions Step2: Analyse
84
<ASSISTANT_TASK:> Python Code: %pylab inline import matplotlib #matplotlib.rc('xtick', labelsize=20) #matplotlib.rc('ytick', labelsize=20) from scipy.spatial import distance x = np.loadtxt("data.txt", comments='//') x.shape print(x.shape) # Plot 2 measurements #for i in x: # plt.plot(i[0],i[1], 'ko'); plt.scatte...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Consider the following data set consisting of the scores of two variables on each of 17 experiments Step2: This data set is to be grouped into ...
85
<ASSISTANT_TASK:> Python Code: sc.addPyFile("https://github.com/ibm-watson-data-lab/simple-data-pipe-connector-flightstats/raw/master/flightPredict/training.py") sc.addPyFile("https://github.com/ibm-watson-data-lab/simple-data-pipe-connector-flightstats/raw/master/flightPredict/run.py") import training import run %matp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: load data from training data set and print the schema Step2: Visualize classes in scatter plot based on 2 features Step3: Load the training da...
86
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt # comment out this line if you don't have seaborn installed import seaborn as sns sns.set_palette("colorblind") import numpy as np # execute this line: from astroquery.sdss import SDSS TSquery = SELECT TOP 10000 p.psfMag_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: Step2: First, we're going to need some data. We'll work with the star-galaxy data from the first session. This uses the astroquery package and then que...
87
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np df = pd.read_excel('https://github.com/chris1610/pbpython/blob/master/data/sample-salesv3.xlsx?raw=true') df.dtypes df['date'] = pd.to_datetime(df['date']) df.head() df.dtypes df[df["account number"]==307599].head() df[df["quantity"] > 22].head(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load in the Excel data that represents a year's worth of sales. Step2: Take a quick look at the data types to make sure everything came through...
88
<ASSISTANT_TASK:> Python Code: import pandas_datareader as pdr import pandas as pd import statsmodels.api as sm from statsmodels.regression.rolling import RollingOLS import matplotlib.pyplot as plt import seaborn seaborn.set_style('darkgrid') pd.plotting.register_matplotlib_converters() %matplotlib inline factors = 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: pandas-datareader is used to download data from Step2: The first model estimated is a rolling version of the CAPM that regresses Step3: We nex...
89
<ASSISTANT_TASK:> Python Code: %matplotlib inline # Let's grab some libraries to help us manipulate symbolic equations from __future__ import print_function from __future__ import division import numpy as np import sympy from sympy import symbols, sin, cos, pi, simplify def makeT(a, alpha, d, theta): # create a mod...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Puma Example Step2: Puma
90
<ASSISTANT_TASK:> Python Code: import os import requests from bs4 import BeautifulSoup import re import json import time import praw import dominate from dominate.tags import * from time import gmtime, strftime #import nose #import unittest import numpy as np import pandas as pd from pandas import * from PIL 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: Something is wrong with the script and it's no longer creating these dir in the correct folder. How did this break? Step2: if i save the data t...
91
<ASSISTANT_TASK:> Python Code: from IPython.display import Image from IPython.core.display import HTML from __future__ import print_function, division import numpy as np import tensorflow as tf import matplotlib.pyplot as plt Image(url= "https://cdn-images-1.medium.com/max/1600/1*UkI9za9zTR-HL8uM15Wmzw.png") #hyperpar...
<SYSTEM_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 figure below shows the input data-matrix, and the current batch batchX_placeholder Step2: As you can see in the picture below that is done...
92
<ASSISTANT_TASK:> Python Code: workDir = '/home/nick/notebook/SIPSim/dev/fullCyc_trim/' emp_data = 'SIP-core_unk_trm' emp_data_preFrac = 'bulk-core_trm' import os import sys %load_ext rpy2.ipython %load_ext pushnote if not os.path.isdir(workDir): os.makedirs(workDir) %cd $workDir !/home/nick/notebook/SIPSim/...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Init Step2: Making a table of shannon index for each fraction community Step3: Making a table of variance in BD spans Step4: Making a communi...
93
<ASSISTANT_TASK:> Python Code: print "Hello world" s="Hello world" print s print s.upper() print s.replace("o","O") 2 -7897 3.4 -7213.6241 2.66e-23 'Ovo je niz znakova.' "Ovo je isto niz znakova." "Ovo je 'niz znakova' u kojem se nalazi 'kombinacija' navodnika." '' "" '3.14' 3.14 'Ovo je niz.'[0] niz='Ovo je ni...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Ime varijable je s, a vrijednost varijable je Hello world. Navedeno ime varijable s navedenom vrijednosti te varijable je instanca klase. Step2:...
94
<ASSISTANT_TASK:> Python Code: import requests #to handle http requests to the API from psycopg2 import connect stationid = 3 #We'll find out the full range of possible stations further down. lineid = 1 #[1,2,4] # The url for the request base_url = "http://www.ttc.ca/Subway/loadNtas.action" # Our query parameters 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: So now we've just received our first request from the API and the response is stored in the requests object r. From previous examination of the ...
95
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from sklearn.pipeline import Pipeline from sklearn.svm import SVC from sklearn.decomposition import PCA from sklearn.preprocessing import PolynomialFeatures estimators = [('reduce_dim', PCA()), ('poly', PolynomialFeatures()), ('svm', SVC())] clf = Pi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
96
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-3', 'landice') # 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...
97
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from matplotlib import pyplot as plt from IPython.html.widgets import interact, interactive, fixed from IPython.display import display from IPython.html import widgets from IPython.display import Image assert True # leave this to grade the import stat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Basic rich display Step2: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi...
98
<ASSISTANT_TASK:> Python Code: s3_client = boto3.client('s3') resource = boto3.resource('s3') # Disable signing for anonymous requests to public bucket resource.meta.client.meta.events.register('choose-signer.s3.*', disable_signing) def file_list(client, bucket, prefix=''): paginator = client.get_paginator('list_ob...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: NEXRAD at O'Hare Zip 60666 Step2: Wunderground
99
<ASSISTANT_TASK:> Python Code: %matplotlib notebook from pylab import * from __future__ import print_function import sys, os from ipywidgets import interact,interact_manual, Image from ptha_paths import data_dir, events_dir # Read in topography data: fixed_grid_file = os.path.join(data_dir, 'MapsTopo', 'fixedgrid_xyB_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Read in the topography data and define a function to make a contour plot Step2: Read in image of Crescent City as background for plots Step3: ...