Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
11,400 | <ASSISTANT_TASK:>
Python Code:
from pyspark import SparkContext
sc = SparkContext('local','example')
from pyspark.mllib.linalg import Vectors
x = Vectors.dense([1,2,3,4])
x[0]
x = [Vectors.dense([1,2,3,4,5]), Vectors.dense([6,7,8,9,10])]
xrdd = sc.parallelize(x, 2)
xrdd.glom().collect()
from pyspark.mllib.regression ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example Labeled Points
Step2: Example Creating a Word-count RDD
Step3: Confusion matrix
Step4: Decision Tree
|
11,401 | <ASSISTANT_TASK:>
Python Code:
from ndreg import *
sparseImg = sitk.Cast(imgRead("../dat/sparse/sparse.img"), sitk.sitkFloat32)
imgShow(sparseImg)
denseImg = sitk.Cast(imgRead("../dat/sparse/dense.img"), sitk.sitkFloat32)
imgShow(denseImg)
imgShow(sparseImg - denseImg, cmap=plt.cm.jet)
alpha=0.1
epsilon = None
(fie... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First we read our images. This one is a sparse image
Step2: This image is a dense image
Step3: Here's the difference between the 2 images befo... |
11,402 | <ASSISTANT_TASK:>
Python Code:
def runningMeanFast(x, N):
return np.convolve(x, np.ones((N,))/N, mode='valid')
def powerme(x1,x2,n):
X = []
for m in range(n+1):
for i in range(m+1):
X.append(np.multiply(np.power(x1,i),np.power(x2,(m-i))))
return np.hstack(X)
def safeSigmoid(x, eps=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: Regularyzacja
Step2: Różne twarze (nie)dopasowania
Step3: Regresja liniowa (wielomianowa)
Step4: Regresja za pomocą k-NN
Step5: Regresja
Ste... |
11,403 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('data/human_body_temperature.csv')
df.info()
df.head()
df['temperature'].hist()
m=df['temperature'].mean()
m
from scipy.stats import t, norm
from math import sqrt
patients=df.shape[0]
n=patients-1
patients
SE=df['temperature'].std()/sqrt(n)
SE
t.cd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question 1
Step2: No, this sample isn't normal, it is definitely skewed. However "this is a condition for the CLT... to apply" is just wrong. T... |
11,404 | <ASSISTANT_TASK:>
Python Code:
j = {'ants_dwi_to_t1': u'ANTS 3 -m CC[ %s, %s, 1, 4] -r Gauss[0,3] -t Elast[1.5] -i 30x20x10 -o %s',
'warp_md_to_t1': u'WarpImageMultiTransform 3 %s %s -R %s %s %s'}
json.dump(j, open('/tmp/templates.json','w'))
cmd = './thesaurus.py -n --name ants_dwi_to_t1 /tmp/templates.json targ... | <SYSTEM_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 $\%s$ represent parameters (such as filenames) that will be provided later.
Step2: The $-n$ option is just a safety lock to display the com... |
11,405 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import Image
%matplotlib inline
# The resulted buildings:
Image("./data/buildings_distribution.png")
Image('./data/train_process.png')
Image('./data/feature_f_scores.png')
Image('./data/bst_tre... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Objective
Step2: Features
Step3: This model resulted in an AUC score of 0.858 on test data. Feature importances are shown below
Step4: Locati... |
11,406 | <ASSISTANT_TASK:>
Python Code:
import autofig
import numpy as np
import matplotlib.pyplot as plt
#autofig.inline()
n = 75
x = np.linspace(0, 4*np.pi, n)
y1 = np.sin(x)
y2 = -np.sin(x)
z1 = np.cos(x)
z2 = -2*np.cos(x)
yerr = np.random.rand(n)*0.3
zerr = np.random.rand(n)
autofig.reset()
plt.gcf().set_size_inches(14,8)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plotting in Autofig
Step2: Replicating in Matplotlib
Step3: We'll replicated everything except highlight and uncover (which require interpolat... |
11,407 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import seaborn as sns
import numpy as np
def find_peaks(a):
Find the indices of the local maxima in a sequence.
b=[]
count=0
while count<(len(a)): # while count (our index indicator) is less than 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:
Step2: Peak finding
Step3: Here is a string with the first 10000 digits of $\pi$ (after the decimal). Write code to perform the following
|
11,408 | <ASSISTANT_TASK:>
Python Code:
T, N, K = 5, 10, 8
x = np.linspace(0, 1, N)
t = np.linspace(0, T, K)
h, tau = 1/(N - 1), T/(K - 1)
u0 = 1*x
y1 = np.zeros_like(t)
y2 = 1/2*t + 1
xv, tv = np.meshgrid(x, t, sparse=True)
f = xv**2 / 2 - tv
u_ans = xv**2 / 2 * tv + xv
fig = plt.figure(figsize=(15, 10))
ax = fig.gca(projectio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Explicit scheme
Step2: Implicit scheme
Step3: Stability of solutions
|
11,409 | <ASSISTANT_TASK:>
Python Code:
import json
import os
import shutil
import subprocess
if not os.path.isfile('./data/hg38.ml.fa'):
print('downloading hg38.ml.fa')
subprocess.call('curl -o ./data/hg38.ml.fa.gz https://storage.googleapis.com/basenji_barnyard/hg38.ml.fa.gz', shell=True)
subprocess.call('gunzip .... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download a few Micro-C datasets, processed using distiller (https
Step2: Write out these cooler files and labels to a samples table.
Step3: Ne... |
11,410 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import psycopg2
import getpass
import pdvega
# for configuring connection
from configobj import ConfigObj
import os
%matplotlib inline
# Create a database connection using settings from config 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:
Step2: Summarize data available in each table
|
11,411 | <ASSISTANT_TASK:>
Python Code:
from pathlib import Path
import os
import csv
import pandas as pd
import yaml
import numpy as np
import statistics
from operator import itemgetter
def get_mixtures(row):
total = row['A'] + row['T'] + row['C'] + row['G']
thresh = 0.05 * total
alleles = {
'qpos': int(row... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get the number of samples N
Step2: Get the total number of nucleotides across all samples
Step3: Get a dataframe of the mismatches only
Step4:... |
11,412 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import sys
print(sys.version)
import sys
sys.path.append("../python")
import setup_dataset
data, labels = setup_dataset.setup_simple_iterables("with_dc")
X_train, X_test, y_train, y_test = setup_dataset.slice_data(data, labels)
# Setting up various compl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Placeholder for small graph
Step2: Saving the models to disk
Step3: The same can be done without additional dependencies using joblib, which i... |
11,413 | <ASSISTANT_TASK:>
Python Code:
R = 40.
H = 60
x_w = 30.
y_w = 90.
Rw = 20
seed = 1
def f(x,y):
np.random.seed(seed)
return - 3.*np.exp( -((x-x_w)**2. + (y-y_w)**2.)/(Rw**2.) ) + \
- 3.*np.exp( -((x-30)**2. + (y-40)**2.)/(20**2.) ) + \
- 1.5*np.exp( -((x-np.random.uniform(-60,60))**2. + (y-... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Monte-Carlo integration
Step2: Cartessian Gausss-Legendre quadrature
Step3: integrating before in y
Step5: Radial Gauss-Leg
|
11,414 | <ASSISTANT_TASK:>
Python Code::
# define the captioning model
def define_model(vocab_size, max_length):
# feature extractor model
inputs1 = Input(shape=(4096,))
fe1 = Dropout(0.5)(inputs1)
fe2 = Dense(256, activation='relu')(fe1)
# sequence model
inputs2 = Input(shape=(max_length,))
se1 = Embedding(vocab_size, 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:
|
11,415 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import openpathsampling as paths
import numpy as np
import math
# the openpathsampling OpenMM engine
import openpathsampling.engines.openmm as eng
old_store = paths.AnalysisStorage("ala_mstis_bootstrap.nc")
print "PathMovers:", len(old_store.pathmovers)
print "Engines... | <SYSTEM_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 things from storage
Step2: A lot of information can be recovered from the old storage, and so we don't have the recreate it. However, w... |
11,416 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo("mrSmaCo29U4")
YouTubeVideo("xIq8Sg59UdY")
# NOTE: THIS CODE IS NOT TO BE RUN, AS IT HAS NO DATA! IT IS THE SHELL FOR THE CODE, WHICH WILL BE RUN IN PROBLEM 3.
# GATHERING DATA FROM A WEB ARTICLE & EXTRACTING FEATURES
# import re
# i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Two videos on storytelling
Step2: Problem 3
Step3: Download data, unzip, and save .csv
Step4: Read .csv file into Pandas Data Frame & save i... |
11,417 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pylab
from __future__ import division
pylab.rcParams['figure.figsize'] = (16, 10)
import scipy.io as sio
import numpy as np
import math
import matplotlib.pyplot as plt
data = sio.loadmat('../data/programming/hw1progde.mat')
test_data = data['x_te']
training_data ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problem 5.1
Step2: Gaussian
Step3: Epanechnikov kernel
Step4: Histogram
Step5: Problem 2
Step6: Problem 3
Step7: So the root is on Sky!
St... |
11,418 | <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: 接下来,使用 Keras 与 Pandas 下载并解析鸢尾花数据集。注意为训练和测试保留不同的数据集。
Step4: 通过检查数据您可以发现有四列浮点型特征和一列 int32 型标签。
Step5: 对于每个数据... |
11,419 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from utils import *
import random
from random import shuffle
data = open('dinos.txt', 'r').read()
data= data.lower()
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
print('There are %d total characters and %d unique characters in your data.' % (da... | <SYSTEM_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 - Problem Statement
Step2: The characters are a-z (26 characters) plus the "\n" (or newline character), which in this assignment plays a role... |
11,420 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
# we can import the CSV data as a numpy rec array
from matplotlib.pylab import csv2rec
trends = csv2rec('trends.csv')
<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: 1. Use the "trends.csv" file and csv2rec() to import the data and reproduce this plot
|
11,421 | <ASSISTANT_TASK:>
Python Code:
#|export
def module(*flds, **defaults):
"Decorator to create an `nn.Module` using `f` as `forward` method"
pa = [inspect.Parameter(o, inspect.Parameter.POSITIONAL_OR_KEYWORD) for o in flds]
pb = [inspect.Parameter(k, inspect.Parameter.POSITIONAL_OR_KEYWORD, default=v)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pooling layers
Step2: If the input is bs x nf x h x h, the output will be bs x 2*nf x 1 x 1 if no size is passed or bs x 2*nf x size x size
Ste... |
11,422 | <ASSISTANT_TASK:>
Python Code:
from sklearn.preprocessing import StandardScaler
X = np.array([[3,6], [6,7]])
#스케일러 객체 생성
scaler = StandardScaler()
#분포 추정
scaler.fit(X)
#스케일링
X2 = scaler.transform(X)
X
X2
X = np.array([[0, 2], [1, 1]])
X
from sklearn.preprocessing import OneHotEncoder
OneHotEncoder().fit_transform(X).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: 문제4
Step2: 문제6
|
11,423 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import scipy.io
import scipy.misc
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from PIL import Image
from nst_utils import *
import numpy as np
import tensorflow as tf
%matplotlib inline
model = load_vgg_model("pretrained-model/imagenet-vgg-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: 1 - Problem Statement
Step2: The model is stored in a python dictionary where each variable name is the key and the corresponding value is a te... |
11,424 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
import h5py
import matplotlib.pyplot as plt
import scipy
from PIL import Image
from scipy import ndimage
import tensorflow as tf
from tensorflow.python.framework import ops
from cnn_utils import *
%matplotlib inline
np.random.seed(1)
# Loading the data (sig... | <SYSTEM_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 next cell to load the "SIGNS" dataset you are going to use.
Step2: As a reminder, the SIGNS dataset is a collection of 6 signs represen... |
11,425 | <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.add_dataset('lc', times=phoebe.linspace(0,1,101))
b.run_compute(irrad_method='none',... | <SYSTEM_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: Model without Spots
Step3... |
11,426 | <ASSISTANT_TASK:>
Python Code:
linear = linear_model.LinearModel(features, labels, terms)
linear.inference()
#PYTEST_VALIDATE_IGNORE_OUTPUT
linear.plot_direction_accuracy()
#PYTEST_VALIDATE_IGNORE_OUTPUT
linear.plot_profit()
<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: accuracy
Step2: profit
|
11,427 | <ASSISTANT_TASK:>
Python Code:
import rebound
import numpy as np
sim = rebound.Simulation()
sim.add(m=1., hash=0)
for i in range(1,10):
sim.add(a=i, hash=i)
sim.move_to_com()
print("Particle hashes:{0}".format([sim.particles[i].hash for i in range(sim.N)]))
sim.add(a=10, hash="Saturn")
print("Particle hashes:{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: Let us add one more particle, this time with a custom name
Step2: Now let us run perform a short integration to isolate the particles that inte... |
11,428 | <ASSISTANT_TASK:>
Python Code:
# Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
from mne import read_evokeds
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
fname = data_path + '/MEG/sample/sample_audvis-ave.fif'
# Reading
condition = 'Left... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Show result as a butterfly plot
|
11,429 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-1', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
11,430 | <ASSISTANT_TASK:>
Python Code:
# A bit of setup
import numpy as np
import matplotlib.pyplot as plt
from cs231n.classifiers.neural_net import TwoLayerNet
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementing a Neural Network
Step2: We will use the class TwoLayerNet in the file cs231n/classifiers/neural_net.py to represent instances of o... |
11,431 | <ASSISTANT_TASK:>
Python Code:
from xml.etree import ElementTree as ET
document_tree = ET.parse( 'data/mondial_database_less.xml' )
# print names of all countries
for child in document_tree.getroot():
print (child.find('name').text)
# print names of all countries and their cities
for element in document_tree.iterf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: XML example
Step2: XML exercise
Step3: 10 countries with the lowest infant mortality rates
Step4: 10 cities with the largest population
Step5... |
11,432 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import glob
import tabulate
import pprint
import click
import numpy as np
import pandas as pd
from ray.tune.commands import *
from nupi... | <SYSTEM_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 check data
Step2: ## Analysis
|
11,433 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
from __future__ import division
import nltk
oracion1 = 'This is the lost dog I found at the park'.split()
oracion2 = 'The progress of the humankind as I progress'.split()
print(nltk.pos_tag(oracion1))
print(nltk.pos_tag(oracion2))
oracion3 = 'Green ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Como primer ejemplo, podemos utilizar la función nltk.pos_tag para etiquetar morfológicamente una oración en inglés, siempre que la especifiquem... |
11,434 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.version
import gdal
import h5py
import numpy as np
from math import floor
import os
import matplotlib.pyplot as plt
def plot_band_array(band_array,image_extent,title,cmap_title,colormap,colormap_limits):
plt.imshow(diff_dsm_array,extent=image_extent)
cbar = plt.col... | <SYSTEM_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 functions
Step2: This next piece of code just helps identify where the script portion of our code starts. It is not essential to the cod... |
11,435 | <ASSISTANT_TASK:>
Python Code:
report_file = '/Users/bking/IdeaProjects/LanguageModelRNN/experiment_results/encdec_noing10_200_512_04drbef/encdec_noing10_200_512_04drbef.json'
log_file = '/Users/bking/IdeaProjects/LanguageModelRNN/experiment_results/encdec_noing10_200_512_04drbef/encdec_noing10_200_512_04drbef_logs.jso... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Perplexity on Each Dataset
Step2: Loss vs. Epoch
Step3: Perplexity vs. Epoch
Step4: Generations
Step5: BLEU Analysis
Step6: N-pairs BLEU An... |
11,436 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import nibabel as nb
from scipy import ndimage
from matplotlib.colors import LinearSegmentedColormap
from m2g.utils.qa_utils import pad_im
from m2g.stats.qa_fast import qa_fast_png
def qa_fast_png(csf, gm, wm, outdir):
FAST (FMR... | <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: qa_fast_png
Step3: Set the input data path
Step4: Call function to generate quality analysis picture
Step5: Potential Issues
Step6: the last... |
11,437 | <ASSISTANT_TASK:>
Python Code:
print "Hello World"
#this is a comment
print 'this is code' #this is also a comment
a = 2
a = 2
b = 3
print a + b
print type(12)
print type(12.1)
print type(True)
print type('blueberries')
print type(blueberries)
blueberries = 5
print type(blueberries)
print 2 + 2
print 'First ' +... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This is a simple one-line piece of code that prints a statement. If you run the cell above, you will see "Hello World" displayed directly below ... |
11,438 | <ASSISTANT_TASK:>
Python Code:
!pip install -q sciunit
import sciunit
from sciunit.models.examples import ConstModel # One of many dummy models included for illustration.
const_model_37 = ConstModel(37, name="Constant Model 37")
from sciunit.capabilities import ProducesNumber
from sciunit.scores import ZScore # One... | <SYSTEM_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 chapter we will use the same toy model in Chapter 1 but write a more interesting test with additional features included in SciUnit.
Step... |
11,439 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bcc', 'sandbox-2', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
11,440 | <ASSISTANT_TASK:>
Python Code:
def fib(n ) :
if(n <= 1 ) :
return n
return fib(n - 1 ) + fib(n - 2 )
n = 9
print(fib(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:
|
11,441 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import sys
import datetime
import warnings
import numpy as np
import matplotlib.pyplot as plt
import pandas
import seaborn
seaborn.set(style='ticks', context='paper')
import wqio
import pybmpdb
import pynsqd
import pycvc
min_precip = 1.9999
palette = seaborn.c... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Hydrologic Relationships
Step2: ED-1
Step3: LV-2
Step4: LV-4
Step5: Water quality loading relationship
Step6: Load CVC Database
Step7: Def... |
11,442 | <ASSISTANT_TASK:>
Python Code:
%%bash
head ../../data/raw/palm_reference_sequences.fasta
%%bash
source activate secapr_env
secapr find_target_contigs -h
import pandas as pd
table = pd.read_csv('../../data/processed/target_contigs/match_table.txt', delimiter = '\t',index_col=0)
table.head()
%%bash
cat ../../data/proc... | <SYSTEM_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 and extract all target contigs
Step2: Note that in this step SECAPR will index all your locus names stored in the reference file, so in al... |
11,443 | <ASSISTANT_TASK:>
Python Code:
import pysal as ps
import numpy as np
import networkx as nx
import shapefile as shp
import gurobipy as gbp
import cplex as cp
import datetime as dt
import time
from collections import OrderedDict
import IPython.display as IPd
%pylab inline
from mpl_toolkits.basemap import Basemap
ntw = 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: <font size='7' face='Times New Roman'><b>1. <u>Data preparation and creation</u></b></font>
Step2: <font size='5' face='Times New Roman'><b>1.2... |
11,444 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-1', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
11,445 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from matplotlib import pyplot as plt
import numpy.random as ra
%matplotlib inline
spectrum = [[1, 2, 3, 4, 5, 6],[2000, 4040, 6500, 6000, 4020, 2070]]
energies = np.array(spectrum[0])
fluxes = np.array(spectrum[1])
spectrum
prob = fluxes/float(sum(fluxes))
cum_prob = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Below is a spectrum which follows an almost bell-curve type distribution (anyway, the specific type of distribution is not important here).
Step... |
11,446 | <ASSISTANT_TASK:>
Python Code:
from pynq import Overlay
Overlay("base.bit").download()
from pynq.iop import Pmod_TC1
from pynq.iop import PMODB
# TC1 sensor is on PMODB
my_tc1 = Pmod_TC1(PMODB)
r = my_tc1.read()
print('Raw Register Value: %08x hex' % r)
print('Ref Junction Temp: %.4f' % my_tc1.reg_to_ref(r))
print('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: 2. Starting logging temperature once every second
Step2: 3. Modifying the temperture
Step3: 4. Plot values over time
|
11,447 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from io import StringIO
print('---欠測値を含むデータ---')
csv_data = '''A,B,C,D
1.0,2.0,3.0,4.0
5.0,6.0,,8.0
10.0,11.0,12.0,'''
df = pd.read_csv(StringIO(csv_data))
print(df)
print('---欠測値のカウント---')
print(df.isnull().sum())
print('---欠測値を含む行を削除---')
print(df.dropna())
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: 欠測値を持つサンプル、特徴量を取り除く
Step2: 欠測値を補完する
Step3: カテゴリデータの処理
Step4: 順序特徴量のマッピング
Step5: クラスラベルのエンコーディング
Step6: 名義特徴量でのone-hotエンコーディング
Step7: そこで、名... |
11,448 | <ASSISTANT_TASK:>
Python Code:
from os.path import basename, exists
def download(url):
filename = basename(url)
if not exists(filename):
from urllib.request import urlretrieve
local, _ = urlretrieve(url, filename)
print("Downloaded " + local)
download("https://github.com/AllenDowney/Thin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Examples from Chapter 1
Step2: Print the column names.
Step3: Select a single column name.
Step4: Select a column and check what type it is.
... |
11,449 | <ASSISTANT_TASK:>
Python Code:
import random
def sample_experiment():
### BEGIN SOLUTION
Returns true if a random number is less than 0
return random.random() < 0
number_of_experiments = 1000
sum(
sample_experiment() for repetition in range(number_of_experiments)
) / number_of_experiments
### ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Computing for Mathematics - 2020/2021 individual coursework
Step3: b. $1/2$
Step5: c. $3/4$
Step7: d. $1$
Step8: Question 2
Step9: b. Creat... |
11,450 | <ASSISTANT_TASK:>
Python Code:
class Directions:
NORTH = 'North'
SOUTH = 'South'
EAST = 'East'
WEST = 'West'
STOP = 'Stop'
def P_1(eps, E_N, E_S):
'''
Calculates: P(X=x|E_{N}=e_{N},E_{S}=e_{S})
Arguments: E_N, E_S \in {True,False}
0 <= eps <= 1 (epsilon)
'''
pd = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: a. Bayes' net for instant perception and position.
Step2: ii. $P(E_{E}=e_{E}|E_{N}=e_{N},E_{S}=E_{S})$
Step3: iii. $P(S)$, where $S\subseteq{e... |
11,451 | <ASSISTANT_TASK:>
Python Code:
##
# The 'import' statement imports external libraries for use in the interactive session.
# ... and 'import <library> as <nickname>' makes a shorter name for convenience.
#
# The '%matplotlib inline' statement allows inline plots here. (see try.jupyter.org)
#
import datetime
import matpl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: OK, Jupyter
Step2: Pandas I/O
Step3: Data description
Step4: Takeaway
Step5: Or we can look at a particular team / teams
Step6: Interpretat... |
11,452 | <ASSISTANT_TASK:>
Python Code:
# set up Python environment: numpy for numerical routines, and matplotlib for plotting
import numpy as np
import matplotlib.pyplot as plt
# display plots in this notebook
%matplotlib inline
# set display defaults
plt.rcParams['figure.figsize'] = (10, 10) # large images
plt.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: Load caffe.
Step2: If needed, download the reference model ("CaffeNet", a variant of AlexNet).
Step3: 2. Load net and set up input preprocessi... |
11,453 | <ASSISTANT_TASK:>
Python Code:
import os as OS
import arcpy as ARCPY
import SSDataObject as SSDO
import SSPanelObject as SSPO
import SSPanel as PANEL
ARCPY.overwriteOutput = True
inputFC = r'../data/CA_Counties_Panel.shp'
outputCube = r'../data/CA_Panel.nc'
fullFC = OS.path.abspath(inputFC)
outputCube = OS.path.abspat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example
Step2: Open Panel Cube From NetCDF File for Analysis
Step3: Number of Locations and Time Periods
Step4: List Variables
Step5: View M... |
11,454 | <ASSISTANT_TASK:>
Python Code:
def check_if_last_char_is_a_letter(txt):
'''
Create a function that returns True if the last character
of a given string is an alphabetical character and is not
a part of a word, and False otherwise.
Note: "word" is a group of characters separated by space.
Example... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
11,455 | <ASSISTANT_TASK:>
Python Code:
! module use /g/data3/hh5/public/modules
! module load conda/analysis27
from ARCCSSive import CMIP5
from ARCCSSive.CMIP5.Model import Instance
from ARCCSSive.CMIP5.other_functions import unique
db=CMIP5.connect()
results=db.outputs(ensemble='r1i1p1',experiment='rcp45',mip='day')
results.... | <SYSTEM_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 start from a simple query and see how we can use different operators to refine it.
Step2: equals ( == )
Step3: not equals ( != )
S... |
11,456 | <ASSISTANT_TASK:>
Python Code:
def logistic(x):
'''
'''
return 1/(1+np.exp(-x))
def U_logistic(theta, Y, X, phi):
'''
'''
return - (Y.T @ X @ theta - np.sum(np.log(1+np.exp(X @ theta))) - 0.5 * phi * np.sum(theta**2))
def gradU_logistic(theta, Y, X, phi):
'''
'''
n = X.shape[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: Everything after here is the script that runs the simulation
Step2: Regression
Step3: HMC
Step4: HMC - Unscaled
Step5: HMC - Unscaled (no in... |
11,457 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import svm
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2
import matplotlib.mlab as mlab
import warnings
warnings.filterwarnings('ignore'... | <SYSTEM_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. APT All Combined Feature Statistics
Step2: 2.1 APT PE/COFF Statistics Graphs.
Step3: 3. APT Reduced Feature Set Statistics
Step4: 3. Virus... |
11,458 | <ASSISTANT_TASK:>
Python Code:
tpl_path = '../../pyfas/test/test_files/'
fname = '11_2022_BD.tpl'
tpl = fa.Tpl(tpl_path+fname)
tpl.filter_data('PT')
tpl.filter_data("'POSITION:' 'EXIT'")
pd.DataFrame(tpl.filter_data('PT'), index=("Trends",)).T
tpl.view_trends('PT')
tpl.view_trends('TM')
tpl.view_trends('PT')
# si... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Trend selection
Step2: or
Step3: The same outpout can be reported as a pandas dataframe
Step4: The view_trends method provides the same info ... |
11,459 | <ASSISTANT_TASK:>
Python Code:
deck = [rank + suit for rank in '23456789TJQKA' for suit in 'SHDC']
print(deck)
import random
def deal(numhands=1, n=5, deck=[r+s for r in '23456789TJQKA' for s in 'SHDC']):
takes in numhands, and optionaly a deck, shuffles and returns a list of numhands hands
assert numhands*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:
Step2: Now to shuffle and deal cards from the deck
|
11,460 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2021 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: Transfer Learning for the Audio Domain with Model Maker
Step2: Import TensorFlow, Model Maker and other libraries
Step3: The Birds dataset
Ste... |
11,461 | <ASSISTANT_TASK:>
Python Code:
# <!-- collapse=True -->
# importando modulos necesarios
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
import seaborn as sns
np.random.seed(2016) # replicar random
# parametros esteticos de seaborn
sns.set_palette("deep", desat=.6)
sns.se... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Función de Masa de Probabilidad
Step2: Función de Distribución Acumulada
Step3: Función de Densidad de Probabilidad
Step4: Distribuciones
Ste... |
11,462 | <ASSISTANT_TASK:>
Python Code:
hightemp = "".join(map(str, [i.replace('\t', ' ') for i in open('hightemp.txt', 'r')]))
print(hightemp)
col1 = open('col1.txt', 'w')
col2 = open('col2.txt', 'w')
hightemp = [i.replace('\t', ' ').split() for i in open('hightemp.txt', 'r')]
col1.write("\n".join(map(str, [i[0] for i in high... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 12. 1列目をcol1.txtに,2列目をcol2.txtに保存
Step2: 13. col1.txtとcol2.txtをマージ
Step3: 14. 先頭からN行を出力
Step4: 15. 末尾のN行を出力
Step5: 16. ファイルをN分割する
Step6: 17... |
11,463 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
def soliton(x, t, c, a):
Return phi(x, t) for a soliton wave with constants c and a.
# YOUR CODE HERE
#... | <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: Using interact for animation with data
Step3: To create an animation of a soliton propagating in time, we are going to precompute the soliton d... |
11,464 | <ASSISTANT_TASK:>
Python Code:
# Author: Alan Leggitt <alan.leggitt@ucsf.edu>
#
# License: BSD (3-clause)
import mne
from mne import setup_source_space, setup_volume_source_space
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
subjects_dir = data_path + '/subjects'
subject = 'sample'
aseg_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup the source spaces
Step2: Plot the positions of each source space
Step3: Compare volume source locations to segmentation file in freeview... |
11,465 | <ASSISTANT_TASK:>
Python Code:
import yaml
import time
import operator
import string
import re
import csv
import random
import nltk.tokenize
from sklearn.feature_extraction import text
import twitter
import scipy
## self-correlation
a = [i for i in range(20)]
scipy.stats.kendalltau(a,a).correlation
## remember that 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: Review Part I
Step2: Finally
Step7: Apply it!
Step8: Do better n-gram extraction
Step9: Simply by looking at this list, we can see other ave... |
11,466 | <ASSISTANT_TASK:>
Python Code:
year = 2015
month = 7
%matplotlib inline
import glob
import os
import netCDF4
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from matplotlib import colors
basedir = "~/DataOceano/MyOcean/INSITU_GLO_NRT_OBSERVATIONS_013_030/monthly/" + str(yea... | <SYSTEM_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 directory where we store the data files
Step2: Simple plot
Step3: Loop on the files
Step4: We also counted how many files don't have the ... |
11,467 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-3', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contribut... | <SYSTEM_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... |
11,468 | <ASSISTANT_TASK:>
Python Code:
class KMeans:
k-means algo
def __init__(self, k):
self.k = k # number of clusters
self.means = None # means of clusters
def classify(self, input):
return the index of the cluster to closest to input
return min(range(self.k),
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: k - means
Step4: Choosing k
Step9: Hierarchical Clustering
|
11,469 | <ASSISTANT_TASK:>
Python Code:
imdb = pd.read_csv("C:\\Users\\Adam\\Google Drive\\School\\ComputerScience\\intro to data science\\rotten_needles\\data\\datasets\\movies_dataset.csv")
#imdb = imdb.dropna()
imdb = imdb.assign(rating10=(imdb['rating']*10))
imdb = imdb.assign(metascore10=(imdb['metascore']/10))
imdb = imd... | <SYSTEM_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 movie profit score column
Step2: Figure shows scatter of gross income against meta score and imdb rating
Step3: Figure shows distributi... |
11,470 | <ASSISTANT_TASK:>
Python Code:
report_files = ["/Users/bking/IdeaProjects/LanguageModelRNN/experiment_results/encdec_noing10_200_512_04dra/encdec_noing10_200_512_04dra.json", "/Users/bking/IdeaProjects/LanguageModelRNN/experiment_results/encdec_noing10_200_512_04drb/encdec_noing10_200_512_04drb.json", "/Users/bking/Ide... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Perplexity on Each Dataset
Step2: Loss vs. Epoch
Step3: Perplexity vs. Epoch
Step4: Generations
Step5: BLEU Analysis
Step6: N-pairs BLEU An... |
11,471 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os, sys
import numpy as np
import matplotlib.pyplot as plt
from eqcat.parsers.isf_catalogue_reader import ISFReader
import eqcat.catalogue_query_tools as cqt
# Read in the catalogue
parser = ISFReader("inputs/isc_test_catalogue_isf.txt")
catalogue1 = parser.read... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Constructing the Database
Step2: Using the Database
Step3: Apply Limiting Selections
Step4: By Polygon
Step5: By Magnitude
Step6: By Depth
... |
11,472 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'Time': ['2015-04-24 06:38:49', '2015-04-24 06:39:19', '2015-04-24 06:43:49', '2015-04-24 06:44:18',
'2015-04-24 06:44:48', '2015-04-24 06:45:18', '2015-04-24 06:47:48', '2015-04-24 06:48:18',
'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
11,473 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from matplotlib import pyplot as plt, cm
import skdemo
plt.rcParams['image.cmap'] = 'cubehelix'
plt.rcParams['image.interpolation'] = 'none'
image = np.array([[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The documentation for scikit-image's morphology module is
Step2: The central value of the structuring element represents the pixel being consid... |
11,474 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
%matplotlib inline
data = pd.read_csv('../../data/titanic_train.csv',
index_col='PassengerId')
data.head(5)
data.describe()
data[(data['Embarked'] == 'C') & (data.Fare > 200)].head()
data[(data['Embarked'] == 'C') &
(data[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Считаем данные из файла в память в виде объекта Pandas.DataFrame
Step2: Данные представлены в виде таблицы. Посмотрим на первые 5 строк
Step3: ... |
11,475 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import numpy as np
import mne
data_path = mne.datasets.opm.data_path()
subject = 'OPM_sample'
subjects_dir = op.join(data_path, 'subjects')
raw_fname = op.join(data_path, 'MEG', 'OPM', 'OPM_SEF_raw.fif')
bem_fname = op.join(subjects_dir, subject, 'bem',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepare data for localization
Step2: Examine our coordinate alignment for source localization and compute a
Step3: Perform dipole fitting
Step... |
11,476 | <ASSISTANT_TASK:>
Python Code:
# import the dataset
from quantopian.interactive.data.eventvestor import contract_win
# or if you want to import the free dataset, use:
# from quantopian.data.eventvestor import contract_win_free
# import data operations
from odo import odo
# import other libraries we will use
import 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: Let's go over the columns
Step2: Finally, suppose we want the above as a DataFrame
|
11,477 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
autoData = pd.read_csv('../datasets/Auto.csv', na_values='?')
autoData.shape
autoData.columns
autoData.head(5)
autoData.info()
autoData.isnull().values.any()
autoData[autoData.isnull().any(axis=1)]
autoData.dropna(axis=0, inplace=True) # Drop any row that has NaNs ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 397 examples of 9 features
Step2: We are interested in the mpg and the horsepower features.
Step3: There are NaNs. We remove those observation... |
11,478 | <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: <table class="tfo-notebook-buttons" align="left">
Step2: Isolated XEB
Step3: Set up Random Circuits
Step4: Set up a Sampler.
Step5: Take Dat... |
11,479 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
covariance, precision, adjacency = new_graph(15,.15,adj_type=adj_type,random_sign=True,seed=1)
covariance2, precision2, adjacency2 = new_graph(15,.2,adj_type=adj_type,random_sign=True, seed=1)
# Set up the matplotlib figure
f, (ax1, ax2, ax3) = plt.subplots(1,3,... | <SYSTEM_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='restart'></a>
Step2: Part II. Sparse Inverse Covariance via Penalized MLE
Step3: Model Selection
Step4: Part III. Compare Estimators
S... |
11,480 | <ASSISTANT_TASK:>
Python Code:
# A first function. Find the length of a list.
a_list = [1, 2, 3]
len(a_list)
len({"a": [1, 2, 3], "b": 4})
range(3)
# Experiment with the builtin function all
all([1, "first", 3.4])
any([False, False])
list(range(3))
fd = open("t.txt", "w")
fd.write("a line")
fd.close()
!ls -l
help(fd)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Builtin Functions
Step2: Notice that Python (in the newest versions, e.g. 3+) has an object type that is a range. This saves memory and speeds... |
11,481 | <ASSISTANT_TASK:>
Python Code:
from csp import *
%psource AC3
%psource revise
%psource AC3b
%psource partition
%psource dom_j_up
%psource sat_up
%psource AC4
sudoku = Sudoku(easy1)
sudoku.display(sudoku.infer_assignment())
%time _, checks = AC3(sudoku, arc_heuristic=no_arc_heuristic)
f'AC3 needs {checks} consisten... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Domain-Heuristics for Arc-Consistency Algorithms
Step2: At any stage in the process of making 2-variable CSP arc-consistent in AC3b
Step3: AC3... |
11,482 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cmcc', 'cmcc-cm2-hr5', 'toplevel')
# 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: 2... |
11,483 | <ASSISTANT_TASK:>
Python Code:
import tarfile
import re
import os
from itertools import count
# You have a copy of this file in your `data` directory. Tate provides the data in a single TAR (tape archive) file
DATA_PATH = '../data/tate-collection-1.2.tar.gz'
DATA_FOBJ = tarfile.open(DATA_PATH)
# We can use Python's too... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exploring
Step2: What we're seeing here is effectively a plain text display of our CSV data … not super pretty but faster than opening Excel. L... |
11,484 | <ASSISTANT_TASK:>
Python Code:
import math
import rebound, rebound.data
%matplotlib inline
sim = rebound.Simulation()
rebound.data.add_outer_solar_system(sim) # add some particles for testing
for i in range(1,sim.N):
sim.particles[i].m *= 50.
sim.integrator = "WHFast" # This will end badly!
sim.dt = sim.particles[1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let us integrate this system for a few hundred years. An instability will occur. We can then measure the energy error, which is a good estimate ... |
11,485 | <ASSISTANT_TASK:>
Python Code:
def list_of_strings_v1(iterable):
converts the iterable input into a list of strings
# build the output
out = [str(i) for i in iterable]
# validate the output
for i in out:
assert type(i) == str
# return
return out
list_of_strings_v1(range(10))
from... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: battle_tested was originally created to harden your safeties.
Step2: Here's an example of what many programmers would consider enough of a test... |
11,486 | <ASSISTANT_TASK:>
Python Code:
# 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 writing, sof... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Compile a model for the Edge TPU
Step2: Now click Runtime > Run all in the Colab toolbar.
Step3: Compile the model
Step4: The compiled model ... |
11,487 | <ASSISTANT_TASK:>
Python Code:
from random import seed
from random import randrange
import random
from csv import reader
from math import sqrt
import copy
# carregar o arquivo de CSV
def carregar_csv(nome_arquivo):
dados = list()
with open(nome_arquivo, 'r') as arquivo:
leitor_csv = reader(arquivo)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Carregando os dados e pre-procesamento
Step2: Proximo nos precisamos fazer os dados tem a mesma quantidade de cada classe. Isso é importante po... |
11,488 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import fetch_20newsgroups
categories = ['alt.atheism', 'soc.religion.christian',
'comp.graphics', 'sci.med']
twenty_train = fetch_20newsgroups(
subset='train',
categories=categories,
shuffle=True,
random_state=42,
remove=('headers',... | <SYSTEM_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 dimension of the input documents is reduced to 100, and then a kernel SVM is used to classify the documents.
Step2: TextExplainer
Step3: ... |
11,489 | <ASSISTANT_TASK:>
Python Code:
from pygameday import GameDayClient
from datetime import datetime
# Use an SQLite URI. A database file named `gameday.db` will be created in the current directory
# if it doesn't already exist
database_uri = "sqlite:///gameday.db"
# Instantiate a GameDayClient with the above URI, a 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: Now specify a URI for your database. This example uses SQLite, a file-based database that can exist locally on your system. SQLite is probably t... |
11,490 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
from snorkel import SnorkelSession
session = SnorkelSession()
from snorkel.models import candidate_subclass
ChemicalDisease = candidate_subclass('ChemicalDisease', ['chemical', 'disease'])
train_cands = session.query(ChemicalDisease).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: Part III
Step2: Text pattern approaches
Step3: Composite LFs
Step4: Rules based on context hierarchy
Step5: Running the LFs on the training ... |
11,491 | <ASSISTANT_TASK:>
Python Code:
def log(func):
def wraper():
print("INFO: Starting {}".format(func.__name__))
func()
print("INFO: Finishing {}".format(func.__name__))
return wraper
@log
def run():
print("Running run...")
run()
from time import sleep, time
def timer(Cls):
def wrap... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 修饰类
Step3: 类作为修饰器
Step4: 传递参数
Step5: 向被修饰的函数传递参数,要看我们的修饰器是如何作用的,如果像上面这个例子一样未执行被修饰函数只是将其原模原样地返回,则不需要任何处理(这就把函数当做普通的值一样看待即可):
Step6: 如果需要在修饰器内... |
11,492 | <ASSISTANT_TASK:>
Python Code:
%%writefile mapper.py
#!/usr/bin/python
import sys
import re
count = 0
WORD_RE = re.compile(r"[\w']+")
filename = sys.argv[2]
findword = sys.argv[1]
with open (filename, "r") as myfile:
#Please insert your code
for line in myfile.readlines():
words = WORD_RE.findall(line.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: Reduce
Step2: Write script to file
Step3: Run the file
Step4: Usage
|
11,493 | <ASSISTANT_TASK:>
Python Code:
from helpers import load_data
# load dataset
x, y = load_data()
def build_k_indices(y, k_fold, seed):
build k indices for k-fold.
num_row = y.shape[0]
interval = int(num_row / k_fold)
np.random.seed(seed)
indices = np.random.permutation(num_row)
k_indices = [indice... | <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: Cross-Validation and Bias-Variance decomposition
Step3: Selection of the best model among various degrees
Step4: Box-plot of the RMSE using th... |
11,494 | <ASSISTANT_TASK:>
Python Code:
from Bio import motifs
from Bio.Seq import Seq
instances = [Seq("TACAA"),
Seq("TACGC"),
Seq("TACAC"),
Seq("TACCC"),
Seq("AACCC"),
Seq("AATGC"),
Seq("AATGC")]
m = motifs.create(instances)
print(m)
len(m)
print(m.counts)
m.counts['A']
m.counts['T', 0]
m.counts... | <SYSTEM_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 we can start creating our first motif objects. We can either create
Step2: then we can create a Motif object as follows
Step3: The instanc... |
11,495 | <ASSISTANT_TASK:>
Python Code:
def fancy_calc(a, b, c):
x1 = basic_calc(a,b)
x2 = basic_calc(b,c)
x3 = basic_calc(c,a)
z = x1 * x2 * x3
return z
def basic_calc(x, y):
result = x + y
return result
x = 1
y = 2
z = 3
result = fancy_calc(x, y, z)
print x
print z
print x1
print result
# run ... | <SYSTEM_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) List the line numbers of the code above in the order that they will be executed. If a line will be executed more than once, list it each tim... |
11,496 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
resolutions = [150, 360, 600, 1200, 2400, 4800] # dpi
inch2cm = 2.54 # cm/inch
nbrOfSubpixels = 32
# Calulation Pixel Pinch
pixel_pitch = np.empty(shape=[len(resolutions)], dtype=np.float64) # um
for i in range(len(resolutions)):
pixel_pitch[i] = (inch2cm/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: Error in Pixel Pitch $\Delta x_{Pitch}$because of substrate speed and clock frequency
Step2: Resolution
Step3: Stitching
Step4: Pixel distanc... |
11,497 | <ASSISTANT_TASK:>
Python Code:
print(data['CITY_NAME'].value_counts())
print(data.pivot_table(index=['TDQ'], columns=['CITY_NAME']))
print(data.pivot_table(index=['TDQ'], columns=['BLOCK']))
data['P'].hist()
(np.log(data['P'])).hist()
data['A'].hi... | <SYSTEM_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: Histogram
Step4: 価格(自然対数)
Step5: 建築後年数
Step6: Plot
Step7: Main Analysis
Step8: 青がOLSの... |
11,498 | <ASSISTANT_TASK:>
Python Code:
import mcpi.minecraft as minecraft
import mcpi.block as block
from time import sleep
world = minecraft.Minecraft.create()
height = 5
material = block.COBBLESTONE
[x,y,z] = world.player.getPos()
[x, y, z]
# This variable will track the current level being created inside the lo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Connect to the Minecraft server, store the connection in a variable named world
Step2: Next, set some variables to customize the pyramid. You m... |
11,499 | <ASSISTANT_TASK:>
Python Code:
import random
def sample_experiment():
### BEGIN SOLUTION
### END SOLUTION
def sample_experiment():
### BEGIN SOLUTION
### END SOLUTION
def sample_experiment():
### BEGIN SOLUTION
### END SOLUTION
def sample_experiment():
### BEGIN SOLUTION
### END SOLUTION
import iter... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: b. $1/2$
Step2: c. $3/4$
Step3: d. $1$
Step4: Question 2
Step5: b. Create a variable direct_number_of_permutations that gives the number of ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.