Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
13,100 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
s = pd.Series([1,3,5,np.nan,6,8])
s
dates = pd.date_range('20130101', periods=6)
dates
df = pd.DataFrame(np.random.randn(6,4), index=dates, columns = ['Ann', "Bob", "Charly", "Don"])
## columns=list... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Object Creation
Step2: Creating a DataFrame by passing a numpy array, with a datetime index and labeled columns
Step3: Having specific dtypes
... |
13,101 | <ASSISTANT_TASK:>
Python Code:
data_dt=1.e20*data.astype(float64).detrend()
filt=sig.firwin(int(8*srate)-1,9./nyquist,pass_zero=False,window='hann')
data_hp=fir_filter(data_dt,filt)
freqs=[52,59.8,60.2,64,112,124,171,179.5,180.5,183,230,242]
#freqs=[110,124,171,179.5,180.5,183,230,242]
#freqs=[480,530,980,1040,1460,15... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Below are three options for bandpasses.
|
13,102 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.time_frequency import tfr_morlet
from mne.stats import permutation_cluster_test
from mne.datasets import sample
print(__doc__)
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: Set parameters
Step2: Factor to downsample the temporal dimension of the TFR computed by
Step3: Compute statistic
Step4: View time-frequency ... |
13,103 | <ASSISTANT_TASK:>
Python Code:
import graphlab
import math
import random
import numpy
from matplotlib import pyplot as plt
%matplotlib inline
random.seed(1)
n = 30
x = graphlab.SArray([random.random() for i in range(n)]).sort()
y = x.apply(lambda x: math.sin(4*x))
e = graphlab.SArray([random.gauss(0,1.0/3.0) for i 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: Create random values for x in interval [0,1)
Step2: Compute y
Step3: Add random Gaussian noise to y
Step4: Put data into an SFrame to manipul... |
13,104 | <ASSISTANT_TASK:>
Python Code:
def print_lines(filename, num_lines):
count = 0
with open(filename,'r') as f:
for line in f:
for word in line.split():
print word
count += 1
if count >= num_lines:
break
print_lines('leaves-of-grass.txt', ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How do we test "contains"
Step2: Without 'in', how do we do this?
Step3: Is this fast? What does fast mean?
Step4: In the worst case, we have... |
13,105 | <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
! pip3 install $USER kfp google-... | <SYSTEM_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: Install the latest GA version of google-cloud-pipeline-components... |
13,106 | <ASSISTANT_TASK:>
Python Code:
# GPUs or CPU
import tensorflow as tf
# Check TensorFlow Version
print('TensorFlow Version: {}'.format(tf.__version__))
# Check for a GPU
print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_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: These two lines of code will download and read in the handwritten digits data automatically.
Step2: We're going to look at only 100 examples at... |
13,107 | <ASSISTANT_TASK:>
Python Code:
import datetime
import graphviz
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
plt.rcParams["figure.figsize"] = (17, 10)
import pandas as pd
import seaborn as sns
sns.set(context = "paper", font = "monospace")
import sklearn.datasets
from sklearn.preprocessing impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: read
Step2: features and targets
Step3: accuracy
|
13,108 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data')
def model_inputs(real_dim, z_dim):
inputs_real = tf.placeholde... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model Inputs
Step2: Generator network
Step3: Discriminator
Step4: Hyperparameters
Step5: Build network
Step6: Discriminator and Generator L... |
13,109 | <ASSISTANT_TASK:>
Python Code:
# to make sure things are working, run this
import pandas as pd
print('Pandas version: ', pd.__version__)
import pandas as pd
import matplotlib.pyplot as plt
import datetime as dt
%matplotlib inline
url = 'http://pages.stern.nyu.edu/~dbackus/Data/beer_production_1947-2004.xlsx'
beer ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If you get something like "Pandas version
Step2: Remind yourself
Step3: Question. Can you see consolidation here?
Step4: Answer these questio... |
13,110 | <ASSISTANT_TASK:>
Python Code:
# Arg: quality and num_per_dim -> tradeoffs between quality and time spent running
# quality affects dense=False, and num_per_dim affects dense=True
ckpt_path = './ckpt/exif_final/exif_final.ckpt'
exif_demo = demo.Demo(ckpt_path=ckpt_path, use_gpu=0, quality=3.0, num_per_dim=30)
# MeanS... | <SYSTEM_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 examples
Step2: Normalized Cuts
|
13,111 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import keras
import numpy as np
import keras
N = 50
# phase_step = 1 / (2 * np.pi)
t = np.arange(50)
phases = np.linspace(0, 1, N) * 2 * np.pi
x = np.array([np.sin(2 * np.pi / N * t + phi) for phi in phases])
print(x.shape)
imshow(x);
plot(x[0]);
plot(x[1]);
plot(x[2]);
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: The model should be able to handle noise-corrupted input signal.
Step2: This time the model should be able to handle also phase-shifted signal ... |
13,112 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import pickle
import statsmodels.api as sm
from sklearn import cluster
import matplotlib.pyplot as plt
%matplotlib inline
from bs4 import BeautifulSoup as bs
import requests
import time
# from ggplot import *
asthma_data = pd.read_csv('asthma-emerge... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Other Useful Packages (not used today)
Step2: Look at those zip codes!
Step3: Rearrange The Data
Step4: Lost Columns! Fips summed!
Step5: A... |
13,113 | <ASSISTANT_TASK:>
Python Code:
!head -5 temps.csv
%matplotlib inline
import matplotlib
matplotlib.rcParams['figure.figsize'] = (12, 5)
import pandas as pd
df = pd.read_csv('temps.csv', header=None, names=['time', 'mac', 'f', 'h'], parse_dates=[0])
df.head()
df.plot();
per_sensor_f = df.pivot(index='time', columns='... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Some prelimaries. Import code, and configure chart sizes to be larger than the default.
Step2: Load the .csv into a pandas DataFrame, adding co... |
13,114 | <ASSISTANT_TASK:>
Python Code:
data = sc.parallelize(range(1, 11))
def duplicar(x): return x*x
# data é um rdd
res = data.map( duplicar )
print (res.collect())
data = sc.parallelize(range(1, 11))
res = data.filter(lambda x: x%2 ==1)
print(res.collect())
data = sc.parallelize(["Linha 1", "Linha 2"])
def partir(l): ret... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: filter(func)
Step2: flatMap(func)
Step3: intersection(otherRDD)
Step4: groupByKey()
Step5: reduceByKey(func)
Step6: sortByKey([asceding])
|
13,115 | <ASSISTANT_TASK:>
Python Code:
def f(p):
return 1-p
print f(0.3)
def f(p):
return p*p
print f(0.3)
def f(p):
return 3 * p * (1-p) * (1-p)
print f(0.5)
print f(0.8)
def f(p1,p2):
return p1 * p2
print f(0.5,0.8)
def f(p0,p1,p2):
return p0 * p1 +(1-p0) * p2
print f(0.3,0.5,0.9)
#Calculate ... | <SYSTEM_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 flips
Step2: Three Flips
Step3: Flip Two Coins
Step4: Flip One Of Two
Step5: Answer
Step6: Cancer Example 2
Step7: Program Bayes Rule ... |
13,116 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
from subprocess import Popen, PIPE
from bisect import bisect_left
tmp_script = 'tmp.praat'
def gen_script():
# This generates temporary praat script file
global tmp_script
with open(tmp_script, 'w') as f:
f.write('''
form extract_formant
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: Main functions
Step2: Run
|
13,117 | <ASSISTANT_TASK:>
Python Code:
from msmbuilder.dataset import dataset
import numpy as np
import os
from mdtraj.utils import timing
from msmbuilder.featurizer import DihedralFeaturizer
import seaborn as sns; sns.set_style("white"); sns.set_palette("Blues")
with timing("Loading data as dataset object"):
wt_xyz = 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: Featurization
Step2: Contact Featurizer
Step3: Intermediate kinetic model
Step4: tICA Heatmap
Step5: Clustering
Step6: MSM
Step7: Macrosta... |
13,118 | <ASSISTANT_TASK:>
Python Code:
#addition
print 4+3
#subtraction
print 4-3
#multiplication
print 4*3
#exponentiation
print 4**3
#division
print 4/3
#addition
print "4+3 = ",4+3
#subtraction
print "4-3 = ",4-3
#multiplication
print '4*3 = ',4*3
#exponentiation
print "4^3 = ",4**3
#division
print "4/3 = ",4/3
#division ... | <SYSTEM_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 lines beginning with # are called comments. These are ignored by Python and are often used to provide explanations of your code. Note that w... |
13,119 | <ASSISTANT_TASK:>
Python Code:
import pymc as pm
parameter = pm.Exponential("poisson_param", 1)
data_generator = pm.Poisson("data_generator", parameter)
data_plus_one = data_generator + 1
print("Children of `parameter`: ")
print(parameter.children)
print("\nParents of `data_generator`: ")
print(data_generator.parents)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: parameter controls the parameter of data_generator, hence influences its values. The former is a parent of the latter. By symmetry, data_generat... |
13,120 | <ASSISTANT_TASK:>
Python Code:
%cd ../examples/superlists/
%ls
%%writefile functional_tests.py
from selenium import webdriver
browser = webdriver.Firefox()
# Edith has heard about a cool new online to-do app. She goes
# to check out its homepage
browser.get('http://localhost:8000')
# She notices the page title and head... | <SYSTEM_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 that I've updated the assert to include the word "To-Do" instead of "Django". Now our test should fail. Let's check that it fails.
Step2:... |
13,121 | <ASSISTANT_TASK:>
Python Code:
#obj = ["3C 454.3", 343.49062, 16.14821, 1.0]
obj = ["PKS J0006-0623", 1.55789, -6.39315, 1.0]
#obj = ["M87", 187.705930, 12.391123, 1.0]
#### name, ra, dec, radius of cone
obj_name = obj[0]
obj_ra = obj[1]
obj_dec = obj[2]
cone_radius = obj[3]
obj_coord = coordinates.SkyCoord(ra=obj_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Matching coordinates
Step2: Plot $W_1-J$ vs $W_1$
Step3: W1-J < -1.7 => galaxy
Step4: Collect relevant data
Step5: Analysis
Step6: DBSCAN
S... |
13,122 | <ASSISTANT_TASK:>
Python Code:
!pip install avalanche-lib==0.2.0
from torch.optim import SGD
from torch.nn import CrossEntropyLoss
from avalanche.benchmarks.classic import SplitMNIST
from avalanche.evaluation.metrics import forgetting_metrics, accuracy_metrics, \
loss_metrics, timing_metrics, cpu_usage_metrics, 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: 🛴 A Comprehensive Example
|
13,123 | <ASSISTANT_TASK:>
Python Code:
import fredpy as fp
import matplotlib.pyplot as plt
import pandas as pd
# Load fredpy API key
fp.api_key = fp.load_api_key('fred_api_key.txt')
# Download labor market data
u = fp.series('unrate').data
u_men = fp.series('LNS14000001').data
u_women = fp.series('LNS14000002').data
lf_men = ... | <SYSTEM_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 data from FRED and manage
Step2: Plots to be produced in Excel
|
13,124 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import warnings
warnings.filterwarnings('ignore')
pass_air_data = pd.read_csv('datasets/passengers.csv')
pass_air_data.head()
# Create a MultiDiGraph from this dataset
passenge... | <SYSTEM_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 pass_air_data dataframe we have the information of number of people that fly every year on a particular route on the list of airlines tha... |
13,125 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
num = [2, 25]
den = [1, 4, 25]
sys = signal.TransferFunction(num, den)
time, response = signal.step(sys)
plt.plot(time,response,label="Simulation")
plt.show()
t = np.linspace(0, 5)
u = 1 * t
tout, resp, x = 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: Now we can define the transfer function using scipy
Step2: Step response
Step3: Once we have the response we can plot it using matplotlib
Step... |
13,126 | <ASSISTANT_TASK:>
Python Code:
import os
from dh_py_access import package_api
import dh_py_access.lib.datahub as datahub
import xarray as xr
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
import imageio
import shutil
import datetime
import matplotlib as mpl
mpl.rcParams['fon... | <SYSTEM_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 define some functions. make_imgs function makes images for animation and make_anim makes animation using images the first function made... |
13,127 | <ASSISTANT_TASK:>
Python Code:
# Data
x = np.array([1.1, 1.9, 2.3, 1.8])
n = len(x)
with pm.Model() as model1:
# prior
mu = pm.Normal('mu', mu=0, tau=.001)
sigma = pm.Uniform('sigma', lower=0, upper=10)
# observed
xi = pm.Normal('xi',mu=mu, tau=1/(sigma**2), observed=x)
# inference
trac... | <SYSTEM_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 from Junpeng Lao
Step2: 4.2 The seven scientists
Step3: 4.3 Repeated measurement of IQ
|
13,128 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
# TODO
# TODO convert over50k to boolean
# TODO convert independend variables
# TODO (hint: use drop(columns,axis=1))
from sklearn.model_selection import train_test_split
# TODO
from sklearn.ensemble import RandomForestClassifier
# TODO
from 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: Exercise 1
Step2: Exercise 2
Step3: Exercise 3
Step4: Exercise 4
Step5: Exercise 5
Step6: Exercise 6
Step7: Exercise 7
|
13,129 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
try:
import seaborn
except ImportError:
pass
pd.options.display.max_rows = 10
df = pd.DataFrame({'key':['A','B','C','A','B','C','A','B','C'],
'data': [0, 5, 10, 5, 10, 15,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Some 'theory'
Step2: Using the filtering and reductions operations we have seen in the previous notebooks, we could do something like
Step3: A... |
13,130 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from IPython.display import (
display_pretty, display_html, display_jpeg,
display_png, display_json, display_latex, display_svg
)
from IPython.display import Image
i = Image(filename='../images/ipython_logo.png')
i
display(i)
Image(url='htt... | <SYSTEM_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 few points
Step2: Images
Step3: Returning an Image object from an expression will automatically display it
Step4: Or you can pass an object... |
13,131 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.font_manager
from sklearn import svm
packet_loss=np.log(np.linspace(0.0001, 1, 100))
latency=np.log(np.linspace(0.01, 200, 500))
xx, yy = np.meshgrid(packet_loss, latency)
xx, yy = np.meshgrid(np.linspace(-5, 5, 500), 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: generate training data
Step2: fit the model
|
13,132 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import openpathsampling as paths
from openpathsampling.visualize import PathTreeBuilder, PathTreeBuilder
from IPython.display import SVG, HTML
import openpathsampling.high_level.move_strategy as strategies # TODO: handle this better
# real fast setup of a small network
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: MoveStrategy and MoveScheme
Step2: OpenPathSampling comes with a nice tool to visualize the move scheme. There are two main columns in the outp... |
13,133 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = "retina"
from __future__ import print_function
from matplotlib import rcParams
rcParams["savefig.dpi"] = 100
rcParams["figure.dpi"] = 100
rcParams["font.size"] = 20
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This is a cross post from the new emcee documentation.
Step2: Now we'll estimate the empirical autocorrelation function for each of these paral... |
13,134 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
import mne
from mne.time_frequency import fit_iir_model_raw
from mne.datasets import sample
print(__doc__)
data_path = sample.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 different time series and PSDs
|
13,135 | <ASSISTANT_TASK:>
Python Code:
show_image("./res/gradient_descent.jpg", figsize=(12,8))
show_image("./res/iterator.jpg")
show_image("./res/incr_opt.png", figsize=(10,5))
show_image("./res/approx.png", figsize=(10,5))
show_image("./res/model.png", figsize=(10,5))
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2.1 增量寻优
Step2: 因为我们始终是找极小值点,这个过程就始终如上图所示"U"形。那么每次的步进方向就可用 $f(x_1) - f(x_0)$ 来指示。也就是说,虽然我们无法对机器$f(x)$建模,但我们可以对寻优的过程 $z = f(x_i) - f(x_{i+1})$ 建... |
13,136 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pylab as pl
import matplotlib.patches as mpatches
import matplotlib.ticker as ticker
import os
import shutil
from IPython.display import Image
from matplotlib.ticker import FormatStrFormatter
ruta=os.getcwd()
c=input('Nombre de la trayectoria ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ruta de la trayectoria
Step2: Convirtiendo la trayectoria DCD -> XTC
Step3: Realizando la conversión de la trayectoria
Step4: Cargando la nue... |
13,137 | <ASSISTANT_TASK:>
Python Code:
print('hello world')
a=1
b=2
a+b
print(a)
#Run this cell multiple times
a=a+1
a
import numpy as np
np.pi
!ls
ls -l
import pandas as pd
pd.DataFrame({'col1':[1,2],'col2':['x','y']})
%matplotlib inline
import matplotlib.pyplot as plt
# Create 1000 evenly-spaced values from 0 to 2 pi
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: Navigating and Selecting Cells
Step2: We Can Run a Cell to Multiple Times
Step3: Code Libraries can be imported via a Code Cell
Step4: Cleari... |
13,138 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from pylab import *
%matplotlib inline
from pyarrow import ArrowIOError
from scrapenhl2.scrape import teams, team_info, schedules
from scrapenhl2.manipulate import manipulate as manip
generate = False
fname = '/Users/muneebalam/Desktop/team_game_data.csv'
if generate:
... | <SYSTEM_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 make some plots and calculate some figures. For example, here's how the correlation (Pearson's r) changes by game number
Step2: Here's h... |
13,139 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
matplotlib.rcParams['figure.figsize'] = [10,7]
import synapseclient
l = synapseclient.login()
l.get("syn10641621", downloadLocation=".", ifcollision="overwrite.local")
l.get("syn10641896", downloadLocation=".", ifcollision="overwrite.local")
!sequana_coverage --download-re... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download FastQ files (1.6Gb)
Step2: Download reference and annotation files
Step3: The Reference must be altered to rename the header so that ... |
13,140 | <ASSISTANT_TASK:>
Python Code:
def countBits(n ) :
count = 0 ;
while(n ) :
count += 1 ;
n >>= 1 ;
return count ;
n = 32 ;
print("Minimum ▁ value ▁ of ▁ K ▁ is ▁ = ", countBits(n ) ) ;
<END_TASK>
| <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
13,141 | <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 matplotlib.pyplot as plt
import numpy as np
import os
import sys
import tarfile
from IPython.display import display, Image
from scipy 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:
Step3: First, we'll download the dataset to our local machine. The data consists of characters rendered in a variety of fonts on a 28x28 image. The lab... |
13,142 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -a 'Sebastian Raschka' -u -d -v -p numpy,pandas,matplotlib,sklearn,nltk
# Added version check for recent scikit-learn 0.18 checks
from distutils.version import LooseVersion as Version
from sklearn import __version__ as sklearn_version
import pyprind
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: The use of watermark is optional. You can install this IPython extension via "pip install watermark". For more information, please see
Step2: O... |
13,143 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
series = pd.Series([np.array([1,2,3,4]), np.array([5,6,7,8]), np.array([9,10,11,12])], index=['file1', 'file2', 'file3'])
def g(s):
return pd.DataFrame.from_records(s.values,index=s.index)
df = g(series.copy())
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
13,144 | <ASSISTANT_TASK:>
Python Code:
#import all the needed package
import numpy as np
import scipy as sp
import re
import pandas as pd
import sklearn
from sklearn.cross_validation import train_test_split,cross_val_score
from sklearn import metrics
import matplotlib
from matplotlib import pyplot as plt
%matplotlib inline
fr... | <SYSTEM_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 the processed data and feature scale Age and Fare
Step2: Select the features from data, and convert to numpy arrays
Step3: We want ... |
13,145 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import time
import structcol as sc
import structcol.refractive_index as ri
from structcol import montecarlo as mc
from structcol import detector as det
from structcol import phase_func_sphere as pfs
import matplotlib.pyplot as plt
import seaborn as sn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Start by running Monte Carlo code for a single sphere
Step2: Sample sphere boundary sizes
Step3: Run Monte Carlo for each of the sphere bounda... |
13,146 | <ASSISTANT_TASK:>
Python Code:
from __future__ import unicode_literals, division, print_function, absolute_import
import numpy as np
np.random.seed(28)
import matplotlib.pyplot as plt
import tensorflow as tf
tf.set_random_seed(28)
import keras
from simec import SimilarityEncoder
%matplotlib inline
%load_ext autoreload
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SVD of a random matrix
Step2: Dealing with missing values
Step3: Eigendecomposition of a square symmetric matrix
|
13,147 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
from ipywidgets import interact
%pylab inline
results = {}
import platform
p = platform.platform()
print(p)
results['platform'] = p
import sys
v = sys.version
print(v)
results['python'] = v
import pypot
import poppy.creatures
results['pypo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: All bench info will be stored in this dictionary so it's easy to compare with other platforms.
Step2: What's the platform
Step3: Make sure all... |
13,148 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import pandas_datareader.data as web
import matplotlib.pyplot as plt
import numpy as np
# Defines the chart color scheme using Tableu's Tableau10
plt.style.use('https://gist.githubusercontent.com/mbonix/8478091db6a2e6836341c2bb3f55b9fc/raw/7155235ed03e235c38b66c160d40... | <SYSTEM_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 are going to download some prices, just as an example. We'll work on Apple (AAPL), Alphabet (former Google, GOOGL), Microsoft (MSFT), McDonal... |
13,149 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import seaborn as sn
with open('SMSSpamCollection.txt') as fh:
lines = list(fh)
data = [(line.split()[0], ' '.join(line.split()[1:])) for line in lines]
data_df = pd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read the Data
Step2: Check Class Imbalance
Step3: Model Construction and Cross-validation
|
13,150 | <ASSISTANT_TASK:>
Python Code:
import os
from modules.DataArxiv import get_date
from modules.DataArxiv import execute_query
from modules.Translate import Translate
CREDENTIALS_JSON = "credentials.json"
CREDENTIALS_PATH = os.path.normpath(
os.path.join(os.getcwd(), CREDENTIALS_JSON)
)
os.environ['GOOGLE_APPLICATION... | <SYSTEM_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 credentials.<br>
Step2: Set the dates.<br>
Step3: Category list.<br>
Step4: Set the query.<br>
Step5: Get bulk data from arXiv.
Step6: ... |
13,151 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import tensorflow as tf
import tflearn
from tflearn.data_utils import to_categorical
reviews = pd.read_csv('reviews.txt', header=None)
labels = pd.read_csv('labels.txt', header=None)
from collections import Counter
total_counts = Counter() # bag o... | <SYSTEM_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 data
Step2: Counting word frequency
Step3: Let's keep the first 10000 most frequent words. As Andrew noted, most of the words in... |
13,152 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scanpy.api as sc
sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=80) # low dpi (dots per inch) yields small inline figures
sc.logging.print_versions()
adata = sc.tl.sim('krumsiek11')
sc.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: Here, we simulate data using a literature-curated boolean gene
Step2: Plot the four realizations of time series.
Step3: Compute further visual... |
13,153 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo("1VXDejQcAWY")
import gmpy2
gmpy2.get_context().precision=200
root2 = gmpy2.sqrt(2)
root7 = gmpy2.sqrt(7)
root5 = gmpy2.sqrt(5)
root3 = gmpy2.sqrt(3)
# phi
𝜙 = (gmpy2.sqrt(5) + 1)/2
# Synergetics modules
Smod = (𝜙 **-5)/2
Emod = (... | <SYSTEM_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 cuboctahedron and icosahedron are related by having the same edge length. The ratio of the two, in terms of volume, is
Step2: Icosa * sfac... |
13,154 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import collections
import math
import matplotlib.pyplot as plt
import h5py
import csv
LABELS_FILE = 'data/ondrejov-dataset.csv'
with open(LABELS_FILE, newline='') as f:
labels = list(csv.DictReader(f))
counts = collections.Counter(map(lambda x: 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: Counts
Step2: Classes Preview
Step3: Let's Add Labels
Step4: Vizualize All Spectra in a Class
Step5: Wavelength Ranges
Step6: Supremum
|
13,155 | <ASSISTANT_TASK:>
Python Code:
import numpy
import wqio
import pynsqd
import pycvc
def get_cvc_parameter(nsqdparam):
try:
cvcparam = list(filter(
lambda p: p['nsqdname'] == nsqdparam, pycvc.info.POC_dicts
))[0]['cvcname']
except IndexError:
cvcparam = numpy.nan
return cv... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create a raw data set, then compute season and apply basic filters
Step2: Show the sample counts for each parameter
Step3: Export TSS to a CSV... |
13,156 | <ASSISTANT_TASK:>
Python Code:
scaler = StandardScaler()
mnist = fetch_mldata('MNIST original')
# converting data to be of type float .astype(float) to supress
# data conversion warrning during scaling
X= pd.DataFrame(scaler.fit_transform(mnist['data'].astype(float)))
y= pd.DataFrame(mnist['target'].astype(int))
# This... | <SYSTEM_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 plot a random 100 images
Step2: Now, let use the Neural Network with 1 hidden layers. The number of neurons in each layer is X_train.shap... |
13,157 | <ASSISTANT_TASK:>
Python Code:
from pyspark import SparkContext
sc =SparkContext()
ListaPalavras = ['gato', 'elefante', 'rato', 'rato', 'gato']
palavrasRDD = sc.parallelize(ListaPalavras, 4)
print type(palavrasRDD)
# EXERCICIO
def Plural(palavra):
Adds an 's' to `palavra`.
Args:
palavra (str): A string... | <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: (1b) Plural
Step3: (1c) Aplicando a função ao RDD
Step4: Nota
Step5: (1e) Tamanho de cada palavra
Step6: (1f) RDDs de pares e tuplas
Ste... |
13,158 | <ASSISTANT_TASK:>
Python Code:
!pip install tensorflow_model_analysis==0.37.0 pandas==1.3.5 google_cloud_storage==1.43.0
# Visualisation-specific imports
import tensorflow_model_analysis as tfma
from tensorflow_model_analysis.view import render_slicing_metrics
from ipywidgets.embed import embed_minimal_html
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: Import Packages
Step3: User Inputs
Step4: Custom Metrics
Step6: Define TFMA model evaluation specs
Step7: Run Evaluation
Step11: Save Evalu... |
13,159 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import pandas as pd
import matplotlib.pyplot as plt
import psycopg2
import os
import sqlite3
# Plot settings
%matplotlib inline
plt.style.use('ggplot')
fontsize = 20 # size for x and y ticks
plt.rcParams['legend.fontsize'] = fontsize
plt.rcParams.update({'font.size': fo... | <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: 2. Display list of tables
Step4: 3. Reviewing the patient table
Step5: Questions
Step6: Questions
Step7: Questions
Step8: Questions
|
13,160 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Eric Larson <larson.eric.d@gmail.com>
# License: BSD (3-clause)
import os.path as op
import numpy as np
from scipy import stats as stats
import mne
from mne import spatial_src_connectivity
from mne.stats 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: Set parameters
Step2: Compute statistic
Step3: Visualize the clusters
|
13,161 | <ASSISTANT_TASK:>
Python Code:
import googlemaps
from datetime import datetime
gmaps = googlemaps.Client(key='somesecretkeyhere')
# Geocoding an address
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
type(geocode_result)
from pprint import pprint
pprint(geocode_result)
# Look up an addr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reminder
Step2: If you print the results above, it will again be a JSON document, yet again unreadible. Let's again make it pretty.
|
13,162 | <ASSISTANT_TASK:>
Python Code:
data = sc.parallelize(
[('Amber', 22), ('Alfred', 23), ('Skye',4), ('Albert', 12),
('Amber', 9)])
data_from_file = sc.\
textFile(
'/Users/drabast/Documents/PySpark_Data/VS14MORT.txt.gz',
4)
data_heterogenous = sc.parallelize([('Ferrari', 'fast'), {'Porsche... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: or read from a repository (a file or a database)
Step2: Note, that to execute the code above you will have to change the path where the data is... |
13,163 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import mne
from mne.datasets import sample
from mne.preprocessing import ICA
from mne.preprocessing import create_eog_epochs, create_ecg_epochs
# getting some data ready
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Before applying artifact correction please learn about your actual artifacts
Step2: Define the ICA object instance
Step3: we avoid fitting ICA... |
13,164 | <ASSISTANT_TASK:>
Python Code:
from planet import api
import time
import os
import rasterio
from rasterio.plot import show
client = api.ClientV1()
# build a filter for the AOI
filter = api.filters.range_filter("clear_percent", gte=90)
# show the structure of the filter
print(filter)
# we are requesting PlanetScope 4 Ba... | <SYSTEM_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 udm2 asset
|
13,165 | <ASSISTANT_TASK:>
Python Code:
class SolutionMissingError(Exception):
def __init__(self):
Exception.__init__(self,"You need to complete the solution for this code to work!")
def REPLACE_WITH_YOUR_SOLUTION():
raise SolutionMissingError
REMOVE_THIS_LINE = REPLACE_WITH_YOUR_SOLUTION
try:
exec(open('So... | <SYSTEM_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 crazy try-except construction is our way of making sure the notebooks will work when completed without actually providing complete code. Yo... |
13,166 | <ASSISTANT_TASK:>
Python Code:
import tarfile
fname_base = 'C:/gh/data/example/lfp_set_PsTs/out.29419325.'
Nfiles = 10
for n in range(Nfiles):
fname = fname_base + str(n) + '.tar.gz'
tar = tarfile.open(fname, "r:gz")
tar.extractall('C:/gh/data/example/lfp_set_PsTs/' + str(n) + '/')
tar.close()
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: 2. Load each array of Ps and Ts
Step2: 3. Load signals
Step3: 4. Plot peaks and troughs on top of signals
|
13,167 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import autograd.numpy as npa
import skimage as sk
import copy
import matplotlib as mpl
mpl.rcParams['figure.dpi']=100
import matplotlib.pylab as plt
from autograd.scipy.signal import convolve as conv
from skimage.draw import circle, circle_perimeter
import sys
sys.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: Define simulation parameters
Step3: Setup the simulation domain using parameters defined above
Step4: Solve for field profiles
Step5: Backwar... |
13,168 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bnu', 'bnu-esm-1-1', 'ocean')
# 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... |
13,169 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('lp', times=[0,1,2], wavelengths=phoebe.linspace(549, 551, 101))
print(b.get_dataset(kind='lp', check_visible=False))
print(b.get_dataset(kind='lp').times)
print(b.get_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new Bundle.
Step2: Dataset Parameters
Step3: For information on the included passban... |
13,170 | <ASSISTANT_TASK:>
Python Code:
# the network
weight = 0.1
def neural_network(input, weight):
prediction = input * weight
return prediction
# using the network to predict something
number_of_toes = [8.5, 9.5, 10, 9]
input = number_of_toes[0]
pred = neural_network(input,weight)
pred
weights = [0.1, 0.2, 0]
def n... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: this is super simple - the input is being multiplied by a weight and returned. The power of NN's lies in the weights and how we update them.
Ste... |
13,171 | <ASSISTANT_TASK:>
Python Code:
from essentia.standard import *
from tempfile import TemporaryDirectory
# Load audio file.
audio = MonoLoader(filename='../../../test/audio/recorded/hiphop.mp3')()
# 1. Compute the onset detection function (ODF).
# The OnsetDetection algorithm provides various ODFs.
od_hfc = OnsetDetectio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can now listen to the resulting audio files to see which of the two onset detection functions works better for our audio example.
Step2: Fin... |
13,172 | <ASSISTANT_TASK:>
Python Code:
bigfile = open('/Users/chengjun/百度云同步盘/Writing/OWS/ows-raw.txt', 'rb')
chunkSize = 1000000
chunk = bigfile.readlines(chunkSize)
print len(chunk)
with open("/Users/chengjun/GitHub/cjc2016/data/ows_tweets_sample.txt", 'w') as f:
for i in chunk:
f.write(i)
with open("/Users/chen... | <SYSTEM_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. 清洗错行的情况
Step2: 问题: 第一行是变量名
Step3: 如何来处理错误换行情况?
Step4: 3. 读取数据、正确分列
Step5: 4. 统计数量
Step6: 5. 清洗tweets文本
Step7: 安装twitter_text
Step8: 获得... |
13,173 | <ASSISTANT_TASK:>
Python Code:
fashion_mnist = keras.datasets.fashion_mnist
(x_train_all,y_train_all),(x_test,y_test) = fashion_mnist.load_data()
x_valid,x_train = x_train_all[:5000],x_train_all[5000:]
y_valid,y_train = y_train_all[:5000],y_train_all[5000:]
print(x_train.shape,y_train.shape)
print(x_valid.shape,y_valid... | <SYSTEM_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.2 构建模型
Step3: 如果sigmoid改成relu的话,精度就会降低非常的多。为啥呢?
Step4: 1.3 训练模型
Step5: 我们把训练过程中的loss及accuracy打印出来
Step6: 1.4 evalua... |
13,174 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
%matplotlib inline
import numpy as np
import dh_py_access.lib.datahub as datahub
import xarray as xr
import matplotlib.pyplot as plt
import ipywidgets as widgets
from mpl_toolkits.basemap import Basemap
import dh_py_access.package_api as package_api
import matplotlib.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font color='red'>Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly ... |
13,175 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
data = np.array([[4, 2, 5, 6, 7],
[ 5, 4, 3, 5, 7]])
bin_size = 3
new_data = data[:, ::-1]
bin_data_mean = new_data[:,:(data.shape[1] // bin_size) * bin_size].reshape(data.shape[0], -1, bin_size).mean(axis=-1)[:,::-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:
|
13,176 | <ASSISTANT_TASK:>
Python Code:
%%bash
bq mk -d ai4f
bq load --autodetect --source_format=CSV ai4f.AAPL10Y gs://cloud-training/ai4f/AAPL10Y.csv
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn import linear_model
from sklearn.metrics import mean_squared_error
from sk... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pull Data from BigQuery
Step2: The query below selects everything you'll need to build a regression model to predict the closing price of AAPL ... |
13,177 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
from scipy import optimize
%pylab inline
pylab.rcParams['figure.figsize'] = (15, 10)
HTML('../style/code_toggle.html')
lam = 3e8/1.4e9 #... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import section specific modules
Step2: 8.1 Calibration as a Least Squares Problem <a id='cal
Step3: Figure 8.1.1
Step4: Our hour angle range ... |
13,178 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
df = pd.read_csv('../../data/processed/complaints-3-29-scrape.csv')
owners = pd.read_csv('../../data/raw/APD_HistOwner.csv')
owners.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h5>First
Step2: <h3>When did River Grove open, when did the last owners take over, and how many companies have owned the facility?</h3>
Step3:... |
13,179 | <ASSISTANT_TASK:>
Python Code:
osgb = ccrs.OSGB()
geod = ccrs.Geodetic()
# Convert from Ordnance Survey GB to lon/lat:
easting = 291813.424
northing = 92098.387
lon, lat = geod.transform_point(
x=easting, y=northing, src_crs=osgb)
print(lon, lat)
# check with mapx, this is UL corner of EASE-Grid 2.0 N!
e2n = ccrs.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: You can project lines with multiple vertices also
Step2: Look at this line on a map
Step3: Using cartopy's io shapefile interface to read Hunz... |
13,180 | <ASSISTANT_TASK:>
Python Code:
def gcd(a,b):
while b:
a,b = b,a%b
return a
def gcdMultiple(*args):
#print(len(args))
#for i in args:
#print(i)
if len(args) < 2:
return -1
for i in range(2,len(args)+1,2):
res = gcd(args[i-2],args[i-1])
fin = gcd(res,args[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: 2) Scrieti o functie care calculeaza cate vocale sunt intr-un sir de caractere.
Step2: 3) Scrieti o functie care returneaza numarul de cuvinte ... |
13,181 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
def newfig(title='?', xlabel='?', ylabel='?', xlim=None, ylim=None,
xscale='linear', yscale='linear', size_inches=(14, 8)):
'''Setup a new axis for plotting'''
fig, ax = plt.subplots(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convenience function for easy plotting
Step2: The problem can be solved by superposition. For this we write the analytical solution as
|
13,182 | <ASSISTANT_TASK:>
Python Code:
def gauss1d(x,mu,sig):
return np.exp(-(x-mu)**2/sig*2/2.)/np.sqrt(2*np.pi)/sig
def pltgauss1d(sig=1):
mu=0
x = np.r_[-4:4:101j]
pl.figure(figsize=(10,7))
pl.plot(x, gauss1d(x,mu,sig),'k-');
pl.axvline(mu,c='k',ls='-');
pl.axvline(mu+sig,c='k',ls='--');
pl.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: Now let us consider a pair of variables $y_1$ and $y_2$, drawn from a bivariate Gaussian distribution. The joint probability density for $y_1$ a... |
13,183 | <ASSISTANT_TASK:>
Python Code:
from sklearn import ensemble , cross_validation, learning_curve, metrics
import numpy as np
import pandas as pd
import xgboost as xgb
%pylab inline
bioresponce = pd.read_csv('bioresponse.csv', header=0, sep=',')
bioresponce.head()
bioresponce_target = bioresponce.Activity.values
bioresp... | <SYSTEM_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: Модель RandomForestClassifier
Step3: Кривые обучения для деревьев большей глубины
|
13,184 | <ASSISTANT_TASK:>
Python Code:
!mkdir squad
!wget https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v2.0.json -O /content/squad/train-v2.0.json
!wget https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v2.0.json -O /content/squad/dev-v2.0.json
import json
from pathlib import Path
def loadJSONData(filename):
... | <SYSTEM_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 split is in a structured json file with a number of questions and answers for each passage (or context). We’ll take this apart into paralle... |
13,185 | <ASSISTANT_TASK:>
Python Code:
lr = LogisticRegression(fit_intercept=False,C=1e7)
lr.fit(PhiX,Pos)
lr.coef_
PosHatPhi = lr.predict(PhiX)
with plt.style.context(('seaborn-white')):
plot_confusion_matrix(skmetrics.confusion_matrix(Pos,PosHatPhi),[0,1],
title="Confusion matrix for linear fit")
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: Transfusion
|
13,186 | <ASSISTANT_TASK:>
Python Code:
def oned_gaussian(xs, mm, sig):
return np.exp(-0.5 * (xs - mm) ** 2 / sig ** 2) / np.sqrt(2. * np.pi * sig)
def make_synth(rv, xs, ds, ms, sigs):
`rv`: radial velocity in m/s (or same units as `c` above
`xs`: `[M]` array of wavelength values
`ds`: depths at line cente... | <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 following is code copied from EPRV/fakedata.py to generate a realistic fake spectrum
Step4: First step
Step5: Next
Step6: and repeat
|
13,187 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-2', 'sandbox-1', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
13,188 | <ASSISTANT_TASK:>
Python Code:
import networkx as nx
G=nx.Graph()
G.add_node(1)
G.add_nodes_from([2,3,"hey"])
print G.nodes()
G.add_edge(1,2)
e=(2,3)
G.add_edge(*e)
G.add_edges_from([(1,2),(1,3), (3, 'hey')])
print G.edges()
print G.neighbors(1)
H=nx.DiGraph(G) # create a DiGraph using the connections from G
print 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: Atrributes
Step2: How far are two nodes? Paths and centralities.
|
13,189 | <ASSISTANT_TASK:>
Python Code:
import os
from netCDF4 import Dataset
import numpy as np
import sys
sys.path.insert(0, '../')
from sound_field_analysis import io
sofa_file_name = 'sofa/mit_kemar_large_pinna.sofa'
sofa_file = Dataset(sofa_file_name, 'r', format='NETCDF4')
print('sofa_file: ' + str(sofa_file))
print('So... | <SYSTEM_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 .sofa file
Step2: SOFA content
Step3: Save as npy file
|
13,190 | <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: 잘라내기 종합 가이드
Step2: 모델 정의하기
Step3: 일부 레이어 잘라내기(순차 및 함수형)
Step4: 이 예에서는 레이어 유형을 사용하여 잘라낼 레이어를 결정했지만, 특정 레이어를 잘라내는 가장 쉬운 방법은 name 속성을 설정하고 clone... |
13,191 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import open_cp.scripted
import open_cp.scripted.analysis as analysis
loaded = open_cp.scripted.Loader("retro_preds.pic.xz")
times = [x[1] for x in loaded]
preds = [x[2] for x in loaded]
fig, axes = plt.subplots(ncols=2, figsize=(16,7))
fo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Optimising the bandwidth
Step2: Grid based algorithm
|
13,192 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
# load data set
df = pd.read_csv('/home/data/APD/COBRA-YTD-multiyear.csv.gz')
print "Shape of table: ", df.shape
dataDict = pd.DataFrame({'DataType': df.dtypes.values, 'Description': '', }, index=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: Review
Step2: We need to enter the descriptions for each entry in our dictionary manually...
Step3: Convert Time Columns
Step4: What's the da... |
13,193 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from IPython.display import Image
# Regular graph initialization
nodes = 1000
k = 10
adj = np.zeros([nodes, nodes])
for i in range(0, nodes):
for j in range(1, k/2 + 1):
adj[i, (i+j) % nodes] = 1
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question 1 - Watts and Strogatz small world network model
Step2: Question 2 - Barabasi Albert Model
Step3: Tweaking the probability
Step4: Qu... |
13,194 | <ASSISTANT_TASK:>
Python Code:
# Data location. Please edit.
# A tfrecord containing tf.Example protos as downloaded from the Waymo dataset
# webpage.
# Replace this path with your own tfrecords.
FILENAME = '/content/waymo-od/tutorial/.../tfexample.tfrecord'
import os
import matplotlib.pyplot as plt
import tensorflow.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: Read 3D semantic segmentation labels from Frame proto
Step5: Visualize Segmentation Labels in Range Images
Step7: Point Cloud Conversion and V... |
13,195 | <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
import 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: 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... |
13,196 | <ASSISTANT_TASK:>
Python Code:
import Bio
from Bio.Blast.Applications import NcbiblastnCommandline
from Bio import SeqIO
from Bio.Blast import NCBIXML
from Bio import Restriction
from Bio.Restriction import *
from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set up input files
Step2: 2. The genome against which generated guides are scored against
Step3: Begin custom processing
Step4: Next, we want... |
13,197 | <ASSISTANT_TASK:>
Python Code:
import logging
from conf import LisaLogging
LisaLogging.setup()
# Generate plots inline
%matplotlib inline
import os
# Support to access the remote target
import devlib
from env import TestEnv
# RTApp configurator for generation of PERIODIC tasks
from wlgen import RTA, Ramp
# Setup targ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import required modules
Step2: Target Configuration
Step3: Workload Execution and Power Consumptions Samping
Step4: Power Measurements Data
|
13,198 | <ASSISTANT_TASK:>
Python Code:
import modin.pandas as pd
import numpy as np
from tqdm import tqdm
from modin.config import ProgressBar
ProgressBar.enable()
frame_data = np.random.randint(0, 100, size=(2**18, 2**8))
df = pd.DataFrame(frame_data).add_prefix("col")
df = df.applymap(lambda x: ~x)
df
!jupyter nbextension ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: On longer functions, its nice to be able to see an estimation of how much longer things will take!
Step2: Concept for exercise
|
13,199 | <ASSISTANT_TASK:>
Python Code:
import risklearning.learning_frequency as rlf
reload(rlf)
import pandas as pd
import numpy as np
import scipy.stats as stats
import math
import matplotlib.style
matplotlib.style.use('ggplot')
import ggplot as gg
%matplotlib inline
# Read in Poisson parameters used to simulate loss counts... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set up frequency distribution to generate samples
Step2: MLE for training data
Step3: Prep simulated losses for neural network
Step4: Set up ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.