Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
1,700 | <ASSISTANT_TASK:>
Python Code:
2 + 2
32 - (4 + 2)**2
1 / 2
1.0 / 2
4.0 + 4**(3/2)
4.0 + 4.0**(3.0 / 2.0)
3+5j
import math
math.sqrt(4)
math.sin(math.pi / 2.0)
math.exp(-math.pi / 4.0)
from math import *
sin(pi / 2.0)
num_students = 80
room_capacity = 85
(room_capacity - num_students) / room_capacity * 100.0
floa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Why do we get the answer above rather than what we would expect?
Step2: Note that Python will make the output a float in this case. What happe... |
1,701 | <ASSISTANT_TASK:>
Python Code:
for a in spot.automata('ltl2tgba -s "a U b"; ltl2tgba --lbtt "b"|', 'ltl2tgba -H "GFa" "a & GFb"|'):
display(a)
spot.automaton('ltl2tgba -s6 "a U b"|')
spot.automaton('non-existing-command|')
for a in spot.automata("ltl2tgba 'a U b'|", 'ltl2tgba "syntax U U error"|'):
display(a)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A single automaton can be read using spot.automaton(), with the same convention.
Step2: Error handling
Step3: Reading an empty file with spot.... |
1,702 | <ASSISTANT_TASK:>
Python Code:
import sklearn as sk
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn .datasets import fetch_olivetti_faces
faces = fetch_olivetti_faces()
faces.DESCR
faces.keys()
faces.images.shape
faces.data.shape
faces.target.shape
np.max(faces.data)
np.min(faces.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: Naive Bayes Using Scikit_Lerarn
Step2: Pre-Processing The Data
|
1,703 | <ASSISTANT_TASK:>
Python Code:
# the output of plotting commands is displayed inline within frontends,
# directly below the code cell that produced it
%matplotlib inline
from time import time
# this python library provides generic shallow (copy)
# and deep copy (deepcopy) operations
from copy import deepcopy
# impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Twiss parameters with and without coupler kick
Step2: Trajectories with Coupler Kick
Step3: Horizantal and vertical emittances
Step4: Trackin... |
1,704 | <ASSISTANT_TASK:>
Python Code:
# code for loading the format for the notebook
import os
# path : store the current path to convert back to it later
path = os.getcwd()
os.chdir(os.path.join('..', '..', 'notebook_format'))
from formats import load_style
load_style(css_style = 'custom2.css', plot_style = False)
os.chdir(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:
Step2: Gradient Boosting Machine (GBM)
Step4: Clearly, Gradient Boosting has some similarities to Random Forests and Extra Trees
Step6: But the way t... |
1,705 | <ASSISTANT_TASK:>
Python Code:
UnitPrice = [38.94, 208.16, 8.69, 195.99]
Shipping = [35, 68.02, 2.99, 3.99, 5.94, 4.95, 7.72, 6.22]
names=['Xue', 'Mary', 'Bob']
Oscars = [
[1984, "A Soldier's Story", 0],
[1984, 'Places in the Heart', 0],
[1984, 'The Killing Fields', 0],
[1984, 'A Passage to India', 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: Accumulate
Step2: We can use any other arithmetic operator we want, such as *. In fact, we can use any function that takes two operands and ret... |
1,706 | <ASSISTANT_TASK:>
Python Code:
from itertools import repeat
from sympy import *
#from type_system import *
%run ../../src/commons.py
%run ./type-system.py
init_printing()
x,y,m,n,t,z = symbols('x y m n t z', commutative=True)
alpha, beta, gamma, eta = symbols(r'\alpha \beta \gamma \eta', commutative=True)
f,g = Functi... | <SYSTEM_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:
|
1,707 | <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: Autoencoders
Step2: Each image in the dataset is 28 x 28 pixels. Let's flatten each to a 1-dimensional vector of length 784.
Step3: Autoencode... |
1,708 | <ASSISTANT_TASK:>
Python Code:
import mne
import os.path as op
from matplotlib import pyplot as plt
data_path = op.join(mne.datasets.sample.data_path(), 'MEG',
'sample', 'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(data_path, preload=True)
raw.set_eeg_reference('average', projection=True) # ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loading continuous data
Step2: <div class="alert alert-info"><h4>Note</h4><p>This size can also be obtained by examining `raw._data.shape`.
Ste... |
1,709 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import os,site
import glob
import h5py
from IPython.display import Image
import numpy as np
from matplotlib import pyplot as plt
#
# add the lib folder to the path assuming it is on the same
# level as the notebooks folder
#
libdir=os.path.abspath('..... | <SYSTEM_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 glob function finds a file using a wildcard to save typing (google
Step2: Read the radiance data from MODIS_SWATH_Type_L1B/Data Fields/EV_1... |
1,710 | <ASSISTANT_TASK:>
Python Code:
# Make plots inline
%matplotlib inline
# Make inline plots vector graphics instead of raster graphics
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('pdf', 'svg')
# import modules for plotting and data analysis
import matplotlib.pyplot as plt
import numpy as 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: Now, we'll tackle the "function in time" part of this model by learning how to make and use arrays to represent time.
Step2: We can assign time... |
1,711 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import num... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
1,712 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn import datasets
lfw_people = datasets.fetch_lfw_people(min_faces_per_person=70, resize=0.4,
data_home='datasets')
lfw_people.data.shape
fig = plt.figure(figsize=(8, 6))
# plot several ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using PCA to extract features
Step2: Let's visualize these faces to see what we're working with
Step3: We'll do a typical train-test split on ... |
1,713 | <ASSISTANT_TASK:>
Python Code:
file = 'sample_report.txt' #Sample Radiology report from MIMIC-III dataset
report = ''
with open(file,'r') as f:
report += f.read()
print(report[:1000])
# Here is a pipeline provided in the fcFinder module
# A custom function can be made by the user
# This section will walk through 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: Document Classification
Step2: Output
Step4: Example of how to expand
|
1,714 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(10, 4), columns=['A', 'B', 'C', 'D'])
df2 = pd.DataFrame(np.random.randn(7, 3), columns=['A', 'B', 'C'])
sum_df = df + df2
sum_df
np.transpose(sum_df.values)
A_df = pd.DataFrame(np.arange(15).reshape((3,5)))
B_df =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NaN are handled correctly by universal function
Step2: dot method on DataFrame implements matrix multiplication
Step3: dot method on Series im... |
1,715 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
pickle_file = 'notMNIST.pickle... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First reload the data we generated in 1_notmnist.ipynb.
Step2: Reformat into a shape that's more adapted to the models we're going to train
Ste... |
1,716 | <ASSISTANT_TASK:>
Python Code:
# Other Imports.
from simple_rl.tasks import NavigationWorldMDP
from simple_rl.agents import QLearningAgent
from simple_rl.planning import ValueIteration
from simple_rl.tasks.grid_world.GridWorldStateClass import GridWorldState
from simple_rl.tasks.navigation.NavigationStateClass import N... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Features used for short horizon
Step2: Features used for long horizon
Step3: Multiple Goals
Step4: Custom Grid
Step5: Updating Goals dynamic... |
1,717 | <ASSISTANT_TASK:>
Python Code:
import pandas
pandas.options.display.max_rows = 100
import cobra.test
model = cobra.test.create_test_model("textbook")
model.optimize()
model.solution.status
model.solution.f
model.objective
# change the objective to ATPM
# the upper bound should be 1000 so we get the actual optimal 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: Running FBA
Step2: The Model.optimize() function will return a Solution object, which will also be stored at model.solution. A solution object ... |
1,718 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas
import glob
FILES = glob.glob('/x/home/kurose/*_srv.csv')
Expected format is comma-separated, floating-point pairs ("timestamp, latency").
1459452334.73, 0.00141596794128
1459452334.83, 0.00196099281311
1459452334.93, 0.00141191482544
...
import os.path
im... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Server Performance - Before and After
Step2: Error rate (percentage response times > 20ms)
Step3: Percentiles
Step4: Server Pauses
Step5: Th... |
1,719 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
USE_COLAB = False
if not USE_COLAB:
plt.rc("text", usetex=True)
import numpy as np
C = 10
alpha = -0.5
q = 0.9
num_iter = 7
sublinear = np.array([C * k**alpha for k in range(1, num_iter + 1)])
linear = np.array([C * q**k for k in rang... | <SYSTEM_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, $\S$ 6)
Step2: Метод золотого сечения
Step3: Сравнение методов одномерно... |
1,720 | <ASSISTANT_TASK:>
Python Code:
import os
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if os.getenv("IS_TESTING"):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Note
Step3: Restart the kernel
Step4: Set your project ID
Step5... |
1,721 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Forward and Backward mode gradients in TFF
Step2: This notebook demonstrates the difference between forward and backward gradient computation
S... |
1,722 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import h5py, os, osr, copy
%matplotlib inline
pwd
cd hyperspectral
from neon_aop_hyperspectral import *
%whos
help(aop_h5refl2array)
#h5_tile = ('../../../data/NEON_D16_MCRA_DP3_566300_4901000_reflectance.h5')
h5_tile = ('../../../... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Use pwd (print working directory) to see what directory we're currently in.
Step2: For this tutorial to run we need to be in the hyperspectral ... |
1,723 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
init_printing()
tnew_x = Symbol('T^{i+1}_x')
tnew_xprev = Symbol('T^{i+1}_{x-1}')
tnew_xafter = Symbol('T^{i+1}_{x+1}')
told_x = Symbol('T^{i}_x')
told_xprev = Symbol('T^{i}_{x-1}')
told_xafter = Symbol('T^{i}_{x+1}')
u_x = Symbol('\kappa_x')
u_xprev = Symbol('\kappa_{... | <SYSTEM_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 coefficients for the $i+1$ temperature (predicted) are
Step2: The coefficients for the $i$ temperature (current) are
|
1,724 | <ASSISTANT_TASK:>
Python Code:
import unittest
def run_tests():
suite = unittest.TestLoader().loadTestsFromTestCase(TestFibonacci)
unittest.TextTestRunner().run(suite)
class TestFibonacci(unittest.TestCase):
def test_fibonacci(self):
self.assertEqual(0, fibonacci(0), "fibonacci(0) should equal 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: Step 1
Step2: Step 1
Step3: Step 2
Step4: Step 2
Step5: Step 3
Step6: Step 3
Step7: Step 4
Step8: Step 5
Step9: Step 5
Step10: Pause
St... |
1,725 | <ASSISTANT_TASK:>
Python Code:
import pandas.io.data
?pandas.io.data # <tab>
import datetime
print(datetime.datetime(2010,1,1))
start = pd.to_datetime('2010-1-1')
end = datetime.datetime(2015,1,1)
ticker_symbols = ['WTI','CHK','TSLA','CBAK']
wti = pd.io.data.get_data_yahoo(ticker_symbols[0],start=start,end=end)
wti.h... | <SYSTEM_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 there’s a lot of volatility in oil right now. It’s been rough for producers to say the least. So let’s check out some stocks that are involv... |
1,726 | <ASSISTANT_TASK:>
Python Code:
import os
from google.cloud import bigquery
import pandas as pd
%load_ext google.cloud.bigquery
PROJECT = # Replace with your PROJECT
BUCKET = PROJECT
REGION = "us-east1"
os.environ['PROJECT'] = PROJECT
os.environ['BUCKET'] = BUCKET
os.environ['REGION'] = REGION
%%bigquery --project $... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Replace the variable values in the cell below
Step2: Create a Dataset from BigQuery
Step3: Let's do some regular expression parsing in BigQuer... |
1,727 | <ASSISTANT_TASK:>
Python Code:
from datascience import *
from client.api.assignment import load_assignment
tests = load_assignment('lab02.ok')
new_year = ...
new_year
_ = tests.grade('q11')
print("I <3", 'Data Science')
woman_asking = ...
woman_quote = '"Can it be that you have come from outer space?"'
gagarin_rep... | <SYSTEM_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. Review
Step2: Check your work by executing the next cell.
Step3: 2. Text
Step4: print prints all of its arguments together, separated by s... |
1,728 | <ASSISTANT_TASK:>
Python Code:
from os.path import join
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data_fname = r"../data_staging/all_by_baby_enriched_v3.csv"
df = pd.read_csv(data_fname)
all = pd.concat([df.t1_ga_weeks, df.t2_ga_weeks, df.t3_ga_weeks])
all.dropna(inplace=True)
print all.de... | <SYSTEM_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, have a look at the distribution of gestational ages, as this might determine which buckets we use.
Step2: Investigate the pappa distribu... |
1,729 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import BoundaryNorm
from matplotlib.ticker import MaxNLocator
from fatiando import gridder, utils
from fatiando.gravmag import sphere
from fatiando.mesher import Sphere
import oblate_ellipsoi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set some parameters for modelling
Step2: Oblate ellipsoid versus sphere
Step3: Sphere
Step4: Total-field anomalies
Step5: Field components
|
1,730 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis A. Engemann <denis.engemann@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import mne
from mne import io
from mne.time_frequency import tfr_stockwell
from mne.datasets import somato
print(__doc__)
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: Set parameters
Step2: Calculate power and intertrial coherence
|
1,731 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import numpy.linalg as la
import mpnum as mp
rng = np.random.RandomState(seed=42)
mpa = mp.random_mpa(sites=4, ldim=2, rank=3, randstate=rng, normalized=True)
mpa
len(mpa)
mpa.ndims
mpa.shape
mpa.ranks
mp.norm(mpa)
arr = mpa.to_array()
arr.shape
mpa2 = mp.MPArr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: MPA and MPS basics
Step2: The MPA is an instance of the MPArray class
Step3: Number of sites
Step4: Number of physical legs at each site (=nu... |
1,732 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import mne
from mne.datasets import sample
data_path = sample.data_path()
raw_empty_room_fname = op.join(
data_path, 'MEG', 'sample', 'ernoise_raw.fif')
raw_empty_room = mne.io.read_raw_fif(raw_empty_room_fname)
raw_fname = op.join(data_path, 'MEG', 'sample', 'sa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Source estimation method such as MNE require a noise estimations from the
Step2: The definition of noise depends on the paradigm. In MEG it is ... |
1,733 | <ASSISTANT_TASK:>
Python Code:
import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pysal as ps
import seaborn as sns
from scipy.stats import stats
np.random.seed(0)
# load CA tracts, display shape
tracts_ca = gpd.read_file('../../data/tl_2017_06_tract/')
tracts_ca = tr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Data prep
Step2: 1.2. California tract-level census variables
Step3: 1.3. Merge the data
Step4: 2. Initial exploration
Step5: Looks like ... |
1,734 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
DON'T MODIFY AN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 语言翻译
Step3: 探索数据
Step6: 实现预处理函数
Step8: 预处理所有数据并保存
Step10: 检查点
Step12: 检查 TensorFlow 版本,确认可访问 GPU
Step15: 构建神经网络
Step18: 处理解码输入
Step21: 编... |
1,735 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.random.seed(0)
r_old = np.random.randint(3, size=(100, 2000)) - 1
np.random.seed(0)
r_new = np.random.randint(3, size=(100, 2000)) - 1
<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:
|
1,736 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import time
import pylab
import numpy as np
import pandas as pd
import seaborn as sns
sns.set_style('white')
from pysurvey.plot import setup_sns as setup
from pysurvey.plot import density, icolorbar, text, legend, outline
people = pd.read_csv('/Users/ajmendez/data/okcup... | <SYSTEM_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 match percentage distribution peaks near ~75%, but differences are hard to see.
Step2: Additionally, there is a decreasing number of users... |
1,737 | <ASSISTANT_TASK:>
Python Code:
import numpy as np # importing this way allows us to refer to numpy as np
mylist = [1., 2., 3., 4.]
mynparray = np.array(mylist)
mynparray
one_vector = np.ones(4)
print one_vector # using print removes the array() portion
one2Darray = np.ones((2, 4)) # an 2D array with 2 "rows" and 4 "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: Creating Numpy Arrays
Step2: You can initialize an array (of any dimension) of all ones or all zeroes with the ones() and zeros() functions
Ste... |
1,738 | <ASSISTANT_TASK:>
Python Code:
# Author: Luke Bloy <luke.bloy@gmail.com>
# Alex Gramfort <alexandre.gramfort@inria.fr>
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.minimum_norm import read_inverse_operator, apply_inverse
from mne.datasets import sample
print(__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: plot the time courses....
Step2: plot brain in 3D with mne.viz.Brain if available
|
1,739 | <ASSISTANT_TASK:>
Python Code:
from numpy import array, dot, outer, sqrt, matrix
from numpy.linalg import eig, eigvals
from matplotlib.pyplot import hist
%matplotlib inline
rv = array([1,2]) # a row vector
rv
cv = array([[3],[4]]) # a column vector
cv
rv
dot(rv,cv)
dot(cv,rv)
outer(rv,cv)
outer(cv,rv)
# Complex nu... | <SYSTEM_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 kinds of vector products we'll see
Step2: 2) Use the function outer(vector1, vector2) to find the outer product of rv and cv. Does the orde... |
1,740 | <ASSISTANT_TASK:>
Python Code:
import rebound
import numpy as np
sim = rebound.Simulation()
sim.add(m=1)
sim.add(m=1e-5, a=1,e=0.1,omega=0.25)
sim.add(m=1e-5, a=1.757)
sim.move_to_com()
N=174
transittimes = np.zeros(N)
p = sim.particles
i = 0
while i<N:
y_old = p[1].y - p[0].y # (Thanks to David Martin for 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:
Step1: Let's set up a coplanar two planet system.
Step2: We're now going to integrate the system forward in time. We assume the observer of the system... |
1,741 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
assert os.path.isfile('yearssn.dat')
data = np.loadtxt('yearssn.dat','float')
year = np.array(range(len(data)),'float')
ssc = np.array(range(len(data)),'float')
for x in range(len(data)):
year[x] = 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: Line plot of sunspot data
Step2: Use np.loadtxt to read the data into a NumPy array called data. Then create two new 1d NumPy arrays named year... |
1,742 | <ASSISTANT_TASK:>
Python Code:
client = pymongo.MongoClient("46.101.236.181")
db = client.allfake
# get collection names
collections = sorted([collection for collection in db.collection_names()])
day = {} # number of tweets per day per collection
diff = {} # cumullative diffusion on day per colletion
for collection in... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Count number of tweets per day for every news, calculate cummulative diffusion
Step2: Plot diffusion for every day for all news together
Step3:... |
1,743 | <ASSISTANT_TASK:>
Python Code:
from google.cloud import bigquery
from timeit import default_timer as timer
from datetime import timedelta
def show_query(query):
client = bigquery.Client()
query_job = client.query(query, bigquery.job.QueryJobConfig(use_query_cache=False))
df = query_job.result().to_dataframe... | <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: This query finds the average prescription claim by state.
Step4: This query finds the average tip based on payment type.
Step6: This query use... |
1,744 | <ASSISTANT_TASK:>
Python Code:
file = build_smarts_file(
**astmg_173_03_m
)
data = send_to_smarts(file)
plt.plot(data.iloc[:,0],data.iloc[:,1],hold=True)
plt.plot(data.iloc[:,0],data.iloc[:,4])
plt.show()
data.columns
ill=Illumination("AM1.5d")
x,y=ill.get_spectrum("nm")
plt.plot(x,y,hold=True,label="AM1.5d")
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Compare the results between standard AM1.5d and the SMARTS-generated spectrum
|
1,745 | <ASSISTANT_TASK:>
Python Code:
import requests
import lxml
import pandas as pd
import numpy as np
from bs4 import BeautifulSoup
wiki_page = requests.get('https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M').text
soup = BeautifulSoup(wiki_page, 'lxml')
table = soup.find('table')
# table
toronto_table = soup... | <SYSTEM_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 2 - Adding Latitude and Longitude
Step2: Part 3 - Clustering
Step3: Above plots shows the regions in Toronto. However the clusters are no... |
1,746 | <ASSISTANT_TASK:>
Python Code:
print(__doc__)
import numpy as np
from skopt import BayesSearchCV
from sklearn.datasets import load_digits
from sklearn.svm import SVC
from sklearn.model_selection import train_test_split
X, y = load_digits(10, True)
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=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: Minimal example
Step2: Advanced example
Step3: Progress monitoring and control using callback argument of fit method
Step4: Counting total it... |
1,747 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import display, HTML
from meta import (
define_website,
video_map,
keys,
url,
)
define_website
# from a package I wrote: https://github.com/dm-wyncode/pynotebook-youtube-editor
from youtube_editor.youtube_editor import (
get_embed_string_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: static versus dynamic websites
|
1,748 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-3', 'landice')
# 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... |
1,749 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
pd.set_option("display.max_rows",1000) # or pd.options.display.max_rows=1000
pd.set_option("display.max_columns",20) # or pd.options.display.max_columns=20
pd.set_option('precision',7)
pd.set_option('large_repr', 'truncate')
import pandas as pd
data = pd.DataFra... | <SYSTEM_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="quick_summary">
Step2: df.info() shows data types, number of rows and columns, and memory usage of your data frame
Step3: <a id='sortin... |
1,750 | <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: Use XLA with tf.function
Step2: Then define some necessary constants and prepare the MNIST dataset.
Step3: Finally, define the model and the o... |
1,751 | <ASSISTANT_TASK:>
Python Code:
def interval_point(a, b, x):
if a < b:
return (b-a)*x + a
else:
return a - (a-b)*x
interval_point(0, 1, 0.5)
interval_point(3, 2, 0.2)
while True:
try:
x = float(raw_input("Please type a new number: "))
inverse = 1.0 / x
print("The inv... | <SYSTEM_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: 해야 할 일 1 (5점)
Step3: 해야 할 일 2 (10점)
Step4: 또한 print_line_sum_of_file을 예를 들어 다음과 같이 작성할 수 있다.
Step5: 위 함수를 이전에 작성한 예제 파일에 적용하면 예... |
1,752 | <ASSISTANT_TASK:>
Python Code:
True and True
True or False
bool(1)
bool(0)
a = None
a is None
b = 'is something'
b is not None
a = 4
if a > 0:
print('more than 0')
if a <= 0:
print('0 or less')
elif a > 0 and a < 10:
print('more than zero, less than 10')
else:
print('something else')
<statement if 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: None
Step2: Control Flow
Step3: There is also a single line version
Step4: for loop
Step5: The Python for loop as a different semantic
Step6... |
1,753 | <ASSISTANT_TASK:>
Python Code:
%run appendix-A/simple01.py
a = [1, 2, 3]
b = a
a.append(4)
print(a)
print(b)
def append_element(fanglist, element):
fanglist.append(element)
data = [1,2,3]
append_element(data, 5)
print(data)
a = 5
type(a)
a = 2.5
type(a)
a = 'hello'
b = 5
print('a is %s, and b is %s' % (type(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: 基础知识
Step2: 用小卡特的爹(好吧,这其实是某本python书的作者,但是我实在想不起来名字了)的话就是:相当于把a和b都贴在了[1,2,3]这个上面,上面a.append[4]之后,相当于把又贴在了[1,2,3,4]上面,因为b是贴在a上的,所以b的值也被改变,成为了[1,2... |
1,754 | <ASSISTANT_TASK:>
Python Code:
s = 'abc' # строка
s = "abc" # тоже строка
n = 2 # int
n = 3.5 # float
l = [] # пустой список
l = [1, 2, 3] # тоже список, но с числами
l = ['a', 1, None] # разные типы в одном списке
t = (1,) # кортеж с одним элементом (не забудьте про запятую!)
d = {} # пустой словарь
d = {'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: Список - непрерывный кусок памяти!
Step2: Методы самого списка
Step3: Строки, списки, срезы
Step4: Разделение - объединение
Step5: Попробуе... |
1,755 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import rcParams
import matplotlib.pyplot as plt
%matplotlib inline
rcParams['figure.figsize'] = (13, 6)
plt.style.use('ggplot')
from nilmtk import DataSet
redd = DataSet('/data/REDD/redd.h5')
elec = redd.buildings[1].elec
elec
elec.nested_metergroups()
elec.mains()
elec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note that there are two nested MeterGroups
Step2: Putting these meters into a MeterGroup allows us to easily sum together the power demand reco... |
1,756 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt # import the plotting module
%matplotlib inline
# This allows us to plot in the notebook environment
thetas=np.arange(0,180,1) # makes an array of thetas from 0 to 180 at 1 degree increments.
Es=np.cos(np.radians(thetas)) # replace ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Write your equation for magnetic energy in words (and Latex) here.
Step2: Problem 1b
|
1,757 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
from sklearn.svm import SVC
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
import numpy as np
#Load data with only two classes
iris = datasets.load_iris()
X = iris.data[:100,:]
y = iris.target[:100]
# Make class highly imbalanced by removi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Iris Flower Dataset
Step2: Imbalanced Iris Flower Classes
Step3: Standardize Features
Step4: Train Support Vector Classifier With Weight... |
1,758 | <ASSISTANT_TASK:>
Python Code:
#$HIDE_INPUT$
from google.cloud import bigquery
# Create a "Client" object
client = bigquery.Client()
# Construct a reference to the "github_repos" dataset
dataset_ref = client.dataset("github_repos", project="bigquery-public-data")
# API request - fetch the dataset
dataset = client.get_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: The second table is the sample_files table, which provides, among other information, the GitHub repo that each file belongs to (in the repo_name... |
1,759 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import calin.math.geometry
import calin.math.hex_array
import calin.simulation.vs_optics
import calin.simulation.ray_processor
def dms(d,m,s):
# Note this function fails for "negative" d=0 (e.g. -00:30:00)
sign = 1
if(d<0):
sign = -1
d = abs(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: 2. Define telescope properties for ray tracer and construct array
Step2: 3. Construct PE imager and ray procesor
Step3: 4. Construct ray gener... |
1,760 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
from scipy import integrate
import matplotlib.pyplot as plt
%matplotlib inline
class Panel:
# Initialisiert ein Objekt der Klasse Panel
def __init__(self, ax, ay, bx, by, lamb=0):
# Panel-Stärke lambda
self.lamb = lamb
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Zeit, das Ganze mal grafisch darzustellen. Wir erzeugen zunächst ein Objekt der Klasse Panel mit dem Namen panel1, den Eckpunkten $a=(0,-2)$ und... |
1,761 | <ASSISTANT_TASK:>
Python Code:
# Put your code here, using additional cells if necessary.
# Put your code here, using additional cells if necessary.
from IPython.display import HTML
HTML(
<iframe
src="https://goo.gl/forms/M7YCyE1OLzyOK7gH3?embedded=true"
width="80%"
height="1200px"
frameborder="0"
marginhei... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Function 2
Step3: Assignment wrapup
|
1,762 | <ASSISTANT_TASK:>
Python Code:
texts = [
"Penny bought bright blue fishes.",
"Penny bought bright blue and orange fish.",
"The cat ate a fish at the store.",
"Penny went to the store. Penny ate a bug. Penny saw a fish.",
"It meowed once at the bug, it is still meowing at the bug and the fish",
"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: When you process text, you have a nice long series of steps, but let's say you're interested in three things
Step2: The scikit-learn package do... |
1,763 | <ASSISTANT_TASK:>
Python Code:
from pybaseball import schedule_and_record
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
yankees = schedule_and_record(1927, 'NYY')
reds = schedule_and_record(1976, 'CIN')
mariners = schedule_and_record(2001, 'SEA')
mariners.describe()
reds.describe()
yankees.desc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Summary Statistics
Step2: Next let's take a look at their records and runs.
Step3: Last let's take a look at score differential
|
1,764 | <ASSISTANT_TASK:>
Python Code:
mod = pysces.model('lin4_fb.psc')
rc = psctb.RateChar(mod)
rc = psctb.RateChar(mod,min_concrange_factor=100,
max_concrange_factor=100,
scan_points=255,
auto_load=False)
mod.species
rc.do_ratechar()
rc.do_ratechar(fixed=['S1','... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Default parameter scan settings relating to a specific RateChar session can also be specified during instantiation
Step2: min_concrange_factor ... |
1,765 | <ASSISTANT_TASK:>
Python Code:
import time
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
from sklearn import preprocessing
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_validation import StratifiedShuffleSplit
from sklearn.cross_validation import 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: <h2> Import the dataframe and remove any features that are all zero </h2>
Step2: <h2> Get mappings between sample names, file names, and sample... |
1,766 | <ASSISTANT_TASK:>
Python Code:
# To use GraphLab Create within PySpark, you need to set the $SPARK_HOME and $PYTHONPATH
# environment variables on the driver. A common usage:
!export SPARK_HOME="your-spark-home-dir"
!export PYTHONPATH=$SPARK_HOME/python/:$SPARK_HOME/python/lib/py4j-0.8.2.1-src.zip:$PYTHONPATH
import g... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 2
Step2: Now that we have the SparkContext setup, let's download the Wikipedia data as an RDD. For this notebook we will only use a subset... |
1,767 | <ASSISTANT_TASK:>
Python Code:
# Import Numpy, TensorFlow, TFLearn, and MNIST data
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
# Retrieve the training and test data
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
# Visualizing the data
import matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Retrieving training and test data
Step2: Visualize the training data
Step3: Building the network
Step4: Training the network
Step5: Testing
|
1,768 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
data_path = "data/Advertising.csv"
# or load the dataset directly from the link
# # data_link = "http://www-bcf.usc.edu/~gareth/ISL/Advertising.csv"
data = pd.read_csv(data_path, index_col=0)
# display the first 5 rows
data.head()
import seaborn as ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Visualizing data
Step2: Form of linear regression
Step3: The Learned Linear Function is
Step4: Model evaluation metrics for regression
Step5:... |
1,769 | <ASSISTANT_TASK:>
Python Code:
try:
import tinygp
except ImportError:
%pip install -q tinygp
try:
import optax
except ImportError:
%pip install -q optax
import tinygp
import jax
import jax.numpy as jnp
class SpectralMixture(tinygp.kernels.Kernel):
def __init__(self, weight, scale, freq):
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: Now let's implement the simulate some data from this model
Step2: One thing to note here is that we've used named parameters in a dictionary, ... |
1,770 | <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_cb = phoebe.default_binary(contact_binary=True)
b_detached = phoebe.default_binary()
print(b_detached.hierarch... | <SYSTEM_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: Here we'll initialize a d... |
1,771 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from torchvision import datasets
import torch
import torch.nn as nn
import torch.optim as optim
train_data = datasets.FashionMNIST('data', download=True, train=True)
# we need FloatTensors as input
train_X = train_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: Preparing the dataset
Step2: IMPORTANT
Step3: Understanding the sizes of the data
Step4: Are the classes equally distributed?
Step5: Flatten... |
1,772 | <ASSISTANT_TASK:>
Python Code:
from landlab import RasterModelGrid
import numpy as np
from matplotlib.pyplot import show
%matplotlib inline
mg = RasterModelGrid((10, 10))
min_x = 2.5
max_x = 5.0
min_y = 3.5
max_y = 7.5
x_condition = np.logical_and(mg.x_of_node < max_x, mg.x_of_node > min_x)
y_condition = np.logical_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: Known coordinates of rectangle
Step2: Define the area inside x and y coordinates
Step3: Define boundaries as CLOSED
Step4: Make a new elevati... |
1,773 | <ASSISTANT_TASK:>
Python Code:
import os, math, time, pickle, subprocess
from importlib import reload
from collections import OrderedDict
import numpy as np
import pandas as pd
pd.set_option('display.width', 100)
import epitopepredict as ep
from epitopepredict import base, sequtils, plotting, peptutils, analysis
from 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: Alleles
Step2: Filtering with MTB srm data
Step3: Predict binders
Step4: Compute clusters of promiscuous binders
Step5: overlapping clusters... |
1,774 | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
from starthinker.util.configuration import Configuration
CONFIG = Configuration(
project="",
client={},
service={},
user="/content/user.json",
verbose=True
)
FIELDS = {
'auth_write':'service', # Credentials used for wri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Set Configuration
Step2: 3. Enter Storage Bucket Recipe Parameters
Step3: 4. Execute Storage Bucket
|
1,775 | <ASSISTANT_TASK:>
Python Code:
import xarray as xr
from cotede.qc import ProfileQC
ds = xr.open_dataset('saildrone-antarctica.nc')
ds.attrs['Conventions']
ds.attrs['featureType']
list(ds.keys())
print(ds["SAL_MEAN"])
print("====")
print(ds["TEMP_CTD_MEAN"])
tsg = ds[['TEMP_CTD_MEAN', 'SAL_MEAN']]
tsg
tsg = tsg.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, learn about the data
Step2: Let's learn about this dataset, starting from the attributes.
Step3: Great, it follows the CF and ACDD conv... |
1,776 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'ec-earth3-cc', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_con... | <SYSTEM_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... |
1,777 | <ASSISTANT_TASK:>
Python Code:
r'''<pre>
+----------------------------------------------------------------------------+
|
key | types | occurrences | percents |
| ---------------------- | -------- | ----------- | ------------------------ |
| _id | ObjectId | ... | <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: Other ideas about the datasets
Step3: Now that we have sample files let me try and understand exactly what kind of data we have in our tags
Ste... |
1,778 | <ASSISTANT_TASK:>
Python Code:
import datetime as dt
import os
import time
from cltk.corpus.greek.tlg.parse_tlg_indices import get_epithet_index
from cltk.corpus.greek.tlg.parse_tlg_indices import get_epithets
from cltk.corpus.greek.tlg.parse_tlg_indices import select_authors_by_epithet
from cltk.corpus.greek.tlg.parse... | <SYSTEM_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 model
Step2: Questions
Step3: Now let's look at the variations of the respective clusters, nmf topic and epithets
Step4: Visualize topic ... |
1,779 | <ASSISTANT_TASK:>
Python Code:
import requests
from bs4 import BeautifulSoup
url = "http://www.epicurious.com/search/Tofu Chili"
response = requests.get(url)
if response.status_code == 200:
print("Success")
else:
print("Failure")
keywords = input("Please enter the things you want to see in a recipe")
url = "ht... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h3>The http request response cycle</h3>
Step2: <h3>Set up the BeautifulSoup object</h3>
Step3: <h3>BS4 functions</h3>
Step4: <h4>find finds ... |
1,780 | <ASSISTANT_TASK:>
Python Code:
import torch
import torch.nn as nn
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv('../Data/NYCTaxiFares.csv')
df.head()
df['fare_class'].value_counts()
def haversine_distance(df, lat1, long1, lat2, long2):
Calculates 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: Load the NYC Taxi Fares dataset
Step3: Conveniently, 2/3 of the data have fares under \$10, and 1/3 have fares \$10 and above.
Step4: Add a da... |
1,781 | <ASSISTANT_TASK:>
Python Code:
pwcnet_train.ipynb
PWC-Net model training.
Written by Phil Ferriere
Licensed under the MIT License (see LICENSE for details)
Tensorboard:
[win] tensorboard --logdir=E:\\repos\\tf-optflow\\tfoptflow\\pwcnet-lg-6-2-cyclic-chairsthingsmix
[ubu] tensorboard --logdir=/media/EDrive/repo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: PWC-Net-large model training (with cyclical learning rate schedule)
Step2: TODO
Step3: Pre-train on FlyingChairs+FlyingThings3DHalfRes mix
Ste... |
1,782 | <ASSISTANT_TASK:>
Python Code:
# These are the libraries will be used for this lab.
import numpy as np
import matplotlib.pyplot as plt
# The class for plotting
class plot_diagram():
# Constructor
def __init__(self, X, Y, w, stop, go = False):
start = w.data
self.error = []
self.par... | <SYSTEM_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 class <code>plot_diagram</code> helps us to visualize the data space and the parameter space during training and has nothing to do with PyTo... |
1,783 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
vgg_dir = 'tensorflow_vgg/'
# Make sure vgg exists
if not isdir(vgg_dir):
raise Exception("VGG directory doesn't exist!")
class DLProgress(tqdm):
last_block = 0
def hook(self, block_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Flower power
Step2: ConvNet Codes
Step3: Below I'm running images through the VGG network in batches.
Step4: Building the Classifier
Step5: ... |
1,784 | <ASSISTANT_TASK:>
Python Code:
ano_eleicao = '2018'
dbschema = f'rede{ano_eleicao}'
dbschema_tse = f'tse{ano_eleicao}'
table_receitas = f'{dbschema}.receitas_{ano_eleicao}'
table_receitas_candidatos = f'{dbschema_tse}.receitas_candidatos_{ano_eleicao}'
table_receitas_candidatos_doador_originario = f'{dbschema_tse}.rece... | <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: ATUALIZA SIGLA ORIGEM DAS RECEITAS
Step4: ATUALIZA DESCRIÇÃO E CÓDIGO DA FONTE DA RECEITA
Step6: ATUALIZA UF DO DOADOR
Step8: ATUALIZA SIGLA/... |
1,785 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'snu', 'sandbox-3', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
1,786 | <ASSISTANT_TASK:>
Python Code:
# Example: We're going to use Pandas dataframes to create a gradebook for this course
import pandas as pd
# Student Rosters:
section_1_students = ['Hao', 'Jennifer', 'Alex']
section_2_students = ['Christa', 'Troy', 'Xin']
# Gradebook columns:
columns = ['raw_grade', 'did_extra_credit', '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: Copying and pasting code can introduce bugs
Step2: Why write functions?
Step4: Mechanics of Writing a Function
Step5: Variable names and scop... |
1,787 | <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: The Jordan-Wigner and Bravyi-Kitaev Transforms
Step2: Ladder operators and the canonical anticommutation relations
Step3: The parity transform... |
1,788 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2018 The TensorFlow 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-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: A simple classification model using Keras with Cloud TPUs
Step2: Resolve TPU Address
Step3: FLAGS used as model params
Step5: Download traini... |
1,789 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import time
import os
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import fits
import drizzlepac
import grizli
import glob
from grizli import utils
import importlib
from grizli.prep import process_direct_grism_visit
from hsaquery import query, over... | <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 results of this notebook are available for download on the team archive (Prep_premade_GS1.tar.gz)
Step3: <h1><center>Contamination models</... |
1,790 | <ASSISTANT_TASK:>
Python Code:
prices = {
'ACME': 45.23,
'AAPL': 612.78,
'IBM': 205.55,
'HPQ': 37.20,
'FB': 10.75
}
# Make a dictionary of all prices over 200
p1 = {key: value for key, value in prices.items() if value > 200}
# Make a dictionary of tech stocks
tech_names = {'AAPL', 'IBM', 'HPQ', 'MSF... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 大多数情况下 字典推导能做到的,可通过创建一个元组sequence 然后将之传至 dict() func 也可
Step2: but 字典推导表达意思更加清晰 同时 运行速度更快(近一倍)<br>同时 第二个例子程序 可重写
Step3: 上述两行推导 -- '&' 与 'and' ... |
1,791 | <ASSISTANT_TASK:>
Python Code:
data_dir = './data'
# FloydHub - Use with data ID "R5KrjnANiKVhLWAkpXhNBe"
#data_dir = '/input'
DON'T MODIFY ANYTHING IN THIS CELL
import helper
helper.download_extract('mnist', data_dir)
helper.download_extract('celeba', data_dir)
show_n_images = 25
DON'T MODIFY ANYTHING IN THIS CELL
%m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Face Generation
Step3: Explore the Data
Step5: CelebA
Step7: Preprocess the Data
Step10: Input
Step13: Discriminator
Step16: Generator
Ste... |
1,792 | <ASSISTANT_TASK:>
Python Code:
from tvb.simulator.lab import *
LOG.info("Configuring...")
#Initialise a Model, Coupling, and Connectivity.
oscillator = models.Generic2dOscillator()
white_matter = connectivity.Connectivity(load_default=True)
white_matter.speed = numpy.array([4.0])
white_matter_coupling = coupling.Linea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Perform the simulation
Step2: Plot pretty pictures of what we just did
|
1,793 | <ASSISTANT_TASK:>
Python Code:
baseurl = 'ftp://cdsarc.u-strasbg.fr/pub/cats/J/ApJ/817/172/'
readme_file = 'ReadMe'
chandra_file = 'chandra.dat'
import astropy
print "astropy version:",astropy.__version__
import mocpy
print "mocpy version:",mocpy.__version__
import healpy
print "healpy version:",healpy.__version__
def... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download ReadMe and chandra.dat files and save them inside ./data/ dir
Step2: Dealing with null values from Vizier metadata
Step3: We can see ... |
1,794 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inm', 'sandbox-1', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "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: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
1,795 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
from sympy.abc import n, i, N, x, lamda, phi, z, j, r, k, a, alpha
from commons import *
from matrix_functions import *
from sequences import *
import functions_catalog
init_printing()
m = 10
eP = Matrix(m, m, lambda n,k: factorial(n)*binomial(n,k)/factorial(k))
eP
in... | <SYSTEM_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: In order to factorize eP as F U F^{-1}, for some matrix U
Step3:
|
1,796 | <ASSISTANT_TASK:>
Python Code:
from tvb.simulator.lab import *
import datetime
START_TIME = datetime.datetime.now()
LOG.info("Configuring...")
#Initialise a Model, Coupling, and Connectivity.
oscillator = models.Generic2dOscillator()
white_matter = connectivity.Connectivity(load_default=True)
white_matter.speed = nump... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Perform the simulation
Step2: ####Plot pretty pictures of what we just did
|
1,797 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.1,<2.2"
%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=np.linspace(0,1,101), dataset='lc01')
b.set_value_all('ld_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: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details.
Step2: And we'll add a single li... |
1,798 | <ASSISTANT_TASK:>
Python Code:
import obspy
import pyadjoint
# Helper function to get some example data used for
# illustrative purposes.
obs, syn = pyadjoint.utils.get_example_data()
# Select the vertical components of both.
obs = obs.select(component="Z")[0]
syn = syn.select(component="Z")[0]
adj_src = pyadjoint.cal... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pyadjoint expects the data to be fully preprocessed thus both observed and synthetic data are expected to have exactly the same length, sampling... |
1,799 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
high = 1
low = 0
mask_elements = 64
bounds = np.empty(shape=[high+1, mask_elements], dtype=np.int32)
for i in range(mask_elements):
bounds[high,i] = (i + 1) * 4 - 1
bounds[low,i] = i * 4
print(" i | High Low \n---|-----------")
for 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: Ricoh GEN5
Step2: KonicaMinolta KM1024i
Step3: Kyocera KJ4B_1200_64k CPLD
Step4: Jetmapping BitSwap
Step5: Manual Data Assignment
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.