Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
9,000
<ASSISTANT_TASK:> Python Code: import re phoneRegex = re.compile(r'/d/d/d-/d/d/d-/d/d/d/d') #phoneRegex.search() # finds first match #phoneRegex.findall() # finds all matches import re phoneRegex = re.compile(r'(/d/d/d)-(/d/d/d-/d/d/d/d)') # Two groups, so returns tuples #phoneRegex.findall() # finds all matches in pa...
<SYSTEM_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.all() returns a list of strings. Step2: To get the total string, just wrap the total regex in its own group, so you get [(totalstring, gr...
9,001
<ASSISTANT_TASK:> Python Code: %%html <style> .example-container { background: #999999; padding: 2px; min-height: 100px; } .example-container.sm { min-height: 50px; } .example-box { background: #9999FF; width: 50px; height: 50px; text-align: center; vertical-align: middle; color: white; font-weight: bold; margin: 2px;}...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Widget Styling Step2: Parent/child relationships Step3: After the parent is displayed Step4: Fancy boxes Step5: TabWidget Step6: Alignment ...
9,002
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image(filename="ImagAnillosNewton.jpg") from IPython.display import Image Image(filename="PaperAnillosNewton.JPG") from IPython.display import Image Image(filename="esquemaAnillosNewton1.jpg") from IPython.display import Image Image(filename="esquemaAn...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: El patrón de interferencias que aparece al reflejarse la luz entre dos superficies transparentes, una curva y otra plana, es conocido como Anill...
9,003
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd df = pd.read_csv('example') df df.to_csv('example',index=False) pd.read_excel('Excel_Sample.xlsx',sheetname='Sheet1') df.to_excel('Excel_Sample.xlsx',sheet_name='Sheet1') df = pd.read_html('http://www.fdic.gov/bank/individual/failed/banklist.htm...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: CSV Step2: CSV Output Step3: Excel Step4: Excel Output Step5: HTML Step6: SQL (Optional)
9,004
<ASSISTANT_TASK:> Python Code: import numpy as np X = np.array([[1, 2, 3], [4, 5, 6]]) X X + 2*X np.matmul(X.transpose(), X) #X^t * X X[1,1] X[1, :] #1. Fila entera X[:, 1] #2. Columna entera X[0:2, 0:2] #3. Slice de n:m, n,n+1,...,m-1 X.shape #Dimensión de arrays vec = np.array([1, 2, 3]) print(vec) class Array:...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Operaciones con arrays Step2: Multiplicación de matrices con numpy.matmul() Step3: Obteniendo datos específicos Step4: Selección y multi sele...
9,005
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import numpy as np import tensorflow as tf from six.moves import cPickle as pickle pickle_file = 'notMNIST.pickle' with open(pickle_file, 'rb...
<SYSTEM_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 reload the data we generated in 1_notmnist.ipynb. Step2: Reformat into a shape that's more adapted to the models we're going to train Ste...
9,006
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt # if using a jupyter notebook: include %matplotlib inline. If constructing a .py-file: comment out %matplotlib inline # if high-resolution images are desired: include %config InlineBackend.figure_format = 'svg' %config InlineBackend.figure_format = 'svg' im...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now we'll build the circuit diagram by creating a SchemDraw Drawing object and adding elements to it. Step2: Find R<sub>t</sub> Step3: Find R<...
9,007
<ASSISTANT_TASK:> Python Code: !pip install nnabla-ext-cuda100 !git clone https://github.com/sony/nnabla-examples.git %cd nnabla-examples import nnabla as nn import nnabla.functions as F import nnabla.parametric_functions as PF import nnabla.solver as S from nnabla.logger import logger import nnabla.utils.save as save...
<SYSTEM_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 always, let's start by importing dependencies. Step4: Let's also define data iterator for MNIST. You can disregard the details for now. Step...
9,008
<ASSISTANT_TASK:> Python Code: from effect_demo_setup import * from concise.models import single_layer_pos_effect as concise_model import numpy as np # Generate training data for the model, use a 1000bp sequence param, X_feat, X_seq, y, id_vec = load_example_data(trim_seq_len = 1000) # Generate the model dc = concise_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: As with any prediction that you want to make with a model it is necessary that the input sequences have to fit the input dimensions of your mode...
9,009
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-lm', 'ocean') # 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...
9,010
<ASSISTANT_TASK:> Python Code: import pandas as pd # redefining the example DataFrame data = {'country': ['Belgium', 'France', 'Germany', 'Netherlands', 'United Kingdom'], 'population': [11.3, 64.3, 81.3, 16.9, 64.9], 'area': [30510, 671308, 357050, 41526, 244820], 'capital': ['Brussels', 'Paris...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Subsetting data Step2: Remember that the same syntax can also be used to add a new columns Step3: Subset observations (rows) Step4: Boolean i...
9,011
<ASSISTANT_TASK:> Python Code: import cv2 import numpy as np import sys import pandas as pd # typeData 为"train"或者"test" # labelsInfo 包含每一个图片的ID # 图片存储在trainResized和testResized文件夹内 def read_data(typeData, labelsInfo, imageSize): labelsIndex = labelsInfo["ID"] x = np.zeros((np.size(labelsIndex), imageSize)) ...
<SYSTEM_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的矩阵当中,每一行为图片的像素值。为了得到统一的表达呢,我们将RGB三个通道的值做平均得到的灰度图像作为每个图片的表示 Step2: 预处理训练集和测试集 Step3: 预览数据: Step4: 模型训练 Step5: 预测 Step6:...
9,012
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'inm', 'inm-cm5-0', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "emai...
<SYSTEM_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...
9,013
<ASSISTANT_TASK:> Python Code: # Import relevant modules %matplotlib inline %load_ext autoreload %autoreload 2 import numpy as np import corner import matplotlib.pyplot as plt from matplotlib import rcParams from NPTFit import nptfit # module for performing scan from NPTFit import create_mask as cm # module for creatin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 1 Step2: Step 2 Step3: Step 3 Step4: Step 4 Step5: Step 5 Step6: We also show a plot of the source count function, although a careful ...
9,014
<ASSISTANT_TASK:> Python Code:: def skipIndices(N , T , arr): sum = 0 count = { } for i in range(N): d = sum + arr[i]- T k = 0 if(d > 0): for u in list(count . keys())[: : - 1]: j = u x = j * count[j] if(d <= x): k +=(d + j - 1)// j break k += count[j] d -= x sum += arr[i] count[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:
9,015
<ASSISTANT_TASK:> Python Code: list_with_for_loop = [x for x in range(10)] print list_with_for_loop list_with_for_loop_conditional = [x for x in range(10) if x%2 == 1] print list_with_for_loop_conditional list_with_nested_loops = [ [x, y] for x in range(3) for y in range(3) ] print list_with_nested_loops list_with_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: Even with conditions in the for loop Step2: Nested loops in a list Step3: Another example of nested loops Step4: The article gives an example...
9,016
<ASSISTANT_TASK:> Python Code: import numpy as np import os import gdal, osr import matplotlib.pyplot as plt import sys import matplotlib.pyplot as plt from scipy import ndimage as ndi %matplotlib inline #Import biomass specific libraries from skimage.morphology import watershed from skimage.feature import peak_local...
<SYSTEM_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 add libraries from skilearn which will help with the watershed delination, determination of predictor variables and random forest a...
9,017
<ASSISTANT_TASK:> Python Code: # variable assignment # https://www.digitalocean.com/community/tutorials/how-to-use-variables-in-python-3 # strings -- enclose in single or double quotes, just make sure they match my_name = 'Cody' # numbers int_num = 6 float_num = 6.4 # the print function print(8) print('Hello!') print(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: Basic math Step2: Lists Step3: Dictionaries Step5: Commenting your code Step7: Comparison operators Step8: String functions Step9: upper()...
9,018
<ASSISTANT_TASK:> Python Code: df = pd.read_csv('../data/wine.data') X_train = df[df.columns[1:]] y_train = df[df.columns[0]] kf = KFold(n_splits=5, random_state=42, shuffle=True) def test_accuracy(kf, X, y): means = list() means_range = range(1, 51) for r in means_range: knn = KNeighborsClassifi...
<SYSTEM_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. Извлеките из данных признаки и классы. Класс записан в первом столбце (три варианта), признаки — в столбцах со второго по последний. Более по...
9,019
<ASSISTANT_TASK:> Python Code: # Load Module import numpy as np from sklearn import datasets from sklearn import metrics from sklearn import model_selection import tensorflow as tf # Load dataset. iris = datasets.load_iris() # 총 150개의 붓꽃 사진과 class load x_train, x_test, y_train, y_test = model_selection.train_test_split...
<SYSTEM_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. TF-slim(tf.contrib.slim) Step2: with TF-Slim Step3: Data Flow Graph Step4: How to get the value of a? Step5: More graphs Step6: Why grap...
9,020
<ASSISTANT_TASK:> Python Code: %matplotlib inline # Required imports from wikitools import wiki from wikitools import category import nltk from nltk.tokenize import word_tokenize from nltk.corpus import stopwords from nltk.stem import WordNetLemmatizer import gensim import numpy as np import lda import lda.datasets fro...
<SYSTEM_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: You can try with any other categories. Take into account that the behavior of topic modelling algorithms may depe...
9,021
<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 to print version # ...
<SYSTEM_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 Python Classes Step2: When the Python compiler sees a private attribute, it actually transforms the actual name to _[Class name]__...
9,022
<ASSISTANT_TASK:> Python Code: %%capture !pip install git+https://github.com/jamesvuc/jax-bayes !pip install SGMCMCJax !pip install distrax import jax.numpy as jnp from jax.experimental import optimizers import jax import jax_bayes import sys, os, math, time import numpy as np from functools import partial from matplot...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data Step2: The Bayesian NN is taken from SGMCMCJAX. However, there are couple of changes made. These can be listed as follows Step3: Model St...
9,023
<ASSISTANT_TASK:> Python Code: import packages.initialization import pioneer3dx as p3dx p3dx.init() def forward(): # copy and paste your code here ... def turn(): # copy and paste your code here ... print('Pose of the robot at the start') p3dx.pose() for _ in range(4): forward() turn() print('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: 3. Program Step2: The trajectory can also be displayed
9,024
<ASSISTANT_TASK:> Python Code: import IPython.display as IPdisplay import matplotlib.cm as cm import matplotlib.pyplot as plt import numpy as np import pandas as pd import pynamical from pynamical import simulate, bifurcation_plot, save_fig %matplotlib inline title_font = pynamical.get_title_font() label_font = pynamic...
<SYSTEM_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, let's see the population values the logistic map produces for a range of growth rate parameters Step2: Now let's visualize the system at...
9,025
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import os import numpy as np import tempfile import matplotlib.pyplot as pyplot import logging logging.basicConfig(level=logging.INFO) import minimask.mask as mask import minimask.healpix_projection as hp import minimask.io.mosaic as mosaic filename = "masks/mosaic.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: Specify the location of the mask file to write Step2: Construct a mask using a tile pattern with centers specified by the healpix grid. Step3: ...
9,026
<ASSISTANT_TASK:> Python Code: %pylab notebook imax = 1 # Normalize imax to 1 freq = 50 # [Hz] w = 2*pi*freq # [rad/s] angluar velocity t = linspace(0, 1./50, 100) # 100 values for one period wt = w*t # we are going to use this quite often # amplit...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set up the basic conditions Step2: First, generate the three component magnetic fields Step3: Calculate the combined current vector Step4: Ca...
9,027
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame([[1,2,3,1],[0,0,0,0],[1,0,0,1],[0,1,2,0],[1,1,0,1]],columns=['A','B','C','D']) def g(df): return df.loc[(df.max(axis=1) != 2), (df.max(axis=0) != 2)] result = g(df.copy()) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
9,028
<ASSISTANT_TASK:> Python Code: import jax.numpy as jnp import jax import matplotlib.pyplot as plt plt.rcParams.update({'font.size': 18}) import ott def create_points(rng, n, m, d): rngs = jax.random.split(rng, 4) x = jax.random.normal(rngs[0], (n,d)) + 1 y = jax.random.uniform(rngs[1], (m,d)) a = jax.random.uni...
<SYSTEM_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 an OT problem comparing two point clouds Step2: Solve it with Sinkhorn and plot plan/map Step3: Experimentations with the Low-Rank appr...
9,029
<ASSISTANT_TASK:> Python Code: # Here's a string representing a three-line SAM file. I'm temporarily # ignoring the fact that SAM files usually have several header lines at # the beginning. samStr = '''\ r1 0 gi|9626243|ref|NC_001416.1| 18401 42 122M * 0 0 TGAATGCGAACTCCGGGACGCTCAGTAATGTGACGATAGCTGAAAACTGTACGATAAACNGT...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: SAM fields Step2: Next we construct a function to parse the MD Step3: Now we can write a fucntion that takes a read sequennce, a parsed CIGAR ...
9,030
<ASSISTANT_TASK:> Python Code: import argparse import logging import joblib import sys import pandas as pd from sklearn.metrics import roc_auc_score from sklearn.model_selection import train_test_split from sklearn.impute import SimpleImputer from xgboost import XGBClassifier logging.basicConfig(format='%(message)s') l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Define the model logic Step6: Define functions to train, evaluate, and save the trained model. Step8: Define a class for your model, with meth...
9,031
<ASSISTANT_TASK:> Python Code: import torch import numpy as np from torchvision import datasets import torchvision.transforms as transforms # convert data to torch.FloatTensor transform = transforms.ToTensor() # load the training and test datasets train_data = datasets.MNIST(root='data', train=True, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Visualize the Data Step2: Linear Autoencoder Step3: Training Step4: Checking out the results
9,032
<ASSISTANT_TASK:> Python Code: #Check that you are using the correct version of Python (should be 3.4+, otherwise gdal won't work) import sys sys.version import numpy as np import h5py import gdal, osr import matplotlib.pyplot as plt %matplotlib inline import warnings warnings.filterwarnings('ignore') f = h5py.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: First let's import the required packages and set our display preferences so that plots are inline and plot warnings are off Step2: Read hdf5 fi...
9,033
<ASSISTANT_TASK:> Python Code: # general imports import pandas as pd import numpy as np from datetime import datetime from collections import defaultdict import pickle # imports for webscraping and text manipulation import requests import re import io import urllib # imports to convert pdf to text from pdfminer.pdfinte...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Part 1 Step2: Clean-up data types and identify hashtags and @mentions Step3: Save clean twitter data as pickle Step4: Scrape and format Data ...
9,034
<ASSISTANT_TASK:> Python Code: import numpy as np objective = np.poly1d([1.3, 4.0, 0.6]) print objective import scipy.optimize as opt x_ = opt.fmin(objective, [3]) print "solved: x={}".format(x_) %matplotlib inline x = np.linspace(-4,1,101.) import matplotlib.pylab as mpl mpl.plot(x, objective(x)) mpl.plot(x_, objecti...
<SYSTEM_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 "optimizer" Step2: Additional components Step3: The gradient and/or hessian Step4: The penalty functions Step5: Optimizer classification...
9,035
<ASSISTANT_TASK:> Python Code: import pandas as pd # data handeling import numpy as np # numeriacal computing import matplotlib.pyplot as plt # plotting core import seaborn as sns # higher level plotting tools %matplotlib inline sns.set() def h(X,a) : # model h(X) = Xa h = np.dot(X,a) return h def a_opt(X,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here's the example data and a plot, Step2: To start lets just try fitting a straight line $h(x) = a_0 + a_1x$. We'll construct the augmented ma...
9,036
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mri', 'mri-esm2-0', '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: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
9,037
<ASSISTANT_TASK:> Python Code: #from imp import * #s=load_source('sygma','/home/nugrid/nugrid/SYGMA/SYGMA_online/SYGMA_dev/sygma.py') #%pylab nbagg import sys import sygma as s print (s.__file__) s.__file__ #import matplotlib #matplotlib.use('nbagg') import matplotlib.pyplot as plt #matplotlib.use('nbagg') import numpy...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: IMF notes Step2: The total number of stars $N_{tot}$ is then Step3: With a yield ejected of $0.1 Msun$, the total amount ejected is Step4: co...
9,038
<ASSISTANT_TASK:> Python Code: import sys,os,glob from collections import OrderedDict import numpy as np from utils.misc import readPickle, createIfAbsent sys.path.append('../') from optvaedatasets.load import loadDataset as loadDataset_OVAE from sklearn.feature_extraction.text import TfidfTransformer default_params =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Model Parameters Step2: For the moment, we will leave everything as is. Some worthwhile parameters to note Step3: Load dataset Step4: Setup S...
9,039
<ASSISTANT_TASK:> Python Code: x = np.arange(-5.0, 5.0, 0.1) y = np.array(x > 0, dtype=np.int) plt.plot(x, y) plt.show() x = np.arange(-5.0, 5.0, 0.1) y = 1 / (1 + np.exp(-x)) plt.plot(x, y) plt.show() x = np.arange(-5.0, 5.0, 0.1) y = np.maximum(0, x) plt.plot(x, y) plt.show() <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: シグモイド関数 Step2: ReLU関数
9,040
<ASSISTANT_TASK:> Python Code: query_url = 'https://data.sfgov.org/resource/wbb6-uh78.json?$order=close_dttm%20DESC&$offset={}&$limit={}' # query_url = "https://data.sfgov.org/resource/wbb6-uh78.json?$where=alarm_dttm>='2013-02-12 04:52:17'&$order=close_dttm%20DESC" # query_url = "https://data.sfgov.org/resource/wbb6-u...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: According to wikipeda, the mission district falls into two zipcodes, 94103, 94110 Step2: Initial Conclusions Step3: Disclaimers from the Fire ...
9,041
<ASSISTANT_TASK:> Python Code: import os os.mkdir("/tmp/park-python") try: os.rmdir("/tmp/park-python") except IOError as err: print(err) path = "/tmp/park-python/lectures/04" if not os.path.exists(path): os.makedirs(path) os.rmdir("/tmp/park-python") import shutil shutil.rmtree("/tmp/park-python") import p...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Работа с файлами Step2: "r" – открытие на чтение (является значением по умолчанию). Step3: stdin, stdout, stderr Step4: Так как дескрипторы s...
9,042
<ASSISTANT_TASK:> Python Code: # Syntax error x = 1; y = 2 b = x == y # Boolean variable that is true when x & y have the same value b = 1 == 2 # Syntax error b # Exception - invalid operation a = 0 5/a # Division by zero # Exception - invalid operation input = '40' float(input)/11 # Incompatiable types for the oper...
<SYSTEM_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: What's the bug here and how do we resolve? Step3: We should have documented the inputs to the function! Step4: Now it works f...
9,043
<ASSISTANT_TASK:> Python Code: # 加载必要的程序包 # PyTorch的程序包 import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch.optim as optim # 数值运算和绘图的程序包 import numpy as np import matplotlib.pyplot as plt import matplotlib # 加载机器学习的软件包,主要为了词向量的二维可视化 from sklearn.decomposit...
<SYSTEM_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: 结论:可以看出,中文的一、二、等数字彼此之间的关系与英文的数字彼此之间的关系很类似
9,044
<ASSISTANT_TASK:> Python Code: %load_ext sql %sql mysql://steinam:steinam@localhost/celko %%sql select * from Register; %%sql SELECT R1.course_nbr, R1.student_name, MIN(R1.teacher_name) as Teacher_1, NULL FROM Register AS R1 GROUP BY R1.course_nbr, R1.student_name HAVING COUNT(*) = 1 UNION SELECT R1.course_nbr, R1.stu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lösung 1 Step2: Lösung 2 Step3: Lösung 3
9,045
<ASSISTANT_TASK:> Python Code: import numpy as np import cv2 import sys import os sys.path.insert(0, os.path.abspath('..')) import salientregions as sr %pylab inline #Load the image path_to_image = 'images/graffiti.jpg' img = cv2.imread(path_to_image) sr.show_image(img) det = sr.SalientDetector(SE_size_factor=0.20, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First, we load the image and show it. Step2: Now we create a SalientDetector object, with some parameters. Step3: We ask the SalientDetector t...
9,046
<ASSISTANT_TASK:> Python Code: print hash_obj([0, 1, 2]) bits = 64*2 n_elements = 200 np.log10(2*2**bits/(n_elements*(n_elements-1))) l = list(['zero', 'one', 'two']) l.__getitem__(0) [x for x in l.__iter__()] l.__setitem__(1, 1) print l l.__getslice__(1,3) l.__setslice__(1, 3, ('b', 'c')) print l from functools 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: Testing out a container class but that
9,047
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pandas as pd from math import log from sklearn import linear_model #comment below if not using ipython notebook %matplotlib inline #read csv anscombe_i = pd.read_csv('../datasets/anscombe_i.csv') plt.scatter(anscombe_i.x, anscombe...
<SYSTEM_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 lets read the first set of data, and make a simple scatter plot. Step2: Luckly for us, we do not need to implement linear regression, since...
9,048
<ASSISTANT_TASK:> Python Code: import numpy as np import ipywidgets as widgets import bqplot.pyplot as plt y = np.random.randn(100).cumsum() # simple random walk # create a button update_btn = widgets.Button(description='Update', button_style='success') # create a figure widget fig1 = plt.figure(animation_duration=750...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Update the plot on a button click Step2: Let's look at an example where we link a plot to a dropdown menu Step3: Let's now create a scatter pl...
9,049
<ASSISTANT_TASK:> Python Code: from nipype import DataGrabber, Node # Create DataGrabber node dg = Node(DataGrabber(infields=['subject_id', 'task_id'], outfields=['anat', 'func']), name='datagrabber') # Location of the dataset folder dg.inputs.base_directory = '/data/ds102' # Necessary 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: Second, we know that the two files we desire are the the following location Step2: Now, comes the most important part of DataGrabber. We need t...
9,050
<ASSISTANT_TASK:> Python Code: def example1(x_1, x_2): z = x_1**0.5*x_2*0.5 return z fig = pl.figure() ax = Axes3D(fig) X = np.arange(0, 1, 0.1) Y = np.arange(0, 1, 0.1) X, Y = np.meshgrid(X, Y) Z = example1(X, Y) ax.plot_surface(X, Y, Z, rstride=1, cstride=1) pl.show() nn = NN() x_1 = Symbol('x_1') x_2 = Sym...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <P>課題の例で使われた関数は以下の通りである。</P> Step2: 以下に使い方を説明する。 Step3: 入力層、中間層、出力層を作る関数を実行する。引数には層の数を用いる。 Step4: <p>nn.set_hidden_layer()は同時にシグモイド関数で変換する前の中...
9,051
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from random import random, randint, choice from itertools import cycle, ifilter, imap, islice, izip, starmap, tee from collections import defaultdict from operator import add, mul from pymonad.Maybe import * from pymona...
<SYSTEM_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 ubiquitous zip Step2: In fact, it is mentioned in the documentation in the section on built-in functions. I guess, it is one of those bits ...
9,052
<ASSISTANT_TASK:> Python Code: # Install the SDK !pip3 install 'kfp>=0.1.31.2' --quiet import kfp.deprecated as kfp import kfp.deprecated.components as components #Define a Python function def add(a: float, b: float) -> float: '''Calculates sum of two arguments''' return a + b add_op = components.create_compone...
<SYSTEM_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 function that just add two numbers Step2: Convert the function to a pipeline operation Step3: A bit more advanced function which demons...
9,053
<ASSISTANT_TASK:> Python Code: # Authors: Jean-Remi King <jeanremi.king@gmail.com> # Alexandre Gramfort <alexandre.gramfort@inria.fr> # Denis Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import matplotlib.pyplot as plt from sklearn.pipeline import make_pipeline from sklearn.preproce...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We will train the classifier on all left visual vs auditory trials Step2: Score on the epochs where the stimulus was presented to the right. St...
9,054
<ASSISTANT_TASK:> Python Code: !hybridizer-cuda ./01-vector-add/01-vector-add.cs -o ./01-vector-add/vectoradd.exe -run !hybridizer-cuda ./01-vector-add/01-vector-add.cs -o ./01-vector-add/parallel-vectoradd.exe -run !hybridizer-cuda ./02-gpu-vector-add/02-gpu-vector-add.cs -o ./02-gpu-vector-add/gpu-vectoradd.exe -ru...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Introduce Parallelism Step2: Run Code on the GPU
9,055
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') from modshogun import * #Needed lists for the final plot classifiers_linear = []*10 classifiers_non_linear = []*10 classifiers_names = []*10 fading...
<SYSTEM_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 = "section1">Data Generation and Visualization</a> Step5: Data visualization methods. Step6: <a id="section2" href="http Step7: SVM - K...
9,056
<ASSISTANT_TASK:> Python Code: import pickle dataset = pickle.load(open('data/cafe.pkl','r')) # or 'pofa.pkl' # This is the neural network class, for your information. from sklearn.decomposition import PCA from sklearn.learning_curve import learning_curve from sklearn.cross_validation import train_test_split from nump...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step6: Backpropagation Demo Step7: Then train the net using the controls here Step8: After the network is trained, use it to classify test images. St...
9,057
<ASSISTANT_TASK:> Python Code: # Load a useful Python libraries for handling data import pandas as pd from IPython.display import Markdown, display # Read the data data_filename = r'gapminder.csv' data = pd.read_csv(data_filename, low_memory=False) data = data.set_index('country') display(Markdown("General information ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We will now have a look at the frequencies of the variables. Step2: This is useless as the variable does not take discrete values. So before re...
9,058
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd %pylab inline pylab.style.use('ggplot') import tensorflow as tf X_val = numpy.array([[0, 0], [0, 1], [1, 0], [1, 1]]) y_val = np.atleast_2d(np.array([0, 0, 0, 1])).T X_val y_val tf.reset_default_graph() n_iter = 500 threshold = 0.5 with tf.variable...
<SYSTEM_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 idea of variable scoping in TensorFlow is to be able to organize the names and initializations of variables that play the same role in a mul...
9,059
<ASSISTANT_TASK:> Python Code: from fretbursts import * sns = init_notebook(apionly=True) print('seaborn version: ', sns.__version__) # Tweak here matplotlib style import matplotlib as mpl mpl.rcParams['font.sans-serif'].insert(0, 'Arial') mpl.rcParams['font.size'] = 12 %config InlineBackend.figure_format = 'retina' u...
<SYSTEM_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 and process data Step2: ALEX joint plot Step3: The inner plot in an hexbin plot, basically a 2D histogram with hexagonal bins. Step4: Or ...
9,060
<ASSISTANT_TASK:> Python Code: %load_ext watermark %watermark -a 'Sebastian Raschka' -v -p tensorflow import tensorflow as tf ########################## ### WRAPPER FUNCTIONS ########################## def fc_layer(input_tensor, n_output_units, name, activation_fn=None, seed=None, weight_para...
<SYSTEM_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 Zoo -- Saving and Loading Trained Models Step2: Train and Save Multilayer Perceptron Step3: Reload Model from Meta and Checkpoint Files ...
9,061
<ASSISTANT_TASK:> Python Code: from __future__ import division import graphlab products = graphlab.SFrame('amazon_baby_subset.gl/') import json with open('important_words.json', 'r') as f: important_words = json.load(f) important_words = [str(s) for s in important_words] # Remote punctuation def remove_punctuati...
<SYSTEM_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 process review dataset Step2: Just like we did previously, we will work with a hand-curated list of important words extracted from the...
9,062
<ASSISTANT_TASK:> Python Code: # setup import numpy as np import sympy as sp import pandas as pd import scipy from pprint import pprint sp.init_printing(use_latex='mathjax') import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (12, 8) # (width, height) plt.rcParams['font.size'] = 14 plt.rcParams['legend.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: Reading raw test data example 1 Step2: Reading test data - example 2 Step3: another example of plotting data Step5: Finding the "first" peak ...
9,063
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'svg' from ipywidgets import interact from ipywidgets import widgets, FloatSlider, Checkbox, RadioButtons, fixed from exact_solvers import shallow_water from exact_solvers import shallow_demos from IPython.display import IFrame 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: If you wish to examine the Python code for this chapter, see Step2: The Riemann problem Step3: The plot above shows the Hugoniot loci in the $...
9,064
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib.ticker import MultipleLocator import scipy from scipy import interpolate from scipy.interpolate import interp1d import scipy.io.wavfile as wf import matplotlib.pyplot as plt import numpy as np def wav2file(fname, data, sr): Write wave data to ...
<SYSTEM_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 the required modules Step3: Functions for working with signals Step9: Plot signals Step14: Signal processing functions Step15: Analyz...
9,065
<ASSISTANT_TASK:> Python Code: import npfl103 import os dpath = os.path.join('.', 'tutorial-assignment') dlist = os.path.join(dpath, 'documents.list') qlist = os.path.join(dpath, 'topics.list') from npfl103.io import Collection coll_docs = Collection(dlist) from npfl103.io import Topic coll_queries = Collection(qlis...
<SYSTEM_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 data Step2: Loading documents and queries Step3: Notice that creating the Collection was fast. This is because the whole pipeline in ...
9,066
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import numpy as np import tensorflow as tf from six.moves import cPickle as pickle from six.moves import range pickle_file = 'notMNIST.pickle...
<SYSTEM_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 reload the data we generated in 1_notmnist.ipynb. Step2: Reformat into a shape that's more adapted to the models we're going to train Ste...
9,067
<ASSISTANT_TASK:> Python Code: x = [1,3,5] x.append(7) x.insert(0,2) x.pop(-2) print(x) x = [5,3,1] y = [2,3] z = x + y z.sort() print(z) x = { 'a' : 'b', 'b' : 2, '2' : 6} x['b'] x = { 'a' : 'b', 'b' : 2, '2' : 6} x[2] students = [ { 'Name':'bob','GPA':3.4 }, { 'Name':'sue','GPA':2.8 }, { '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: A. [1,3,5,7] Step2: A. [1,2,3,3,5] Step3: A. 2 Step4: A. 2 Step5: Watch Me Code 3 Step6: A. 3.4
9,068
<ASSISTANT_TASK:> Python Code: import os import discoursegraphs as dg ddg = dg.corpora.pcc.get_document('maz-6728') dg.DATA_ROOT_DIR # dg.corpora.pcc.get_files_by_layer('syntax') tdg = dg.read_tiger(os.path.join( dg.DATA_ROOT_DIR, 'potsdam-commentary-corpus-2.0.0/syntax/maz-11766.xml')) # dg.info(tdg) #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: There are only very few RST spans that match to non-S/CS nodes Step3: Are there any 'S'/'CS' that are not sentence root nodes?
9,069
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt plt.style.use('ggplot') from libs import utils # utils.<tab> files = utils.get_celeb_files() img = plt.imread(files[50]) # img.<tab> print(img) # If nothing is drawn and you are using notebook, try uncommenting the 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: I'll be using a popular image dataset for faces called the CelebFaces dataset. I've provided some helper functions which you can find on the re...
9,070
<ASSISTANT_TASK:> Python Code: import numpy as np incomes = np.random.normal(27000, 15000, 10000) # (center around, stdev, population ) np.mean(incomes) # calculate mean %matplotlib inline import matplotlib.pyplot as plt # segment the income data into 50 buckets and plot as a histogram plt.hist(incomes, 50) plt.show()...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We can segment the income data into 50 buckets, and plot it as a histogram Step2: Now compute the median - since we have a nice, even distribut...
9,071
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import os import sys import pandas as pd import numpy as np %matplotlib inline from matplotlib import pyplot as plt import seaborn as sns import datetime #set current working directory os.chdir('D:/Practical Time Series') #Read the dataset into a pand...
<SYSTEM_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 notebook, we will use a multi-layer perceptron to develop time series forecasting models. Step2: To make sure that the rows are in the ...
9,072
<ASSISTANT_TASK:> Python Code: from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm vgg_dir = 'tensorflow_vgg/' # Make sure vgg exists if not isdir(vgg_dir): raise Exception("VGG directory doesn't exist!") class DLProgress(tqdm): last_block = 0 def hook(self, block_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Flower power Step2: ConvNet Codes Step3: Below I'm running images through the VGG network in batches. Step4: Building the Classifier Step5: ...
9,073
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame.read_csv('Philadelphia_Crime_Rate_noNA.csv/') sales graphlab.canvas.set_target('ipynb') sales.show(view="Scatter Plot", x="CrimeRate", y="HousePrice") crime_model = graphlab.linear_regression.create(sales, target='HousePrice', features=['CrimeRat...
<SYSTEM_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 some house value vs. crime rate data Step2: Exploring the data Step3: Fit the regression model using crime as the feature Step4: Let's s...
9,074
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import math def velocity(radius, model='galaxy'): describe the streaming velocity as function of radius in or around an object such as a star or a galaxy. We usually define the velocity to be 1 at a radius of ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Initialize the data Step3: Plotting the Rotation Curve Step4: This curve of velocity as function of radius is called a Rotation Curve, and ext...
9,075
<ASSISTANT_TASK:> Python Code: from tensorflow.python.client import device_lib print(device_lib.list_local_devices()) import tensorflow as tf # Creates a graph. a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a') b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b') c = tf.matmul(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Part 02 -- Manually specifying devices for running Tensorflow code Step2: Setting up Tensorflow to run on CPU Step3: Setting up Tensorflow to ...
9,076
<ASSISTANT_TASK:> Python Code: database_path = os.path.join('..', 'data', 'Ana', 'database', 'Garmin-Ana-180226-1.csv') print(os.path.abspath(database_path)) data = pd.read_csv(database_path) data.columns = [s.replace('_', ' ') for s in data.columns] data = data.set_index('file name') data.head() data.shape data.groupb...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Filter the data Step2: Scale and encode the data Step3: Split the data Step4: Train the model Step5: Test the model
9,077
<ASSISTANT_TASK:> Python Code: import pandas as pd invocations = pd.read_csv("datasets/test_code_invocations.csv", sep=";") invocations.head() invocation_matrix = invocations.pivot_table( index=['test_type', 'test_method'], columns=['prod_type', 'prod_method'], values='invocations', fill_value=0 ) # 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: What we've got here are all names of our test types (test_type) and production types (prod_type) as well as the signatures of the test methods (...
9,078
<ASSISTANT_TASK:> Python Code: from sklearn.tree import DecisionTreeClassifier as dtc X = [[0, 0], [1, 1]] Y = [0, 1] clf = dtc() clf = clf.fit(X, Y) clf.predict([[2., 2.]]) clf.predict_proba([[2., 2.]]) from sklearn.datasets import load_iris from sklearn import tree iris = load_iris() print(iris.DESCR) print(iris.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: After being fitted, the model can then be used to predict the class of samples Step2: Alternatively, the probability of each class can be predi...
9,079
<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 reading...
<SYSTEM_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 BigQuery Query To View Recipe Parameters Step3: 4. Execute BigQuery Query To View
9,080
<ASSISTANT_TASK:> Python Code: strat_train_set_copy = strat_train_set.copy() housing.plot(kind="scatter", x='longitude', y='latitude') housing.plot(kind="scatter", x='longitude', y='latitude', alpha=0.1) strat_train_set_copy.plot(kind='scatter', x='longitude', y='latitude', alpha=0.4, s=strat_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Experimenting with Attribute Combinations Step2: 2.5 Prepare the Data for Machine Learning Algorithms Step3: Handling Text and Categorical Att...
9,081
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import datetime from matplotlib import pyplot as plt import seaborn as sns from sklearn.preprocessing import MinMaxScaler df = pd.read_csv('data/pm25.csv') print(df.shape) df.head() df.isnull().sum()*100/df.shape[0] df.dropna(subset=['pm2.5'], axis=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: Step2: Note Step3: Note
9,082
<ASSISTANT_TASK:> Python Code: import scipy import numpy as np a = np.array([[26, 3, 0], [3, 195, 1], [0, 1, 17]]) a = 1-np.sign(a) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
9,083
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division %matplotlib inline import matplotlib import numpy as np import pandas as pd import matplotlib.pyplot as plt # use matplotlib style sheet plt.style.use('ggplot') # import the t-distribution from scipy.stats from scipy.stats import t y = np.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: CI for continuous data, Pg 18 Step2: Numpy uses a denominator of N in the standard deviation calculation by Step3: CI for proportions, Pg 18 S...
9,084
<ASSISTANT_TASK:> Python Code: import cv2 import matplotlib.pyplot as plt %matplotlib inline # TODO: Feel free to try out your own images here by changing img_path # to a file path to another image on your computer! img_path = 'data/udacity_sdc.png' # load color image bgr_img = cv2.imread(img_path) # convert to graysc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Define and visualize the filters Step2: Define a convolutional layer Step3: Visualize the output of each filter Step4: Let's look at the outp...
9,085
<ASSISTANT_TASK:> Python Code: labVersion = 'cs190.1x-lab3-1.0.4' print labVersion # load testing library from test_helper import Test import os.path baseDir = os.path.join('mnt', 'spark-mooc') inputPath = os.path.join('cs190', 'millionsong.txt') fileName = os.path.join(baseDir, inputPath) numPartitions = 2 rawData = ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: WARNING Step3: (1b) Using LabeledPoint Step5: Visualization 1 Step6: (1c) Find the range Step7: (1d) Shift labels Step8: Visualization 2...
9,086
<ASSISTANT_TASK:> Python Code: import sys import math import numpy as np import pandas as pd import scipy.optimize as so import scipy.integrate as si import matplotlib.pyplot as plt import nest %matplotlib inline plt.rcParams['figure.figsize'] = (12, 3) def Vpass(t, V0, gNaL, ENa, gKL, EK, taum, I=0): tau_eff = ta...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Neuron Model Step2: Agreement is excellent. Step3: Agreement is as good as possible Step5: ISIs are as predicted Step6: I_h channel Step7: ...
9,087
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.2,<2.3" %matplotlib inline import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() b['ecc'] = 0.2 b['dperdt'] = 2.0 * u.deg/u.d b.add_dataset('lc', times=np.linspace(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: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details. Step2: In order for apsidal moti...
9,088
<ASSISTANT_TASK:> Python Code: %pylab inline %matplotlib inline import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') # import all shogun classes from shogun import * import shogun as sg #number of data points. n=100 #generate a random 2d line(y1 = mx1 + c) m = random.randint(1,10) c = random.randint...
<SYSTEM_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 Formal Background (Skip if you just want code examples) Step2: Step 2 Step3: Step 3 Step4: Step 5 Step5: In the above figure, the blue ...
9,089
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np, matplotlib.pyplot as plt, matplotlib.gridspec as gridspec from mpl_toolkits.basemap import Basemap from ipywidgets import interact, interactive, fixed import ipywidgets as widgets [ra, dec, z], [ra_isol, dec_isol, z_isol], [ra_pair, dec_pair, z_pair...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Run the following code to load the catalogues of galaxies that will be represented. In this case we represent the LSS by all the galaxies in the...
9,090
<ASSISTANT_TASK:> Python Code: %%cython cpdef noop(): pass %load_ext Cython %%cython cimport numpy cpdef cysum(numpy.ndarray[double] A): Compute the sum of an array cdef double a=0 for i in range(A.shape[0]): a += A[i] return a def pysum(A): Compute the sum of an array a = 0 for ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Customizing IPython - Extensions Step3: Let's see what Cython's load_ipython_extension function looks like Step4: Our own extension Step5: %i...
9,091
<ASSISTANT_TASK:> Python Code: import numpy as np d = 5e-9 # particle radius in meters eta = 1.0e-3 # viscosity of water in SI units (Pascal-seconds) at 293 K kB = 1.38e-23 # Boltzmann constant T = 293 # Temperature in degrees Kelvin D = kB*T/(3*np.pi*eta*d) # [m^2 / s] D Du = D*(1e6)**2/(1e3) # [u...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Or expressing $D$ in $\textrm{nm}^2 /\mu s$ Step2: We can also estimate $D$ experimentally from the knowledge of the PSF and the diffusion time...
9,092
<ASSISTANT_TASK:> Python Code: %%capture %matplotlib inline import numpy as np import sympy as sp import matplotlib.pyplot as plt # To get equations the look like, well, equations, use the following. from sympy.interactive import printing printing.init_printing(use_latex=True) from IPython.display import display # Tool...
<SYSTEM_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 member of the Lorentz group that reverses time is remarkably simple Step2: Create a 4-vector. Step3: Do the time reversal a bunch of times...
9,093
<ASSISTANT_TASK:> Python Code: # The Python Spark (pyspark) libraries include functions designed to be run on columns of data # stored in Spark data frames. They need to be imported in order to use them. Here we # are going to use from pyspark.sql.functions import year # The matplotlib package is used for graphing. 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: Loading the data set Step2: Examining the data Step3: Next we can look at the first row of data. The (1) after head tells Python how many rows...
9,094
<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: Step1: ユニバーサルセンテンスエンコーダー Step2: Tensorflow のインストールに関する詳細は、https Step3: セマンティックテキストの類似性タスクの例 Step4: 類似性の視覚化 Step5: 評価 Step7: 文章埋め込みの評価
9,095
<ASSISTANT_TASK:> Python Code: import os import tensorflow.compat.v1 as tf import pprint assert 'COLAB_TPU_ADDR' in os.environ, 'Did you forget to switch to TPU?' tpu_address = 'grpc://' + os.environ['COLAB_TPU_ADDR'] with tf.Session(tpu_address) as sess: devices = sess.list_devices() pprint.pprint(devices) device_is...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Authentication Step2: Check imports Step3: Training ESRGAN Step4: Load Training Dataset Step5: Visualize the dataset Step6: Network Archite...
9,096
<ASSISTANT_TASK:> Python Code: purity_coll = client['run']['purity'] purity_coll.count() d = purity_coll.find_one() for d in purity_coll.find(sort=(('calculation_time', -1), )): print(str(d['calculation_time']), parse_expr(d['function'])) import numpy as np data = np.array([ 4, 0.9948, # Julien 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: Try to add drift velocity correction function Step2: Systematic error on drift velocity estimates is around 0.2%, see Step3: Insert in runs d...
9,097
<ASSISTANT_TASK:> Python Code: # Add tools # NOTE: This should only be needed if you do not store the notebook on the lxmls root import sys sys.path.append('../../') from pdb import set_trace # Location of Part-of-Speech WSJ Data WSJ_TRAIN = "../../data/train-02-21.conll" WSJ_TEST = "../../data/test-23.conll" WSJ_DEV =...
<SYSTEM_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 configuration Step2: Exercise 6.2 Step3: The following example should help you understand about matrix multiplications and passing value...
9,098
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst !pip install --user google-cloud-bigquery==1.25.0 !pip install --user apache-beam[interactive]==2.24.0 import apache_beam as beam print(beam.__version__) import tensorflow as tf print("TensorFlow version: ",tf.version.VE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Kindly ignore the deprecation warnings and incompatibility errors related to google-cloud-storage. Step2: NOTE Step3: You may receive a UserWa...
9,099
<ASSISTANT_TASK:> Python Code: from EQTransformer.utils.plot import plot_data_chart plot_data_chart('preproc/time_tracks.pkl', time_interval=10) from EQTransformer.utils.plot import plot_detections, plot_helicorder plot_helicorder(input_mseed='downloads_mseeds/CA06/GS.CA06.00.HHZ__20190901T000000Z__20190902T000000Z.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: Check your current directory for 'data_chart.png' Step2: Now you can mark those events that you have detected in your helicorder plot to check ...