Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
3,800 | <ASSISTANT_TASK:>
Python Code::
# beam search
def beam_search_decoder(data, k):
sequences = [[list(), 0.0]]
# walk over each step in sequence
for row in data:
all_candidates = list()
# expand each current candidate
for i in range(len(sequences)):
seq, score = sequences[i]
for j in range(len(row)):
ca... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
3,801 | <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', 'atmos')
# 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... |
3,802 | <ASSISTANT_TASK:>
Python Code:
1 / 2
1. / 2
4. + 4.0**(3.0/2)
4 + 3j
import math
math?
math.sqrt(2.0)
math.sin(math.pi / 2.0)
from math import *
sin(pi)
num_students = 80
room_capacity = 85
(room_capacity - num_students) / room_capacity * 100.0
float(room_capacity - num_students) / float(room_capacity) * 100.0
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: Python returns the floor of the 1 / 2 because we gave it integers to divide. It then interprets the result as also needing to be an integer. I... |
3,803 | <ASSISTANT_TASK:>
Python Code:
files = glob("/home/greg/Documents/Summer Research/rinex files/ma*")
poop=rinexobs(files[6])
plt.figure(figsize=(14,14))
ax1 = plt.subplot(211)
ax1.xaxis.set_major_formatter(fmt)
plt.plot(2.85*(poop[:,23,'P2','data']*1.0E9/3.0E8-poop[:,23,'C1','data']*1.0E9/3.0E8)[10:],
'.',marke... | <SYSTEM_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 plot is uncorrected, it is a remake of the plot in Anthea's email on Wed, Jun 15, 2016 at 7
Step2: try some stuff out from "An Automatic E... |
3,804 | <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: Examine a single patient
Step5: We can make a few observations
Step7: Hospitals with data available
|
3,805 | <ASSISTANT_TASK:>
Python Code:
from os import path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.forward import make_forward_dipole
from mne.evoked import combine_evoked
from mne.simulation import simulate_evoked
data_path = mne.datasets.sample.data_path()
subjects_dir = op.join(data_path... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's localize the N100m (using MEG only)
Step2: Calculate and visualise magnetic field predicted by dipole with maximum GOF
Step3: Estimate t... |
3,806 | <ASSISTANT_TASK:>
Python Code:
dir = 'data/testing/cyan_tests/'
man_E1 = dir + 'run-man.csv'
man_R1 = dir + 'run-man-R1.csv'
raw_man_E1 = pd.read_csv(man_E1)
#raw_man_E1 = pd.read_csv(man_R1)
#cyan_16 = dir + 'run-1-fac-16.dat'
#cyan_17 = dir + 'run-1-fac-17.dat'
#cyan_18 = dir + 'run-1-fac-18.dat'
cyan_16 = dir + 'r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Check Seeding Random on Time
Step2: For LEU Signal, 'H seed' should match 'no seed' because both of them have deterministic NormalDist.
Step3: ... |
3,807 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# You can ignore the pink warning that appears
import itertools
import math
import nltk
import string
nltk.data.path = ['../nltk_data']
import matplotlib.pyplot as plt
import numpy as np
from scipy.spatial.distance import pdist, squareform
from scipy.cluster.hierarchy 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: TF-IDF (Term Frequency, Inverse Document Frequency)
Step2: What if you change some of those docs, or add another one? Add another c in the last... |
3,808 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import liboptpy.unconstr_solvers.fo as fo
import liboptpy.step_size as ss
import liboptpy.base_optimizer as base
import matplotlib.pyplot as plt
%matplotlib inline
np.random.seed(42)
n = 100
A = np.random.randn(n, n)
A = A.T.dot(A)
A_eigvals = np.linalg.eigvalsh(A)
mu =... | <SYSTEM_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: Эксперимент на неквадратичной задаче
|
3,809 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
df = pd.DataFrame({'a': np.arange(1E6), 'b': np.arange(1E6)})
%timeit -o df.c = df.a + df.b
a = df.a.values
b = df.b.values
%%timeit
c = a + b
df = pd.DataFrame({'a': np.arange(100), 'b': np.arange(100)})
%%timeit
df.c = df.a + df.b
a = df.a.value... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We have just created a relatively large dataframe with some dummy data, enough to prove my initial point. Let's see how much time it takes to ad... |
3,810 | <ASSISTANT_TASK:>
Python Code:
# Authors: Eric Larson <larson.eric.d@gmail.com>
# Adam Li <adam2392@gmail.com>
# Alex Rockhill <aprockhill@mailbox.org>
#
# License: BSD-3-Clause
import os.path as op
import numpy as np
import mne
from mne.datasets import fetch_fsaverage
# paths to mne datasets - sample... | <SYSTEM_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 load some sEEG data with channel locations and make epochs.
Step2: Let use the Talairach transform computed in the Freesurfer recon-all
S... |
3,811 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import antipackage
import github.ellisonbg.misc.vizarray as va
def checkerboard(size):
Return a 2d checkboard of 0.0 and 1.0 as a NumPy array
a = np.zeros((size,size))
x=0
while 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:
Step2: Checkerboard
Step3: Use vizarray to visualize a checkerboard of size=20 with a block size of 10px.
Step4: Use vizarray to visualize a checkerb... |
3,812 | <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: AdaNet on TPU
Step2: Fashion MNIST
Step6: input_fn Changes
Step16: model_fn Changes
Step17: Launch TensorBoard
Step18: Using adanet.TPUEsti... |
3,813 | <ASSISTANT_TASK:>
Python Code:
reload(pynoddy.history)
reload(pynoddy.output)
reload(pynoddy.experiment.uncertainty_analysis)
reload(pynoddy)
from pynoddy.experiment.uncertainty_analysis import UncertaintyAnalysis
# the model itself is now part of the repository, in the examples directory:
history_file = os.path.join(r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The next step is to perform the Monte Carlo purturbation of this initial model, and use this to estimate uncertainty. This sampling is wrapped i... |
3,814 | <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.
if type(x) or type(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:
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... |
3,815 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from functools import partial
from sklearn.manifold import TSNE
import sklearn.metrics as metrics
from scRNA.simulation import generate_toy_data, split_source_target
from scRNA.nmf_clustering import NmfClustering_init... | <SYSTEM_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. Simulating scRNA read count data
Step2: Let's have a tSNE plot on the simulated data. We se that cluster are nicely
Step3: Plotting the re... |
3,816 | <ASSISTANT_TASK:>
Python Code:
import pyensae
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import pyensae
import os
from pyensae.finance import StockPrices
cache = os.path.abspath("cache")
if not os.path.exists(cache):
os... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initialisation
Step2: Créer un objet StockPrices
Step3: La classe <tt>StockPrices</tt> contient un objet <a href="http
Step4: De la même mani... |
3,817 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
def random_line(m, b, sigma, size=10):
Create a line y = m*x + b + N(0,sigma**2) between x=[-1.0,1.0]
Param... | <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: Line with Gaussian noise
Step5: Write a function named plot_random_line that takes the same arguments as random_line and creates a random line ... |
3,818 | <ASSISTANT_TASK:>
Python Code:
from ndreg import *
import matplotlib
import ndio.remote.neurodata as neurodata
server = "dev.neurodata.io"
userToken = txtRead("userToken.pem").strip()
refToken = "ara3"
refImg = imgDownload(refToken, channel="average", server=server, userToken=userToken)
refThreshold = imgPercentile(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We define the server and our user token
Step2: First we'll download the atlas image
Step3: Next we'll visuaize the image. To ensure that the ... |
3,819 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
np.random.randint(low=1, high=20+1, size=1)
rolls = np.random.randint(low=1, high=20+1, size=(5, 2))
rolls
rolls.max(axis=1)
def expected_value_advantage(n_rolls: int=100, n_sides: int=20) -> float:
rolls = np.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Expected value of "advantage" and "disadvantage"
Step2: And if we want to simulate two rolls of the die, repeated 4 times, we pass a shape of (... |
3,820 | <ASSISTANT_TASK:>
Python Code:
from arboretum.datasets import load_diabetes
xtr, ytr, xte, yte = load_diabetes()
xtr.shape, xte.shape
from sklearn.metrics import mean_squared_error as mse
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor
from arboretum import SmoothRegre... | <SYSTEM_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 compare a smoothed regression tree from arboretum to a regression tree and a random forest from scikit-learn. First, we'll just run the ... |
3,821 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
import numpy as np
from ipywidgets import interact
import matplotlib.pyplot as plt
%matplotlib nbagg
def potential(x, V0=20.0):
if x < 0 or x > 1:
return V0
else:
return 0
# Smallest position for which we w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The cell below defines the potential
Step2: Double click here to edit, and describe this potential in words
Step4: YOU NEED TO ADD THE CODE BE... |
3,822 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install -U google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if not os.getenv("IS_TESTING... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
3,823 | <ASSISTANT_TASK:>
Python Code:
import pypsa
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# use 24 hour period for consideration
index = pd.date_range("2016-01-01 00:00", "2016-01-01 23:00", freq="H")
# consumption pattern of BEV
bev_usage = pd.Series([0.0] * 7 + [9.0] * 2 + [0.0] * 8 + [9.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: Initialize the network
Step2: The optimal panel size in kW is
Step3: The losses in kWh per pay are
|
3,824 | <ASSISTANT_TASK:>
Python Code:
import healpix_util as hu
import astropy as ap
import numpy as np
from astropy.io import fits
from astropy.table import Table
import astropy.io.ascii as ascii
from astropy.io import fits
from astropy.constants import c
import matplotlib.pyplot as plt
import math as m
from math import pi
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read the data file (taken from http
Step2: Read the data file (taken from http
Step3: BallTree.two_point_correlation works almost 10 times fas... |
3,825 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
#load the files
train = pd.read_csv('input/train.csv')
test = pd.read_csv('input/test.csv')
data = pd.concat([train, test])
#size of training dataset
train_samples = train.shape[0]
#print some of them
data.head()
# remove the Id feature
data.drop(['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: First problem
Step2: Selecting only numeric columns (by now)
Step3: Find if there's null values
Step4: Normalizing
Step5: Using Box-Cox
Step... |
3,826 | <ASSISTANT_TASK:>
Python Code:
# --- INITIAL DEFINITIONS ---
from dscribe.descriptors import LMBTR
import numpy as np
from visualise import view
from ase import Atoms
import ase.data
import matplotlib.pyplot as mpl
# atomic positions as matrix
molxyz = np.load("./data/molecule.coords.npy")
# atom types
moltyp = np.loa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Atom description
Step2: Setting LMBTR hyper-parameters
Step3: Calculate LMBTR
Step4: Plotting
|
3,827 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
# Create TensorFlow object called tensor
hello_constant = tf.constant('Hello World!')
with tf.Session() as sess:
# Run the tf.constant operatin in the session
output = sess.run(hello_constant)
print(output)
# A is a 0-dimensional int32 tensor
A = tf.co... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Tensor
Step2: The tensor returned by tf.constant() is called a constant tensor, because the value of the tensor never changes.
Step3: The code... |
3,828 | <ASSISTANT_TASK:>
Python Code:
import os,json,glob,pickle
import numpy,pandas
import nibabel
import sklearn.multiclass
from sklearn.svm import SVC
import sklearn.metrics
import sklearn.model_selection
import sklearn.preprocessing
import scipy.stats,scipy.io
import random
import seaborn
%matplotlib inline
import matplo... | <SYSTEM_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 exercise we will decode orientation using data collected for the Cognitive Neuroscience module in 2017. The subject performed a task th... |
3,829 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
np.random.seed(1)
# Define a function that,
def f(x):
# Outputs x multiplied by a random number drawn from a normal distribution
return x * np.random.normal(size=1)[0]
# Create some values of x
xs = [1,2,3,4,5,6]
#Define argmin that
def ar... | <SYSTEM_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 A Function, f(x)
Step2: Create Some Values Of x
Step3: Find The Argmin Of f(x)
Step4: Check Our Results
|
3,830 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
df = pd.read_csv("data/hanford.csv")
df
df['Exposure'].mean()
df['Exposure'].describe()
df.corr()
df.plot(kind='scatter', x='Mortality', y='Exposure')
lm = smf.ols(formula='Mor... | <SYSTEM_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. Read in the hanford.csv file
Step2: 3. Calculate the basic descriptive statistics on the data
Step3: 4. Calculate the coefficient of correl... |
3,831 | <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: Proximities and Prototypes with Random Forests
Step2: Train a Random Forest model
Step3: Following are the first five examples of the training... |
3,832 | <ASSISTANT_TASK:>
Python Code:
x = 0
while x < 10:
print 'x is currently: ',x
print ' x is still less than 10, adding 1 to x'
x+=1
x = 0
while x < 10:
print 'x is currently: ',x
print ' x is still less than 10, adding 1 to x'
x+=1
else:
print 'All Done!'
x = 0
while x < 10:
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: Notice how many times the print statements occured and how the while loop kept going until the True condition was met, which occured once x==10.... |
3,833 | <ASSISTANT_TASK:>
Python Code:
for i in range(4):
print(i)
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
X = np.linspace(-np.pi, np.pi, 656)
F = np.sin(1/(X**2+0.07))
plt.plot(X,F)
from ipywidgets import interact
def f(x):
print(x)
interact(f, x=10);
from ipywidgets import widgets
w =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: widgets
Step2: Notebook magics
Step3: Widget callback przykład
|
3,834 | <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, softwar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Android Management API - Quickstart for Web Apps
Step2: Declare your enterprise
Step3: Create a web app with the managed Google Play iframe
St... |
3,835 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import os
s3file = 'https://dsclouddata.s3.amazonaws.com/churn.csv'
churnDF = pd.read_csv(s3file, delimiter=',')
churnDF.head(5)
# Install MySQLdb, the interface to the popular MySQL database server for Python for use with SQLalchemy
!sudo apt-get install python-mysql... | <SYSTEM_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. Put the Data in a Database
Step2: Write the dataframe as a table called 'account_info'
|
3,836 | <ASSISTANT_TASK:>
Python Code:
class Student(object):
skills = []
def __init__(self, name):
self.name = name
stu = Student('ly')
print Student.skills # 访问类数据属性
Student.skills.append('Python')
print Student.skills
print stu.skills # 通过实例也能访问类数据属性
print dir(Student)
Student.age = 25... | <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: 特殊的类属性
Step3: 方法
Step4: 定义一个Animal类,初始化方法把形参name赋值给实例对象数据属性name
Step5: @classmethod 类方法
Step6: 私有变量
Step7: 通常在类中定义方法去访问和修改这些私有变量。
Step8: 约... |
3,837 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
from snorkel import SnorkelSession
session = SnorkelSession()
import os
from snorkel.parser import XMLMultiDocPreprocessor
# The following line is for testing only. Feel free to ignore it.
file_path = 'data/CDR.BioC.small.xml' if 'CI'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configuring a DocPreprocessor
Step2: Creating a CorpusParser
Step3: Part II
Step4: We should get 8268 candidates in the training set, 888 can... |
3,838 | <ASSISTANT_TASK:>
Python Code:
import graphlab
people = graphlab.SFrame('people_wiki.gl/')
people.head()
len(people)
obama = people[people['name'] == 'Barack Obama']
john = people[people['name'] == 'Elton John']
john
obama['text']
clooney = people[people['name'] == 'George Clooney']
clooney['text']
obama['word_cou... | <SYSTEM_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 text data - from wikipedia, pages on people
Step2: Data contains
Step3: Explore the dataset and checkout the text it contains
Step4:... |
3,839 | <ASSISTANT_TASK:>
Python Code:
from bokeh.plotting import figure, show, output_notebook
output_notebook()
# prepare some data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
# output to static HTML file
# output_file("lines.html", title="line plot example")
# create a new plot with a title and axis labels
p = figure(title="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: Sanity Check
Step2: Grammar of Graphics
Step3: Customizing Tooltips
Step4: Let's Use some real (interesting) data!
|
3,840 | <ASSISTANT_TASK:>
Python Code:
# Basic imports
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
import scipy.optimize as spo
import sys
from time import time
from sklearn.metrics import r2_score, median_absolute_error
from multiprocessing import Pool
%matplotlib inl... | <SYSTEM_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 show the symbols data, to see how good the recommender has to be.
Step2: Let's run the trained agent, with the test set
Step3: And now a... |
3,841 | <ASSISTANT_TASK:>
Python Code:
__author__ = "Christopher Potts"
__version__ = "CS224u, Stanford, Spring 2022"
import os
import pandas as pd
import torch
from transformers import BertModel, BertTokenizer
from transformers import RobertaModel, RobertaTokenizer
import utils
import vsm
DATA_HOME = os.path.join('data', 'vs... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Contents
Step2: The transformers library does a lot of logging. To avoid ending up with a cluttered notebook, I am changing the logging level. ... |
3,842 | <ASSISTANT_TASK:>
Python Code:
from tessfpe.dhu.fpe import FPE
from tessfpe.dhu.unit_tests import check_house_keeping_voltages
fpe1 = FPE(1, debug=False, preload=True, FPE_Wrapper_version='6.1.1')
print fpe1.version
fpe1.cmd_start_frames()
fpe1.cmd_stop_frames()
if check_house_keeping_voltages(fpe1):
print "Wrapper... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Useful Commands
Step2: Reading a housekeeping value has this form
Step3: Setting an operating parameter has this form
Step4: Setting all the ... |
3,843 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
import numpy as np
import thinkstats2
def ReadFemPreg(dct_file='2002FemPreg.dct',
dat_file='2002FemPreg.dat.gz'):
Reads the NSFG pregnancy data.
dct_file: string file name
dat_file: string file name
returns: ... | <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: The NSFG data is in a fixed-width format, documented in a Stata dictionary file. ReadFemPreg reads the dictionary and then reads the data into ... |
3,844 | <ASSISTANT_TASK:>
Python Code:
!conda install ipython-sql -y
%load_ext sql
%config SqlMagic.autopandas=True
import pandas as pd
import sqlite3
%%sql sqlite://
CREATE TABLE presidents (first_name, last_name, year_of_birth);
INSERT INTO presidents VALUES ('George', 'Washington', 1732);
INSERT INTO presidents VALUES ('Jo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SQL
Step3: Through pandas directly
|
3,845 | <ASSISTANT_TASK:>
Python Code:
fig,ax=subplots(3,3,figsize=(10, 10))
n=1
for i in range(3):
for j in range(3):
ax[i,j].scatter(X[:,0],X[:,n],c=Y)
n+=1
Xnorm=sklearn.preprocessing.normalize(X)
pca=sklearn.decomposition.PCA()
pca.fit(Xnorm)
fig,ax=subplots(1,3,figsize=(16, 4))
ax[0].scatter(pca.transf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Con un unico componente se logra explicar casi toda la varianza. Sin embargo incluso con esta separacion en componentes principales, los diferen... |
3,846 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import pudl
from pudl import constants as pc
from pathlib import Path
import pandas as pd
pd.options.display.max_columns = 150
pd.options.display.max_rows = 150
# make notebooks full width
from IPython.core.display import display, HTML
display(HTML("<sty... | <SYSTEM_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 shows the state of the columns for each year for each sheet. When a column is introduced (or disappears), that entry will be NaN. This part... |
3,847 | <ASSISTANT_TASK:>
Python Code:
import urllib.request
import json
import datetime
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from pandas.io.json import json_normalize
def get_data(dataurl, filename):
get data from url then store into jason file in 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:
Step 1
Step2: Then I write a function to get scource data from url and then store data into jason files. The inputs of the function are source data url... |
3,848 | <ASSISTANT_TASK:>
Python Code:
!wget -O - 'http://www.cs.nyu.edu/~roweis/data/nips12raw_str602.tgz' > /tmp/nips12raw_str602.tgz
import tarfile
filename = '/tmp/nips12raw_str602.tgz'
tar = tarfile.open(filename, 'r:gz')
for item in tar:
tar.extract(item, path='/tmp')
import os, re
# Folder containing all NIPS paper... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the following sections we will load the data, pre-process it, train the model, and explore the results using some of the implementation's fun... |
3,849 | <ASSISTANT_TASK:>
Python Code:
file_path = '../data/2011.0.00419.S/sg_ouss_id/group_ouss_id/member_ouss_2013-03-06_id/product/IRAS16547-4247_Jet_CS_v1_7-6.clean.fits'
noise_pixel = (15, 4)
train_pixels = [(133, 135),(134, 135),(133, 136),(134, 136)]
img = fits.open(file_path)
meta = img[0].data
hdr = img[0].header
# 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: Creation of Dictionary
Step2: Recalibration of Dictionary
|
3,850 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Importando os pacotes
import numpy as np
import pandas as pd
import matplotlib as mat
import matplotlib.pyplot as plt
import colorsys
pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Análise Exploratória de Dados
Step2: Distribuição de Idade
Step3: Distribuição de Sexo
Step4: Distribuição de Interesses
Step5: Distribuição... |
3,851 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
x = np.array([1, 4, 7, 11, 34, -3, 5, 7, 5, 2, 3, 13])
###-------###
x[::2]
x[:-1] + x[1:]
x[1:] - x[:-1]
x[::2] / x[1::2]
N = len(x)
x[:N // 2] * x[N // 2:]
import numpy.linalg as linalg
A = np.array([ [3, 2, -1], [6, 4, -2], [5, 0, 3]])
B = np.array([ [2, 3, 2], ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1.2 Answer
Step2: 1.3 Answer
Step3: 1.4 Answer
Step4: 1.5 Answer
Step5: 2. Matrix Calculations (12 Points)
Step6: Answer 2.2
Step7: Answer... |
3,852 | <ASSISTANT_TASK:>
Python Code:
import NotebookImport
from metaPCNA import *
import GTEX as GTEX
f_win.order().tail()
gabr = [g for g in rna_df.index if g.startswith('GABR')]
f = dx_rna.ix[gabr].dropna()
f.join(f_win).sort(f_win.name)
GTEX.plot_tissues_across_gene('GABRD', log=True)
gtex = np.log2(GTEX.gtex)
meta = GTEX... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: GABRD is highly expressed in many areas of the brain as well as in the testis. Interestingly it is the highest expressed subunit in the testis.
... |
3,853 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (100, 110)
DON'T MODIFY ANYTHING IN THIS CELL
import ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
3,854 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'sandbox-3', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("na... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
3,855 | <ASSISTANT_TASK:>
Python Code:
import girder_client
import numpy as np
from matplotlib import pylab as plt
from matplotlib.colors import ListedColormap
from histomicstk.saliency.tissue_detection import (
get_slide_thumbnail, get_tissue_mask)
%matplotlib inline
APIURL = 'http://candygram.neurology.emory.edu:8080/ap... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Constants and Prepwork
Step2: First, let's fetch the slide thumbnail
Step3: (Optional) Color normalization of thumbnail
Step4: Get the tissue... |
3,856 | <ASSISTANT_TASK:>
Python Code:
# 基础库导入
from __future__ import print_function
from __future__ import division
import warnings
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import os
import sys
# 使用insert 0即只使用gi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 受限于沙盒中数据限制,本节示例的相关性分析只限制在abupy内置沙盒数据中,完整示例以及代码请阅读《量化交易之路》中相关章节。
Step2: 在运行完成第15节中相关内容后,使用load_abu_result_tuple读取上一节保存在本地的训练集数据:
Step3: 1. 跳空主裁... |
3,857 | <ASSISTANT_TASK:>
Python Code:
# Setup feedback system
from learntools.core import binder
binder.bind(globals())
from learntools.time_series.ex5 import *
# Setup notebook
from pathlib import Path
from learntools.time_series.style import * # plot style settings
import matplotlib.pyplot as plt
import pandas as pd
from 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: In the next two questions, you'll create a boosted hybrid for the Store Sales dataset by implementing a new Python class. Run this cell to creat... |
3,858 | <ASSISTANT_TASK:>
Python Code:
from quantopian.pipeline.data import Fundamentals
# Since the underlying data of Fundamentals.exchange_id
# is of type string, .latest returns a Classifier
exchange = Fundamentals.exchange_id.latest
from quantopian.pipeline.classifiers.fundamentals import Sector
morningstar_sector = 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: Previously, we saw that the latest attribute produced an instance of a Factor. In this case, since the underlying data is of type string, latest... |
3,859 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
# scientific
%matplotlib inline
from matplotlib import pyplot as plt;
import matplotlib as mpl;
import numpy as np;
import sklearn as skl;
import sklearn.datasets;
import sklearn.cluster;
import sklearn.mixture;
# ipython
import IPython;
# python
import os;... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: EECS 445
Step2: Review
Step3: Gaussian Mixture Models
Step4: Complete Data Log-Likelihood
Step5: Coin Flip
Step6: Coin Flip
Step7: Coin Fl... |
3,860 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sys
from rdflib import Graph,URIRef
from gastrodon import LocalEndpoint,one,QName
import gzip
import pandas as pd
pd.set_option("display.width",100)
pd.set_option("display.max_colwidth",80)
g=Graph()
g.parse(gzip.open("data/dbpedia_2015-10.nt.gz"),format="nt")
... | <SYSTEM_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 graph
Step2: Now it is loaded in memory in an RDF graph which I can do SPARQL queries on; think of it as a hashtable on steroids. ... |
3,861 | <ASSISTANT_TASK:>
Python Code:
icon_create_function = \
function(cluster) {
return L.divIcon({
html: '<b>' + cluster.getChildCount() + '</b>',
className: 'marker-cluster marker-cluster-large',
iconSize: new L.Point(20, 20)
});
}
from folium.plugins import MarkerCluster
m = folium.Map(
location=[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Adding all icons in a single call
Step2: Explicit loop allow for customization in the loop.
Step4: FastMarkerCluster is not as flexible as Mar... |
3,862 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from math import atan2, sqrt, sin, cos, pi
import re
X, Y, Z, MX, MY, MZ = 0, 1, 2, 3, 4, 5 # indices in coord dictionary items
RO = 180 * 3600 / pi
# initial coordinates
coo1 = {'K1': [ 0.0, 5.9427, 0.9950],
'K2': [ 6.0242, 0.0, 1.3998],
'K3'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sample data
Step3: A function to calculate three parameter transformation based on commmon points. The point coordinates are stored in dictiona... |
3,863 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append("..")
import splitwavepy as sw
import matplotlib.pyplot as plt
import numpy as np
data = sw.Pair(noise=0.05,pol=40,delta=0.1)
data.plot()
data.split(40,1.6)
data.plot()
data.unsplit(80,1.6)
data.plot()
# Let's start afresh, and this time put the splitting on ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now let's add a bit of splitting. Note, this shortens trace length slightly. And the pulse is still at the centre.
Step2: Measuring shear wave... |
3,864 | <ASSISTANT_TASK:>
Python Code:
from ecell4 import *
A = Species("A")
B = Species("B")
A = Species("A")
A.set_attribute("radius", "0.005")
A.set_attribute("D", "1")
A.set_attribute("location", "cytoplasm")
A = Species("A", "0.005", "1", "cytoplasm") # XXX: serial, radius, D, location
print(A.serial()) # will return... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: each expression describes a Species named A or B.
Step2: The 1st argument for set_attribute is the name of attribute.
Step3: When you want to ... |
3,865 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import matplotlib.pyplot as plt
import numpy as np
#import widgets
from ipywidgets import widgets
mywidget = widgets.FloatSlider()
display(mywidget)
print mywidget.value
def on_value_change(name, value):
print(value)
int_range = widgets.IntSlider(min=0, max=10, step=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Widgets
Step2: A simple slider
Step3: You can slide the slider back and forth and then "get" the current value from the widget object with
Ste... |
3,866 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import matplotlib.pyplot as plt
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(samp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Background on filtering
Step2: A half-period of this slow drift appears to last around 10 seconds, so a full
Step3: Looks like 0.1 Hz was not ... |
3,867 | <ASSISTANT_TASK:>
Python Code:
#$HIDE$
import pandas as pd
pd.plotting.register_matplotlib_converters()
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
print("Setup Complete")
# Path of the file to read
spotify_filepath = "../input/spotify.csv"
# Read the file into a variable spotify_data
spot... | <SYSTEM_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'll work with the same code that we used to create a line chart in a previous tutorial. The code below loads the dataset and creates the char... |
3,868 | <ASSISTANT_TASK:>
Python Code:
# Import py_entitymatching package
import py_entitymatching as em
import os
import pandas as pd
# Get the datasets directory
datasets_dir = em.get_install_path() + os.sep + 'datasets'
# Get the paths of the input tables
path_A = datasets_dir + os.sep + 'person_table_A.csv'
path_B = datas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then, read the (sample) input tables for blocking purposes.
Step2: Generating Features for Manually
Step3: Getting Attribute Correspondences
S... |
3,869 | <ASSISTANT_TASK:>
Python Code:
!git clone https://github.com/benelot/pybullet-gym lib/pybullet-gym
!pip install -e lib/pybullet-gym
import gym
import numpy as np
import pybulletgym
env = gym.make("AntPyBulletEnv-v0")
# we want to look inside
env.render()
# examples of states and actions
print("observation space: ", en... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First, we will create an instance of the environment. In pybullet-gym, if render is called before the first reset, then you will (hopefully) see... |
3,870 | <ASSISTANT_TASK:>
Python Code:
print("Exemplo 9.8")
omega = 60
L = 0.1
V = 12
#v = 12[45º]
#I = V/jwL[45 - 90]
I = V/(omega*L)
phi = 45 - 90
print("Corrente fasorial: {}[{}]".format(I,phi))
print("Corrente temporal: {}cos({}t + {})".format(I,omega,phi))
print("Problema Prático 9.8")
V = 10
u = 10**(-6)
C = 50*u
omega ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problema Prático 9.8
Step2: Impedância e Admitância
Step3: Problema Prático 9.9
|
3,871 | <ASSISTANT_TASK:>
Python Code:
# Useful Functions
def find_cointegrated_pairs(data):
n = data.shape[1]
score_matrix = np.zeros((n, n))
pvalue_matrix = np.ones((n, n))
keys = data.keys()
pairs = []
for i in range(n):
for j in range(i+1, n):
S1 = data[keys[i]]
S2 = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercise 1
Step2: b. Cointegration Test II
Step3: Exercise 2
Step4: b. Real Cointegration Test II
Step5: Exercise 3
Step6: Exercise 4
Step7... |
3,872 | <ASSISTANT_TASK:>
Python Code:
#import libraries
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import requests, bs4
import time
from sklearn import model_selection
from collections import OrderedDict
from sklearn.preprocessing import StandardScaler
from sklearn.model_sel... | <SYSTEM_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 look at the data)
Step2: Посмотрим подробней на некоторые комбинации, в которых есть намек на линейную зависимос... |
3,873 | <ASSISTANT_TASK:>
Python Code:
import os
import logging
import tensorflow as tf
import fairing
import numpy as np
from datetime import datetime
from fairing.cloud import gcp
# Setting up google container repositories (GCR) for storing output containers
# You can use any docker container registry istead of GCR
# For loc... | <SYSTEM_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 the model logic
Step2: Train an Keras model in a notebook
Step3: Spicify a image registry that will hold the image built by fairing
Ste... |
3,874 | <ASSISTANT_TASK:>
Python Code:
import sys
assert sys.version_info[0] == 3
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0.0, 10.0, 0.1)
plt.plot(x, np.sin(x))
import pandas as pd
pd.DataFrame([(0, 1), (2, 3)], columns=['A', 'B'])
!which ansible
!which wget
!which curl
!which pap... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Libraries
Step2: pandas to display tables
Step3: Utilities
|
3,875 | <ASSISTANT_TASK:>
Python Code:
import trappy
import numpy
config = {}
# TRAPpy Events
config["THERMAL"] = trappy.thermal.Thermal
config["OUT"] = trappy.cpu_power.CpuOutPower
config["IN"] = trappy.cpu_power.CpuInPower
config["PID"] = trappy.pid_controller.PIDController
config["GOVERNOR"] = trappy.thermal.ThermalGovernor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get the Trace
Step2: Run Object
Step3: Assertions
Step4: Assertion
Step5: Assertion
Step6: Statistics
Step7: Check if the mean temperautur... |
3,876 | <ASSISTANT_TASK:>
Python Code:
!pip install websocket-client
!pip install python-swiftclient
import pandas as pd
import matplotlib.pyplot as plt
import json
import websocket
import thread
import time
import swiftclient
import codecs
from io import StringIO
olympics_data_filename = 'olympics.csv'
dictionary_data_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: Install IBM Bluemix Object Storage Client
Step2: 1.2 Import packages and libraries
Step3: 2. Configuration
Step7: 3. Persistence and Storage
... |
3,877 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from geoscilabs.seismic.NMOwidget import ViewWiggle, InteractClean, InteractNosiy, NMOstackthree
from SimPEG.utils import download
# Define path to required data files
synDataFilePath = 'http://github.com/geoscixyz/geosci-labs/raw/master/assets/seismic/syndata1.npy'
obsDataF... | <SYSTEM_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 common-mid-point (CMP) gathers
Step2: Step 2
Step3: Step 3
Step4: Step 4
|
3,878 | <ASSISTANT_TASK:>
Python Code:
from sklearn import datasets, neighbors, linear_model
digits = datasets.load_digits() # Retrieves digits dataset from scikit-learn
print(digits['DESCR'])
digits['images'][0]
import matplotlib.pyplot as plt
plt.gray()
plt.matshow(digits.images[0])
plt.matshow(digits.images[10])
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: What does our data look like?
Step2: Extract our input data (X digits), our target output data (Y digits) and the number of samples we will pro... |
3,879 | <ASSISTANT_TASK:>
Python Code:
import regionmask
regionmask.__version__
import xarray as xr
import numpy as np
# don't expand data
xr.set_options(display_style="text", display_expand_data=False)
lon = np.arange(-179.5, 180)
lat = np.arange(-89.5, 90)
regionmask.defined_regions.srex
mask = regionmask.defined_regions... | <SYSTEM_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 xarray and numpy
Step2: Creating a mask
Step3: We will create a mask with the SREX regions (Seneviratne et al., 2012).
Step4: The functi... |
3,880 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.fft as sf
N = 8
result = sf.dct(np.eye(N), axis=0, norm= 'ortho')
<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:
|
3,881 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display, Image
from IPython.display import (
display_pretty, display_html, display_jpeg,
display_png, display_json, display_latex, display_svg
)
#raise NotImplementedError()
assert True # leave this to grade the import statements
Image (url = "http://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: Basic rich display
Step2: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi... |
3,882 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-1', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_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... |
3,883 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TensorFlow Lite による芸術的スタイル転送
Step2: コンテンツ画像とスタイル画像、および事前トレーニング済みの TensorFlow Lite モデルをダウンロードします。
Step3: 入力を前処理する
Step4: 入力を可視化する
Step5: Tens... |
3,884 | <ASSISTANT_TASK:>
Python Code:
import os
import time
import pandas as pd
from google.cloud import aiplatform, bigquery
from sklearn.compose import ColumnTransformer
from sklearn.linear_model import SGDClassifier
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler
REGIO... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configure environment settings
Step2: We now create the ARTIFACT_STORE bucket if it's not there. Note that this bucket should be created in the... |
3,885 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_blobs
X, y = make_blobs(random_state=42)
X.shape
plt.scatter(X[:, 0], X[:, 1]);
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=3, random_state=42)
labels = kmeans.fit_predict(X)
labels
print("¿Hemos acertado en todas las etiquetas?", 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: En el scatter anterior, podemos ver tres grupos separados de datos y nos gustaría recuperarlos utilizando agrupamiento (algo así como "descubrir... |
3,886 | <ASSISTANT_TASK:>
Python Code:
response = requests.get('https://api.spotify.com/v1/search?query=Lil&type=artist&limit=50&market=US')
Lil_data = response.json()
Lil_data.keys()
Lil_data['artists'].keys()
Lil_artists = Lil_data['artists']['items']
for artist in Lil_artists:
print(artist['name'], artist['popularity']... | <SYSTEM_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) With "Lil Wayne" and "Lil Kim" there are a lot of "Lil" musicians. Do a search and print a list of 50 that are playable in the USA (or the co... |
3,887 | <ASSISTANT_TASK:>
Python Code:
# Import all ploting and scientific library,
# and embed figures in this file.
%pylab inline
# Package to manipulate dataframes.
import pandas as pd
# Nice looking plot functions.
import seaborn as sn
# The Pearson correlation function.
from scipy.stats import pearsonr
# Read the dataset.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pearson correlation $r$
Step2: As we can see above, $r = 0.60$ with $pvalue=1.06*10^{-18}$, shows a moderately strong correlation between life ... |
3,888 | <ASSISTANT_TASK:>
Python Code:
PROJECT_DIR = os.path.dirname(dotenv_path)
RAW_DATA_DIR = PROJECT_DIR + os.environ.get("RAW_DATA_DIR")
INTERIM_DATA_DIR = PROJECT_DIR + os.environ.get("INTERIM_DATA_DIR")
files=os.environ.get("FILES").split()
print("Project directory is : {0}".format(PROJECT_DIR))
print("Raw data directo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Importing pandas and matplotlib.pyplot
Step2: Reading a file in Pandas
Step3: Mental health conditions
Step4: Arthritis indicator itself is v... |
3,889 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import os
# TO USE A DATABASE OTHER THAN SQLITE, USE THIS LINE
# Note that this is necessary for parallel execution amongst other things...
# os.environ['SNORKELDB'] = 'postgres:///snorkel-intro'
from snorkel import SnorkelSession
sess... | <SYSTEM_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 Corpus
Step2: Running a CorpusParser
Step3: We can then use simple database queries (written in the syntax of SQLAlchemy, which Sn... |
3,890 | <ASSISTANT_TASK:>
Python Code:
from dolo import *
import numpy as np
import matplotlib.pyplot as plt
filename = ('https://raw.githubusercontent.com/EconForge/dolo/master/examples/models/rbc.yaml')
pcat(filename) # Print the model file
model = yaml_import(filename)
print(model)
dr_pert = approximate_controls(mod... | <SYSTEM_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 first thing we'll want to do is read, import, and check the steady state of the model object. Doing this with yaml_import, we'll be able to ... |
3,891 | <ASSISTANT_TASK:>
Python Code::
import cv2
import numpy as np
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
faces = face_cascade.detectMultiScale(image, 1.3, 5)
for (x,y, w, h) in faces:
start_point , end_point = (x, y), (x+w, y+h)
cv2.rectangle(image, pt1 = start_point, pt2 = end_point,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
3,892 | <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: Word embeddings
Step2: Download the IMDb Dataset
Step3: Take a look at the train/ directory. It has pos and neg folders with movie reviews lab... |
3,893 | <ASSISTANT_TASK:>
Python Code:
import suspect
import numpy as np
from matplotlib import pyplot as plt
%matplotlib nbagg
data = suspect.io.load_rda("/home/jovyan/suspect/tests/test_data/siemens/SVS_30.rda")
# create a parameters dictionary to set the basis set to use
params = {
"FILBAS": "/path/to/lcmodel/basis.BAS... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: LCModel
Step2: We can use some IPython magic to show the files that were created
Step3: and to look at the contents of the .CONTROL file
Step4... |
3,894 | <ASSISTANT_TASK:>
Python Code:
from quantopian.pipeline import CustomFactor
import numpy
class StdDev(CustomFactor):
def compute(self, today, asset_ids, out, values):
# Calculates the column-wise standard deviation, ignoring NaNs
out[:] = numpy.nanstd(values, axis=0)
def make_pipeline():
std_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: Next, let's define our custom factor to calculate the standard deviation over a trailing window using numpy.nanstd
Step2: Finally, let's instan... |
3,895 | <ASSISTANT_TASK:>
Python Code:
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import xarray as xr
# Any import of metpy will activate the accessors
import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.units import units
# Open the netCDF file as 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: Getting Data
Step2: Preparing Data
Step3: Units
Step4: WARNING
Step5: Indexing and Selecting Data
Step6: For full details on xarray indexin... |
3,896 | <ASSISTANT_TASK:>
Python Code:
import requests
from pprint import pprint
redirect_uri = 'https://not-a-real-site/authorized'
data = {
'client_name': 'Fake Research Application',
'redirect_uris': [redirect_uri],
'scope': 'launch/patient patient/*.read offline_access'
}
response = requests.post('https://porta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Launch the OAuth workflow
Step2: Collect the authorization code
Step3: Exchange for access token
Step4: Note
Step5: Now let's try the same r... |
3,897 | <ASSISTANT_TASK:>
Python Code:
import os, json, math
import numpy as np
import tensorflow as tf
from tensorflow.python.feature_column import feature_column_v2 as fc # This will change when Keras FeatureColumn is final.
from matplotlib import pyplot as plt
print("Tensorflow version " + tf.__version__)
tf.enable_eager_e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Colab-only auth
Step2: Config
Step3: Linear Keras model [WORK REQUIRED]
|
3,898 | <ASSISTANT_TASK:>
Python Code:
help('learning_lab.01_device_control')
from importlib import import_module
script = import_module('learning_lab.01_device_control')
from inspect import getsource
print(getsource(script.main))
print(getsource(script.demonstrate))
run ../learning_lab/01_device_control.py
from basics.odl_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementation
Step2: Execution
Step3: HTTP
|
3,899 | <ASSISTANT_TASK:>
Python Code:
from planet4 import io
db = io.DBManager()
data = db.get_all()
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
le.fit(data.user_name)
len(le.classes_)
data.user_name = le.transform(data.user_name)
le.transform(data.tail().user_name)
import pickle
folder = Path('/Users/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reversing name encoding
Step2: Find a certain user
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.