Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
2,800
<ASSISTANT_TASK:> Python Code: # test image stack arr = [] for i in range(50): b = np.random.rand(500,500) b= (b*(2**16-1)).astype('uint16') arr.append(b) # snap (MPL) button = widgets.Button(description='Snap') display.display(button) def on_button_clicked(b): img=arr.pop() plt.imshow(img, cma...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Video Step2: GUI and BUTTONS Step3: Arrows
2,801
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import urllib.request import numpy as np import simplejson as json import pandas as pd from netCDF4 import Dataset, date2num, num2date import ipywidgets as widgets from IPython.display import display, clear_output import dateutil.parser import matplotlib.pyplot as plt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <font color='red'>Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly ...
2,802
<ASSISTANT_TASK:> Python Code: # Installs the latest version of TFC compatible with the installed TF version. !pip install tensorflow-compression~=$(pip show tensorflow | perl -p -0777 -e 's/.*Version: (\d\.\d).*/\1.0/sg') # Downloads the 'models' directory from Github. ![[ -e /tfc ]] || git clone https://github.com/te...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Enabling GPU Step2: Imports and Definitions Step3: Load files Step4: Compress images Step5: Show output Step6: Download all compressed imag...
2,803
<ASSISTANT_TASK:> Python Code: # Importing standard libraries import numpy as np import pandas as pd from ionchannelABC import IonChannelModel icat = IonChannelModel('icat', 'models/Generic_iCaT.mmt', vvar='membrane.V', logvars=['environment.time', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setting up an ion channel model and experiments Step2: Now that we have loaded a cell model, we need to specify how we will test it to compare ...
2,804
<ASSISTANT_TASK:> Python Code: # Author: Olaf Hauk <olaf.hauk@mrc-cbu.cam.ac.uk> # # License: BSD (3-clause) import mne from mne.datasets import sample from mne.minimum_norm.resolution_matrix import make_inverse_resolution_matrix from mne.minimum_norm.spatial_resolution import resolution_metrics print(__doc__) data_pat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: EEGMEG Step2: MEG Step3: Visualization Step4: For MEG only Step5: Subtract the two distributions and plot this difference Step6: These plot...
2,805
<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(plot_style=False) os.chdir(path) # 1. magic for inline pl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Evaluating Imbalanced Datasets Step2: A brief description of the dataset based on the data overview section from the download source. Step3: C...
2,806
<ASSISTANT_TASK:> Python Code: import argparse import os import matplotlib.pyplot as plt from matplotlib.pyplot import imshow import scipy.io import scipy.misc import numpy as np import pandas as pd import PIL import tensorflow as tf from keras import backend as K from keras.layers import Input, Lambda, Conv2D from ker...
<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: Important Note Step4: Expected Output Step6: Expected Output Step8: Expected Output Step9: Expected Output Step10: 3.1 - Defining classes, ...
2,807
<ASSISTANT_TASK:> Python Code: print('Hello) 1 / 0 open('doesnotexistfile.txt') print(locals()['__builtins__']) import sys def divide(a,b): try: return a / b except: print(sys.exc_info()[0]) divide (1,2) divide (2,0) # This will be captured by the 'except' clause # print custom erro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exceptions Step2: Built-in Exceptions Step3: Following are some of the built-in exceptions. Step4: Catching Specific Exceptions Step5: The l...
2,808
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from neus import pyramid from neus import partition # instantiate a window object center = [1.0] width = [0.5] win = pyramid.Pyramid(center, width) # plot the support of the pyramid object x = np.linspace(0.0, 2....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Window objects Step2: Partition objects Step3: Partition objects act like callable lists so some of the expected list operations also work wit...
2,809
<ASSISTANT_TASK:> Python Code: import ibis import os hdfs_port = os.environ.get('IBIS_WEBHDFS_PORT', 50070) hdfs = ibis.hdfs_connect(host='quickstart.cloudera', port=hdfs_port) con = ibis.impala.connect(host='quickstart.cloudera', database='ibis_testing', hdfs_client=hdfs) print('Hello!') tab...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Projections Step2: First, the basics Step3: You can make a list of columns you want, too, and pass that Step4: You can also use the explicit ...
2,810
<ASSISTANT_TASK:> Python Code: # import from sklearn.cluster import KMeans, MiniBatchKMeans from sklearn.linear_model import LogisticRegression from sklearn import metrics from sklearn.utils import shuffle import mahotas as mh from mahotas.features import surf import glob import numpy as np import matplotlib.pyplot as ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Evaluating clusters Step2: Image Quantization Step3: Clustering to learn features
2,811
<ASSISTANT_TASK:> Python Code: precipitation_df.head() precipitation_df.tail() precipitation_df['Country or Area'].values precipitation_df = precipitation_df.set_index(precipitation_df["Country or Area"]) precipitation_df.drop(['Country or Area'], axis=1, inplace=True) precipitation_df.head() %matplotlib inline ge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Each row in the table lists Step2: Having the names of the countries or areas as a column comes in handy, but it would be more useful to have t...
2,812
<ASSISTANT_TASK:> Python Code: a = array([5,8,12,13,100,18,74]) print a print "max:", a.max() print "min: ", a.min() print u"součet:", a.sum() print u'dékla:', a.size linspace(2,5,9) linspace(0,5,4) linspace(0,1,20) arange(5) arange(3,10) arange(10,20,0.2) zeros(5) ones(20) t=linspace(0,10,11) print t print t[1:5] ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: linspace Step2: arange Step3: zeros, ones Step4: Nejen výřezy Step5: Ve výřezech lze prvky i přeskakovat Step6: Výřez je možné použít i k p...
2,813
<ASSISTANT_TASK:> Python Code: lambda0 = 6301.5 JUp = 1.0 JLow = 1.0 gUp = 2.5 gLow = 0.0 lambdaStart = 6300.8 lambdaStep = 0.01 nLambda = 150 wavelength = lambdaStart + np.arange(nLambda) * lambdaStep lineInfo = np.asarray([lambda0, JUp, JLow, gUp, gLow, lambdaStart, lambdaStep]) s = pymilne.milne(nLambda, lineInfo) 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: Strong-field approximation Stokes V Step2: Longitudinal magnetograph Step3: Center-of-gravity Step4: Influence of filling factor on inclinati...
2,814
<ASSISTANT_TASK:> Python Code: from mysolr import Solr PDBE_SOLR_URL = "http://wwwdev.ebi.ac.uk/pdbe/search/pdb" solr = Solr(PDBE_SOLR_URL, version=4) UNLIMITED_ROWS = 10000000 # necessary because default in mysolr is mere 10 import logging, sys #reload(logging) # reload is just a hack to make logging work in the noteb...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Find your protein Step2: Let us assume we are interested in carbonic anhydrases. We write the protein name as a regular expression allowing for...
2,815
<ASSISTANT_TASK:> Python Code: from fig_utils import * import matplotlib.pyplot as plt import time %matplotlib inline # Parameters country_names = ['nigeria', 'tanzania', 'uganda', 'malawi', 'pooled'] country_paths = ['../data/output/LSMS/nigeria/', '../data/output/LSMS/tanzania/', '../...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Out-of-country performance Step2: Panel B
2,816
<ASSISTANT_TASK:> Python Code: import numpy as np np mylist = [3, 6, 1, 0, 10, 3] mylist print("The first element of 'mylist' is: " + str(mylist[0])) print("The second element of 'mylist' is: " + str(mylist[1])) myarray = np.array(mylist) # equivalent to np.array([3, 6, 1, 0, 10, 3]) myarray # look at what type m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now, we have access to all NumPy functions via the variable np (this is the convention in the Scientific Python community for referring to NumPy...
2,817
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt from simmit import smartplus as sim from simmit import identify as iden import os dir = os.path.dirname(os.path.realpath('__file__')) x = np.arange(0,182,2) path_data = dir + '/data/' peak_file = '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: In this Python Notebook we will show how to properly run a simulation of a composite material, providing the ODF (orientation density function) ...
2,818
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mpi-m', 'mpi-esm-1-2-hr', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("nam...
<SYSTEM_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...
2,819
<ASSISTANT_TASK:> Python Code: np.random.seed(0) data = np.random.randn(10, 10) from ipywidgets import * fig = plt.figure(padding_y=0.0) grid_map = plt.gridheatmap(data) fig grid_map.display_format = ".2f" grid_map.font_style = {"font-size": "16px", "fill": "blue", "font-weight": "bold"} axes_options = { "column"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Basic Heat map Step2: Hide tick_labels and color axis using 'axes_options' Step3: Non Uniform Heat map Step4: Alignment of the data with resp...
2,820
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.sparse as sps from porepy.numerics.ad.forward_mode import Ad_array import porepy.numerics.ad.functions as af x = Ad_array(2, 1) y = x**2 + 3 print('y value is: ', y.val) print('dy/dx is: ', y.jac) h = af.exp(y) print('h value is: ', h.val) print('dh/dx ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Scalar AD-variables Step2: We can now define a function $y=x^2 + 3$ Step3: To obtain the function value and the derivative we can call .val an...
2,821
<ASSISTANT_TASK:> Python Code: from lammps import IPyLammps L = IPyLammps() # 3d Lennard-Jones melt L.units("lj") L.atom_style("atomic") L.atom_modify("map array") L.lattice("fcc", 0.8442) L.region("box block", 0, 4, 0, 4, 0, 4) L.create_box(1, "box") L.create_atoms(1, "box") L.mass(1, 1.0) L.velocity("all create", 1.4...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Visualize the initial state Step2: Queries about LAMMPS simulation Step3: Working with LAMMPS Variables Step4: Accessing Atom data Step5: Ac...
2,822
<ASSISTANT_TASK:> Python Code: from mpl_toolkits.mplot3d import Axes3D, axes3d fig, ax = plt.subplots(1, 1, subplot_kw={'projection': '3d'}) X, Y, Z = axes3d.get_test_data(0.05) ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10) plt.show() from mpl_toolkits.axes_grid1 import AxesGrid fig = plt.figure() grid = AxesGrid...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: axes_grid1 Step2: This next feature is commonly requested on the mailing lists. The problem is that most people who request it don't quite kno...
2,823
<ASSISTANT_TASK:> Python Code: import hashlib import os import pickle from urllib.request import urlretrieve import numpy as np from PIL import Image from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer from sklearn.utils import resample from tqdm import tqdm from zipfil...
<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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this...
2,824
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nasa-giss', 'sandbox-2', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("nam...
<SYSTEM_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...
2,825
<ASSISTANT_TASK:> Python Code: # Copyright 2018 The TensorFlow Hub Authors. All Rights Reserved. # # 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 # # http://www.apache.org/licenses/LICENSE...
<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: 使用膨胀 3D CNN 进行动作识别 Step4: 使用 UCF101 数据集 Step5: 运行 ID3 模型并打印前 5 个动作预测。 Step6: 现在,尝试一个新的视频,地址为:https
2,826
<ASSISTANT_TASK:> Python Code: import fb_scraper.prodcons APP_ID = '' APP_ID_SECRET = '' ACCESS_TOKEN = '' mgr = fb_scraper.prodcons.Manager( access_token=ACCESS_TOKEN, api_key=APP_ID, api_secret=APP_ID_SECRET ) mgr.graph.extend_token() mgr.start() mgr.scrape_post('XXXXXXXXXXXXXX') # Where 'XXXXXXX...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Producer/Consummer Manager Step2: Extending ACCESS_TOKEN Step3: Start scraping threads Step4: Add scraping jobs
2,827
<ASSISTANT_TASK:> Python Code: # Q1. Create a graph g = ... with g.as_default(): # Define inputs with tf.name_scope("inputs"): a = tf.constant(2, tf.int32, name="a") b = tf.constant(3, tf.int32, name="b") # Ops with tf.name_scope("ops"): c = tf.multiply(a, b, name="c") 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: Q4-8. You are to implement the graph below. Complete the code.
2,828
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline #%config InlineBackend.figure_format = 'svg' #%config InlineBackend.figure_format = 'pdf' import freqopttest.tst as tst import kgof import kgof.data as data import kgof.density as density import kgof.goftest as gof import kgof.intertst...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Test with random test locations Step2: Test with optimized test locations
2,829
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt from scipy.interpolate import InterpolatedUnivariateSpline as spline from pathlib import Path %load_ext autoreload %autoreload 2 hmcode_dir = Path("/home/steven/Documents/Projects/halos/HALOMOD/other-codes/HMcode") def...
<SYSTEM_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 HMcode Step2: Make halomod model Step3: The big picture (1h+2h) Step4: Intermediate Products Step5: Mass to Radius Step6: sigma Step7: ...
2,830
<ASSISTANT_TASK:> Python Code: ri = (40, 50, 60, 70, 80, 90, 100, 108) ro = (40.7, 52.9, 69, 90.5, 123, 182, 305, 500) Cq = (46.3, 47.0, 46.9, 47.0, 47.0, 47.0, 46.9, 46.9) #Cq = (46.3, 49.5, 46.9, 49.5, 47.0, 51.7, 46.9, 54) Cg = (1.5, 1.44, 1.47, 1.45, 1.46, 1.49, 1.42, 1.48) Cgnd = (39.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: CPW Step2: $\lambda/4$ readout resonators Step3: Qubit parameters Step4: Feedline with and without crossovers Step5: Inductive Coupling Step...
2,831
<ASSISTANT_TASK:> Python Code: from oedes.fvm import mesh1d from oedes import progressbar, testing, init_notebook, models, context init_notebook() %matplotlib inline import matplotlib.pylab as plt import numpy as np params = {'T': 2500., 'electron.mu': 1e-6, 'electron.energy': 0., 'electr...
<SYSTEM_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 and parameters Step2: Results Step3: Distribution of the electric field Step4: Distribution of electrons and holes Step5: Distribution...
2,832
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import xarray as xr import climlab from climlab import constants as const import cartopy.crs as ccrs # use cartopy to make some maps ncep_url = "http://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis.derived/" ncep...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Make two maps Step2: Make a contour plot of the zonal mean temperature as a function of time of year Step3: Exploring the amplitude of the sea...
2,833
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('..') from synset2vec import Synset2Vec from im2vec import Image2Vec from tagger import ZeroshotTagger i2v = Image2Vec() s2v = Synset2Vec() tagger = ZeroshotTagger() labels = map(str.strip, open('../data/synsets_ilsvrc12_test1k.txt').readlines()) from PIL 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 the label set $Y_0$ Step2: 2. Load a pretrained CNN model Step3: 3. Define a preprocess function for input images Step4: 4. Perform zero...
2,834
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import quandl mydata = quandl.get("EIA/PET_RWTC_D") mydata.head() mydata.plot(figsize = (12, 6)) mydata = quandl.get("EIA/PET_RWTC_D", returns = "numpy") mydata = quandl.get("...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Make a Basic Data Call Step2: Note that you need to know the "Quandl code" of each dataset you download. In the above example, it is "EIA/PET_R...
2,835
<ASSISTANT_TASK:> Python Code: # RUN THIS BLOCK FIRST TO SET UP VARIABLES! a = True b = False x = 2 y = -2 cat = "Mittens" print a print (not a) print (a == b) print (a != b) print (x == y) print (x > y) print (x = 2) print (a and b) print (a and not b) print (a or b) print (not b or a) print not (b or a) print (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: (^^ you might find it helpful to copy these variables somewhere you can easily see them when doing the problems. e.g. a piece of paper or a text...
2,836
<ASSISTANT_TASK:> Python Code: import math as m def CountPairs(n ) : cnt = 0 i = 1 while i * i <= n : if(n % i == 0 ) : div1 = i div2 = n // i sum = div1 + div2 ; if(m . gcd(sum , n ) == 1 ) : cnt += 1   i += 1  return cnt  n = 24 print(CountPairs(n ) ) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
2,837
<ASSISTANT_TASK:> Python Code: row = 'NO PARKING (SANITATION BROOM SYMBOL) 7AM-7:30AM EXCEPT SUNDAY' assert from_time(row) == '07:00AM' assert to_time(row) == '07:30AM' special_case1 = 'NO PARKING (SANITATION BROOM SYMBOL) 11:30AM TO 1PM THURS' assert from_time(special_case1) == '11:30AM' assert to_time(special_case1) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Find out if any rows has NaN Step2: Confirm that every row has from_time and to_time Step3: Day of the week Step4: Save to CSV
2,838
<ASSISTANT_TASK:> Python Code: !python -V #!pip3 install torch torchvision import torch print("PyTorch version: ") torch.__version__ print("Device Name: ") torch.cuda.get_device_name(0) print("CUDA Version: ") print(torch.version.cuda) print("cuDNN version is: ") print(torch.backends.cudnn.version()) # NVIDIA profiling...
<SYSTEM_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 is a tensor? Step2: Tensor Types Step3: Every torch.Tensor has these attributes Step4: Tensor datatypes are given in the table below. No...
2,839
<ASSISTANT_TASK:> Python Code: from shapely.geometry import Point, Polygon # Create Point objects p1 = Point(24.952242, 60.1696017) p2 = Point(24.976567, 60.1612500) # Create a Polygon coords = [(24.950899, 60.169158), (24.953492, 60.169158), (24.953510, 60.170104), (24.950958, 60.169990)] poly = Polygon(coords) # Let'...
<SYSTEM_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 check if those points are within the polygon Step2: Okey, so we can see that the first point seems to be inside that polygon and the othe...
2,840
<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: Load and prepare the data Step2: Checking out the data Step3: Dummy variables Step4: Scaling target variables Step5: Splitting the data into...
2,841
<ASSISTANT_TASK:> Python Code: !pip install Theano !pip install lasagne import numpy as np def sum_squares(N): return сумма квадратов чисел от 0 до N %%time sum_squares(10**8) import theano import theano.tensor as T #будущий параметр функции N = T.scalar("a dimension",dtype='int32') #рецепт получения суммы квадрат...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: theano teaser Step2: Как оно работает? Step3: Компиляция Step4: хинт для отладки Step5: Для отладки желательно уменьшить масштаб задачи. Есл...
2,842
<ASSISTANT_TASK:> Python Code: import os import csv import cv2 import matplotlib.pyplot as plt import random import pprint import numpy as np from numpy import expand_dims %tensorflow_version 1.x import tensorflow as tf tf.logging.set_verbosity(tf.logging.ERROR) from keras import backend as K from keras.models import M...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Confirm TensorFlow can see the GPU Step2: Load the Dataset Step3: Parse the CSV File Step4: Clean and Pre-process the Dataset Step5: Detect ...
2,843
<ASSISTANT_TASK:> Python Code: !pip3 install tensorflow_hub %%bash pip install --upgrade tensorflow # Import helpful libraries and setup our project, bucket, and region import os import tensorflow as tf import tensorflow_hub as hub # PROJECT = "cloud-training-demos" # REPLACE WITH YOUR PROJECT ID # BUCKET = "cloud-tra...
<SYSTEM_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 reset the notebook's session kernel! Since we're no longer using Cloud Dataflow, we'll be using the python3 kernel from here on out so don't...
2,844
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns %matplotlib inline pd.set_option('display.max_columns', 500) df = sns.load_dataset('titanic') # Write the code to look at the head of the dataframe # Create a histogram to examine age distributi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Like scikit-learn, Seaborn has "toy" datasets available to import for exploration. This includes the Titanic data we have previously looked at. ...
2,845
<ASSISTANT_TASK:> Python Code: import WizardTree as wt story = wt.CrawlComment(comment_id = "cy8z5uv") wt.Export(story, "Output/WizardTree.json") import WizardTree as wt story = wt.Import("Output/WizardTree.json") print "Title: " + story['title'] print "Author: " + story['author'] print "Url: " + story['url'] 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: Load story from JSON file Step2: For the following examples, the variable story is assumed to contain the story Step3: Visualize story structu...
2,846
<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: Estimators を使用するブースティング木 Step2: データセットはトレーニングセットと評価セットで構成されています。 Step3: トレーニングセットと評価セットには、それぞれ 627 個と 264 個の例があります。 Step4: 乗船者の大半は 20 代から 30 ...
2,847
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import random from collections import defaultdict import mdtraj as md import numpy as np import scipy.cluster.hierarchy stride = 5 subsampled = md.load('ala2.h5', stride=stride) print(subsampled) distances = np.empty((subsampled.n_frames, subsampled....
<SYSTEM_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 the pairwise RMSD between all of the frames. This requires Step2: Now that we have the distances, we can use out favorite clustering St...
2,848
<ASSISTANT_TASK:> Python Code: import pandas as pd pd.plotting.register_matplotlib_converters() import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns # Set up code checking import os if not os.path.exists("../input/fifa.csv"): os.symlink("../input/data-for-datavis/fifa.csv", "../input/fifa.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: The code you just ran sets up the system to give you feedback on your work. You'll learn more about the feedback system in the next step. Step ...
2,849
<ASSISTANT_TASK:> Python Code: from civis.ml import ModelPipeline from civis import APIClient client = APIClient() # dynamically get database name creds = client.credentials.list() dbs = [db for db in find(creds, type='Database') if 'redshift' in db.name.lower()] db_name = dbs[0].name model = ModelPipeline('ran...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the first example, we'll use a random forest model from scikit-learn. In addition, we'll grid search over hyperparameters for the maximum dep...
2,850
<ASSISTANT_TASK:> Python Code: import os PROJECT = "cloud-training-demos" # REPLACE WITH YOUR PROJECT ID BUCKET = "cloud-training-demos-ml" # REPLACE WITH YOUR BUCKET NAME REGION = "us-central1" # REPLACE WITH YOUR BUCKET REGION e.g. us-central1 # Do not change these os.environ["PROJECT"] = PROJECT os.environ["BUCKET"]...
<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: Create raw dataset Step3: Create dataset for WALS Step4: Creating rows and columns datasets Step5: To summarize, you created the following da...
2,851
<ASSISTANT_TASK:> Python Code: import sys import os sys.path.append(os.getcwd()+'/../') # our lib from lib.resnet50 import ResNet50 from lib.imagenet_utils import preprocess_input, decode_predictions #keras from keras.preprocessing import image from keras.models import Model # sklearn import sklearn from sklearn.line...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Extract NN Features Step2: Predicting Own Labels from Selected Images Step3: Horizontal Striped Data Step4: neither the svm or the logistic r...
2,852
<ASSISTANT_TASK:> Python Code: %%javascript IPython.OutputArea.prototype._should_scroll = function(lines) { return false; } import datetime import matplotlib.pyplot as plt import pandas as pd import talib from talib.abstract import * from talib import MA_Type import pinkfish as pf # Format price data pd.options.dis...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Some global data Step2: Fetch symbol data from cache, if available. Step3: Select timeseries between start and end. Step4: Get info about TA-...
2,853
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np dtype_dict = {'bathrooms':float, 'waterfront':int, 'sqft_above':int, 'sqft_living15':float, 'grade':int, 'yr_renovated':int, 'price':float, 'bedrooms':float, 'zipcode':str, 'long':float, 'sqft_lot15':float, 'sqft_living'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Useful pandas summary functions Step2: As we see we get the same answer both ways Step3: Aside Step4: We can test that our function works by ...
2,854
<ASSISTANT_TASK:> Python Code: %matplotlib inline from parcels import Field, FieldSet, ParticleSet, JITParticle, plotTrajectoriesFile, AdvectionRK4 import numpy as np xdim, ydim = (10, 20) Uflow = Field('U', np.ones((ydim, xdim), dtype=np.float32), lon=np.linspace(0., 1e3, xdim, dtype=np.float32), ...
<SYSTEM_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, let's first define a zonal and meridional velocity field on a 1kmx1km grid with a flat mesh. The zonal velocity is uniform and 1 m/s, and t...
2,855
<ASSISTANT_TASK:> Python Code: import torch import numpy as np x = np.array([0, 1, 2, 3, 4]).astype('float32').reshape(-1,1) y = x * 2 + 1 class Model(torch.nn.Module): def __init__(self): super(Model,self).__init__() self.layer = torch.nn.Linear(1,1) def forward(self, x): return self.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: Detail version with monitoring variables Step2: Compatible version Step3: GPU Version Step4: GPU인지 CPU인지 검사
2,856
<ASSISTANT_TASK:> Python Code: !pip install git+https://github.com/google/starthinker from starthinker.util.configuration import Configuration CONFIG = Configuration( project="", client={}, service={}, user="/content/user.json", verbose=True ) FIELDS = { 'auth_read':'user', # Credentials used for writing...
<SYSTEM_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. Set Configuration Step2: 3. Enter DV360 User Audit Recipe Parameters Step3: 4. Execute DV360 User Audit
2,857
<ASSISTANT_TASK:> Python Code: # Author: Hicham Janati <hicham.janati@inria.fr> # # License: MIT License import numpy as np import matplotlib.pylab as pl import ot # necessary for 3d plot even if not used from mpl_toolkits.mplot3d import Axes3D # noqa from matplotlib.collections import PolyCollection # parameters 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: Generate data Step2: Plot data Step3: Barycenter computation Step4: Barycentric interpolation
2,858
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
2,859
<ASSISTANT_TASK:> Python Code: # Imports from sklearn import metrics from sklearn.tree import DecisionTreeClassifier import pandas as pd # Training Data training_raw = pd.read_table("../data/training_data.dat") df_training = pd.DataFrame(training_raw) # test Data test_raw = pd.read_table("../data/test_data.dat") df_tes...
<SYSTEM_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 again. Step2: one more time Step3: We see that the results are not the same. This is because the Decision Tree Classifier chooses a featu...
2,860
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib.pyplot as plt %matplotlib inline df = pd.read_excel("H-2B_Disclosure_Data_FY15_Q4.xlsx") df.head() #df.info() df['CASE_NUMBER'].count() df['NBR_WORKERS_REQUESTED'].sum() df.groupby('FULL_TIME_POSITION')['NBR_WORKERS_REQUESTED'].sum() df['NBR_WORKER...
<SYSTEM_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. How many requests did the Office of Foreign Labor Certification (OFLC) receive in 2015? Step2: 2. How many jobs did that regard in total? An...
2,861
<ASSISTANT_TASK:> Python Code: import tarfile # 檔案名稱格式 filename_format="M06A_{year:04d}{month:02d}{day:02d}.tar.gz".format xz_filename_format="xz/M06A_{year:04d}{month:02d}{day:02d}.tar.xz".format csv_format = "M06A/{year:04d}{month:02d}{day:02d}/{hour:02d}/TDCS_M06A_{year:04d}{month:02d}{day:02d}_{hour:02d}0000.csv".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: 利用 pandas 來處理資料 Step2: csv 欄位依照手冊設定 Step3: 查看一下內容
2,862
<ASSISTANT_TASK:> Python Code: from sklearn.feature_extraction.text import CountVectorizer # Create a list of text documents: text = ["The quick brown fox jumped over the lazy dog."] # Create the transform: vectorizer = CountVectorizer() # Tokenize and build vocabulary: vectorizer.fit(text) # Summarize: print("vectoriz...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Above, you can see that we access the vocabulary to see what exactly was tokenized by calling Step2: We can see that all words were made lowerc...
2,863
<ASSISTANT_TASK:> Python Code: # NOTE: we use non-random initializations for the cluster centers # to make autograding feasible; normally cluster centers would be # randomly initialized. data = np.load('data/X.npz') X = data['X'] centers = data['centers'] print ('X: \n' + str(X)) print ('\ncenters: \n' + str(center...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Also, take a look at the imported functions k_means Step4: This is the function you will run in Part C once you have completed the helper funct...
2,864
<ASSISTANT_TASK:> Python Code: import csv data = {} with open("songdata.csv") as file: for author,_,_,lyric in csv.reader(file): data[author] = data.get(author,{}) for word in set(lyric.lower().split()): data[author][word] = data[author].get(word,0) + 1 data["ABBA"] import re # ht...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Algo que no hicimos durante la clase, pero que si hay que hacer, es sacar las palabras que no nos dan informacion. Otra cosa que habria que hace...
2,865
<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: TensorFlowアドオンのコールバック:TimeStopping Step2: データのインポートと正規化 Step3: シンプルなMNIST CNNモデルの構築 Step4: シンプルなTimeStoppingの使用法
2,866
<ASSISTANT_TASK:> Python Code: %matplotlib inline # Common imports import os import numpy as np import pandas as pd import matplotlib.pyplot as plt import sklearn.linear_model as skl from sklearn.metrics import mean_squared_error from sklearn.model_selection import train_test_split from sklearn.preprocessing import Mi...
<SYSTEM_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 preprocessing examples, breast cancer data and classification, Support Vector Machines Step2: More on Cancer Data, now with Logistic Reg...
2,867
<ASSISTANT_TASK:> Python Code: target = pd.read_csv('../data/train_target.csv') target.describe() target = target / 1000 logtarget = np.log1p(target) def read(): Read training and test data and return a dataframe with ['Dataset','Id'] multi-index raw_train = pd.read_csv('../data/train_prepared_light.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: The sale price is in hte hundreds of thousands, so let's divide the price by 1000 to get more manageable numbers. Step3: Merge the training and...
2,868
<ASSISTANT_TASK:> Python Code: # This is an inline comment: Python3 print('hello world') # Python2 print 'hello world' 1 * 1.0 a = 3 type(a) b = 3 > 5 print(b), type(b) L = ['red', 'blue', 'green', 'black', 'white'] print(L) L[1], L[3:], L[3:15] L[1] = 'yellow' print(L) T = ('red', 'black') T[1] = 'yellow' print(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: Basic Types Step2: Let us now turn to containers Step3: Lists are mutable objects, i.e. they can be changed. Step4: What is an example of an ...
2,869
<ASSISTANT_TASK:> Python Code: from poppy.creatures import Poppy4dofArmMini mini_dof = Poppy4dofArmMini() for m in mini_dof.motors: m.compliant = False m.goto_position(0,1) for m in mini_dof.motors: m.pid=(4,1,0.1) mini_dof.m3.goto_behavior= 'minjerk' mini_dof.m3.goto_behavior from pypot.primitive 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: With the goto_position method, you can set an angle and a time. But you can not be absolutely sure that the position will be effectively reach. ...
2,870
<ASSISTANT_TASK:> Python Code: gPlayers = [ 'X', 'O' ] gStart = tuple( tuple(' ' for col in range(3)) for row in range(3) ) gStart def to_list(State): return [list(row) for row in State] def to_tuple(State): return tuple(tuple(row) for row in State) def empty(Board): return [ (row, col) for row in ran...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the following naive implementation, states are represented as tuples of tuples of strings. The game starts with an empty board. An empty fi...
2,871
<ASSISTANT_TASK:> Python Code: import toytree # get a random tree with 10 tips tree1 = toytree.rtree.unittree(ntips=10, seed=123) # draw tree with admixture from node 2 to 3 tree1.draw(ts='s', admixture_edges=(2, 3)); # draw tree with admixture from tip r2 to ancestor of r4,r5 tree1.draw(ts='s', admixture_edges=('r2',...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Quick example Step2: Styling admixture edges Step3: Admixture timing Step4: Admixture edge style Step5: Label Step6: Parsing SNAQ newick fo...
2,872
<ASSISTANT_TASK:> Python Code: import torch x = torch.Tensor(5, 3) print(x) import torch from torch.autograd import Variable # N is batch size; D_in is input dimension; # H is hidden dimension; D_out is output dimension. N, D_in, H, D_out = 64, 1000, 100, 10 # Create random Tensors to hold inputs and outputs, and wra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Tutorial Step2: nn module Step3: https Step4: Quickstart
2,873
<ASSISTANT_TASK:> Python Code: # Import numpy import numpy as np # Define T and g T = 40 y0 =50 g = 0.01 # Compute yT using the direct approach and print yT = (1+g)**T*y0 print('Direct approach: ',yT) # Initialize a 1-dimensional array called y that has T+1 zeros y = np.zeros(T+1) # Set the initial value of y to eq...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: matplotlib Step2: Next, we want to make sure that the plots that we create are displayed in this notebook. To achieve this we have to issue a c...
2,874
<ASSISTANT_TASK:> Python Code: import numpy as np import sys # local api/python3 path - adjust path for your system japipath = 'C:\\j64\\j64-807\\addons\\api\\python3' if japipath not in sys.path: sys.path.append(japipath) sys.path import jbase as j print(j.__doc__) # start J - only one instance currently allowed...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configure the J Python3 addon Step2: Character data is passed as bytes. Step3: j.j() enters a simple REPL Step4: J accepts a subset of NumPy ...
2,875
<ASSISTANT_TASK:> Python Code: from py2cytoscape.data.cynetwork import CyNetwork from py2cytoscape.data.cyrest_client import CyRestClient from py2cytoscape.data.style import StyleUtil import py2cytoscape.util.cytoscapejs as cyjs import py2cytoscape.cytoscapejs as renderer import networkx as nx import pandas as pd 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: Long Description Step2: With py2cytoscape Step3: Status Step4: Creating empty networks Step5: Load networks from files, URLs or web services...
2,876
<ASSISTANT_TASK:> Python Code: # Load libraries from sklearn import linear_model, datasets # Load data iris = datasets.load_iris() X = iris.data y = iris.target # Create cross-validated logistic regression clf = linear_model.LogisticRegressionCV(Cs=100) # Train model clf.fit(X, y) <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: Load Iris Dataset Step2: Use Cross-Validation To Find The Best Value Of C
2,877
<ASSISTANT_TASK:> Python Code: import numpy as np print np.linspace(0,9,10), np.exp(-np.linspace(0,9,10)) # This line configures matplotlib to show figures embedded in the notebook, # instead of opening a new window for each figure. More about that later. # If you are using an old version of IPython, try using '%pyl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Balance bewteen 'speed' (Beta-coefficient) and 'momentum' of the learning Step2: Minimize An Expression Step3: Here is a summary Step4: Cauti...
2,878
<ASSISTANT_TASK:> Python Code: !conda install boto3 --yes import logging logging.basicConfig(level=logging.INFO) log = logging.getLogger(__name__) from pyspark.sql.types import * def create_struct(schema): Take a JSON schema and return a pyspark StructType of equivalent structure. replace_definitions(sc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step4: We create the pyspark datatype for representing the crash data in spark. This is a slightly modified version of peterbe/crash-report-struct-code...
2,879
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('../Data/kc_house_data.gl/') from math import log, sqrt sales['sqft_living_sqrt'] = sales['sqft_living'].apply(sqrt) sales['sqft_lot_sqrt'] = sales['sqft_lot'].apply(sqrt) sales['bedrooms_square'] = sales['bedrooms']*sales['bedrooms'] # In the 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: Load in house sales data Step2: Create new features Step3: Squaring bedrooms will increase the separation between not many bedrooms (e.g. 1) a...
2,880
<ASSISTANT_TASK:> Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG if os.getenv("IS_TESTING"): !...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
2,881
<ASSISTANT_TASK:> Python Code: # Basic imports import os import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime as dt import scipy.optimize as spo import sys from time import time from sklearn.metrics import r2_score, median_absolute_error %matplotlib inline %pylab inline pylab.rcParams[...
<SYSTEM_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 generate the datasets Step2: Let's generate the test dataset, also Step3: Let's train a predictor with the same hyperparameters as for t...
2,882
<ASSISTANT_TASK:> Python Code: data_dir = './data' # FloydHub - Use with data ID "R5KrjnANiKVhLWAkpXhNBe" #data_dir = '/input' DON'T MODIFY ANYTHING IN THIS CELL import helper helper.download_extract('mnist', data_dir) helper.download_extract('celeba', data_dir) show_n_images = 25 DON'T MODIFY ANYTHING IN THIS CELL %m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Face Generation Step3: Explore the Data Step5: CelebA Step7: Preprocess the Data Step10: Input Step13: Discriminator Step16: Generator Ste...
2,883
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.array([1, 2, 3]) # Create a rank 1 array print(type(a)) # Prints "<type 'numpy.ndarray'>" print(a.shape) # Prints "(3,)" print(a[0], a[1], a[2]) # Prints "1 2 3" a[0] = 5 # Change an element of the array 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: As you can see, we can easily access all this information. One-dimensional arrays in NumPy can be used to represent vectors, while two-dimension...
2,884
<ASSISTANT_TASK:> Python Code: def secondary_polygon(Angle ) : edges_primary = 360 // Angle if edges_primary >= 6 : edges_max_secondary = edges_primary // 2 return edges_max_secondary + 3  else : return "Not ▁ Possible "   if __name__== ' __main __' : Angle = 45 print(secondary_polygon(Angle ) )...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
2,885
<ASSISTANT_TASK:> Python Code: one_to_ten = [1,2,3,4,5,6,7,8,9,10] print one_to_ten one_to_ten = [] one_to_ten.append(1) print one_to_ten one_to_ten.append(2) print one_to_ten one_to_ten.append(3) print one_to_ten one_to_ten.append(4) print one_to_ten one_to_ten.append(5) print one_to_ten one_to_ten.append(6) print 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: This is great, because now we can remember values that our sensors returned at specific instances of time. There are many operations we can use ...
2,886
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np from math import sqrt import sys from bokeh.plotting import figure, show, ColumnDataSource, save from bokeh.models import Range1d, HoverTool from bokeh.io import output_notebook, output_file import quandl from gurobipy import * # output_notebook() #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: First of all, we need some data to proceed. For that purpose we use Quandl. First, you're going to need the quandl package. This isn't totally n...
2,887
<ASSISTANT_TASK:> Python Code: import sys, os # verbose = os.environ.get('RADICAL_PILOT_VERBOSE', 'REPORT') os.environ['RADICAL_PILOT_VERBOSE'] = 'ERROR' from adaptivemd import Project project = Project('test') from adaptivemd import LocalCluster AllegroCluster resource_id = 'local.jhp' if resource_id == 'local.jhp...
<SYSTEM_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 want to stop RP from reporting all sorts of stuff for this example so we set a specific environment variable to tell RP to do so. If you want...
2,888
<ASSISTANT_TASK:> Python Code: import sys import pandas as pd import numpy as np ALL = -1 # DEBUG = True DEBUG = False ##============================================================ # Data file format: # * tab-delimited input file # * 1st line: dimension names and the last dimension is assumed to be the measure # * 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: Now we can implement the buc_rec() algorithm and test it. Step2: With the following pivot table, we can easily see the output is correct (i.e.,...
2,889
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csir-csiro', 'sandbox-1', 'atmos') # 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...
2,890
<ASSISTANT_TASK:> Python Code: # Pipeline class from quantopian.pipeline import Pipeline def make_pipeline(): # Create and return an empty Pipeline return Pipeline() # Import Pipeline class and USEquityPricing dataset from quantopian.pipeline import Pipeline from quantopian.pipeline.data import EquityPricing 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: To add an output to our pipeline we need to include a reference to a dataset, and specify the computations we want to carry out on that data. Fo...
2,891
<ASSISTANT_TASK:> Python Code: import os from nipype import Workflow, Node, Function def sum(a, b): return a + b wf = Workflow('hello') adder = Node(Function(input_names=['a', 'b'], output_names=['sum'], function=sum), name='a_plus_b') adder.inputs.a = 1 ad...
<SYSTEM_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 Workflow with one Node that adds two numbers Step2: Creating a second node and connecting to the hello Workflow Step3: And we can che...
2,892
<ASSISTANT_TASK:> Python Code: import pandas as pd import pastas as ps import matplotlib.pyplot as plt ps.set_log_level("ERROR") ps.show_versions(numba=True, lmfit=True) head = pd.read_csv("data_wagna/head_wagna.csv", index_col=0, parse_dates=True, squeeze=True, skiprows=2).loc["2006":] evap = pd.r...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Read Data and plot autocorrelation Step2: 2. Run models with AR(1) noise model Step3: 3. Run models with ARMA(1,1) noise model Step4: 4. P...
2,893
<ASSISTANT_TASK:> Python Code: %matplotlib inline from shapely.geometry import Point from geopandas import datasets, GeoDataFrame, read_file # NYC Boros zippath = datasets.get_path('nybb') polydf = read_file(zippath) # Generate some points b = [int(x) for x in polydf.total_bounds] N = 8 pointdf = GeoDataFrame([ {'g...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Joins Step2: We're not limited to using the intersection binary predicate. Any of the Shapely geometry methods that return a Boolean can be use...
2,894
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst import os # TODO 1 PROJECT_ID = "cloud-training-demos" # Replace with your PROJECT BUCKET = PROJECT_ID REGION = 'us-central1' os.environ["PROJECT_ID"] = PROJECT_ID os.environ["BUCKET"] = BUCKET !mkdir train !touch trai...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Next we will configure our environment. Be sure to change the PROJECT_ID variable in the below cell to your Project ID. This will be the project...
2,895
<ASSISTANT_TASK:> Python Code: import rebound import numpy as np def test_case(): sim = rebound.Simulation() sim.integrator = 'whfast' sim.add(m=1.) # add the Sun sim.add(m=3.e-6, a=1.) # add Earth sim.move_to_com() sim.dt = 0.2 return sim sim = test_case() sim.integrator_whfast_safe_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: By default WHFast synchronizes and recalculates the Jacobi coordinates from the inertial ones every timestep. This guarantees that the user alw...
2,896
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nerc', '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...
2,897
<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...
2,898
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' import matplotlib as mpl import matplotlib.pyplot as plt plt.style.use('ggplot') import numpy as np from sympy import * init_printing() def linear_rgb(x): return ((x+0.055)/1.055)**2.4 x = Symbol('x', real=True) serie...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The following is the conversion from RGB to linear RGB (aka. gamma-correction), where I'm dropping the conditional part for very small values of...
2,899
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pycomlink as pycml import xarray as xr from tqdm import tqdm import urllib.request import io import pycomlink.processing.blackout_gap_detection as blackout_detection # Do show xarray.Dataset representation as text because gitlab/gi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: CMLs with more than 35 minutes of blackout within the 10-day example data Step2: Investiagte blackouts for two CMLs over three years Step3: Th...