text_prompt
stringlengths
168
30.3k
code_prompt
stringlengths
67
124k
<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: Load data and construct predictions Step5: Creating Figures
<ASSISTANT_TASK:> Python Code: Load the ND data, which we want to analyze path = "../data/ND_data_filtered" W = gather_data(path, "width") W = W[0,:,:,:] log_mean = np.mean(np.log(W), axis=2) log_std = np.std(np.log(W), axis=2) Load the 1D data, for predictions path = "../data/1D_data_for_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: Now we will load the dataSciencePilot action set and the decisionTree action set. Step2: Next, we must connect to our data source. We are usin...
<ASSISTANT_TASK:> Python Code: import swat import numpy as np import pandas as pd conn = swat.CAS('localhost', 5570, authinfo='~/.authinfo', caslib="CASUSER") conn.builtins.loadactionset('dataSciencePilot') conn.builtins.loadactionset('decisionTree') tbl = 'hmeq' hmeq = conn.read_csv("./data/hmeq.csv", casout=dict(na...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get Forecast.io API key from config file Step2: Import API wrapper module Step3: Get weather data in daily and hourly resolution Step4: You c...
<ASSISTANT_TASK:> Python Code: import os import sys import inspect import pandas as pd import charts from opengrid import config config = config.Config() #get Forecast.io API Key api_key = config.get('Forecast.io', 'apikey') from opengrid.library import forecastwrapper start = pd.Timestamp('20150813') end = pd.Times...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reset TensorFlow Graph Step2: Create TensorFlow Session Step3: Load Model Training and Test/Validation Data Step4: Randomly Initialize Variab...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow.python.client import timeline import pylab import numpy as np import os %matplotlib inline %config InlineBackend.figure_format = 'retina' tf.logging.set_verbosity(tf.logging.INFO) tf.reset_default_graph() sess = tf.Session() print(sess) from datet...
<SYSTEM_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 solution Step2: Inspect each article for mentions of groups and locations Step3: Transform defaultdict to a Pandas DataFrame
<ASSISTANT_TASK:> Python Code: # To get you started we can import Pandas and Seaborn which might help you # build a graph or visualisation of the data % matplotlib inline from collections import defaultdict, Counter import matplotlib.pyplot as plt import matplotlib as mpl import pandas as pd import seaborn as sns impor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Working With Data Files Step2: Pandas is magic but it doesn't automatically know where to find your data of interest. You likely will have to ...
<ASSISTANT_TASK:> Python Code: !curl -Lo conda_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py import conda_installer conda_installer.install() !/root/miniconda/bin/conda info -e !pip install --pre deepchem import deepchem deepchem.__version__ !conda install pubchempy 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: Further Cleaning Step2: Sorting by date and by score Step3: Ploting my score data Step4: Using the linear regression models I can now get the...
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt %pylab inline col_names = ["Name", "End Time", "Game End Time", "Enemy", "x hit", "Damage", "Weapon", "PV", "Pos Dam", "Score", "Turns", "Zones", "Storied Items", "Artifact"] #read in the data from the text file, setti...
<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: Multicollearity Step4: As we can see in this example, the model indeed recovers the underlying structure of the data very well, despite quite s...
<ASSISTANT_TASK:> Python Code: # code for loading the format for the notebook import os # path : store the current path to convert back to it later path = os.getcwd() os.chdir(os.path.join('..', 'notebook_format')) from formats import load_style load_style() os.chdir(path) # 1. magic for inline plot # 2. magic to 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: Any one point inside the unit square would represent an image. For example the image associated with the point $(0.25,0.85)$ is shown below. Ste...
<ASSISTANT_TASK:> Python Code: x1 = np.random.uniform(size=500) x2 = np.random.uniform(size=500) fig = plt.figure(); ax = fig.add_subplot(1,1,1); ax.scatter(x1,x2, edgecolor='black', s=80); ax.grid(); ax.set_axisbelow(True); ax.set_xlim(-0.25,1.25); ax.set_ylim(-0.25,1.25) ax.set_xlabel('Pixel 2'); ax.set_ylabel('Pixel...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Quantities can be converted to other units systems or factors by using to() Step2: We can do arithmetic operations when the quantities have the...
<ASSISTANT_TASK:> Python Code: from astropy import units as u # Define a quantity length # print it # Type of quantity # Type of unit # Quantity # value # unit # information # Convert it to: km, lyr # arithmetic with distances # calculate a speed # decompose it #1 #2 #3 # create a composite unit # and in the imper...
<SYSTEM_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...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cmcc', 'sandbox-2', 'ocnbgchem') # 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: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' class DLProgress(tqdm): last_b...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create combined data Step2: Load Datafiles Step3: Shuffle the data Step4: Get parts of speech for text string Step5: Get POS trigrams for a ...
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import tensorflow as tf import tflearn from tflearn.data_utils import to_categorical import spacy nlp = spacy.load('en') import re from nltk.util import ngrams, trigrams import csv import subprocess subprocess.Popen("python combine.py childrens_frag...
<SYSTEM_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 is the software package that you will use to generate "data frames" which are just Python representations of data that you have collected...
<ASSISTANT_TASK:> Python Code: # this would be a comment # cells like this are like an advanced calculator # for example: 2+2 # Load the packages into memory by running this cell import pandas as pd import numpy as np import pygal # Example of how to use pandas to read and load a "comma-separated-value" or 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: 3.8.1 Sorting out the metadata Step2: Our Project has to be updated with the recent changes to the spreadsheet Step3: Such fixes can also be d...
<ASSISTANT_TASK:> Python Code: from reprophylo import * pj = unpickle_pj('outputs/my_project.pkpj', git=False) from IPython.display import Image Image('images/fix_otus.png', width = 400) pj.correct_metadata_from_file('data/Tetillida_otus_corrected.csv') concat = Concatenation('large_concat', # ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Target configuration Step2: Workload execution Step3: Energy estimation Step4: Data analysis Step5: We can see on the above plot that the sy...
<ASSISTANT_TASK:> Python Code: from conf import LisaLogging LisaLogging.setup() # One initial cell for imports import json import logging import os from env import TestEnv # Suport for FTrace events parsing and visualization import trappy from trappy.ftrace import FTrace from trace import Trace # Support for plotting #...
<SYSTEM_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 choice of the distance function (divergence) can be important. In practice, a popular choice is the Euclidian distance but this is by no mea...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pylab as plt df = pd.read_csv(u'data/iris.txt',sep=' ') df X = np.hstack([ np.matrix(df.sl).T, np.matrix(df.sw).T, np.matrix(df.pl).T, np.matrix(df.pw).T]) print X[:5] # sample view c = np.matrix(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: Definimos de una vez todas las variables necesarias Step2: Y definimos las variables que dependen de otra variable, especificamente en este cal...
<ASSISTANT_TASK:> Python Code: from sympy import var, sin, cos, pi, Matrix, Function, Rational, simplify from sympy.physics.mechanics import mechanics_printing mechanics_printing() var("l1:3") var("m1:3") var("J1:3") var("g t") q1 = Function("q1")(t) q2 = Function("q2")(t) def DH(params): from sympy import Matri...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <code>del</code> statement can be used to remove an item from a list given its index Step2: <code>list()</code> Step3: Sort a list Step4: Lis...
<ASSISTANT_TASK:> Python Code: pets = ['dog', 'cat', 'pig'] print pets.index('cat') pets.insert(0, 'rabbit') print pets pets.pop(1) print pets a = range(10) print a del a[2] print a print a[:3] del a[:3] print a print list('i can eat glass') print sorted([2, 3, 1], reverse=True) a = [2, 3, 1] print a.sort(reverse=Tr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import pandas and several display and plotting options Step2: If you already know the series ID you want (say by searching on the FRED website)...
<ASSISTANT_TASK:> Python Code: from fredapi import Fred fred = Fred() import pandas as pd pd.options.display.max_colwidth = 60 %matplotlib inline import matplotlib.pyplot as plt from IPython.core.pylabtools import figsize figsize(20, 5) s = fred.get_series('SP500', observation_start='2014-09-02', observation_end='201...
<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: For each row in the file, you need to make sure all the constraints are matching the desired ones. If so, keep count of the BMI group using a di...
<ASSISTANT_TASK:> Python Code: import csv # Import csv module for reading the file def get_BMI_count(dict_constraints): Take as input a dictionary of constraints for example, {'Age': '28', 'Sex': 'female'} And return the count of the various groups of BMI # We use a dictionary to store th...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Вариант с квадратами Step2: Вариант поскейленных данных Step3: В прошлом ноутбуке изучается рпспределение цен. Оно так себе - очень большая пл...
<ASSISTANT_TASK:> Python Code: data.drop(['Bal_na', 'Distr_N', 'Brick_na'], axis = 1, inplace = True) data_sq = data.copy() squared_columns = ['Distance', 'Kitsp', 'Livsp', 'Totsp', 'Metrokm'] squared_columns_new = ['Distance_sq', 'Kitsp_sq', 'Livsp_sq', 'Totsp_sq', 'Metrokm_sq'] for i in range(len(squared_columns)): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Group Travel Optimization Step4: This will print a line containing each person’s name and origin, as well as the depar- ture time, arrival time...
<ASSISTANT_TASK:> Python Code: import time import random import math people = [('Seymour','BOS'), ('Franny','DAL'), ('Zooey','CAK'), ('Walt','MIA'), ('Buddy','ORD'), ('Les','OMA')] # LaGuardia airport in New York destination='LGA' Load this data into a dictionary w...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: And some more specialized dependencies Step2: Configuration for this figure. Step3: Open a chest located on a remote globus endpoint and load ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib matplotlib.rcParams['figure.figsize'] = (10.0, 16.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 cla...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: NumPy provides various functions for creating common arrays Step2: Array operations Step3: But could that be done with lists? Yes but the syn...
<ASSISTANT_TASK:> Python Code: import numpy as np # standard import abbreviation a = np.array([1, 2, 3]) # a NumPy array of three integers a a.shape # tuple representing the size of each dimension a.ndim # number of dimensions a.dtype # Data type information b = np.array([1., 2., 3., 4.]) # a NumPy array of four...
<SYSTEM_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 Step2: Passing values to functions Step3: Conclusion Step4: Initialization of variables within function definition Step5: * operato...
<ASSISTANT_TASK:> Python Code: #Example_1: return keyword def straight_line(slope,intercept,x): "Computes straight line y value" y = slope*x + intercept return y print("y =",straight_line(1,0,5)) #Actual Parameters print("y =",straight_line(0,3,10)) #By default, arguments have a positional behaviour #Each 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: Step2: We then create a function to read in our dataset and clean it, pruning specifically the columns that we care about. Step3: We then create our c...
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division import pandas as pd import sys import numpy as np import math import matplotlib.pyplot as plt from sklearn.feature_extraction import DictVectorizer %matplotlib inline import seaborn as sns from collections import defaultdict, Counter import ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: bqplot scatter plot Step2: Ipyvolume quiver plot Step3: Linking ipyvolume and bqplot Step4: Embedding
<ASSISTANT_TASK:> Python Code: import numpy as np import vaex ds = vaex.example() N = 2000 # for performance reasons we only do a subset x, y, z, vx, vy, vz, Lz, E = [ds.columns[k][:N] for k in "x y z vx vy vz Lz E".split()] import bqplot.pyplot as plt plt.figure(1, title="E Lz space") scatter = plt.scatter(Lz, 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: If you never played with the low-level components of TensorFlow before, you probably would have expected the print operation to show the value o...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf a = tf.constant(3.0) b = a + 2.0 print(b) sess = tf.Session() with sess.as_default(): print(sess.run(b)) with tf.Session() as sess: c = sess.run(1.5*b) print(b) !pip install tensorflow==v1.7rc0 import tensorflow as tf import tensorflow.contrib.eager as tf...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 变量是动态的 Step2: 理解 Python 变量在内存中的表示 Step3: Python 有一些很优雅的设计,来提升性能,对于0-256这些常用的数字,Python 内部是有缓存的。 Step4: 下面的例子引入条件判断语句,if 语句。Python 中 if 语句很容易理解...
<ASSISTANT_TASK:> Python Code: counter = 100 # 整型变量 miles = 1000.0 # 浮点型(小数) name = "John" # 字符串 name2 = 'Tom' # 显示指定变量名的内容 print(name2) flag = False # 布尔值 #显示变量的类型 print(type(flag)) # 多个变量赋值, Python 的写法比较简洁 a = b = c = 1 b = 2 print(a,b,c) # 字符串变量赋值 s = s1 = 'Hello' print(s,s1) # 多个变量赋值 a, b, c = 1, 2, 3 print(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: <a id='joint'></a> Step2: The marginal distributions of a bivariate normal distribution are (univariate) normal distributions. Step3: <a id='m...
<ASSISTANT_TASK:> Python Code: from symbulate import * %matplotlib inline RV(BivariateNormal(mean1 = 0, mean2 = 1, sd1 = 1, sd2 = 2, corr = 0.5)).sim(5) x = RV(BivariateNormal(mean1 = 0, mean2 = 1, sd1 = 1, sd2 = 2, corr = 0.5)).sim(1000) x.plot(alpha = 0.2) x.mean(), x.sd(), x.corr() RV(BivariateNormal(mean1 = 0, mea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: MNIST Step2: Binary classifier Step3: Note Step4: ROC curves Step6: Multiclass classification Step7: Multilabel classification Step8: Warn...
<ASSISTANT_TASK:> Python Code: # To support both python 2 and python 3 from __future__ import division, print_function, unicode_literals # Common imports import numpy as np import os # to make this notebook's output stable across runs np.random.seed(42) # To plot pretty figures %matplotlib inline import matplotlib 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: Load Step2: Account for NaN in column name. Step3: Transform Step4: Bag of Words Step5: Stop Words Step6: This code Step7: To DF Step8: W...
<ASSISTANT_TASK:> Python Code: import re import random #import lda import csv import numpy as np import pandas as pd from collections import Counter from nltk.corpus import stopwords from nltk.tokenize import word_tokenize from sklearn.feature_extraction.text import CountVectorizer df = pd.read_csv('../../data/cleaned...
<SYSTEM_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 Step3: Call function to compute benchmarks Step4: Lets look at the results Step5: Timing and some accuracy scores across trials Ste...
<ASSISTANT_TASK:> Python Code: import numpy as np import time import matplotlib.pyplot as plt from sklearn import tree from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from IPython.display import display, Image from sklearn.datasets import load_breast_cancer # 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: Given a variable called angle, print out the sine of it like so Step2: Using string formatting show the decimal and binary representation of th...
<ASSISTANT_TASK:> Python Code: from math import pi print('{:.3}'.format(pi / 2)) from math import * x = 1.2 print('The sine of {:.2} radians is {:.2}'.format(x, sin(x))) print('binary: {0:b}, decimal: {0:}'.format(34)) for i in range(9): print('{:5b}'.format(i)) <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: As you can see, the squad has about 47% chance of scoring 1 or 0 hits and around 53% chance of scoring 2 or more hits. The expectation is 1.7, w...
<ASSISTANT_TASK:> Python Code: profiles[0] = {'shots': 10, 'p_hit': 1 / 2, 'p_wound': 1 / 2, 'p_unsaved': 4 / 6, 'damage': '1'} profile_damage = damage_dealt(profiles[0]) wound_chart(profile_damage, profiles) profiles[0]['p_hit'] = 0.583 wound_chart(damage_dealt(profiles[0]), profiles) profiles[0]['p_hit'] = 0.5 prof...
<SYSTEM_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="ref0"></a> Step2: dataset object Step3: <a id='ref1'> </a> Step4: A function used to train. Step5: A function used to calculate accur...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from matplotlib.colors import ListedColormap torch.manual_seed(1) def plot_decision_regions_3class(model,data_set): cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA'...
<SYSTEM_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 prepare the data Step2: Checking out the data Step3: Dummy variables Step4: Scaling target variables Step5: Splitting the data into...
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' import numpy as np import pandas as pd import matplotlib.pyplot as plt data_path = 'Bike-Sharing-Dataset/hour.csv' rides = pd.read_csv(data_path) rides.head() rides[:24*10].plot(x='dteday', y='cnt') dummy_fields = ['seas...
<SYSTEM_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 core tables in the data warehouse are derived from 5 separate core operational systems (each with many tables) Step2: Question Step3: Ques...
<ASSISTANT_TASK:> Python Code: %%bigquery SELECT dataset_id, table_id, -- Convert bytes to GB. ROUND(size_bytes/pow(10,9),2) as size_gb, -- Convert UNIX EPOCH to a timestamp. TIMESTAMP_MILLIS(creation_time) AS creation_time, TIMESTAMP_MILLIS(last_modified_time) as last_modified_time, row_count, CASE ...
<SYSTEM_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='variables'></a> Step2: <a id='strings'></a> Step3: <a id='lists'></a> Step4: <a id='tricks'></a> Step5: <a id='list_methods'></a>
<ASSISTANT_TASK:> Python Code: # Addition 2+5 # Let's have Python report the results from three operations at the same time print(2-5) print(2*5) print(2/5) # If we have all of our operations in the last line of the cell, Jupyter will print them together 2-5, 2*5, 2/5 # And let's compare values 2>5 # 'a' is being give...
<SYSTEM_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 software and filenames definitions Step2: Data folder Step3: List of data files Step4: Data load Step5: Laser alternation selection Ste...
<ASSISTANT_TASK:> Python Code: ph_sel_name = "all-ph" data_id = "12d" # ph_sel_name = "all-ph" # data_id = "7d" from fretbursts import * init_notebook() from IPython.display import display data_dir = './data/singlespot/' import os data_dir = os.path.abspath(data_dir) + '/' assert os.path.exists(data_dir), "Path '%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: EBLUP Predictor Step2: Now the the model has been fitted, we can obtain the EBLUP average expenditure on milk by running predict() which is a m...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import samplics from samplics.datasets import ExpenditureMilk from samplics.sae import EblupAreaModel # Load Expenditure on Milk sample data milk_exp_cls = ExpenditureMilk() milk_exp_cls.load_data() milk_exp = milk_exp_cls.data nb_obs = 15 print(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: cf. Examples for solve_ivp Step2: An example for unit tests Step3: Consider example Step4: We first solve this problem using RK4 with $h = 0....
<ASSISTANT_TASK:> Python Code: from pathlib import Path import sys notebook_directory_parent = Path.cwd().resolve().parent.parent if str(notebook_directory_parent) not in sys.path: sys.path.append(str(notebook_directory_parent)) %matplotlib inline import numpy as np import scipy import sympy from numpy import linsp...
<SYSTEM_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. Corpus acquisition Step2: 1.1.2. Parsing XML Step3: or directly reading a string Step4: fromstring() parses XML from a string directly int...
<ASSISTANT_TASK:> Python Code: # Common imports import numpy as np # import pandas as pd # import os from os.path import isfile, join # import scipy.io as sio # import scipy import zipfile as zp # import shutil # import difflib xmlfile = '../data/1600057.xml' with open(xmlfile,'r') as fin: print(fin.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: We have 5 coefficients. If we make the maximum ratio a 10 Step2: Well, that's not very efficient. As the ratio increases, the computation takes...
<ASSISTANT_TASK:> Python Code: def combos(combo_min, combo_max, combo_len): for combo in it.product(xrange(combo_min, combo_max + 1), repeat=combo_len): yield combo def combo_dicts(param_names, combo_min, combo_max, combo_len): for d in (OrderedDict(it.izip(param1_na...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'awi', 'sandbox-2', 'aerosol') # 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: JAX에서 TensorFlow 확률(TFP on JAX) Step2: TFP의 최신 야간 빌드를 사용하여 TFP on JAX를 설치할 수 있습니다. Step3: 몇 가지 유용한 Python 라이브러리를 가져옵니다. Step4: 또한 몇 가지 기본 JAX...
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" } # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: A repository Step2: And this is pretty much the essence of Git! Step3: And how you will edit text files (it will often ask you to edit message...
<ASSISTANT_TASK:> Python Code: ls import sha # Our first commit data1 = 'This is the start of my paper2.' meta1 = 'date: 1/1/12' hash1 = sha.sha(data1 + meta1).hexdigest() print 'Hash:', hash1 # Our second commit, linked to the first data2 = 'Some more text in my paper...' meta2 = 'date: 1/2/12' # Note we add the pare...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Scope Review Step2: Remember that Python functions create a new scope, meaning the function has its own namespace to find variable names when t...
<ASSISTANT_TASK:> Python Code: def func(): return 1 func() s = 'Global Variable' def func(): print locals() print globals() print globals().keys() globals()['s'] func() def hello(name='Jose'): return 'Hello '+name hello() greet = hello greet greet() del hello hello() greet() def hello(name='Jose'):...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Simple logistic Regression Step2: Lets get VGG embeddings for train and test input images and convert them to transfer learnt space. Step3: Mo...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot=False) img = mnist.train.images[123] img = np.reshape(img,(28,28)) plt.imshow(img, cmap = 'gray') 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: Задание 1 Step2: Задание 2 Step3: Задание 3 Step4: Задание 4 Step5: Задание 5
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split from sklearn.tree import DecisionTreeRegressor from sklearn.metrics import mean_squared_error from skle...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Selecting data Step2: Indexes in a numpy array can only be integers. Step3: In this second example indexing is made using strings, that are th...
<ASSISTANT_TASK:> Python Code: # first, the imports import os import datetime as dt import pandas as pd import numpy as np import matplotlib.pyplot as plt from IPython.display import display np.random.seed(19760812) %matplotlib inline # We read the data in the file 'mast.txt' ipath = os.path.join('Datos', 'mast.txt') 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: Step2: With these 3 elements it is possible to assemble a OGC Filter Encoding (FE) using the owslib.fes* module. Step4: We have created a csw object, ...
<ASSISTANT_TASK:> Python Code: from datetime import datetime # Region: Northwest coast. bbox = [-127, 43, -123.75, 48] min_lon, max_lon = -127, -123.75 min_lat, max_lat = 43, 48 bbox = [min_lon, min_lat, max_lon, max_lat] crs = "urn:ogc:def:crs:OGC:1.3:CRS84" # Temporal range of 1 week. start = datetime(2017, 4, 14, 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: 1. Identify Balmer absorption lines in a star Step2: 2. Identify Balmer emission lines in a galaxy Step3: Balmer Series Step4: Find the wavel...
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.interpolate as interpolate import astropy.io.fits as fits import matplotlib.pyplot as plt import requests def find_nearest(array, value): index = (np.abs(array - value)).argmin() return index def find_local_min(array, index): min_index = np.arg...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Creating NumPy arrays Step2: Multidimensional lists (or tuples) produce multidimensional arrays Step3: Evenly spaced values Step4: Specific s...
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.array((1, 2, 3, 4)) print(a) print(a.dtype) print(a.size) a = np.array((1,2,3,4), dtype=float) # Type can be explicitly specified print(a) print(a.dtype) print(a.size) my_list = [[1,2,3], [4,5,6]] a = np.array(my_list) print(a) print(a.size) print(a.shape) 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: The object new_data has been reprojected to Alberts and a linear model have been fitted with residuals stored as residuals Step2: The empirical...
<ASSISTANT_TASK:> Python Code: from external_plugins.spystats import tools %run ../HEC_runs/fit_fia_logbiomass_logspp_GLS.py from external_plugins.spystats import tools hx = np.linspace(0,800000,100) new_data.residuals[:10] gvg.plot(refresh=False,legend=False,percentage_trunked=20) plt.title("Semivariogram of residua...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Just adding some imports and setting graph display options. Step2: Let's look at our data! Step3: We'll be looking primarily at candidate, cr...
<ASSISTANT_TASK:> Python Code: from arrows.preprocess import load_df from textblob import TextBlob import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib import seaborn as sns import cartopy pd.set_option('display.max_colwidth', 200) pd.options.display.mpl_style = 'default' matplotlib...
<SYSTEM_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...
<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', 'seaice') # 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: Create scoring method Step2: Run Gensim LSI test
<ASSISTANT_TASK:> Python Code: %matplotlib inline import json import codecs import os import time docs = [] for filename in os.listdir("reuters-21578-json/data/full"): f = open("reuters-21578-json/data/full/"+filename) js = json.load(f) for j in js: if 'topics' in j and 'body' in j: 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: Performing and evaluating the regression Step2: Coefficient of determination Step3: Partition into training set and test set
<ASSISTANT_TASK:> Python Code: import pickle import pandas as pd !ls *.pickle # check !curl -o "stations_projections.pickle" "http://mas-dse-open.s3.amazonaws.com/Weather/stations_projections.pickle" data = pickle.load(open("stations_projections.pickle",'r')) data.shape data.head(1) # break up the lists of coefficien...
<SYSTEM_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 simple output Step2: The standard output stream Step3: Normal output + standard output Step4: The standard error stream is highlighted and ...
<ASSISTANT_TASK:> Python Code: # 2 empty lines before, 1 after 6 * 7 print('Hello, world!') print('Hello, world!') 6 * 7 import sys print("I'll appear on the standard error stream", file=sys.stderr) print("I'll appear on the standard output stream") "I'm the 'normal' output" %%bash for i in 1 2 3 do echo $i do...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: YOUR ANSWER HERE Step2: (c) What are the 20 most common words in the corpus and how often do they occur? What is the 50th most common word, the...
<ASSISTANT_TASK:> Python Code: ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## ## YOUR CODE HERE ## from collections import defaultdict d = defaultdict(float) d["new key...
<SYSTEM_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 data Step2: after loading the data, extract the receptor names so that it is possible to form the seperate data subsets. Step3: Now i...
<ASSISTANT_TASK:> Python Code: import pandas as pd import time import glob import numpy as np from scipy.stats import randint as sp_randint from prettytable import PrettyTable from sklearn.preprocessing import Imputer from sklearn.model_selection import train_test_split, cross_val_score, RandomizedSearchCV from sklearn...
<SYSTEM_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 file, see what we're working with Step2: Parse the table with BeautifulSoup Step3: Decide how to target the table Step4: Looping ...
<ASSISTANT_TASK:> Python Code: from bs4 import BeautifulSoup import csv # in a with block, open the HTML file with open('mountain-goats.html', 'r') as html_file: # .read() in the contents of a file -- it'll be a string html_code = html_file.read() # print the string to see what's there print(html_...
<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: Clean up the data a bit Step3: It looks like Portland!!! Step4: We'll use K Means Clustering because that's the clustering method I recently l...
<ASSISTANT_TASK:> Python Code: with open('../pipeline/data/Day90ApartmentData.json') as f: my_dict = json.load(f) def listing_cleaner(entry): print entry listing_cleaner(my_dict['5465197037']) type(dframe['bath']['5399866740']) dframe.bath = dframe.bath.replace('shared',0.5) dframe.bath = dframe.bath.repl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Globals Step2: Helper functions Step3: LSH Cosine Similarity Algorithm Step4: Algorithm Description
<ASSISTANT_TASK:> Python Code: import gzip import tarfile import numpy as np import pandas as pd import h5py as h5 import os import glob from sklearn import preprocessing import math import time from scipy.spatial.distance import cosine from itertools import combinations # 1 million summary data. Takes long! data_path...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TV Script Generation Step3: Explore the Data Step6: Implement Preprocessing Functions Step9: Tokenize Punctuation Step11: Preprocess all the...
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper data_dir = './data/simpsons/moes_tavern_lines.txt' text = helper.load_data(data_dir) # Ignore notice, since we don't use it for analysing the data text = text[81:] view_sentence_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL import num...
<SYSTEM_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 of the project Step3: Mapping sequence --> structure Step4: Downloading and ranking structures Step5: Loading ...
<ASSISTANT_TASK:> Python Code: import sys import logging # Import the Protein class from ssbio.core.protein import Protein # Printing multiple outputs per cell from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" # Create logger logger = logging.getLogger() logger....
<SYSTEM_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. Trends in TOC Step2: The data suggests that TOC increased rapidly from 1990 to around 2000, and then continued to increase more slowly.
<ASSISTANT_TASK:> Python Code: # Select project prj_grid = nivapy.da.select_resa_projects(eng) prj_grid # Select project prj_df = prj_grid.get_selected_df() prj_df # Get stations for these projects stn_df = nivapy.da.select_resa_project_stations(prj_df, eng) print (len(stn_df), 'stations associated with the selected pr...