Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
14,300 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
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', validation_size=0)
img = mnist.train.images[300]
plt.imshow(img.reshape((28, 28)), cmap=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Network Architecture
Step2: Training
Step3: Denoising
Step4: Checking out the performance
|
14,301 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'ukesm1-0-ll', 'seaice')
# 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: 2... |
14,302 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
X = [['asdf', '1'], ['asdf', '0']]
clf = DecisionTreeClassifier()
from sklearn.feature_extraction import DictVectorizer
X = [dict(enumerate(x)) for x in X]
vect = DictVectorizer(sparse=False)
new_X = ve... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
14,303 | <ASSISTANT_TASK:>
Python Code:
%load_ext rpy2.ipython
%%R
workDir = '/home/nick/notebook/SIPSim/dev/fullCyc/'
physeqDir = '/home/nick/notebook/SIPSim/dev/fullCyc_trim/'
physeqBulkCore = 'bulk-core_trm'
physeqSIP = 'SIP-core_unk_trm'
ampFragFile = '/home/nick/notebook/SIPSim/dev/bac_genome1147/validation/ampFrags_kde.pk... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Init
Step2: Loading phyloseq list datasets
Step3: Infer abundance distribution of each bulk soil community
Step4: Relative abundance of most ... |
14,304 | <ASSISTANT_TASK:>
Python Code:
from ceo import data_cleaning
from ceo import missing_data
from ceo import svr_prediction
from ceo import ridge_prediction
data_cleaning.clean_all_data()
missing_data.predict_all()
ridge_prediction.ridge_predict_all()
svr_prediction.SVR_predict_all()
%%HTML
<div class='tableauPlaceho... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: datacleaning
Step2: missing_data
Step3: ridge_prediction
Step4: svr_prediction
Step5: plots
|
14,305 | <ASSISTANT_TASK:>
Python Code:
x = [10, 20, 30, 40, 50]
for item in x:
print "Item is ", item
#IPython is what you are using now to run the notebook
import IPython
print ("IPython version: %6.6s (need at least 1.0)" % IPython.__version__)
# Numpy is a library for working with Arrays
import numpy as np
print (... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Python Libraries
Step2: If any of these libraries are missing or out of date, you will need to install them and restart IPython
Step3: If that... |
14,306 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import numpy as np
import matplotlib.pyplot as plt
from cs231n.gradient_check import eval_numerical_gradient_array, eval_numerical_gradient
from cs231n.layers import *
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
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: Modular neural nets
Step2: Affine layer
Step3: Affine layer
Step4: ReLU layer
Step5: ReLU layer
Step6: Loss layers
Step7: Convolution laye... |
14,307 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input 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: Run the Demo
Step2: Insert input file path and host IP
Step3: Output Format
Step4: Advanced options
|
14,308 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import faps as fp
import matplotlib.pylab as plt
import pandas as pd
from time import time, localtime, asctime
np.random.seed(37)
allele_freqs = np.random.uniform(0.2, 0.5, 50)
adults = fp.make_parents(10, allele_freqs, family_name='adult')
family1 = fp.make_offspring... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: There are multiple ways to mate adults to generate offspring. If you supply a set of adults and an integer number of offspring, make_offspring m... |
14,309 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'snu', 'sandbox-1', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
14,310 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# NO NEED TO DO MAGIC INLINE COMMAND ON QUANTOPIAN!
mcdon = get_pricing('MCD',
start_date = '2017-01-01',
end_date = '2017-02-01',
frequency = 'minute')
mc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting Information
Step2: symbols()
Step3: get_fundamentals()
Step4: The get_fundamentals() function takes in a SQLAlchemy query which can b... |
14,311 | <ASSISTANT_TASK:>
Python Code:
!curl -Lo conda_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import conda_installer
conda_installer.install()
!/root/miniconda/bin/conda info -e
!pip install --pre deepchem
import deepchem as dc
dc.__version__
tasks, datasets, transfor... | <SYSTEM_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 import the deepchem package to play with.
Step2: Anatomy of a Dataset
Step3: We now have three Dataset objects
Step4: There's a lo... |
14,312 | <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: Better performance with the tf.data API
Step2: Throughout this guide, you will iterate across a dataset and measure the performance.
Step3: Th... |
14,313 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import numpy as np
class Distiller(keras.Model):
def __init__(self, student, teacher):
super(Distiller, self).__init__()
self.teacher = teacher
self.student = student
... | <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: Construct Distiller() class
Step3: Create student and teacher models
Step4: Prepare the dataset
Step5: Train the teacher
Step6: Distill teac... |
14,314 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from qiskit_aqua.operator import Operator
from qiskit_aqua import get_initial_state_instance
num_qubits = 2
evo_time = 1
temp = np.random.random((2 ** num_qubits, 2 ** num_qubits))
h1 = temp + temp.T
qubitOp = Operator(matrix=h1)
state_in = get_initial_state_instance('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: With the operator and the initial state, we can easily compute the groundtruth evolution result as follows.
Step2: The evolve method as provide... |
14,315 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas
import statsmodels
import statsmodels.formula.api
import statsmodels.stats.api
import statsmodels.stats
import statsmodels.stats.outliers_influence
import statsmodels.graphics.regressionplots
import sklearn.preprocessing
import matplotlib.pyplot as plt
imp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Regression diagnostics
Step2: Part 1
Step3: We can see fomt the tables above that $DFBETA$ values for some of the data points are quite signif... |
14,316 | <ASSISTANT_TASK:>
Python Code:
class A(object):
pass
a_object = A()
print(type(a_object))
class B(object):
value = 1
b_object = B()
print(b_object.value)
class B(object):
value = 1
def show_value(self, another_arg):
print('self.value is {}'.format(self.value))
b1 = B()
b1.sho... | <SYSTEM_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 the reference to object, this means that our new class inherits from object. We won't be going into too much detail about inheritance, but ... |
14,317 | <ASSISTANT_TASK:>
Python Code:
# crie uma matriz 8 x 8 com valores em forma de xadrez 0,1
import numpy as np
print (matriz)
print ()
print (matriz2 )
# normalize uma matriz
matriz = np.array( [[3.,2.,1.,5.,1.],[2.,1.,4.,5.,1.],[5.,2.,1.,5.,3.] ] )
print (matriz)
# converter matriz N x 2 representando coordenadas ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercício 02
Step2: Exercício 03
Step3: Exercício 04
Step4: Exercício 05
Step5: Exercício 06
Step6: Exercício 07
Step7: Ele é representado... |
14,318 | <ASSISTANT_TASK:>
Python Code:
import math
import torch
import gpytorch
import pyro
import tqdm
import matplotlib.pyplot as plt
%matplotlib inline
intensity_max = 50
true_intensity_function = lambda times: torch.cos(times * 2 * math.pi).add(1).mul(intensity_max / 2.)
max_time = 2
times = torch.linspace(0, max_time, 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: Create sample training set
Step2: Determine how many arrivals there are
Step3: Determine when the arrivals occur
Step4: The result
Step5: Pa... |
14,319 | <ASSISTANT_TASK:>
Python Code:
import statsmodels
import statsmodels.formula.api as smf
import pandas as pd
# Load data
data_url = "https://raw.githubusercontent.com/nguyen-toan/ISLR/07fd968ea484b5f6febc7b392a28eb64329a4945/dataset/Advertising.csv"
df = pd.read_csv(data_url).drop('Unnamed: 0', axis=1)
df.head()
# Fitt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simple multiple linear regression
Step10: Diagnostic Figures/Table
Step11: Making use of the
Step12: A. Residual vs Fitted values
Step13: B... |
14,320 | <ASSISTANT_TASK:>
Python Code:
a=1
b=3.14
# Assigning value 1 to variable a and 3.14 to variable b
a = 20
b = 10
c = 15
d = 5
e = 0
e = (a + b) * c / d #( 30 * 15 ) / 5
print ("Value of (a + b) * c / d is ", e)
e = ((a + b) * c) / d # (30 * 15 ) / 5
print ("Value of ((a + b) * c) / d is ", e)
e = (a + b) *... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mathematical Operations on Variables
Step2: In case you are using Python 2 and want floating point division (e.g
Step3: Operations on Strings
... |
14,321 | <ASSISTANT_TASK:>
Python Code:
def doit(a,b):
return a+b
x = 4
y = 3
z = doit(x,x)
print(z)
x = int(input())
z = 0
for i in range(x):
z = z + i
print(z)
def x(a,b):
return b
w = int(input())
y = 2
for i in range(w):
z = x(i,y)
t = x(y,i)
print(t)
x = "Mike"
y = x.upper().replace("I","K")
y
text ... | <SYSTEM_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. 8
Step2: A. 3
Step3: A. 8
Step4: A. 'Miie'
|
14,322 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from figures import make_dataset
x, y = make_dataset()
X = x.reshape(-1, 1)
from sklearn.tree import DecisionTreeRegressor
reg = DecisionTreeRegressor(max_depth=5)
reg.fit(X, y)
X_fit = np.linspace(-3, 3, 1000).reshape... | <SYSTEM_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'll explore a class of algorithms based on decision trees.
Step2: A single decision tree allows us to estimate the signal in a non-param... |
14,323 | <ASSISTANT_TASK:>
Python Code:
def strip_id(s):
try:
index = s.index(':')
except ValueError:
index = len(s)
return s[:index]
columns = [
'agency_id',
'service_date_id', 'service_date_date',
'route_id', 'route_short_name', 'route_long_name',
'trip_id', 'trip_headsign', 'trip_... | <SYSTEM_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 process the CSV to stem the stop_id as they are currently not in the official form. The geops dataset add a suffix to each stop_id if they co... |
14,324 | <ASSISTANT_TASK:>
Python Code:
a = list(range(10))
b = list(range(100))
a.append('ich bin keine Zahl')
b.append('ich bin keine Zahl')
a.pop()
b.pop()
anew = []
for x in a:
x = str(x)
anew.append(x)
anew
bnew = []
for x in b:
x = str(x)
bnew.append(x)
bnew[:10]
b[-11:-1]
lst = [4,6,2328,926,323,21,... | <SYSTEM_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.Mache dasselbe mit einer Liste aus 100 Elementen und ordne sie der Variabel b zu.
Step2: 3.Füge beiden Listen folgenden String an
Step3: 4.L... |
14,325 | <ASSISTANT_TASK:>
Python Code:
solow.Model.output?
# define model variables
A, K, L = sym.symbols('A, K, L')
# define production parameters
alpha, sigma = sym.symbols('alpha, sigma')
# define a production function
cobb_douglas_output = K**alpha * (A * L)**(1 - alpha)
rho = (sigma - 1) / sigma
ces_output = (alpha * K**... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Examples
Step2: 1.2 Defining model parameters
Step3: In addition to the standard parameters $g, n, s, \delta$, one will also need to specify a... |
14,326 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 使用 Multilingual Universal Sentence Encoder 研究跨语言相似度和构建语义搜索引擎
Step2: 下面是附加的样板代码,我们在其中导入了预训练的 ML 模型,在此笔记本中我们将用它来对文本进行编码。
Step3: 可视化语言之间的文本相似度
St... |
14,327 | <ASSISTANT_TASK:>
Python Code:
# Set things up
%matplotlib inline
# Importing CartoPy
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
# Works with matplotlib's built-in transform support.
fig = plt.figure(figsize=(10, 4))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.Robin... | <SYSTEM_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 simplest plot we can make sets a projection with no parameters. The one below uses the Robinson projection
Step2: We also have fine-tuned c... |
14,328 | <ASSISTANT_TASK:>
Python Code:
# Find the city in a weather related query
train_x = [
"What is the weather like in Paris ?",
"What kind of weather will it do in London ?",
"Give me the weather forecast in Berlin please .",
"Tell me the forecast in New York !",
"Give me the weather in San Francisco .... | <SYSTEM_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 import all the modules we will need.
Step2: It's now time to write our network as described before.
Step3: We will also need a function to... |
14,329 | <ASSISTANT_TASK:>
Python Code:
# %load Source/fastICA_0.py
import numpy as np
from sklearn import preprocessing
def sym_decorrelation(W):
Symmetric decorrelation
K = np.dot(W, W.T)
s, u = np.linalg.eigh(K)
W = (u @ np.diag(1.0/np.sqrt(s)) @ u.T) @ W
return W
def g_logcosh(wx,alpha):
derivativ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step6: Implementation and Optimization for Independent Component Analysis
Step7: 3. Code Profiling and Optimization
Step8: 3.2 Bottlenecks
Step9: Th... |
14,330 | <ASSISTANT_TASK:>
Python Code:
pd.read_csv("../datasets/google_trends_datascience.csv", index_col=0).plot();
import pandas as pd
log = pd.read_csv("../datasets/git_log_intellij.csv.gz")
log.head()
log.info()
log['timestamp'] = pd.to_datetime(log['timestamp'])
log.head()
# use log['timestamp'].max() instead of pd.Ti... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: "100" == max. popularity!
Step2: We explore some basic key elements of the dataset
Step3: <b>1</b> DataFrame (~ programmable Excel worksheet),... |
14,331 | <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: Create and convert a TensorFlow model
Step2: Generate data
Step3: Add some noise
Step4: Split our data
Step5: Design a model
Step6: Train t... |
14,332 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from cs231n.classifiers.fc_net import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check import eval_numerical_gradient, eval_numer... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fully-Connected Neural Nets
Step4: Affine layer
Step5: Affine layer
Step6: ReLU layer
Step7: ReLU layer
Step8: "Sandwich" layers
Step9: Lo... |
14,333 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
from sklearn.cross_validation import train_test_split
from sklearn import cross_validation, metrics
from sklearn import preprocessing
import matplotlib.pyplot as plt
cols = ['Area', 'Perimeter','Compactness','Kernel_Length','Kernel... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <hr>
Step2: No of components will be equal to no of feature variables i.e. 7.
Step3: The explained variance is high for the first two dimensio... |
14,334 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import fetch_20newsgroups
dataset = fetch_20newsgroups(shuffle=True, random_state=1, remove=('headers', 'footers', 'quotes'))
documents = dataset.data
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
no_features = 1000
# NMF is able to us... | <SYSTEM_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 creation of the bag of words matrix is very easy in Scikit Learn — all the heavy lifting is done by the feature extraction functionality pro... |
14,335 | <ASSISTANT_TASK:>
Python Code:
np.random.seed(0)
x = 10 * np.random.rand(100)
def model(x, sigma=0.3):
fast_oscillation = np.sin(5 * x)
slow_oscillation = np.sin(0.5 * x)
noise = sigma * np.random.rand(len(x))
return slow_oscillation + fast_oscillation + noise
plt.figure(figsize = (12,10))
y = model(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: Fit a Random Forest Model
Step2: Print out the misfit using the mean squared error.
Step3: Using ANN
Step4: Exercise
|
14,336 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
df_all = pd.read_csv('All content.csv')
df_erik = pd.read_csv('Erik content.csv')
df_all = df_all[(df_all.Published > df_erik.at[6,'Published']) &
(df_all['Url'].str.contains('/arti... | <SYSTEM_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 eliminate any article published more recently than last Friday or any article published before Erik joined the company. This is done in ... |
14,337 | <ASSISTANT_TASK:>
Python Code:
cursor.execute(SELECT *
FROM dot_311
LIMIT 1)
cursor.fetchone()
cursor.execute(SELECT column_name FROM information_schema.columns WHERE table_name='dot_311')
cursor.fetchall()
cursor.execute(SELECT created_date, closed_date
FROM dot_311
LIMIT 1)
cursor.fetchone()
cu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: What does this data look like?
Step3: What are the column names?
Step5: What does a created and closed date look like?
Step7: Okay, let's jus... |
14,338 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow import keras
class CustomModel(keras.Model):
def train_step(self, data):
# Unpack the data. Its structure depends on your model and
# on what you pass to `fit()`.
x, y = data
with tf.GradientTape() as tape:
... | <SYSTEM_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 first simple example
Step2: Let's try this out
Step3: Going lower-level
Step4: Supporting sample_weight & class_weight
Step5: Providing yo... |
14,339 | <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... |
14,340 | <ASSISTANT_TASK:>
Python Code:
# WELL
# all valves closed
st = 'A01'
x1,y1,z1 = locs[st]
Z.move(42)
XY.move_xy(x1,y1)
Z.move(z1)
log.append([time.ctime(time.time()), 'AT '+st])
# ACQUIRE 120 frames 11000 ms
# OPEN Hep_1 + W_1 (tree in + out)
log.append([time.ctime(time.time()), 'OPEN tree in + out'])
# flow 20 min (fil... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SETUP
Step2: Autosipper
Step3: Manifold
Step4: Micromanager
Step5: Preset
Step6: MM Get info
Step7: Video
Step8: EXIT
|
14,341 | <ASSISTANT_TASK:>
Python Code:
# Imports
from __future__ import print_function
from convert_frcmod import *
import openeye.oechem as oechem
import openeye.oeiupac as oeiupac
import openeye.oeomega as oeomega
import openeye.oedepict as oedepict
from IPython.display import display
from openff.toolkit.typing.engines.smirn... | <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: Relevant methods
Step4: 1. Convert specified SMIRKS frcmod file to SMIRNOFF FFXML
Step5: 2. Load smirnoff99Frosst from current release
Step6: ... |
14,342 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn import svm
from sklearn import preprocessing
# Define a useful helper function to read in our PCL files and store the gene names,
# matrix of values, and sample names
# We'll use this function later, but we don't need to dig into how it works here.
def rea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Congratulations! You've built your first SVM, and on training data it separates tumor data from normal data with over 90% accuracy! Now that we'... |
14,343 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False)
DO NOT MODIFY THIS CELL
def fully_connected(prev_layer, num_units):
Create a fully connectd layer with the given layer... | <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: Batch Normalization using tf.layers.batch_normalization<a id="example_1"></a>
Step6: We'll use the following function to create convolutional l... |
14,344 | <ASSISTANT_TASK:>
Python Code:
from azure.identity import AzureCliCredential
from azure.digitaltwins.core import DigitalTwinsClient
# using yaml instead of
import yaml
import uuid
# using altair instead of matplotlib for vizuals
import numpy as np
import pandas as pd
# you will get this from the ADT resource at portal... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I'm going to set up a generic function that runs queries and gets the data. This will keep me from doing it over and over.
Step3: Note that th... |
14,345 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.covariance import LedoitWolf
import seaborn as sns
import statsmodels.api as sm
tickers = ['WFC', 'JPM', 'USB', 'XOM', 'BHI', 'SLB'] # The securities we want to go long on
historical_prices = get_pricing(... | <SYSTEM_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 Fundamental Law of Asset Management
Step2: The result here is that we have six bets and they are all very highly correlated.
Step3: The be... |
14,346 | <ASSISTANT_TASK:>
Python Code:
import processing.procore as pcore
import features.socios as s
tbls = pcore.loadTables()
print("Stored Data Tables\n")
for k in sorted(list(tbls.keys())):
print(k)
tbls['questionaires'][tbls['questionaires'].QuestionaireID.isin([3, 4, 6, 7, 1000000, 1000001, 1000002])]
searchterm = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: List of Questionaires
Step2: Search Questions
Step3: Search Answers
Step4: List of Site Locations and Corresponding RecorderIDs by Year
|
14,347 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import urllib2
import scipy.stats as stats
url = ('https://raw.githubusercontent.com/Upward-Spiral-Science/data/master/syn-density/output.csv')
data = urllib2.urlopen(url)
csv = np.genfromtxt(data, delimiter=",")[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: Set up different sections of data based on clusters of 3 and regressions
Step2: Start regressions in cluster
Step3: 1.2) 2nd cluster
Step4: 1... |
14,348 | <ASSISTANT_TASK:>
Python Code:
def lenet(num_classes):
import mxnet as mx
data = mx.symbol.Variable('data')
# first conv
conv1 = mx.symbol.Convolution(data=data, kernel=(5,5), num_filter=20)
tanh1 = mx.symbol.Activation(data=conv1, act_type="tanh")
pool1 = mx.symbol.Pooling(data=tanh1, pool_type... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: DeepWater for MXNET
Step2: Let's create the lenet model architecture from scratch using the MXNet Python API
Step3: To import the model inside... |
14,349 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
print(dir(np.random))
%pylab inline
import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams.update({'font.size': 20})
rdata = np.random.randn(1000)
fig = plt.figure(figsize=(6, 4))
plt.hist(rdata)
print(np.mean(rdata), np.median(rdata), np.std(rdata))
... | <SYSTEM_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 to draw samples from a gaussian distribution
Step2: other distributions ...
Step3: $\log_{10}(d) = 1 + \mu /5 $
Step4: 2. plotting
Step5:... |
14,350 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import scipy as sp
import pymc as pm
import seaborn as sb
import matplotlib.pyplot as plt
def sample_path(rho, sigma, T, y0=None):
'''
Simulates the sample path for y of length T+1 starting from a specified initial value OR if y0
is Non... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Probabilistic model
Step2: Probabilistic models in pymc
Step3: 2) Determinsitic variable
Step4: (b) Conditional mean of $y_t$, $\mu_y$, is a ... |
14,351 | <ASSISTANT_TASK:>
Python Code:
for p in (True, False):
for q in (True, False):
print("%10s %10s %10s" %(p, q, (p and q)))
for p in (True, False):
for q in (True, False):
for r in (True, False):
print("%10s %10s %10s %s" %(p, q, r, not p and (q or r)))
def implies(a, b):
if 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: To get more intuition, let's consider the code segment that generates the truth table for the expression $\neg p \wedge (q\vee r)$
Step2: Other... |
14,352 | <ASSISTANT_TASK:>
Python Code:
# Print the last item from year and pop
# print(year[-1])
# print(pop[-1])
# Import matplotlib.pyplot as plt
# import matplotlib.pyplot as plt
# Make a line plot: year on the x-axis, pop on the y-axis
# plt.plot( year, pop)
# plt.show()
# Print the last item of gdp_cap and life_exp
# pri... | <SYSTEM_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 2
Step2: Scatter Plot 1
Step4: Scatter Plot 2
Step5: Histograms
Step6: RQ3
Step8: Build a histogram 3
Step10: Choose the right ... |
14,353 | <ASSISTANT_TASK:>
Python Code:
from pygsf.io.gdal.raster import try_read_raster_band
source_data = "/home/mauro/Documents/projects/gsf/example_data/others/horiz_plane.asc"
success, cntnt = try_read_raster_band(raster_source=source_data)
print(success)
geotransform, projection, band_params, data = cntnt
type(geotransf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test case 1
Step2: We read the data source with success. So we may unpack the result.
Step3: Hmmm, there is no projection info. In fact, there... |
14,354 | <ASSISTANT_TASK:>
Python Code:
# Clone the repository from GitHub
!git clone --depth 1 -q https://github.com/tensorflow/tensorflow
# Copy the training scripts into our workspace
!cp -r tensorflow/tensorflow/lite/micro/examples/magic_wand/train train
# Download the data we will use to train the model
!wget http://downl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepare the data
Step2: We'll then run the scripts that split the data into training, validation, and test sets.
Step3: Load TensorBoard
Step4... |
14,355 | <ASSISTANT_TASK:>
Python Code:
# Authors: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
from os import path as op
import mne
from mne.preprocessing import maxwell_filter
print(__doc__)
data_path = op.join(mne.datasets.misc.data_path(verbose=True), 'movement')
head_pos = mne.chpi.read_head_pos(op.joi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Visualize the "subject" head movements. By providing the measurement
Step2: This can also be visualized using a quiver.
Step3: Process our sim... |
14,356 | <ASSISTANT_TASK:>
Python Code:
#先把数据读进来
import pandas as pd
data = pd.read_csv('kaggle_bike_competition_train.csv', header = 0, error_bad_lines=False)
#看一眼数据长什么样
data.head()
# 处理时间字段
temp = pd.DatetimeIndex(data['datetime'])
data['date'] = temp.date
data['time'] = temp.time
data.head()
# 设定hour这个小时字段
data['hour'] = p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 把datetime域切成 日期 和 时间 两部分。
Step2: 时间那部分,好像最细的粒度也只到小时,所以我们干脆把小时字段拿出来作为更简洁的特征。
Step3: 仔细想想,数据只告诉我们是哪天了,按照一般逻辑,应该周末和工作日出去的人数量不同吧。我们设定一个新的字段dayofwe... |
14,357 | <ASSISTANT_TASK:>
Python Code:
# Two threads that have a critical section executed in parallel without mutual exclusion.
# This code does not work!
import threading
import time
counter = 10
def task_1():
global counter
for i in range(10**6):
counter += 1
def task_2():
global counter
for... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The same example, using mutual exclusion (using a lock)
Step2: Notice that both tasks are CPU-bound. This means that using threading has not an... |
14,358 | <ASSISTANT_TASK:>
Python Code:
def get_max_profit(stock_prices_yesterday):
max_profit = 0
# go through every time
for outer_time in xrange(len(stock_prices_yesterday)):
# for every time, go through every OTHER time
for inner_time in xrange(len(stock_prices_yesterday)):
# for each... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: But that will take O(n^2) time, since we have two nested loops—for every time, we're going through every other time. Can we do better?
Step2: W... |
14,359 | <ASSISTANT_TASK:>
Python Code:
# import the dataset
from quantopian.interactive.data.quandl import fred_icsa
# Since this data is public domain and provided by Quandl for free, there is no _free version of this
# data set, as found in the premium sets. This import gets you the entirety of this data set.
# import data 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: The data goes all the way back to 1947 and is updated quarterly.
Step2: Let's go plot for fun. 2545 rows are definitely small enough to just pu... |
14,360 | <ASSISTANT_TASK:>
Python Code:
d = {'Angela': 23746, 'Sofia': 2514, 'Luis': 3747, 'Diego': 61562}
d['Angela']
d['Diego']
d['Luis']
d['Sofia']
d['Valeriano'] = 1234
print(d)
d.pop('Angela')
print(d)
list(d.keys())
list(d.values())
'Miguel' in d.keys()
'Luis' in d.keys()
activities = {
'Monday': {'study':4, '... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In this example the keys are strings (corresponding to names) and the values are numbers.
Step2: Adding a new element in the dictionary is very... |
14,361 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inm', 'sandbox-1', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
14,362 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.ndimage
square = np.zeros((32, 32))
square[10:-10, 10:-10] = np.random.randint(1, 255, size = (12, 12))
np.random.seed(12)
x, y = (32*np.random.random((2, 20))).astype(int)
square[x, y] = np.random.randint(1, 255, size = (20,))
def filter_isolated_cells(arr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
14,363 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'sandbox-1', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
14,364 | <ASSISTANT_TASK:>
Python Code:
plt.imshow(reshaped_sample, cmap = 'gray')
test_sample = mnist.test.images[0]
print(test_sample.shape)
reshaped_test_sample = test_sample.reshape((28,28))
print(reshaped_sample.shape)
plt.imshow(reshaped_test_sample, cmap = 'gray')
import tensorflow as tf
x = tf.placeholder(tf.float32, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Testing Data Sample
Step2: Main Code
Step3: reduce_sum
Step4: softmax_cross_entropy_with_logits(logits, labels, dim=-1, name=None)
Step5: ... |
14,365 | <ASSISTANT_TASK:>
Python Code:
L = [2, 4, 6, 8, 10] #use enumerate to get both index and value of a list
for i, val in enumerate(L):
print(i, val)
L = [2, 4, 6, 8, 10]
R = [3, 6, 9, 12, 15]
for lval, rval in zip(L, R):
print(lval, rval)
# find the first 10 square numbers
square = lambda x: x ** 2
for val 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: zip
Step2: map and filter
Step3: The filter iterator looks similar, except it only passes-through values for which the filter function evaluat... |
14,366 | <ASSISTANT_TASK:>
Python Code:
import requests
from bs4 import BeautifulSoup
def listFD(url, ext=''):
page = requests.get(url).text
soup = BeautifulSoup(page, 'html.parser')
return [url + node.get('href') for node in soup.find_all('a')
if node.get('href').endswith(ext)]
site = 'http://people.du... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step6: 2. (25 points) Accelerating CPU bound procedures
Step7: 3. (25 points) Use C++ to
Step8: 4. (25 points) 4. Write a C++ function that uses the ... |
14,367 | <ASSISTANT_TASK:>
Python Code:
%%bash
java -version
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
import seaborn as sns
from matplotlib import pylab
import numpy as np
pylab.rcParams['figure.figsize'] = (16.0, 8.0)
sns.set(style="whitegrid")
def createTestFileCollection... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: También es necesario tener añadida al PATH la carpeta bin de spark 2.2.1 para hadoop 2.7 o posterior (descarga).
Step2: Creación de las colecci... |
14,368 | <ASSISTANT_TASK:>
Python Code:
# import third party python libraries
import pandas as pd
import matplotlib.pylab as plt
import numpy as np
# make plots inline
%matplotlib inline
# later try %matplotlib notebook
#%matplotlib notebook
# import pygslib
import pygslib
# importing drillhole tables into pandas dataframes
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: Need some help? Just type
Step2: Pandas provides a large set of functions to modify your data. Let's remove some columns and make non-assayed i... |
14,369 | <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... |
14,370 | <ASSISTANT_TASK:>
Python Code:
# Model category name used throughout the subsequent analysis
model_cat_id = "03"
# Which features from the dataset should be loaded:
# ['all', 'actual', 'entsoe', 'weather_t', 'weather_i', 'holiday', 'weekday', 'hour', 'month']
features = ['actual', 'weather']
# LSTM Layer configuration
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Module imports
Step2: Overall configuration
Step3: Preparation and model generation
Step4: Loading the data
Step5: Running through all gener... |
14,371 | <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
|
14,372 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'sandbox-3', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
14,373 | <ASSISTANT_TASK:>
Python Code:
for i in range(5):
print (i)
for character in "Hi There!":
print (character)
dico={"a":1,"b":2,"c":3}
for k in dico.keys():
print (k)
# Si une seule variable itérative est spécifiée, celle-ci est un-tuple.
for kv in dico.items():
print (kv)
# Si deux variables itérative... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: L'appel à la fonction range(n) permet d'itérer sur les entiers de 0 à n-1 mais il est possible de spécifier des intervalles des valeurs de chaqu... |
14,374 | <ASSISTANT_TASK:>
Python Code:
# Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
# sphinx_gallery_thumbnail_number = 3
import matplotlib.pyplot as plt
import numpy as np
import mne
from mne.datasets import sample
from mne.beamformer import make_lcmv, apply_lcmv
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: Get epochs
Step2: Run beamformers and look at maximum outputs
Step3: We can also look at the spatial distribution
|
14,375 | <ASSISTANT_TASK:>
Python Code:
# This to clear all variable values
%reset
# Import the required modules
import pandas as pd
import numpy as np
#import scipy as sp
# simple function to read in the user data file.
# the argument parse_dates takes in a list of colums, which are to be parsed as date format
user_data_raw = ... | <SYSTEM_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 column name watching_videos (binary - 1 for yes, blank/0 for no) is too long and has special chars, lets change it to watching_videos
Step2:... |
14,376 | <ASSISTANT_TASK:>
Python Code:
pa = 0.001
pbga = 0.95
pac = 1-pa
pbgac = 0.05
print "Total probability of P(B) is " + \
str(0.001*0.95 + 0.05* 0.999)
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import mpld3
mpld3.enable_notebook()
fig, ax = plt.subplots(subplot_kw=dict(axisbg='#EEEEEE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 你被檢出,但妳趁的事
|
14,377 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
import time
from matplotlib import rcParams
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from six import iteritems
from nilmtk import DataSet, TimeFrame, MeterGroup, HDFDataStore
from nilmtk.legacy.disaggregate 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: Dividing data into train and test set
Step2: Let us use building 1 for demo purposes
Step3: Let's split data at April 30th
Step4: Visualizing... |
14,378 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import optimize
import pymc3 as pm
import theano as thno
import theano.tensor as T
# configure some basic options
s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load and Prepare Data
Step2: Observe
Step3: Sample
Step4: View Traces
Step5: NOTE
Step6: Sample
Step7: View Traces
Step8: Observe
Step9: ... |
14,379 | <ASSISTANT_TASK:>
Python Code:
import io, os, sys, types
from IPython.nbformat import current
from IPython.core.interactiveshell import InteractiveShell
def find_notebook(fullname, path=None):
find a notebook, given its fully qualified name and an optional path
This turns "foo.bar" into "foo/bar.ipynb"
... | <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: Import hooks typically take the form of two objects
Step5: Notebook Loader
Step7: The Module Finder
Step8: Register the hook
Step9: After th... |
14,380 | <ASSISTANT_TASK:>
Python Code:
PATH=Config().data_path()/Path('rossmann/')
table_names = ['train', 'store', 'store_states', 'state_names', 'googletrend', 'weather', 'test']
tables = [pd.read_csv(PATH/f'{fname}.csv', low_memory=False) for fname in table_names]
train, store, store_states, state_names, googletrend, weathe... | <SYSTEM_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 turn state Holidays to booleans, to make them more convenient for modeling. We can do calculations on pandas fields using notation very simil... |
14,381 | <ASSISTANT_TASK:>
Python Code:
import numpy
import pandas
from matplotlib import pyplot
import pycwt
%matplotlib inline
url = '../dat/GSPC.csv.gz'
dat = pandas.read_csv(url, index_col=0, parse_dates=[0])
dat.describe()
fig = pyplot.figure(figsize=[8, 4])
ax = dat['Close'].plot()
ax.set_ylabel('Close')
ax.grid('on')
fi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Série temporal S&P 500
Step2: Nota-se que o índice possui um aumento com tendência exponencial e dois instantes de queda abrupta -- durante as ... |
14,382 | <ASSISTANT_TASK:>
Python Code:
# Provided simple test() function used in main() to print
# what each function returns vs. what it's supposed to return.
def test(got, expected):
if got == expected:
prefix = ' OK '
else:
prefix = ' X '
print '%s got: %s expected: %s' % (prefix, repr(got), 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: Fill in the code for the functions below. main() is already set up
Step2: B. sort_last
Step3: C. linear_merge
|
14,383 | <ASSISTANT_TASK:>
Python Code:
# modules
from keras.layers import Input, Dense, Dropout
from keras.models import Model
from keras.datasets import mnist
from keras.models import Sequential, load_model
from keras.optimizers import RMSprop
from keras.callbacks import TensorBoard
from __future__ import print_function
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: Import and basic data inspection
Step2: The dataframe consists of only positive values and the classes are encoded as strings in the variable w... |
14,384 | <ASSISTANT_TASK:>
Python Code:
import math
def gamblers_ruin(i, p, q, N):
if math.isclose(p,q):
return i/N
else:
return ((1 - (q/p)**i)) / (1 - (q/p)**N)
p = 0.49
q = 1.0 - p
N = 20
i = N/2
print("With N={} and p={}, probability that A wins all is {:.2f}".format(N, p, gamblers_ruin(i, p, q, 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: And assuming a fair game where $p = q = 0.5$
Step2: Could the game ever continue forever on to infinity?
|
14,385 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from ipywidgets import interact
f1 = lambda x: x[0]**2+x[1]**2-1
f2 = lambda x: x[1]-x[0]**2
F = lambda x: np.array([f1(x),f2(x)], dtype=float)
J = lambda x: np.array([[2*x[0], 2*x[1]],[-2*x[0], 1.0]], dtype=float)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <div id='newton' />
Step2: The Newton Step takes advantage of the vectorized implementation!
Step3: The next cell of code is just needed for p... |
14,386 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile
from tqdm import tqdm
class DLProgress(tqdm):
last_block = 0
def hook(self, block_num=1, block_size=1, total_size=None):
self.total = total_size
self.update((block_num - self.last_block) * block_size... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Overview
Step2: Load the Data
Step3: Preprocess the Data
Step6: Normalize the features
Step7: One-Hot Encode the labels
Step8: Keras Sequen... |
14,387 | <ASSISTANT_TASK:>
Python Code:
import sqlite3
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
#import CGATPipelines.Pipeline as P
import os
import statistics
#import collections
#load R and the R packages required
#%load_ext rpy2.ipython
#%R... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This is where we are and when the notebook was run
Step2: First lets set the output path for where we want our plots to be saved and the databa... |
14,388 | <ASSISTANT_TASK:>
Python Code:
import csv
import string
import datetime
import pandas as pd
import numpy as np
# import matplotlib pyplot commands
from matplotlib.pyplot import *
# Show Plots in the Notebook
%matplotlib inline
rcParams['figure.figsize']= (10, 8) # set Chart Size
rcParams['font.size'] = 14 ... | <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: Use this function to clean up point names and location names
Step3: Use the Python csv module to read the file
Step4: Create the Final DataFra... |
14,389 | <ASSISTANT_TASK:>
Python Code:
import gammalib
import ctools
import cscripts
%matplotlib inline
import matplotlib.pyplot as plt
caldb = 'prod2'
irf = 'South_5h'
emin = 0.1 # TeV
emax = 160.0 # TeV
pointing_file = 'pointings.txt'
# open file
f = open(pointing_file, 'w')
# header
f.write('id,ra,dec,tmin,tmax\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: We also import the matplotlib package for plotting.
Step2: Simulated dataset
Step3: We will simulate an observation of the region around the f... |
14,390 | <ASSISTANT_TASK:>
Python Code:
#Plotting the relationships between variables
sns.set_style("white")
dfcont = df.drop(['carname','cylinders','modelyear','origin'], axis=1)
# Declare that you want to make a scatterplot matrix.
g = sns.PairGrid(dfcont, diag_sharey=False)
# Scatterplot.
g.map_upper(plt.scatter, alpha=.5)
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From the correlation matrix it seems that displacement, horsepower and weight are strongly correlated. Acceleration is less correlated with the ... |
14,391 | <ASSISTANT_TASK:>
Python Code:
# grab the entire Penn World Tables data from the web...
pwt = pypwt.load_pwt_data()
#...this gives us a panel (i.e., two dimensional) data set
pwt
def labor_supply(data, year="1950-01-01"):
Labor supply in a given year is the product of number of employed
persons, 'emp', 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:
Step4: <h1 class="title-slide"> (Linear) Regression </h1>
Step5: Let's focus on a relation between...
Step7: <h2 class="section-header">Step 3
Step8:... |
14,392 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
import numpy as np
from scipy.special import beta
# Two variable drichlet ditribution with alpha = (1,2)
def drichlet_pdf(x, y):
return (np.power(x, 1)*np.power(y, 2))/beta(x, y)
from pgmpy.factors.continuous import ContinuousFactor
drichlet_factor ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Continuous Factors
Step2: This class supports methods like marginalize, reduce, product and divide just like what we have with discrete classes... |
14,393 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
%matplotlib inline
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import math
import os
import rand... | <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: Download the text corpus.
Step4: Read the data into a string.
Step5: Build the dictionary and replace rare words with UNK token.
Step6: Funct... |
14,394 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import datetime
np.random.seed(1337) # for reproducibility
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
from keras.utils import 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: Settings
Step2: Dataset Preparation
Step3: Your Turn
Step4: ```python
|
14,395 | <ASSISTANT_TASK:>
Python Code:
import hashlib
import os
import pickle
from urllib.request import urlretrieve
import numpy as np
from PIL import Image
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
from sklearn.utils import resample
from tqdm import tqdm
from zipfil... | <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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this... |
14,396 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def well2d(x, y, nx, ny, L=1.0):
Compute the 2d quantum well wave function.
answer = np.array(2/L * np.sin(nx*np.pi*x/L)*np.sin(ny*np.pi*y/L))
return answer
psi = well2d(np.linspace(0,1,10), np.linspace(0,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:
Step2: Contour plots of 2d wavefunctions
Step3: The contour, contourf, pcolor and pcolormesh functions of Matplotlib can be used for effective visuali... |
14,397 | <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... |
14,398 | <ASSISTANT_TASK:>
Python Code:
sample_rate = 4096
nyquist = sample_rate/2
time_length_seconds = 512
# Make the data twice as long so we can cut off the wrap-around
num_noise_samples=2*time_length_seconds*sample_rate
white_noise_fd=rfft(np.random.normal(size=num_noise_samples))
sim_freqs=np.arange(len(white_noise_fd))/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Generate fake Gaussian noise
Step4: The estimate using the Hann window recovers the true spectrum very well. However, forgetting to use a windo... |
14,399 | <ASSISTANT_TASK:>
Python Code:
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
tf.__version__
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("tm... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Artificial Neural Networks
Step2: Exercise 8
Step3: 8.2) Write the training code, and train the model for about 20 epochs (i.e. enough trainin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.