Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
6,800 | <ASSISTANT_TASK:>
Python Code:
from pylab import *
from copy import deepcopy
from matplotlib import animation, rc
from IPython.display import HTML
%matplotlib inline
rc('text', usetex=True)
font = {'family' : 'normal',
'weight' : 'bold',
'size' : 15}
matplotlib.rc('font', **font)
E1, E2, E3 = 0., 20.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Superexchange in a three-level system.
Step2: (b)
Step3: 2. The one-dimensional soft-core potential.
Step4: 3. Ionization from a one-dimen... |
6,801 | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
from starthinker.util.configuration import Configuration
CONFIG = Configuration(
project="",
client={},
service={},
user="/content/user.json",
verbose=True
)
FIELDS = {
'auth_read':'user', # Credentials used for reading... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Set Configuration
Step2: 3. Enter Sheet Clear Recipe Parameters
Step3: 4. Execute Sheet Clear
|
6,802 | <ASSISTANT_TASK:>
Python Code:
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
tf.__version__
learning_rate = 0.01
momentum = 0.8
filenames = ["data/life_satisfaction.csv"]
n_epochs = 500
batch_size = 5
graph = tf.Graph()
with graph.as_default():
reader =... | <SYSTEM_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 previous notebooks
Step2: TensorBoard
Step3: 6.4) Print out the name of a few operations. Notice how the names now have the scope as a pr... |
6,803 | <ASSISTANT_TASK:>
Python Code:
max_k =50
accuracies = np.zeros(max_k, dtype='float64')
cv = model_selection.StratifiedKFold(n_splits=5)
for k in range(max_k + 1)[1:]:
estimator = neighbors.KNeighborsClassifier(n_neighbors=k)
accuracies[k - 1] = model_selection.cross_val_score(estimator,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Посмотрим на точность в зависимости от $k$ при кросс-валидации на 5 обычных фолдов.
Step2: Посмотрим, что будет на 3 классах.
Step3: Посмотрим... |
6,804 | <ASSISTANT_TASK:>
Python Code:
# ph_sel_name = "all-ph"
# data_id = "7d"
from fretbursts import *
init_notebook()
from IPython.display import display
data_dir = './data/singlespot/'
import os
data_dir = os.path.abspath(data_dir) + '/'
assert os.path.exists(data_dir), "Path '%s' does not exist." % data_dir
from glob... | <SYSTEM_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 software and filenames definitions
Step2: Data folder
Step3: Check that the folder exists
Step4: List of data files in data_dir
Step5: ... |
6,805 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import os
import numpy as np
import pandas as pd
from sklearn.preprocessing import scale
from sklearn.preprocessing import normalize
from sklearn import cross_validation as cv
from sklearn.metrics import confusion_matrix, classification_report
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: Let's try it together.
Step2: More than 50 samples?
Step4: Predicting a quantity or a category?
Step5: Since our categorical dataset has few... |
6,806 | <ASSISTANT_TASK:>
Python Code:
!pip install dm-sonnet tqdm
# Get enformer source code
!wget -q https://raw.githubusercontent.com/deepmind/deepmind-research/master/enformer/attention_module.py
!wget -q https://raw.githubusercontent.com/deepmind/deepmind-research/master/enformer/enformer.py
import tensorflow as tf
# Mak... | <SYSTEM_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
Step3: Code
Step4: Load dataset
Step5: Model training
Step13: Evaluate
Step14: Restore Checkpoint
|
6,807 | <ASSISTANT_TASK:>
Python Code:
Celsius = [36.2, 36.7, 47.3, 17.8]
Fahrenheit = [1.8 * C + 32 for C in Celsius]
Fahrenheit
colors = ["red", "purple", "yellow", "blue", "green"]
things = [ "triangle", "rectangle", "pentagon" ]
all_combination = [(x, y) for x in things for y in colors]
all_combination
import urllib
ur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 위 리스트를 이용하여 화씨 온도로 이루어진 리스트를 구현하는 방법은 아래와 같다.
Step2: 예제
Step3: (모양, 색깔) 형태의 튜플들의 가능한 모든 조합을 갖는 리스트를 구현하려면 다음과 할 수 있다.
Step4: 해시 테이이블 활용
Step5... |
6,808 | <ASSISTANT_TASK:>
Python Code:
from PersistenceExplorer import *
[ filename for filename in os.listdir('../data/bmp') if filename.endswith('.bmp') ]
ProcessImageFolderWithPHAT('../data/bmp/')
[ filename for filename in os.listdir('../data/bmp/pd_sub') if filename.endswith('.csv') ]
with open('../data/bmp/pd_sub/000... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Computing persistence of images
Step2: Now that we know we have a set of images, we want to compute the corresponding persistence diagrams. The... |
6,809 | <ASSISTANT_TASK:>
Python Code:
from google.cloud import aiplatform
REGION = 'us-central1'
PROJECT_ID = !(gcloud config get-value project)
PROJECT_ID = PROJECT_ID[0]
# Set `PATH` to include the directory containing KFP CLI
PATH=%env PATH
%env PATH=/home/jupyter/.local/bin:{PATH}
!cat trainer_image_vertex/Dockerfile
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: Understanding the pipeline design
Step2: Let's now build and push this trainer container to the container registry
Step3: To match the ml fram... |
6,810 | <ASSISTANT_TASK:>
Python Code:
import torch as t
# Tensors
a = t.tensor([1,2,3])
# Can specify type during construction
a = t.tensor([1,2,3], dtype=t.half)
# Can cast to different types once constructed
a
a.double()
a.float()
a.short()
a.long()
import numpy as np
x = t.Tensor([1,2,3])
x
y = x.numpy()
type(y)
x
y
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: | Data type | dtype |CPU tensor |GPU tensor |
Step2: However, they point to the s... |
6,811 | <ASSISTANT_TASK:>
Python Code:
# Importing a few necessary libraries
import numpy as np
import matplotlib.pyplot as pl
from sklearn import datasets
from sklearn.tree import DecisionTreeRegressor
# Make matplotlib show our plots inline (nicely formatted in the notebook)
%matplotlib inline
# Create our client's feature 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: Statistical Analysis and Data Exploration
Step 1
Step2: Question 1
Step4: Answer
Step6: Question 3
Step8: Question 4
Step11: Question 5
Ste... |
6,812 | <ASSISTANT_TASK:>
Python Code:
def squared_numbers(n):
return [x*x for x in range(n)]
def sum_squares(n):
return sum(squared_numbers(n+1))
sum_squares(20000000)
def squared_numbers_alternate(n):
for x in range(n):
yield x*x
def sum_squares_alternate(n):
return sum(squared_numbers_alter... | <SYSTEM_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 code works and is all great, but it has one flaw
Step2: At this you may wonder, doesn't range() return a list? The short answer is no, but ... |
6,813 | <ASSISTANT_TASK:>
Python Code:
from pomegranate import *
# The guests initial door selection is completely random
guest = DiscreteDistribution( { 'A': 1./3, 'B': 1./3, 'C': 1./3 } )
# The door the prize is behind is also completely random
prize = DiscreteDistribution( { 'A': 1./3, 'B': 1./3, 'C': 1./3 } )
# Monty 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: Probability
Step2: Inference
Step3: We are returned three DiscreteDistribution objects, each representing the marginal distribution for each v... |
6,814 | <ASSISTANT_TASK:>
Python Code:
#training data
#fn = 'data/ocr/optdigits.tra'
#testing data
fn = 'data/ocr/optdigits.tes'
header="x11,x12,x13,x14,x15,x16,x17,x18,x21,x22,x23,x24,x25,x26,x27,x28,x31,x32,x33,x34,x35,x36,x37,x38,x41,x42,x43,x44,x45,x46,x47,x48,x51,x52,x53,x54,x55,x56,x57,x58,x61,x62,x63,x64,x65,x66,x67,x68... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: After running the cell below, you can move the slider to visualize the various instances of the dataset, change factor slider to increase the sh... |
6,815 | <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:]
text
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
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: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
6,816 | <ASSISTANT_TASK:>
Python Code:
import os
os.chdir(os.getcwd() + '/..')
# Run some setup code for this notebook
import random
import numpy as np
import matplotlib.pyplot as plt
from utils.data_utils import get_CIFAR10_data
from utils.metrics_utils import rel_error
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Batch normalization
Step2: Batch Normalization
Step3: Batch Normalization
Step4: Fully Connected Nets with Batch Normalization
Step5: Batchn... |
6,817 | <ASSISTANT_TASK:>
Python Code:
from pynq import Overlay
Overlay("base.bit").download()
from pynq.drivers import HDMI
from pynq.drivers.video import VMODE_1920x1080
hdmi_out = HDMI('out', video_mode=VMODE_1920x1080)
hdmi_in = HDMI('in', init_timeout=10, frame_list=hdmi_out.frame_list)
hdmi_in.start()
hdmi_out.start()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 2
Step2: Step 3
Step3: Step 4
Step4: Step 5
Step5: Step 6
Step6: Step 7
Step7: Step 7
|
6,818 | <ASSISTANT_TASK:>
Python Code:
import mxnet as mx
from mxnet import nd, autograd
mx.random.seed(1)
x = nd.array([[1, 2], [3, 4]])
x
# Returns None type:
x.attach_grad()
with autograd.record():
y = x * 2
z = y * x
print(x)
print(y)
print(z)
# Returns None type
z.backward()
print(x.grad)
with autograd.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Attaching gradients
Step2: Once we compute the gradient of f with respect to x, we'll need a place to store it.
Step3: Now we’re going to defi... |
6,819 | <ASSISTANT_TASK:>
Python Code:
!pip install astronn
import torch
import matplotlib.pyplot as plt
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.ensemble import IsolationForest
from astroNN.datasets import load_galaxy10
from astroNN.datasets.galaxy10 import galaxy10cls_lookup
from s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problem 1a
Step2: Problem 1b.
Step3: Problem 3. Training
Step4: Problem 4a. Understand our Results
Step5: Problem 4b.
Step6: Bonus Problem ... |
6,820 | <ASSISTANT_TASK:>
Python Code:
from collections import deque
q = deque(maxlen = 3)
q.append(1)
q.append(2)
q.append(3)
q
q.append(4)
q
q.append(5)
q
q = deque()
q.append(1)
q.append(2)
q.append(3)
q
q.appendleft(4)
q
q.pop()
q
q.popleft()
<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: 尽管你也可以手动在一个列表上实现这一的操作(比如增加、删除等等)。但是这里的队列方案会更加优雅并且运行得更快些。
|
6,821 | <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: Train your first neural network
Step2: Import the Fashion MNIST dataset
Step3: Loading the dataset returns four NumPy arrays
Step4: Explore t... |
6,822 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
from sklearn.decomposition import FastICA, PCA
np.random.seed(0) # set seed for reproducible results
n_samples = 2000
time = np.linspace(0, 8, n_samples)
s1 = np.sin(2 * time) # Signal 1 : sinusoidal signal
s2 =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now try to recover the sources
|
6,823 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
% config InlineBackend.figure_format = 'retina'
from scipy import stats
x = np.linspace(3.5, 4.0, 100)
loc = 3.7
scl = 0.02
y = stats.norm.pdf(x, loc=loc, scale=scl)
yalt = stats.norm.logpdf(x, lo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We want a a continuous prior
Step2: The normalization doesn't matter, but it's nice to know that it's close to normalized.
Step3: What do the ... |
6,824 | <ASSISTANT_TASK:>
Python Code:
from nltk.util import ngrams
from collections import defaultdict
from collections import OrderedDict
import string
import time
import gc
from math import log10
start_time = time.time()
#returns: string
#arg: string
#remove punctuations and make the string lowercase
def removePunctuations... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <u>Do preprocessing</u>
Step2: Tokenize and load the corpus data
Step3: Create a Hash Table for Probable words for Trigram sentences
Step4: C... |
6,825 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
print("TensorFlow version: ", tf.version.VERSION)
# This will be an int32 tensor by default; see "dtypes" below.
rank_0_tensor = tf.constant(4)
print(rank_0_tensor)
# Let's make this a float tensor.
rank_1_tensor = tf.constant([2.0, 3.0, 4.0])
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lab Task 1
Step2: A "vector" or "rank-1" tensor is like a list of values. A vector has 1-axis
Step3: A "matrix" or "rank-2" tensor has 2-axes
... |
6,826 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data[:, [2, 3]]
y = iris.target
n_samples, n_features = X.shape
plt.scatter(X[:, 0], X[:, 1], c=y);
from scipy.cluster.hierarchy import linkage
from scipy.cluster.hierarchy import dendrogram
clusters = linkage(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: First, we start with some exploratory clustering, visualizing the clustering dendrogram using SciPy's linkage and dendrogram functions
Step2: N... |
6,827 | <ASSISTANT_TASK:>
Python Code:
s = specdal.Spectrum(filepath="/home/young/data/specdal/aidan_data/SVC/ACPA_F_B_SU_20160617_003.sig")
print(s)
print(type(s.measurement))
print(s.measurement.head())
s.interpolate(method='linear')
print(s.measurement.head())
s.plot()
plt.show()
s.stitch(method='mean')
s.plot()
plt.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: The print output shows the four components of the Spectrum object. For example, we can access the measurements as follows.
Step2: Spectrum obje... |
6,828 | <ASSISTANT_TASK:>
Python Code:
# Authors: Martin Billinger <martin.billinger@tugraz.at>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
from mne import Epochs, pick_types, find_events
from mne.channels import read_layout
from mne.io import concatenate_raws, read_raw_edf
from mne.datasets ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Classification with linear discrimant analysis
Step2: Look at performance over time
|
6,829 | <ASSISTANT_TASK:>
Python Code:
# Step by Step version
def search(aList, target):
for v in aList:
if target == v:
return True
return False
# Recursive approach
def searchRecursive(aList, target):
if len(aList) == 0:
return False
if aList[0] == target:
return True
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: Comments
Step2: Implement the Binary Tree
|
6,830 | <ASSISTANT_TASK:>
Python Code:
print "Hello", "World!"
print "Tips 3: Use \ to escape an characters like \""
print "Tips 4: Use \\n \n to make a newline character"
print '''Tips 5: Use three \' to
make
multiple
line
'''
time.sleep(0.5);
print "Too bad"
import time
time.sleep(0.5);
print "Now its work"
print "We 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: The magic command (ipython specific)
|
6,831 | <ASSISTANT_TASK:>
Python Code:
d = cmudict.dict()
def readability_ease(num_sentences, num_words, num_syllables):
asl = num_words / num_sentences
asw = num_syllables / num_words
return(206.835 - (1.015 * asl) - (84.6 * asw))
def readability_ease_interpretation(x):
if 90 <= x:
res = "5th grad... | <SYSTEM_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 make a few modifications
Step2: What about Reddit?
Step3: Same thread, different question
Step4: NA are mostly because words are not real
... |
6,832 | <ASSISTANT_TASK:>
Python Code:
#Program that solves exercise 1b.
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
def gradient_descent(xk,dx_f,gamma):
return xk-gamma*dx_f
def quadratic(a,b,c,x):
return a*x**2+b*x+c
def dx_quadratic(a,b,x):
return 2*a*x+b
#One variable examples
a,b,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: c) Quadratic functions as the one in exercise b) are particularly forigiving to work with since they only have one minimum/maximum, which in tur... |
6,833 | <ASSISTANT_TASK:>
Python Code:
from sympy import var, sin, cos, Matrix, Integer, eye, Function, Rational, exp, Symbol, I, solve, pi, trigsimp, dsolve, sinh, cosh, simplify
from sympy.physics.mechanics import mechanics_printing
mechanics_printing()
var("m1 m2 m3 J1 J2 J3 l1 l2 L1 L2 L0 t g")
q1 = Function("q1")(t)
q2 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Y declaramos todas las constantes involucradas en este calculo simbolico
Step2: Asi como algunas de las variables de nuestro problema
Step3: Y... |
6,834 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Barachant <alexandre.barachant@gmail.com>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cross_validation import StratifiedKFold
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LogisticRegression... | <SYSTEM_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 and read data
|
6,835 | <ASSISTANT_TASK:>
Python Code:
# Import the required packages
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import scipy
# Package imports
import numpy as np
import matplotlib.pyplot as plt
import sklearn
import sklearn.datasets
import sklearn.linear_model
def layer_sizes(X, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Let's implement our first MLP
Step4: Initialize the model's parameters
Step7: The Loop
Step9: Now that you have computed $A^{[2]}$ (in the Py... |
6,836 | <ASSISTANT_TASK:>
Python Code:
problem1 = {
"left_lines": [
r"HE|LL|O+", # HE|LL|O+ line 1
r"[PLEASE]+", # [PLEASE]+ line 2
],
"right_lines": None,
"top_columns": [
r"[^SPEAK]+", # [^SPEAK]+ column 1
r"EP|IP|EF", # EP|IP|EF column 2
],
"bottom_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: The keys "right_lines" and "bottom_columns" can be empty, as for easier problems there are no constraints on the right and bottom.
Step2: Diffi... |
6,837 | <ASSISTANT_TASK:>
Python Code:
import healpix_util as hu
import astropy as ap
import numpy as np
from astropy.io import fits
from astropy.table import Table
import astropy.io.ascii as ascii
from astropy.constants import c
import matplotlib.pyplot as plt
import math
import scipy.special as sp
sdssq=ascii.read("/home/ro... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read the data file
Step2: Create a healpix map with NSIDE=64 (no. of pixels = 49152 as $NPIX=12\times NSIDE^2$) because the no. of galaxies in ... |
6,838 | <ASSISTANT_TASK:>
Python Code:
def c2(masses, radii, e, a, rotation=None):
f = (1.0 - e**2)**-2
g = (8.0 + 12.0*e**2 + e**4)*f**(5.0/2.0) / 8.0
if rotation == None:
omega_ratio_sq = 0.0
elif rotation == 'synchronized':
omega_ratio_sq = (1.0 + e)/(1.0 - e)**3
else:
omega_rati... | <SYSTEM_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 complicates the issue is that the interior structure constants for the B components also vary as a function of age, so we need to compute a... |
6,839 | <ASSISTANT_TASK:>
Python Code:
# Now convert all text to index using vocab!
corpus = np.array(list(map(vocab.get, data)))
print ("Type of 'corpus' is %s, shape is %s, and length is %d"
% (type(corpus), corpus.shape, len(corpus)))
check_len = 10
print ("\n'corpus' looks like %s" % (corpus[0:check_len]))
for i in 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:
Step2: Now, we are ready to make our RNN model with seq2seq
Step3: Run the command line
|
6,840 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pylab
import matplotlib.patches as patches
import matplotlib.path as path
from ipywidgets import interact
import numpy
import sys
import random
import itertools
import time
import scipy.special
import math
pylab.rcParams['figure.figsize'] = 16, 10... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problem definition
Step2: Now let $A_i$, $B_j$ be grid and facet masks respectively, so $A_i(x) = 0$ iff $\left|x-x_i\right| > x_A$, $\sum_i A_... |
6,841 | <ASSISTANT_TASK:>
Python Code:
import os # to access system environment variables
import pandas as pd # data management
import seaborn as sns # for data visualization
import matplotlib.pyplot as plt ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Challenger Data
Step2: The method below returns a dictionary of ranked statistics for a player based on the champion played. Using the key [Non... |
6,842 | <ASSISTANT_TASK:>
Python Code:
!pip install kaggle
import os
import glob
import zipfile
import functools
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['axes.grid'] = False
mpl.rcParams['figure.figsize'] = (12,12)
from sklearn.model_selection import train_test_split
import matp... | <SYSTEM_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 all the files
Step2: Only import kaggle after adding the credentials.
Step3: We'll download the data from Kaggle
Step4: You must accept t... |
6,843 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sklearn
import scipy.stats as stats
import scipy.optimize
import matplotlib.pyplot as plt
import seaborn as sns
import time
import numpy as np
import os
import pandas as pd
# We install various packages for approximate Bayesian inference
# To avoid installing pac... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linear regression (MLE)
Step2: Bayesian linear regression
Step3: Compute posterior
Step4: Compute posterior predictive
|
6,844 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from parcels import FieldSet, ParticleSet, JITParticle, AdvectionRK4, ParticleFile, plotTrajectoriesFile
import numpy as np
from datetime import timedelta as delta
from os import path
filenames = path.join('SWASH_data', 'field_*.nc')
variables = {'U': 'cross-shore velo... | <SYSTEM_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 use sample data from the SWASH model. We first set the filenames and variables
Step2: Now, the first key step when reading time-evolvi... |
6,845 | <ASSISTANT_TASK:>
Python Code:
#@title Copyright 2020 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/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: <table class="tfo-notebook-buttons" align="left">
Step2: Reading image for input
Step3: Visualization method
Step4: Loading an Image
Step5: ... |
6,846 | <ASSISTANT_TASK:>
Python Code:
from problem_formulation import joint
joint
sobol_samples = joint.sample(10000, rule="sobol")
antithetic_samples = joint.sample(10000, antithetic=True, seed=1234)
halton_samples = joint.sample(10000, rule="halton")
from matplotlib import pyplot
pyplot.rc("figure", figsize=[16, 4])
pyplot... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then we generate samples from the three schemes
Step2: From the three plots above it is easy to see both how the Sobol sequence have
Step3: Er... |
6,847 | <ASSISTANT_TASK:>
Python Code:
notas = {'bia': 10, 'pedro': 0, 'ana': 7}
notas
notas.keys()
notas.pop('bia')
notas
dir(notas)
notas
notas.__getitem__('ana')
notas['ana']
notas.__getitem__('joselito')
notas['joselito']
notas.__class__
notas.__doc__
print(notas.__doc__)
3 + 4
print(3 .__doc__)
3 .__add__(4)
3 .__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: O dicionários possui diversos métodos que usamos para alterar os objetos
Step2: Podemos usar a função dir() para inspecionar os métodos e atrib... |
6,848 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-1', 'land')
# 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... |
6,849 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alex Rockhill <aprockhill@mailbox.org>
# Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD-3-Clause
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
import nibabel as nib
import nilearn.plotting
from dipy.align import resample
import mne
fro... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Aligning the T1 to ACPC
Step3: Freesurfer recon-all
Step4: Now we need to align our CT image to the T1 image.
Step5: <div class="alert alert-... |
6,850 | <ASSISTANT_TASK:>
Python Code:
import pymc3 as pm
import seaborn as sns
import scipy
import scipy.stats
import numpy as np
import spacepy.toolbox as tb
import matplotlib.pyplot as plt
from theano import theano, tensor as tt
sns.set(font_scale=1.5)
from pymc3.distributions.dist_math import bound
def pot1(z):
z = z.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Given example
Step2: Now can we do this from a histogram?
|
6,851 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
from __future__ import print_function
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt... | <SYSTEM_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 data
Step2: Extract Features
Step3: Train SVM on features
Step4: Inline question 1
|
6,852 | <ASSISTANT_TASK:>
Python Code:
from os.path import basename, exists
def download(url):
filename = basename(url)
if not exists(filename):
from urllib.request import urlretrieve
local, _ = urlretrieve(url, filename)
print("Downloaded " + local)
download("https://github.com/AllenDowney/Thin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Examples from Chapter 1
Step2: Print the column names.
Step3: Select a single column name.
Step4: Select a column and check what type it is.
... |
6,853 | <ASSISTANT_TASK:>
Python Code:
%%bash
ipython profile create blake
mkdir /Users/houghb/.ipython/profile_blake/static/
mkdir /Users/houghb/.ipython/profile_blake/static/custom/
touch /Users/houghb/.ipython/profile_blake/static/custom/custom.css
%%file /Users/houghb/.ipython/profile_blake/static/custom/custom.css
/**Thi... | <SYSTEM_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 file that you edit in the next cell (custom.css) will change how your notebook cells look.
Step2: To use your newly created custom.css you ... |
6,854 | <ASSISTANT_TASK:>
Python Code:
# Note - these lines added to make it work with shared Jupyter Hub instance,
# modifying the system path so that locally installed modules installed with the shell commands below will be found -
# they would need to be modified for your instance, or to install the modules normally remov... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Cosine Similarity
Step2: String comparison using cosine similarity https
Step3: Cosine works fine with whole words and word transposition but ... |
6,855 | <ASSISTANT_TASK:>
Python Code:
from pyspark import SparkContext
sc = SparkContext(master = 'local')
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("Python Spark SQL basic example") \
.config("spark.some.config.option", "some-value") \
.getOrCreate()
mtcars = ... | <SYSTEM_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 DataFrame object
Step2: Create DataFrame with createDataFrame function
Step3: From pandas DataFrame
Step4: From a list
Step5: The f... |
6,856 | <ASSISTANT_TASK:>
Python Code:
#from imp import *
#s=load_source('sygma','/home/nugrid/nugrid/SYGMA/SYGMA_online/SYGMA_dev/sygma.py')
#import mpld3
#mpld3.enable_notebook()
import sygma as s
reload(s)
import matplotlib.pyplot as plt
%matplotlib inline
s1=s.sygma(iniZ=0.02,dt=1e7,tend=2e7)
s1.plot_yield_input() #[1,3,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: plot_yield_input
Step2: The following commands plot the ISM metallicity in spectroscopic notation.
Step3: s1.plot_massfrac
Step4: s1.plot_spe... |
6,857 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
from phoebe import u # units
logger = phoebe.logger()
b = phoebe.default_binary()
b.get_setting()
b['setting']
b['dict_set_all@setting']
b['teff@component']
b.set_value_all('teff@component', 4000)
print(b['value@teff@primary@component... | <SYSTEM_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 longger and a new Bundle.
Step2: Accessing Settings
Step3: or via filtering/twig access
Step4: a... |
6,858 | <ASSISTANT_TASK:>
Python Code:
# In Google Colab, uncomment this:
# !wget https://bit.ly/2FMJP5K -O setup.py && bash setup.py
# XVFB will be launched if you run on a server
import os
if type(os.environ.get("DISPLAY")) is not str or len(os.environ.get("DISPLAY")) == 0:
!bash ../xvfb start
os.environ['DISPLAY'] =... | <SYSTEM_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 stochastic policy
Step3: Play the game
Step6: Crossentropy method steps
Step8: Training loop
Step9: Reflecting on results
|
6,859 | <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: Keras 콜백 개요
Step3: 그런 다음 Keras 데이터세트 API에서 훈련 및 테스트용 MNIST 데이터를 로드합니다.
Step4: 이제 다음의 경우 로깅하는 간단한 사용자 정의 콜백을 정의합니다.
Step5:... |
6,860 | <ASSISTANT_TASK:>
Python Code:
target = pd.read_csv('../data/train_target.csv')
target.describe()
target = target / 1000
sns.distplot(target);
plt.title('SalePrice')
import scipy as sp
sp.stats.skew(target)
sp.stats.skewtest(target)
logtarget = np.log1p(target)
print('skewness of logtarget = ', sp.stats.skew(logtarge... | <SYSTEM_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 sale price is in hte hundreds of thousands, so let's divide the price by 1000 to get more manageable numbers.
Step2: The distribution is sk... |
6,861 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
class DLProgress(tqdm):
last_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: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
6,862 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
from phoebe import u # units
logger = phoebe.logger()
b = phoebe.default_binary()
phoebe.list_available_datasets()
b.add_dataset(phoebe.dataset.orb,
compute_times=phoebe.linspace(0,10,20),
dataset='orb01',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Adding a Dataset from Arrays
Step2: Without Observations
Step3: Here we used phoebe.linspace. This is essentially just a shortcut to np.linsp... |
6,863 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import openpathsampling as paths
import numpy as np
# NBVAL_IGNORE_OUTPUT
import pyemma.coordinates as coor
# NBVAL_IGNORE_OUTPUT
ref_storage = paths.Storage('engine_store_test.nc', mode='r')
# NBVAL_IGNORE_OUTPUT
storage = paths.Storage('delete.nc', ... | <SYSTEM_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 a PyEmma Coordinates Module
Step2: Now use this featurizer generating function to build a collective variable out of it. All we need for... |
6,864 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-mh', 'toplevel')
# 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... |
6,865 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('U_Q6Xjz9QHg', width=720, height=400, loop=1, autoplay=0, playlist='U_Q6Xjz9QHg')
from IPython.display import YouTubeVideo
YouTubeVideo('jHxyP-nUhUY', width=500, height=400, autoplay=0, start=60)
from IPython.display import HTML
HTM... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Overall Goal
Step2: Brain structures
Step3: Neurons in the brain
Step4: Kinds of data from the brain
Step5: <img src="files/lecture1/catgrat... |
6,866 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# 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: Load data
Step2: Extract Features
Step3: Train SVM on features
Step4: Inline question 1
|
6,867 | <ASSISTANT_TASK:>
Python Code:
print 'This is a string'
s = 'STRING'
print 'Place another string with a mod and s: %s' %(s)
print 'Floating point numbers: %1.2f' %(13.144)
print 'Floating point numbers: %1.0f' %(13.144)
print 'Floating point numbers: %1.5f' %(13.144)
print 'Floating point numbers: %10.2f' %(13.144)
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: Strings
Step2: Floating Point Numbers
Step3: Conversion Format methods.
Step4: Multiple Formatting
Step5: Using the string .format() method
|
6,868 | <ASSISTANT_TASK:>
Python Code:
import jax
import jax.numpy as jnp
import numpy as np
from matplotlib import pyplot as plt
# Check connected accelerators. Depending on what runtime you're connected to,
# this will show a single CPU/GPU, or 8 TPU cores (jf_2x2 aka JellyDonut).
# You can start a TPU runtime via : "Connect... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Randomness
Step2: jnp vs. np
Step3: grad()
Step4: vmap()
Step5: jit()
Step6: pmap()
Step7: pytrees
Step9: JAX Linear Classifier
Step12: ... |
6,869 | <ASSISTANT_TASK:>
Python Code:
import numpy
import keras
from keras import backend as K
from keras import losses, optimizers, regularizers
from keras.datasets import mnist
from keras.layers import Activation, ActivityRegularization, Conv2D, Dense, Dropout, Flatten, MaxPooling2D
from keras.models import Sequential
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: Activation Functions
Step2: Activation as a layer
Step3: Activation from a TensorFlow function
Step4: Regularizers
Step5: Regularization as ... |
6,870 | <ASSISTANT_TASK:>
Python Code:
# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
import matplotlib.pyplot as plt
import mne
from mne.datasets import sample
from mne.minimum_norm import apply_inverse_raw, read_inverse_operator
print(__doc__)
data_path = sample.data_path()
fname_inv = (... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: View activation time-series
|
6,871 | <ASSISTANT_TASK:>
Python Code:
import gensim
import gensim.downloader as api
from gensim.utils import save_as_line_sentence
from gensim.models.word2vec import Word2Vec
print(gensim.models.word2vec.CORPUSFILE_VERSION) # must be >= 0, i.e. optimized compiled version
corpus = api.load("text8")
save_as_line_sentence(corpu... | <SYSTEM_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 prepare the full Wikipedia dataset as training corpus
Step2: Word2Vec
Step3: Training with corpus_file took 3.7x less time!
Step4: The ... |
6,872 | <ASSISTANT_TASK:>
Python Code:
class Person(object):
A class definition for a person. The following attributes are supported:
Attributes:
name: A string representing the person's name.
age: An integer representing the person's age.
mammal = True
def __init__(self, name, age):
... | <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: Week 11
Step3: Before we go on a note of caution is needed for class attributes. Do you remember the strange fibonacci sequence function from o... |
6,873 | <ASSISTANT_TASK:>
Python Code:
from deepchem.molnet.load_function import hiv_datasets
from deepchem.models import GraphConvModel
from deepchem.data import NumpyDataset
from sklearn.metrics import average_precision_score
import numpy as np
tasks, all_datasets, transformers = hiv_datasets.load_hiv(featurizer="GraphConv")... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Retrain Model Over Full Dataset For The Screen
Step2: 2. Create Work-Units
Step3: 5. Consume work units from "distribution mechanism"
Step4: ... |
6,874 | <ASSISTANT_TASK:>
Python Code:
#@title Install MuJoco (Edit to add your license key)
mjkey =
MuJoCo License Here
.strip()
mujoco_dir = "$HOME/.mujoco"
# Install OpenGL deps
!apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx libosmesa6 libglew2.0
# Fetch MuJoCo binaries from Roboti
!wget ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: World Models Library
Step2: Task
Step3: World Model
Step4: In addition to reset_fn, observe_fn and predict_fn, we also need to define a train... |
6,875 | <ASSISTANT_TASK:>
Python Code:
import random as rd
cara = 0
vig = 0
for j in range(200):
for i in range(5):
rdnum = rd.random()
if (rdnum < 0.90):
cara += 1
if cara > 3:
#print('Vigarista ganhou')
vig = vig + 2
cara = 0
else:
#print('Ambulante gan... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Questão 1
Step2: Questão 2
Step3: Bêbado
Step4: Questão 4
Step5: Porta da esperança
Step6: Questão 6
Step7: Balística
|
6,876 | <ASSISTANT_TASK:>
Python Code:
#Import matplotlib
%matplotlib inline
#Import pandas, seaborn, and ipython display
import pandas as pd
import seaborn as sns
from IPython.display import display, HTML
#Read in taxonmic classification results from sourmash with pandas
#Dataframe name, read in csv file
mg_1_table = pd.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: 2) Convert sourmash output (i.e. csv) to dataframe from visualization
Step2: Terms
Step3: 3) Compare metagenomes with sourmash compare
Step4: ... |
6,877 | <ASSISTANT_TASK:>
Python Code:
a = list(range(10))
print(a)
b = list(range(100))
print(b)
a.append("ich bin keine Zahl")
b.append("ich bin keine Zahl")
print(a,b)
a.pop()
b.pop()
print(a,b)
a = list(map(str, a))
b = list(map(str, b))
print(a,b)
for element_in_der_liste in a:
print(str(element_in_der_liste))
lee... | <SYSTEM_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... |
6,878 | <ASSISTANT_TASK:>
Python Code:
from cntk import load_model
import findspark
findspark.init('/root/spark-2.1.0-bin-hadoop2.6')
import os
import numpy as np
import pandas as pd
import pickle
import sys
from pyspark import SparkFiles
from pyspark import SparkContext
from pyspark.sql.session import SparkSession
sc =SparkCo... | <SYSTEM_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 name="tarball"></a>
Step2: <a name="rdd"></a>
Step3: To convince ourselves that the data has been properly loaded, let's visualize a few of... |
6,879 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
import tellurium as te
# to get the tellurium version use
print('te.__version__')
print(te.__version__)
# or
print('te.getTelluriumVersion()')
print(te.getTelluriumVersion())
# to print the full version info use
print('-' * 80)
te.p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Repeat simulation without notification
Step3: File helpers for reading and writing
|
6,880 | <ASSISTANT_TASK:>
Python Code:
import os
from google.cloud import bigquery
import pandas as pd
%load_ext google.cloud.bigquery
PROJECT = "cloud-training-demos" # Replace with your PROJECT
BUCKET = PROJECT
REGION = "us-east1"
os.environ['PROJECT'] = PROJECT
os.environ['BUCKET'] = BUCKET
os.environ['REGION'] = REGIO... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Replace the variable values in the cell below
Step2: Create a Dataset from BigQuery
Step3: Let's do some regular expression parsing in BigQuer... |
6,881 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib notebook
# execute dummy code here
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
iris = datasets.load_iris()
RFclf = RandomForestClassifier().fit(iris.data, iris.target)
print(np.shape( # 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: Problem 1) Introduction to scikit-learn
Step2: Generally speaking, the procedure for scikit-learn is uniform across all machine-learning algori... |
6,882 | <ASSISTANT_TASK:>
Python Code:
# Getting Basic Data
import goldsberry
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
pd.set_option("display.max_columns", 50)
pd.options.mode.chained_assignment = None
print goldsberry.__version__
print pd.__version__
# Getting Players 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: The query in the below box no longer works thanks to the NBA restricting access to the data.
Step2: Wrapping data merge into a function
Step3: ... |
6,883 | <ASSISTANT_TASK:>
Python Code:
#Imort modules
from __future__ import print_function, division, absolute_import
import numpy as np
#Import citlalatonac from pyaneti_extras, note that pyaneti has to be compiled in your machine
#and pyaneti has to be in your PYTHONPATH, e.g., you have to add in your bashrc file
#export PY... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: let us summon citlalatonac powers and create synthetic stellar data
Step2: At this point we have a model of the three signals created following... |
6,884 | <ASSISTANT_TASK:>
Python Code:
from tax_credit.framework_functions import \
generate_simulated_datasets, distance_comparison, \
test_cross_validated_sequences, \
test_novel_taxa_datasets
from os.path import expandvars, join
import pandas as pd
%matplotlib inline
project_dir = expandvars("../..")
data_dir = ... | <SYSTEM_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 will import these to a dataframe and view it. You should not need to modify the following cell.
Step2: Generate "clean" reference taxono... |
6,885 | <ASSISTANT_TASK:>
Python Code:
# Arithmetic operations
k = symbols('k')
s = symbols('s')
# 1D stencil
# multiplication addition
AI_dxi = k + 1 + k - 1
AI_dxxi = k + 1 + k - 1
AI_dxxij = 2*k + 2*k-1
# square stencil (all uses... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Operational intensity of wave equations
|
6,886 | <ASSISTANT_TASK:>
Python Code:
print('Hello, world')
print(10)
print(3.14159)
print(True)
# Print an integer
print(10)
# Print a float
print(3.14159)
# Print a bool
print(True)
print(1 + 1) # this should be 2
print(4 / 2) # this should be 2
print(40 - 38) # this should be 2
print(2^4) # this should be 16
print(2**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 the above code, we called the print function and passed the text Hello, world. surrounded by single quotation marks ''. The text was passed a... |
6,887 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
import mdtraj as md
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
traj = md.load('ala2.h5')
traj
pca1 = PCA(n_components=2)
traj.superpose(traj, 0)
reduced_cartesian = pca1.fit_transform(traj.xyz.reshape(tr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lets load up our trajectory. This is the trajectory that we generated in
Step2: Create a two component PCA model, and project our data down int... |
6,888 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import pandas as pd
import numpy as np
import json
import os,sys
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
import numpy as np
pd.options.display.float_format = '{:,.2f}'.format
dataset_base_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: Overview
Step2: Processing original dataset
Step3: Shuffle and Split into Train (70%) and Test set (30%)
Step4: Computing Invese propensity w... |
6,889 | <ASSISTANT_TASK:>
Python Code:
def net_force(mass, acceleration):
return mass * acceleration
def net_force(mass, acceleration):
force = mass * acceleration
return force
print(net_force(10,10))
def net_force(mass, acceleration):
Calculates f=ma, returns force.
We assume mass & acceleration 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: Literally this function takes two objects and returns mass * acceleration; But what does that actually mean? And why should we care?
Step3: De... |
6,890 | <ASSISTANT_TASK:>
Python Code:
import time
from collections import namedtuple
import numpy as np
import tensorflow as tf
with open('anna.txt', 'r') as f:
text=f.read()
vocab = set(text)
vocab_to_int = {c: i for i, c in enumerate(vocab)}
int_to_vocab = dict(enumerate(vocab))
chars = np.array([vocab_to_int[c] for 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: First we'll load the text file and convert it into integers for our network to use.
Step3: Now I need to split up the data into batches, and in... |
6,891 | <ASSISTANT_TASK:>
Python Code:
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode,iplot
init_notebook_mode(connected=True)
import pandas as pd
df = pd.read_csv('2014_World_Power_Consumption')
df.head()
data = dict(type ='choropleth',
locations=df['Country'],
colorsc... | <SYSTEM_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 pandas and read the csv file
Step2: Check the head of the DataFrame.
Step3: Referencing the lecture notes, create a Choropleth Plot of ... |
6,892 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
width = 3.18 # cm
thickness = 0.46 # cm
length = 48 # cm
volume = length*width*thickness # cm^3
density = 2.77 # g/cm
massBar = density*volume
print('mass of bar =', massBar, 'g')
gammaL = 1.88 # 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: Constants
Step2: Part 2
Step3: Now lets get to the math.
|
6,893 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
from statsmodels.graphics.gofplots import ProbPlot
plt.style.use('seaborn') # pretty matplotlib plots
plt.rc('font', size=14)
plt.rc('figur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loading the data, and getting rid of NAs
Step2: The fitted linear regression model, using statsmodels R style formula API
Step3: Calculations ... |
6,894 | <ASSISTANT_TASK:>
Python Code::
import tensorflow_datasets as tfds
ds, meta = tfds.load('citrus_leaves', with_info=True, split='train', shuffle_files=True)
<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:
|
6,895 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
%matplotlib inline
import matplotlib.pyplot as plt
import openpathsampling as paths
old_storage = paths.Storage("ad_tps_equil.nc", "r")
engine = old_storage.engines['300K']
C_7eq = old_storage.volumes['C_7eq']
alpha_R = old_storage.volumes['alpha_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: Loading from storage
Step2: Building a trajectory to suit the ensemble
Step3: Plot the trajectory
Step4: Save stuff
|
6,896 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
plt.style.use('seaborn-whitegrid')
def f(x):
The function to predict.
return x * np.sin(x)
def make_data(N, rseed=1):
np.random.seed(rseed)
# Create some observations with noise
X = np.random.u... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Make Some Data
Step3: Gaussian Process Regression with Scikit-Learn
Step4: Gaussian Processes by-hand
Step5: Quick kernel comparison with GPy... |
6,897 | <ASSISTANT_TASK:>
Python Code:
import datetime
import pandas as pd
import numpy as np
import linecache, bisect
import os
spath = os.getcwd()
path = spath.split("/")
date = path[len(path)-1]
def makeGraphqlRequest(query, variables):
return GraphQLClient.request(query, variables)
suspicious_query = query($date:Spot... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Request Data
Step3: Now that we have a function, we can run a query like this
Step4: Pandas Dataframes
Step5: Additional operations
Step6: O... |
6,898 | <ASSISTANT_TASK:>
Python Code:
import pickle
import pprint
data = [{'a': 'A', 'b': 2, 'c': 3.0}]
print('DATA:', end=' ')
pprint.pprint(data)
data_string = pickle.dumps(data)
print('PICKLE: {!r}'.format(data_string))
import pickle
import pprint
data1 = [{'a': 'A', 'b': 2, 'c': 3.0}]
print('BEFORE: ', end=' ')
pprint.ppr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Working with Stream
Step2: Problem with Reconstructing Objects
|
6,899 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%load_ext autoreload
%autoreload 2
from lxmls import DATA_PATH
import lxmls
import lxmls.sequences.crf_online as crfo
import lxmls.readers.pos_corpus as pcc
import lxmls.sequences.id_feature as idfc
import lxmls.sequences.extended_feature as exfc
from lxmls.readers 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: Load data from the conll task
Step2: Feature generation
Step3: About feature_mappers
Step4: An observation on the features for a given exampl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.