Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
6,300
<ASSISTANT_TASK:> Python Code: # importing import numpy as np import matplotlib.pyplot as plt import matplotlib # showing figures inline %matplotlib inline # plotting options font = {'size' : 30} plt.rc('font', **font) plt.rc('text', usetex=True) matplotlib.rc('figure', figsize=(30, 15) ) # define (unknown) group 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: Parameters Step2: Observe and Estimate Using Max-Estimator Step3: Show Results for Additional Estimators
6,301
<ASSISTANT_TASK:> Python Code: from bigbang.archive import Archive from bigbang.archive import load as load_archive import bigbang.parse as parse import bigbang.graph as graph import bigbang.mailman as mailman import bigbang.process as process import networkx as nx import matplotlib.pyplot as plt import pandas as pd fr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First, we shall compute the word counts on the lists. Step2: Let's print some useful descriptive data Step3: We want to compute the list of c...
6,302
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy import stats import statsmodels.api as sm from statsmodels.base.model import GenericLikelihoodModel data = sm.datasets.spector.load_pandas() exog = data.exog endog = data.endog print(sm.datasets.spector.NOTE) print(data.exog.head()) exog = sm.add_constant(e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The Spector dataset is distributed with statsmodels. You can access a vector of values for the dependent variable (endog) and a matrix of regres...
6,303
<ASSISTANT_TASK:> Python Code: import json import numpy as np import h5py import seaborn as sns from scipy.interpolate import splev,splrep import matplotlib.pyplot as plt import astropy.units as u from sunpy.instr import aia import ChiantiPy.core as ch import ChiantiPy.tools.data as ch_data %matplotlib inline response...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Wavelength Response Step2: Temperature Response Step3: The main question is Step4: Boerner et al. (2012) use the coronal abundances of Feldma...
6,304
<ASSISTANT_TASK:> Python Code: import trappy import numpy config = {} # TRAPpy Events config["THERMAL"] = trappy.thermal.Thermal config["OUT"] = trappy.cpu_power.CpuOutPower config["IN"] = trappy.cpu_power.CpuInPower config["PID"] = trappy.pid_controller.PIDController config["GOVERNOR"] = trappy.thermal.ThermalGovernor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get the Trace Step2: FTrace Object Step3: Assertions Step4: Assertion Step5: Assertion Step6: Statistics Step7: Check if the mean temperau...
6,305
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # Martin Luessi <mluessi@nmr.mgh.harvard.edu> # Eric Larson <larson.eric.d@gmail.com> # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne import io, read_...
<SYSTEM_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: Plot the raw PSD Step3: Plot a cleaned PSD Step4: Alternative functions for PSDs
6,306
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import pystan import warnings warnings.filterwarnings("ignore") schools_code = data { int<lower=0> J; // number of schools real y[J]; // estimated treatment effects real<lower=0> sigma[J]; // s.e. of effect estimates } ...
<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: Eight schools example Step4: Optimization in Stan
6,307
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS from IPython.display import HTML from ipywidgets import interact HTML('../style/code_toggle.html') def loop_DFT(x): Implementin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import section specific modules Step3: 2.8. The Discrete Fourier Transform (DFT) and the Fast Fourier Transform (FFT)<a id='math Step5: Althou...
6,308
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import mapp4py from mapp4py import md from lib.elasticity import rot, cubic, resize, displace, HirthEdge, HirthScrew from mapp4py import mpi if mpi().rank!=0: with open(os.devnull, 'w') as f: sys.stdout = f; xprt = md.export...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Block the output of all cores except for one Step2: Define an md.export_cfg object Step3: Screw dislocation Step4: Create a $\langle110\rangl...
6,309
<ASSISTANT_TASK:> Python Code: import numpy as np num = np.array([3,4,2,5,7,23,56,23,7,23,89,43,676,43]) num print "Mean :",num.mean() print "sum :",num.sum() print "max :",num.max() print "std :",num.std() #slicing num[:5] #find index of any element let say max print "index of max :",num.argmax() print "data Type of...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Array are similar to python list , but it all element must be of same data type, and it faster than list Step2: Lets see some of functionality ...
6,310
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame({'DateTime': ['2000-01-04', '2000-01-05', '2000-01-06', '2000-01-07'], 'Close': [1460, 1470, 1480, 1450]}) def g(df): df['label'] = df.Close.diff().fillna(1).gt(0).astype(int) return df df = g(df.copy()) <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:
6,311
<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...
6,312
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np # modulo de computo numerico import matplotlib.pyplot as plt # modulo de graficas # esta linea hace que las graficas salgan en el notebook import seaborn as sns %matplotlib inline df=pd.read_csv('files/ejemplo.csv') print('df.shape) df.head() sns.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: Un mini-ejemplo Step2: Visualizando
6,313
<ASSISTANT_TASK:> Python Code: #!/usr/bin/python %matplotlib inline import numpy as np import matplotlib.pyplot as plt from stats import parse_results, get_percentage, get_avg_per_seed, draw_pie, draw_bars, draw_bars_comparison, draw_avgs pr, eigen, bet = parse_results('test_genws.txt') draw_pie(get_percentage(pr)) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Parse results Step2: PageRank Seeds Percentage Step3: Avg adopters per seed comparison Step4: Eigenvector Seeds Percentage Step5: Avg adopte...
6,314
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-2', 'toplevel') # 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: 2...
6,315
<ASSISTANT_TASK:> Python Code: # With Hashmap. # Time Complexity: O(n) def if_unique(string): chr_dict = {} for char in string: if char not in chr_dict: chr_dict[char] = 1 else: return False return True # Without additional memory. # Time Complexity: O(n^2) def 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: P2. Check Permutation Step2: P3. URLify Step3: P4. Palindrome Permutation Step4: P5. One Away Step5: P6. String Compression Step6: P7. Rota...
6,316
<ASSISTANT_TASK:> Python Code: !wget http://archive.ics.uci.edu/ml/machine-learning-databases/00299/StoneFlakes.dat !head StoneFlakes.dat import pandas d = pandas.read_csv(open('StoneFlakes.dat')) d[:5] d = pandas.read_csv(open('StoneFlakes.dat'),sep=',') d[:5] ! tr -s ' ' ',' < StoneFlakes.dat > StoneFlakes2.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: Step1: Let's look at the first few lines. Step2: Read about the column names and the meaning of the ID values at the data set's web site. Step3: Le...
6,317
<ASSISTANT_TASK:> Python Code: import numpy as np def number_to_words(n): Given a number n between 1-1000 inclusive return a list of words for the number. # YOUR CODE HERE #raise NotImplementedError() ones=['one','two','three','four','five','six','seven','eight','nine','ten'] teens=['eleven','twelve...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Project Euler Step2: Now write a set of assert tests for your number_to_words function that verifies that it is working as expected. Step4: No...
6,318
<ASSISTANT_TASK:> Python Code: data_in_shape = (6, 6, 3, 4) L = GlobalAveragePooling3D(data_format='channels_last') layer_0 = Input(shape=data_in_shape) layer_1 = L(layer_0) model = Model(inputs=layer_0, outputs=layer_1) # set weights to random (use seed for reproducibility) np.random.seed(270) data_in = 2 * np.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: [pooling.GlobalAveragePooling3D.1] input 3x6x6x3, data_format='channels_first' Step2: [pooling.GlobalAveragePooling3D.2] input 5x3x2x1, data_fo...
6,319
<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: Optimization Analysis Step2: Load Data Step3: Plot Step4: Hardware Grid Step5: SK Model Step6: 3 Regular MaxCut
6,320
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import matplotlib.pyplot as plt from pylab import * from tensorflow.examples.tutorials.mnist import input_data %matplotlib inline epochs = 1000 learning_rate = 0.5 mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) print (mnist.train...
<SYSTEM_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 and Labels Step2: Data Visualization Step3: "one-hot" format to present labels
6,321
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division %matplotlib inline import numpy as np import nsfg import first import thinkstats2 import thinkplot live, firsts, others = first.MakeFrames() first_wgt = firsts.totalwgt_lb first_wgt_dropna = first_wgt.dropna() print('Firsts', len(first_wgt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Examples Step2: And compute the distribution of birth weight for first babies and others. Step3: We can plot the PMFs on the same scale, but i...
6,322
<ASSISTANT_TASK:> Python Code: import time from kafka import KafkaProducer import json import random import csv import uuid import datetime Usage: bin/spark-submit ~/spark/kafkaProducrerTest.py producer = KafkaProducer(bootstrap_servers='localhost:9092') pitch = 0 position = 0 def getRandomPitch(min,max): pitch =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Kafka Producer Test Script Step2: The "getRandomPitch" method will generate a mock "reading" between a min and max range. The position can be ...
6,323
<ASSISTANT_TASK:> Python Code: from pandas import DataFrame, Series import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline weather = pd.read_table('daily_weather.tsv') usage = pd.read_table('usage_2012.tsv') stations = pd.read_table('stations.tsv') newseasons = {'Summer': 'Spring', '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: Question 1 Step2: Question 2 Step3: Question 3 Step4: Question 4
6,324
<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: Integrated gradients Step2: Download a pretrained image classifier from TF-Hub Step3: From the module page, you need to keep in mind the follo...
6,325
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nims-kma', 'sandbox-2', '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...
6,326
<ASSISTANT_TASK:> Python Code: # Configure Jupyter so figures appear in the notebook %matplotlib inline # Configure Jupyter to display the assigned value after an assignment %config InteractiveShell.ast_node_interactivity='last_expr_or_assign' # import functions from the modsim.py module from modsim import * def make_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step7: Code from previous chapters Step8: Contact number Step9: The following loop shows how we can loop through the columns and rows of the SweepFra...
6,327
<ASSISTANT_TASK:> Python Code: from jupyterthemes import get_themes from jupyterthemes.stylefx import set_nb_theme themes = get_themes() set_nb_theme(themes[3]) # 1. magic for inline plot # 2. magic to print version # 3. magic so that the notebook will reload external python modules # 4. magic to enable retina (high 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: Rossman Deep Learning Modeling Step2: Here, we will remove all records where the store had zero sale / was closed (feel free to experiment with...
6,328
<ASSISTANT_TASK:> Python Code: def cube_positif( x ): if abs( x*x*x >= 0.0): return x*x*x print("Erreur") return cube_positif(-4) %matplotlib inline import matplotlib.pyplot as plt #On commence sans fonction, XX=[] YY=[] X=range(10,-10,-1) for x in X: XX.append(x) YY.append(x*x*x) 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: Maintenant on peux se servir de Step2: 2) Correction de fonctions en vrac (les fonction suivantes doivent être corrigées) Step3: 2.2) Factori...
6,329
<ASSISTANT_TASK:> Python Code: import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers IMG_SHAPE = (28, 28, 1) BATCH_SIZE = 512 # Size of the noise vector noise_dim = 128 fashion_mnist = keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_la...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Prepare the Fashion-MNIST data Step2: Create the discriminator (the critic in the original WGAN) Step3: Create the generator Step5: Create th...
6,330
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-3', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,331
<ASSISTANT_TASK:> Python Code: from scipy import stats import h5py ! cat configurations.json ! cat architecture.json train = h5py.File('../data/hdf5datasets/NSMSDSRSCSTSRI_500bp/train.h5', 'r') train.items() validation = h5py.File('../data/hdf5datasets/NSMSDSRSCSTSRI_500bp/validation.h5', 'r') validation.items() 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: INTRO Step2: architecture.json Step3: RELEVANT HDF5 FILES Step4: validation = h5py.File('../data/hdf5datasets/validation.h5', 'r') Step5: te...
6,332
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import datetime as dt import scipy.spatial.distance as dist %matplotlib inline import glob allFiles = glob.glob('4months' + "/*.csv") frame = pd.DataFrame() list_ = [] for file_ in allFiles: df = pd.read_csv(file_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Section 2 Step2: Section 3 Step3: Display variable power Step4: Use parser function from dateutil module to convert the timestamps in power f...
6,333
<ASSISTANT_TASK:> Python Code: 1 -5 print 2 + 10 # addition print 5 - 3 # subtraction print 6 * 4 # multiplication print 10 / 5 # division print 2**4 # exponents 2 / 3 2 / 3.0 1.5 type(1.5) 0.1 + 0.2 from decimal import Decimal Decimal('0.1') + Decimal('0.2') 'Hello python learners' print 'Hello' print "there" 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: There is something I should mention here. python 2 can trip people up when trying to do something like the following Step2: This is because pyt...
6,334
<ASSISTANT_TASK:> Python Code: fig, axes = plt.subplots(1, 2, figsize=(10,4)) axes[0].plot(x, x**2, x, np.exp(x)) axes[0].set_title("Normal scale") axes[1].plot(x, x**2, x, np.exp(x)) axes[1].set_yscale("log") axes[1].set_title("Logarithmic scale (y)"); fig, ax = plt.subplots(figsize=(10, 4)) ax.plot(x, x**2, 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: Placement of ticks and custom tick labels Step2: There are a number of more advanced methods for controlling major and minor tick placement in ...
6,335
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'sandbox-3', 'seaice') # 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: 2...
6,336
<ASSISTANT_TASK:> Python Code: import nbinteract as nbi nbi.multiple_choice(question="What is 10 + 2 * 5?", choices=['12', '60', '20'], answers=2) nbi.multiple_choice(question="Select all prime numbers.", choices=['12', '3', '31'], answers...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: nbinteract.multiple_choice Step2: nbinteract.short_answer
6,337
<ASSISTANT_TASK:> Python Code: %load_ext watermark %watermark -a 'Sebastian Raschka' -u -d -v -p numpy,pandas,matplotlib,scikit-learn # to install watermark just uncomment the following line: #%install_ext https://raw.githubusercontent.com/rasbt/watermark/master/watermark.py from sklearn import datasets import numpy a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Sections Step2: Splitting data into 70% training and 30% test data Step3: Standardizing the features Step4: <br> Step5: Training a perceptro...
6,338
<ASSISTANT_TASK:> Python Code: import tensorflow as tf with tf.Session(): input1 = tf.constant([1.0, 1.0, 1.0, 1.0]) input2 = tf.constant([2.0, 2.0, 2.0, 2.0]) output = tf.add(input1, input2) result = output.eval() print result print [x + y for x, y in zip([1.0] * 4, [2.0] * 4)] import numpy as np x, y = np....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: What we're doing is creating two vectors, [1.0, 1.0, 1.0, 1.0] and [2.0, 2.0, 2.0, 2.0], and then adding them. Here's equivalent code in raw Pyt...
6,339
<ASSISTANT_TASK:> Python Code: # define model parameters ces_params = {'A0': 1.0, 'L0': 1.0, 'g': 0.02, 'n': 0.03, 's': 0.15, 'delta': 0.05, 'alpha': 0.33, 'sigma': 0.95} # create an instance of the solow.Model class ces_model = solowpy.CESModel(params=ces_params) # check the docstring... ces_model.stead...
<SYSTEM_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 Analytic results Step2: 2.2 Numerical methods Step3: Example usage Step4: We can display the value and confirm that the algorithm did ind...
6,340
<ASSISTANT_TASK:> Python Code: if not os.path.isfile('data/hg19.ml.fa'): subprocess.call('curl -o data/hg19.ml.fa https://storage.googleapis.com/basenji_tutorial_data/hg19.ml.fa', shell=True) subprocess.call('curl -o data/hg19.ml.fa.fai https://storage.googleapis.com/basenji_tutorial_data/hg19.ml.fa.fai', shell...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Compute scores Step2: Plot Step3: The resulting plots reveal a low level of activity, with a GC-rich motif driving the only signal.
6,341
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D df = pd.read_csv('ex1data2.txt', header=None) print(df.head()) #Lets try to visualize the data fig = plt.figure() ax = Axes3D(fig) ax.scatter(df[0], df[1], df[2]) ax.set_zlabel('price') plt.xlabel(...
<SYSTEM_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 will start with normalization of the features because size of the house is in different range as compared to number of bedrooms Step2: D...
6,342
<ASSISTANT_TASK:> Python Code: import pandas as pd import shl_pm ## which month to predictsimulate? # shl_sm_parm_ccyy_mm = '2017-04' # shl_sm_parm_ccyy_mm_offset = 1647 # shl_sm_parm_ccyy_mm = '2017-05' # shl_sm_parm_ccyy_mm_offset = 1708 shl_sm_parm_ccyy_mm = '2017-06' shl_sm_parm_ccyy_mm_offset = 1769 # shl_sm_par...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import SHL Prediction Module Step2: shl_sm parameters Step3: shl_pm Initialization Step4: MISC - Validation
6,343
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import os import sys import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import (MultipleLocator, FormatStrFormatter, AutoMinorLocator) import pandas as pd os.chdir('..') os.getcwd() sys.path.append('../scripts/') import bicorr_plot as bicorr_plo...
<SYSTEM_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 $E_n$ vs $\theta$ Step2: Divide by experimental
6,344
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt from __future__ import print_function import numpy as np import mesh.boundary as bnd import mesh.patch as patch import multigrid.MG as MG nx = ny = 256 mg = MG.CellCenterMG2d(nx, ny, xl_BC_type="dirichlet", xr_BC_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Constant-coefficent Poisson equation Step2: Next, we initialize the RHS. To make life easier, the CellCenterMG2d object has the coordinates of...
6,345
<ASSISTANT_TASK:> Python Code: # Mendefinisikan isi list bisa dilakukan dengan banyak cara. # Salah satunya adalah mendeklarasikan isinya dengan meletakkannya # di antara dua tanda kurung siku atau brackets. kotakota = ["Bandung", "Jakarta", "Surabaya"] arahangin = ["Utara", "Barat", "Timur", "Selatan"] print(kotako...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Untuk menambahkan, kita bisa menggunakan fungsi append pada list tersebut. Untuk membuang, kita bisa menggunakan fungsi del pada koordinat yang ...
6,346
<ASSISTANT_TASK:> Python Code: # Create folders !mkdir -p '/android/sdk' # Download and move android SDK tools to specific folders !wget -q 'https://dl.google.com/android/repository/tools_r25.2.5-linux.zip' !unzip 'tools_r25.2.5-linux.zip' !mv '/content/tools' '/android/sdk' # Copy paste the folder !cp -r /android/sdk/...
<SYSTEM_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 BAZEL with Baselisk Step2: Build .aar files
6,347
<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' # Use Floyd's cifar-10 dataset if ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
6,348
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline with open('data/reviews.txt','r') as file_handler: reviews = np.array(list(map(lambda x:x[:-1], file_handler.readlines()))) with open('data/labels.txt','r') as file_handler: labels = np.array(list(map(lambda x: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: The dataset is perfectly balanced across the two categories POSITIVE and NEGATIVE. Step2: Well, at a first glance, that seems dissapointing. A...
6,349
<ASSISTANT_TASK:> Python Code: # the output of plotting commands is displayed inline within frontends, # directly below the code cell that produced it %matplotlib inline # this python library provides generic shallow (copy) and deep copy (deepcopy) operations from copy import deepcopy import time # import from Ocelot...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Layout of the corrugated structure insertion. Create Ocelot lattice <img src="4_layout.png" /> Step2: Load beam file Step3: Initialization of ...
6,350
<ASSISTANT_TASK:> Python Code: #!/usr/bin/env python # A code line that shows the result of 7 times 3 print 7 * 3 # A line broken by backslash a = 7 * 3 + \ 5 / 2 # A list (broken by comma) b = ['a', 'b', 'c', 'd', 'e'] # A function call (broken by comma) c = range(1, 11) # Prints everything print a, b, c # For i on...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Examples of broken lines Step2: The command print inserts spaces between expressions that are received as a parameter, and a newline character ...
6,351
<ASSISTANT_TASK:> Python Code: import pylearn2.utils import pylearn2.config import numpy as np %matplotlib inline import matplotlib.pyplot as plt import os.path model = pylearn2.utils.serial.load(os.path.expandvars('${DATA_DIR}/plankton/models/learning_rate_experiment/ilr_5e-2_lin_decay_adj_on_recent.pkl')) print(mode...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Model trained on on 0.1 split of data Step2: Plot train and valid set NLL Step3: Strangely though overfitting to training set does not seem to...
6,352
<ASSISTANT_TASK:> Python Code: %pylab inline !cd toy_datasets; wget -O MiniBooNE_PID.txt -nc MiniBooNE_PID.txt https://archive.ics.uci.edu/ml/machine-learning-databases/00199/MiniBooNE_PID.txt import numpy, pandas from rep.utils import train_test_split from sklearn.metrics import roc_auc_score data = pandas.read_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: Loading data Step2: Training variables Step3: Folding strategy - stacking algorithm Step4: Define folding model Step5: Default prediction (p...
6,353
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from IPython.core.pylabtools import figsize import matplotlib.pyplot as plt figsize( 12.5, 5 ) sample_size = 100000 expected_value = lambda_ = 4.5 poi = np.random.poisson N_samples = range(1,sample_size,100) for k in range(3): samples = poi( lambd...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Looking at the above plot, it is clear that when the sample size is small, there is greater variation in the average (compare how jagged and jum...
6,354
<ASSISTANT_TASK:> Python Code: #importing some useful packages import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import cv2 %matplotlib inline #reading in an image image = mpimg.imread('test_images/solidWhiteRight.jpg') #printing out some stats and plotting print('This image is:', typ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Read in an Image Step10: Ideas for Lane Detection Pipeline Step11: Test Images Step12: Build a Lane Finding Pipeline Step13: Test on Videos ...
6,355
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('scm-hello.png') imgplot = plt.imshow(img) plt.axis('off') plt.show() # Initialize logging. import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) sente...
<SYSTEM_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 method was perhaps first introduced in the article “Soft Measure and Step2: The first two sentences sentences have very similar content, a...
6,356
<ASSISTANT_TASK:> Python Code: import json import pandas as pd import re import string from scipy import sparse import numpy as np from pymongo import MongoClient from nltk.corpus import stopwords %matplotlib inline import matplotlib.pyplot as plt from sklearn import svm from sklearn.decomposition import LatentDirichle...
<SYSTEM_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 files and word dictionaries Step2: Pick a subset of users that have at least 200 reviews, run an iterative test on these users Step...
6,357
<ASSISTANT_TASK:> Python Code: import larch, numpy, pandas, os, geopandas larch.__version__ import larch.exampville larch.exampville.files.shapefile taz_shape = geopandas.read_file("zip://"+larch.exampville.files.shapefile) taz_shape.plot(edgecolor='k'); larch.exampville.files.employment emp = pandas.read_csv(larch...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Welcome to Exampville, the best simulated town in this here part of the internet! Step2: TAZ Shapefile Step3: Geopandas can open and read this...
6,358
<ASSISTANT_TASK:> Python Code: %matplotlib inline print(df['gender'].value_counts()) df.groupby('gender')['networthusbillion'].mean() df.groupby('gender')['sourceofwealth'].value_counts() df.plot(kind='scatter', x='gender', y='networthusbillion') <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's make a graph 'bout it
6,359
<ASSISTANT_TASK:> Python Code: file_listcal = "alma_sourcecat_searchresults_20180419.csv" q = databaseQuery() listcal = q.read_calibratorlist(file_listcal, fluxrange=[0.1, 999999]) len(listcal) print("Name: ", listcal[0][0]) print("J2000 RA, dec: ", listcal[0][1], listcal[0][2]) print("Alias: ", listcal[0][3]) print("...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example, retrieve all the calibrator with a flux > 0.1 Jy Step2: Select all calibrators that heve been observed at least in 3 Bands [ >60s in B...
6,360
<ASSISTANT_TASK:> Python Code: import pandas as pd # pandas is a dataframe library import matplotlib.pyplot as plt # matplotlib.pyplot plots data %matplotlib inline df = pd.read_csv("./data/pima-data.csv") df.shape df.head(5) df.tail(5) df.isnull().values.any() def plot_corr(df, size=11): ...
<SYSTEM_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 and Reviewing the Data Step2: Definition of features Step4: Correlated Feature Check Step5: The skin and thickness columns are correl...
6,361
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import numpy as np import tensorflow as tf from six.moves import cPickle as pickle from six.moves import range pickle_file = '../notMNIST.pick...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reformat into a TensorFlow-friendly shape Step2: Let's build a small network with two convolutional layers, followed by one fully connected lay...
6,362
<ASSISTANT_TASK:> Python Code: %pylab notebook p = 12 n_m = 600 # [r/min] n_pulses = 3*p*n_m print(''' n_pulses = {:.0f} pulses/min = {:.0f} pulses/sec ============================================'''.format(n_pulses, n_pulses/60)) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Description Step2: SOLUTION
6,363
<ASSISTANT_TASK:> Python Code: from scipy import sparse c1 = sparse.csr_matrix([[0, 0, 1, 0], [2, 0, 0, 0], [0, 0, 0, 0]]) c2 = sparse.csr_matrix([[0, 3, 4, 0], [0, 0, 0, 5], [6, 7, 0, 8]]) Feature = sparse.hstack((c1, c2)).tocsr() <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:
6,364
<ASSISTANT_TASK:> Python Code: # ライブラリのインポート from itertools import product import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn import datasets from sklearn import tree from sklearn.tree import DecisionTreeClassifier from sklearn.neighbors import KNeighborsClassifier from sklearn.svm 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: scikit-learn準拠の識別器を作る Step2: 精度の評価 Step3: 世の中の機械学習モデルをいくつか試す Step5: Confusion Matrix Step6: グリッドサーチで最適なパラーメタを探す
6,365
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'uhh', 'sandbox-2', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "email...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,366
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline #import seaborn as sns #sns.set() N = 100 #points to generate X = np.sort(10*np.random.rand(N, 1)**0.8 , axis=0) #abscisses y = 4 + 0.4*np.random.rand(N) - 1. / (X.ravel() + 0.5)**2 - 1. / (10.5 - X.ravel() ) # some...
<SYSTEM_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 will obviously be a bad fit. Step2: Let us transform it into a 3-degree polynomial fit and perform the same linear regression...
6,367
<ASSISTANT_TASK:> Python Code: import gmaps, os # Used for interactive visualizations from game_types import NPlayerGame import tensorflow as tf import pandas as pd gmaps.configure(api_key=os.environ["GOOGLE_API_KEY"]) locs = [ [(37.760851, -122.443118), (37.760853, -122.443120)], # Silcon Valley [(40.092034...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configuring stuff for visualizations Step2: Playing Peace War Game with 14 Players for 650,000 iterations Step3: Grabbing scores of each agent...
6,368
<ASSISTANT_TASK:> Python Code: import numpy as np numerator = 98 denominator = 42 gcd = np.gcd(numerator, denominator) result = (numerator//gcd, denominator//gcd) <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:
6,369
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) img = mnist.train.images[2] plt.imshow(img.reshape((28, 28)), cmap='...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Below I'm plotting an example image from the MNIST dataset. These are 28x28 grayscale images of handwritten digits. Step2: We'll train an autoe...
6,370
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-1', 'ocean') # 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...
6,371
<ASSISTANT_TASK:> Python Code: x = 3 x = 4.5 x = 3 x = 4.5 x = 3 y = 3.0 x is y x == y x = 'Hello' x = 'Hello' x.lower() x x = 'Hello' x = x.lower() x for i in range(0, 10): print(i) i = 2 while i < 12: print(i) i += 3 for i in range(0, 10, 2): print(i) for i in range(0, 10): if i % 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: Python accepts the previous because of dynamic typing (C would throw an error!) Step2: The previous line is going to cause a PyIntObject to be...
6,372
<ASSISTANT_TASK:> Python Code: # Bibliotecas utilizadas para confeccionar el mapa %matplotlib inline import matplotlib.pyplot as plt from descartes import PolygonPatch import matplotlib.cm as cmx import matplotlib.colors as colors import matplotlib.colorbar as colorbar from shapely import geometry from shapely import o...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1.- BASE DE DATOS DE CULTIVOS DE BAJÍO AMAZÓNICO Step2: Obtenemos un consolidado por estrato para hacernos una idea Step3: 2.- Linderos de las...
6,373
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import tectosaur as tct import tectosaur.qd import tectosaur.qd.plotting tct.qd.configure( gpu_idx = 0, # Which GPU to use if there are multiple. Best to leave as 0. fast_plot = True, # Let's make fast, inexpensive figures. Set 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: Now, we load the data from the previous run. Check what folder was created! If you ran the simulation code multiple times, each time a new folde...
6,374
<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: Quantization aware training in Keras example Step2: Train a model for MNIST without quantization aware training Step3: Clone and fine-tune pre...
6,375
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline def activation_sigmoid(x, derivative): sigmoid_value = 1/(1+np.exp(-x)) if not derivative: return sigmoid_value else: return sigmoid_value*(1-sigmoid_value) x_values = np.arange(-5, 6, 0.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: Sigmoid Step2: When plotted on a range of -5,5, this gives the following shape. Step3: Tanh Step4: ReLU Step5: It is probably worth noting, ...
6,376
<ASSISTANT_TASK:> Python Code: import numpy as np import os from skimage.transform import resize from sklearn.ensemble import RandomForestClassifier from sklearn import svm import tools as im from matplotlib import pyplot as plt %matplotlib inline path=os.getcwd()+'/' # finds the path of the folder in which the noteboo...
<SYSTEM_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 define the function prep_datas (props to Alexandre), already used the previous week. However now we reshape the images from a 32x32 matrix (t...
6,377
<ASSISTANT_TASK:> Python Code: import os import re import operator import matplotlib.pyplot as plt import warnings import gensim import numpy as np warnings.filterwarnings('ignore') # Let's not pay heed to them right now from gensim.models import CoherenceModel, LdaModel, LsiModel, HdpModel from gensim.models.wrappers...
<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: Analysing our corpus. Step4: Preprocessing our data. Remember Step5: Finalising our dictionary and corpus Step6: Topic modeling with LSI Step...
6,378
<ASSISTANT_TASK:> Python Code: %matplotlib inline import importlib import utils2; importlib.reload(utils2) from utils2 import * np.set_printoptions(4) PATH = 'data/spellbee/' limit_mem() from sklearn.model_selection import train_test_split lines = [l.strip().split(" ") for l in open(PATH+"cmudict-0.7b", encoding='lat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The CMU pronouncing dictionary consists of sounds/words and their corresponding phonetic description (American pronunciation). Step2: Next we'r...
6,379
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib import matplotlib.pyplot as plt import sys, time, math import numpy as np from numpy import linalg as nplin from dcpyps.samples import samples from dcpyps import dataset, mechanism, dcplots, dcio # LOAD DATA: Burzomato 2004 example set. scnfiles = [["...
<SYSTEM_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: Initialise Single-Channel Record from dcpyps. Note that SCRecord takes a list of file names; several SCN files from the same p...
6,380
<ASSISTANT_TASK:> Python Code: # boilerplate code import os from io import BytesIO import numpy as np from functools import partial import PIL.Image from IPython.display import clear_output, Image, display, HTML from __future__ import print_function import tensorflow as tf #!wget https://storage.googleapis.com/downloa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <a id='loading'></a> Step6: To take a glimpse into the kinds of patterns that the network learned to recognize, we will try to generate images ...
6,381
<ASSISTANT_TASK:> Python Code: A = np.mat([ [4, 5, 4, 1, 1], [5, 3, 5, 0, 0], [0, 1, 0, 1, 1], [0, 0, 0, 0, 1], [1, 0, 0, 4, 5], [0, 1, 0, 5, 4], ]) U, S, V = np.linalg.svd(A) U.shape, S.shape, V.shape U S np.diag(S) V def reconstruct(U, S, V, rank): return U[:,0:rank] * np.diag(S[:rank]...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Left singular vectors Step2: Singular values Step3: As you can see, the singular values are sorted descendingly. Step4: Reconstructing the or...
6,382
<ASSISTANT_TASK:> Python Code: # install Pint if necessary try: import pint except ImportError: !pip install pint # download modsim.py if necessary from os.path import exists filename = 'modsim.py' if not exists(filename): from urllib.request import urlretrieve url = 'https://raw.githubusercontent.com/A...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Modeling tree growth Step2: And here's the series of heights for a site with index 45, indicating that height at 30 years is 45 feet. Step3: H...
6,383
<ASSISTANT_TASK:> Python Code: import stix2 stix2.Indicator() from stix2 import Indicator Indicator() import stix2.v20 stix2.v20.Indicator() from stix2.v20 import Indicator Indicator() import stix2.v20 as stix2 stix2.Indicator() import stix2 stix2.v20.Indicator() stix2.v21.Indicator() from stix2 import v20, v21 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: or, Step2: People who want to use an explicit version Step3: or, Step4: or even, (less preferred) Step5: The last option makes it easy to up...
6,384
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt plt.style.use('notebook.mplstyle') %matplotlib inline from scipy.stats import mode a = np.random.multivariate_normal([1., 0.5], [[4., 0.], [0., 0.25]], size=512) b = n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's imagine we measure 2 quantities, $x_1$ and $x_2$ for some objects, and we know the classes that these objects belong to, e.g., "star", 0, ...
6,385
<ASSISTANT_TASK:> Python Code: import subprocess Creates models for each fold and runs evaluation with results featureset = "o" entity_name = "adversereaction" for fold in range(1,1): #training has already been done training_data = "../ARFF_Files/%s_ARFF/_%s/_train/%s_train-%i.arff" % (entity_name, featureset, en...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Experimental Results from a Decision Tree based NER model Step3: Rather lackluster performance. Step4: It appears adding in the morphological ...
6,386
<ASSISTANT_TASK:> Python Code: from wordcloud import WordCloud from nltk.corpus import stopwords from nltk.sentiment import * import pandas as pd import numpy as np import nltk import time import matplotlib.pyplot as plt import seaborn as sns import pycountry %matplotlib inline # import data directory = 'hillary-clinto...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Comparison between extracted body text and raw text Step2: By reading a few emails we can see that the extracted body text is just the text tha...
6,387
<ASSISTANT_TASK:> Python Code: print("Mike") # insert your own code here! x = 5 print(x) x = 2 print(x) print(x * x) print(x + x) print(x - 6) seconds_in_seven_weeks = 70560 print(seconds_in_seven_weeks) first_number = 5 second_number = first_number first_number = 3 print(first_number) print(second_number) # not ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Can you describe what this code did? Step2: Excellent! You have just written and executed your very first program! Please make sure to run ever...
6,388
<ASSISTANT_TASK:> Python Code: import sys import logging # Import the GEM-PRO class from ssbio.pipeline.gempro import GEMPRO # Printing multiple outputs per cell from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" # Create logger logger = logging.getLogger() logge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Logging Step2: Initialization Step3: Mapping gene ID --> sequence Step4: Mapping representative sequence --> structure Step5: Homology model...
6,389
<ASSISTANT_TASK:> Python Code: %matplotlib inline stats_file = '../test_data/ALL_N95_Mean_cope2_thresh_zstat1.nii.gz' view = 'ortho' colormap = 'RdBu_r' threshold = '2.3' black_bg %run ../scripts/mni_glass_brain.py --cbar --display_mode $view --cmap $colormap --thr_abs $threshold $stats_file from IPython.display im...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Upload all statistical maps into the data folder Step2: 3. Run the visualization script Step3: 4. Look at your data
6,390
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from sklearn.linear_model import LogisticRegression from sklearn import metrics from rdkit import Chem from rdkit.Chem import Draw %matplotlib inline m = Chem.MolFromSmiles('Cc1ccccc1') Chem.Kekulize(m) Chem.MolToSmiles(m,kekuleSmiles=True) fig = Dr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Look at Chemicals Step2: Look at a grid of chemicals
6,391
<ASSISTANT_TASK:> Python Code: # Authors: Marijn van Vliet <w.m.vanvliet@gmail.com> # Ezequiel Mikulan <e.mikulan@gmail.com> # # License: BSD (3-clause) import os import os.path as op import shutil import mne data_path = mne.datasets.sample.data_path() subjects_dir = op.join(data_path, 'subjects') bem_dir = op...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exporting surfaces to Blender Step2: Editing in Blender Step3: Back in Python, you can read the fixed .obj files and save them as
6,392
<ASSISTANT_TASK:> Python Code: # data = np.genfromtxt("data/ionosphere.data") data = pd.read_csv('data/ionosphere.data', sep=",", header=None) data.head() data.describe() df_tab = data df_tab[34] = df_tab[34].astype('category') tab = pd.crosstab(index=df_tab[34], columns="frequency") tab.index.name = 'Class/Direction'...
<SYSTEM_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 a very small dataset. Step2: About 63% of all observations are good. Step3: Set Global Parameters Step5: Train Classifier Step6: Wha...
6,393
<ASSISTANT_TASK:> Python Code: import os PROJECT_ID = "dougkelly-sandbox" # TODO: your PROJECT_ID here. os.environ["PROJECT_ID"] = PROJECT_ID BUCKET_NAME = "xai-labs" # TODO: your BUCKET_NAME here. REGION = "us-central1" os.environ['BUCKET_NAME'] = BUCKET_NAME os.environ['REGION'] = REGION %%bash exists=$(gsutil ls -...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Run the following cell to create your Cloud Storage bucket if it does not already exist. Step2: Timestamp Step3: Import libraries Step4: Down...
6,394
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import importlib import os import sys from elasticsearch import Elasticsearch from skopt.plots import plot_objective # project library sys.path.insert(0, os.path.abspath('..')) import qopt importlib.reload(qopt) from qopt.notebooks import evaluate_mrr100...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Baseline evaluation Step2: That's pretty impressive for the baseline query. It beats our baseline cross_fields query but not quite the optimize...
6,395
<ASSISTANT_TASK:> Python Code: # ensure that plots are shown inline %matplotlib inline import numpy as np # <- efficient vector/matrix operations (similar to MATLAB) # the next ones are not required here, but might become useful later on, check if they're installed import matplotlib as plt # <- basic plotting import se...
<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: Session 2 Primer Step3: Example call
6,396
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division %matplotlib inline import warnings warnings.filterwarnings('ignore', category=FutureWarning) import numpy as np import pandas as pd import random import thinkstats2 import thinkplot import nsfg preg = nsfg.ReadFemPreg() complete = preg.quer...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Survival analysis Step3: The survival function is just the complementary CDF. Step4: Here's the CDF and SF. Step5: And here's the hazard func...
6,397
<ASSISTANT_TASK:> Python Code: % matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.special import binom from scipy.optimize import brentq np.seterr(over='raise') def StoneMod(Rtot, Kd, v, Kx, L0): ''' Returns the number of mutlivalent ligand bound to a cell with Rtot receptors,...
<SYSTEM_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) We will fit the data contained within Fig. 3B. Plot this data and describe the relationship you see between Kx, Kd, and valency. Step2: (2)...
6,398
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np # Make flux time-series with random noise, and # two periodic oscillations, one 70% the amplitude # of the other: np.random.seed(42) n_points = 1000 primary_period = 2.5*np.pi secondary_period = 1.3*np.pi all_times = n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now we'll use two interpacf methods on these simulated fluxes Step2: Comparing with McQuillan, Aigrain & Mazeh (2013) Step3: Now measure the p...
6,399
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import numpy as np import LearnyMcLearnface as lml affine = lml.layers.AffineLayer(30, 10, 1e-2) test_input = np.random.randn(50, 30) dout = np.random.randn(50, 10) _ = affine.forward(test_input) dx_num = lml.utils.numerical_gradient_layer(lambda x : af...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Affine Layer Step2: Batch Normalization Layer Step3: Dropout Layer Step4: PReLU (Parametric Rectified Linear Unit) Layer Step5: ReLU (Rectif...