Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
6,900 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'awi-cm-1-0-mr', 'seaice')
# 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: 2... |
6,901 | <ASSISTANT_TASK:>
Python Code:
import os
from urllib.request import urlopen
# MovieLensのサイトから、Zipファイルを取得し、ローカルに保存します.
# この処理は少しだけ時間がかかるので、未ダウンロードの場合のみ、実行します.
file_name = "data/ml-100k.zip"
if not os.path.exists(os.path.dirname(file_name)):
os.makedirs(os.path.dirname(file_name))
if not os.path.exists("data/ml-100k.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. データの前処理
Step2: 上記の形式だとモデルの学習に用いづらいため、 行が映画、列がユーザーの行列(マトリックス) に変換します。
Step3: (参考までに)
Step4: 全70,000件中、66,103件は好評価のようです(94%)。今回は、評価>=3の考慮はあま... |
6,902 | <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: Parametrisation
Step2: Choose "gridding" function extents
Step3: Placing facets and subgrids
Step4: Sizing the intermediate grid
Step5: We n... |
6,903 | <ASSISTANT_TASK:>
Python Code:
from PyQt5.QtCore import QSettings
myOrganization = 'MyOrg' # 组织名称
myApplication = 'MyApp' # 应用名称
settings = QSettings(myOrganization, myApplication)
settings.setValue("editor/wrapMargin", 68)
print (settings.value("editor/wrapMargin"))
print (settings.value("editor/someth"))
# 如果在程序中多... | <SYSTEM_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,904 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import swap
base_collection_path = '/nfs/slac/g/ki/ki18/cpd/swap/pickles/15.09.02/'
base_directory = '/nfs/slac/g/ki/ki18/cpd/swap_catalog_diagnostics/'
annotated_catalog_path = base_directory + 'annotated_catalog.csv'
cut_empty = True
stages = [1, 2]
categories = ['ID... | <SYSTEM_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 the knownlens catalog
Step2: Convert the annotated catalog and knownlens catalog into cluster catalogs and cutouts
|
6,905 | <ASSISTANT_TASK:>
Python Code:
# The interpreter can be used as a calculator, and can also echo or concatenate strings.
3 + 3
3 * 3
3 ** 3
3 / 2 # classic division - output is a floating point number
# Use quotes around strings, single or double, but be consistent to the extent possible
'dogs'
"dogs"
"They're going to ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Try It Yourself
Step2: Variables can be reassigned
Step3: The ability to reassign variable values becomes important when iterating through gro... |
6,906 | <ASSISTANT_TASK:>
Python Code:
# Import all functions from external file
from download_and_process_DE_functions import *
# Jupyter functions
%matplotlib inline
download_from = 'original_sources'
#download_from = 'opsd_server'
if download_from == 'original_sources':
# BNetzA Power plant list
url_bnetza = ('htt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 3. Download settings
Step2: 4. Define functions
Step3: 5.2 Download the UBA Plant list
Step4: 6. Translate contents
Step5: 6.2 Fuel types
St... |
6,907 | <ASSISTANT_TASK:>
Python Code::
# create sequences of images, input sequences and output words for an image
def create_sequences(tokenizer, max_length, descriptions, photos, vocab_size):
X1, X2, y = list(), list(), list()
# walk through each image identifier
for key, desc_list in descriptions.items():
# walk throu... | <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,908 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
# le code qui suit n'est pas indispensable, il génère automatiquement un menu
# dans le notebook
from jyquickhelper import add_notebook_menu
add_notebook_menu()
url = "https://www.insee.fr/fr/statistiques/fichier/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Population française janvier 2017
Step2: La récupération de ces données est implémentée dans la fonction population_france_year
Step3: D'aprè... |
6,909 | <ASSISTANT_TASK:>
Python Code:
def decaying_sin(params, x):
amp = params['amp']
phaseshift = params['phase']
freq = params['frequency']
decay = params['decay']
return amp * np.sin(x*freq + phaseshift) * np.exp(-x*x*decay)
x = np.linspace(0.0, 10.0, 100)
default_params = {"amp" : 10.0, "decay" : 0.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: Plotting function for default parameters
Step2: Defining objective function
|
6,910 | <ASSISTANT_TASK:>
Python Code:
import matplotlib as mpl
from matplotlib import cm
import matplotlib.pyplot as plt
from qutip import *
from qutip.piqs import *
#TLS parameters
N = 6
ntls = N
nds = num_dicke_states(ntls)
[jx, jy, jz] = jspin(N)
jp = jspin(N, "+")
jm = jp.dag()
w0 = 1
gE = 0.1
gD = 0.01
gP = 0.1
gCP = 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:
Step1: Wigner function Visualization
Step2: The Wigner function of the photonic part of the system displays the two displaced squeezed blobs typical o... |
6,911 | <ASSISTANT_TASK:>
Python Code:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
mpl.rcParams['figure.figsize'] = (13,9) # change default figure size
cmap1 = 'Blues'
x = np.arange(0, np.pi, 0.1)
y = np.arange(0, 2*np.pi, 0.1)
xx, yy = np.meshgrid(x, y)
zz = np.clip(6*(np.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: We will start with the colormap used in the original question.
Step2: In the absence of the data used in the given figure, we create a random a... |
6,912 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
test_data = pd.read_csv("../data/person-video-sparse-multiple-choice.csv")
test_data.head()
import crowdtruth
from crowdtruth.configuration import DefaultConfig
class TestConfig(DefaultConfig):
inputColumns = ["videolocation", "subtitles", "imagetags", "subtitlet... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Declaring a pre-processing configuration
Step2: Our test class inherits the default configuration DefaultConfig, while also declaring some addi... |
6,913 | <ASSISTANT_TASK:>
Python Code:
info_struct=dict()
info_struct['addr']=10000
info_struct['content']=''
class Server(object):
content=''
def recv(self, info):
pass
def send(self, info):
pass
def show(self):
pass
class infoServer(Server):
def recv(self,info):
self.conten... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: infoServer有接收和发送的功能,发送功能由于暂时用不到,保留。另外新加一个接口show,用来展示服务器接收的内容。接收的数据格式必须如info_struct所示,服务器仅接受info_struct的content字段。那么,如何给这个服务器设置一个白名单,使得只有白名单里的地址可... |
6,914 | <ASSISTANT_TASK:>
Python Code:
from sklearn import datasets
import numpy as np
from sklearn.cross_validation import train_test_split
from sklearn.preprocessing import StandardScaler
# Load the iris data
iris = datasets.load_iris()
# Create a variable for the feature data
X = iris.data
# Create a variable for the targe... | <SYSTEM_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: Split Data For Cross Validation
Step3: Standardize Feature Data
|
6,915 | <ASSISTANT_TASK:>
Python Code:
%run "../Functions/1. Google form analysis.ipynb"
binarized = getAllBinarized()
answersCount = len(binarized.index)
totalScorePerQuestion = pd.DataFrame(data=np.dot(np.ones(answersCount),binarized),index=binarized.columns,columns=['score'])
totalScorePerQuestion['perc'] = totalScorePerQu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sorted total answers to questions
Step2: Cross-samples t-tests
Step3: Conclusion
|
6,916 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('orb',
compute_times=phoebe.linspace(0,10,10),
dataset='orb0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we'll import our packages and initialize the default PHOEBE bundle.
Step2: And we'll attach some dummy datasets. See the datasets tutorial... |
6,917 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import nibabel as nb
import matplotlib.pyplot as plt
# Let's create a short helper function to plot 3D NIfTI images
def plot_slice(fname):
# Load the image
img = nb.load(fname)
data = img.get_data()
# Cut in the middle of the brain
cut = int(data.sha... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example 1 - Command-line execution
Step2: This is simple and straightforward. We can see that this does exactly what we wanted by plotting the ... |
6,918 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pylab as pl
import astropy.io.fits as fits
import rtpipe
import rtlib_cython as rtlib
import astropy.units as units
import astropy.coordinates as coord
from astropy.time import Time
# confirm version is is earlier than 1.54 if using old dm scal... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Useful functions
Step2: Read coherently dedispersed Arecibo dynamic spectrum
Step3: Define python names for Arecibo header info
Step4: Read d... |
6,919 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn.datasets import load_breast_cancer
import numpy as np
from functools import reduce
# Import our custom utilities
from imp import reload
from utils import irf_jupyter_utils
from utils import irf_utils
reload(irf_jupyter_utils)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1
Step2: Check out the data
Step3: Step 2
Step4: STEP 3
Step5: Print out all of the intersected nodes and their ids
Step7: Print out a... |
6,920 | <ASSISTANT_TASK:>
Python Code:
def pretty_print_review_and_label(i):
print(labels[i] + "\t:\t" + reviews[i][:80] + "...")
g = open('reviews.txt','r') # What we know!
reviews = list(map(lambda x:x[:-1],g.readlines()))
g.close()
g = open('labels.txt','r') # What we WANT to know!
labels = list(map(lambda x:x[:-1].uppe... | <SYSTEM_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
Step2: Lesson
Step3: Project 1
Step4: We'll create three Counter objects, one for words from postive reviews, one for words from negativ... |
6,921 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-2', '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,922 | <ASSISTANT_TASK:>
Python Code:
# Obtain sample data and set new Grass mapset
import urllib
from zipfile import ZipFile
import os.path
zip_path = "/home/jovyan/work/tmp/nc_spm_08_grass7.zip"
mapset_path = "/home/jovyan/grassdata"
if not os.path.exists(zip_path):
urllib.urlretrieve("https://grass.osgeo.org/sampledata... | <SYSTEM_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 startup pannel set GIS Data Directory to path to datasets,
Step2: Range of coordinates at lower resolution
Step3: Decrease resolution and t... |
6,923 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import random
import numpy as np
import pickle
import matplotlib.pyplot
from matplotlib.pyplot import imshow
from PIL import Image
from scipy.spatial import distance
from igraph import *
from tqdm import tqdm
images, pca_features, pca = pickle.load(open('../... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, open your saved feature vectors with pickle, and ensure the images are in the correct paths.
Step2: The following cell is optional. If yo... |
6,924 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import os
import requests
import easydict
import linecache
import pprint
import random
import itertools
pp = pprint.PrettyPrinter(indent=4)
species = 'yeast' # species of interest to load of and save the resut for
if species=='human':
associatio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configuration<a id='2'></a>
Step2: asserting raw data exist
Step9: Loading Gene Ontology<a id='3'></a>
Step11: Loading Genes and Annotations<... |
6,925 | <ASSISTANT_TASK:>
Python Code:
# We'll make the number of bins, B
B = 50
plt.figure(0)
plt.hist(X[:, 0], bins = B, normed = True)
plt.title("Dimension 1 ($x$-axis)")
plt.figure(1)
plt.hist(X[:, 1], bins = B, normed = True)
plt.title("Dimension 2 ($y$-axis)")
rng = np.random.RandomState(74)
t = rng.normal(size = (2, 2)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You see the data are easily separable along both the $x$ and $y$ axes. Put another way--if someone gives you an $x$ value of a data point and as... |
6,926 | <ASSISTANT_TASK:>
Python Code:
import sqlite3
import sys
from glob import glob
conn = sqlite3.connect('/users/mikespears/Desktop/mydb.db') #file-based db
#conn = sqlite3.connect(':memory:') # in-memory db
c = conn.cursor()
c.execute('''DROP TABLE IF EXISTS uoftcoders''')
c.execute('''CREATE TABLE uoftcoders (date, 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: Connect to a database file or create an in-memory database
Step2: SQLite basics
Step3: Full-Text-Search
|
6,927 | <ASSISTANT_TASK:>
Python Code:
import seaborn as sns; sns.set_style("whitegrid")
import random
from matplotlib import pyplot as plt
%matplotlib inline
import numpy as np
class MIR(object):
'''Class for the MIR exam.
Parameters
----------
study_level: int
The level of preparation you have. Must 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: What happens if we take the exam 10000 times randomly, without having studied at all?
Step2: There's chances that you can luck out and get clos... |
6,928 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import pandas as pd
import time
pd.set_option('display.width', 500)
pd.set_option('display.max_columns', 100)
pd.set_option('display.notebook_repr_h... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Below we write a function to scrape an IMDB url and return a movie name.
Step2: Now let's get the list of URLs for each of our data sets
Step3:... |
6,929 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow import keras
x = tf.constant([[5, 2], [1, 3]])
print(x)
x.numpy()
print("dtype:", x.dtype)
print("shape:", x.shape)
print(tf.ones(shape=(2, 1)))
print(tf.zeros(shape=(2, 1)))
x = tf.random.normal(shape=(2, 2), mean=0.0, stddev=1.0)
x = tf.rando... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introduction
Step2: You can get its value as a NumPy array by calling .numpy()
Step3: Much like a NumPy array, it features the attributes dtyp... |
6,930 | <ASSISTANT_TASK:>
Python Code:
# Ignore numpy warnings
import warnings
warnings.filterwarnings('ignore')
import matplotlib.pyplot as plt
%matplotlib inline
# Some defaults:
plt.rcParams['figure.figsize'] = (12, 6) # Default plot size
%reset -f
import pycuda
from pycuda import compiler
import pycuda.driver as drv
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: PyCUDA Imports
Step2: Available CUDA Devices
|
6,931 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from scipy import stats
Ns=np.arange(20,200,4);
K=10000;
ps=np.zeros((Ns.size,3))
res=np.zeros(4)
cs=np.zeros((Ns.size,8))
i=0
for N in Ns:
for k in range(K):
x1=np.zeros(N);x1[N/2:]=1
x2=np.mod(range(N),2)
y= 42+x1+x2+x1*x2+np.random.randn(N)*2
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we look at the probability that the various configurations of significant and non-significant results will be obtained.
|
6,932 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import colors
import matplotlib.pylab as plt
from oedes.fvm import mesh1d
from oedes import context,init_notebook,testing,models
import numpy as np
from oedes.functions import Aux2
init_notebook()
class CustomMobility(models.MobilityModel):
def mu_f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model and parameters
Step2: Results
Step3: Concentration dependent mobility
|
6,933 | <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... |
6,934 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
import numpy.random as rnd
import numpy
N = 2000
bruit1 = rnd.normal(size=(N,))
temps = numpy.arange(N)
bruit1[:5], temps[:5]
import random
bruit2 = numpy.zeros((N,))
for i in range(0, 10):
h = random... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Une série articielle
Step2: On crée un bruit aberrant.
Step3: Autocorrélations
Step4: L'autocorrélogramme à proprement parler.
Step5: Etant ... |
6,935 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy import linalg
plt.style.use('ggplot')
plt.rc('axes', grid=False) # turn off the background grid for images
my_matrix = np.array([[1,2],[1,1]])
print(my_matrix.shape)
print(my_matrix)
my_matrix_transposed =... | <SYSTEM_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 work with the matrix
Step2: numpy matrix multiply uses the dot() function
Step3: Caution the * will just multiply the matricies on an e... |
6,936 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd # data package
import matplotlib.pyplot as plt # graphics
import sys # system module, used to get Python version
import os # operating system tools (check files)
import datetime as dt # date tools, used... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Debt to Earnings by University
Step2: Debt to Earnings by Locale
Step3: Top 20 Universities by Median Earnings
Step4: 20 Universities with th... |
6,937 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.integrate as integrate
from scipy.stats import norm
import matplotlib.pyplot as plt
def f_YgivenX(y,x,sigman):
return np.exp(-((y-x)**2)/(2*sigman**2))/np.sqrt(2*np.pi)/sigman
def f_Y(y,sigman):
return 0.5*(f_YgivenX(y,+1,sigman)+f_YgivenX(y,-1,si... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Conditional pdf $f_{Y|X}(y|x)$ for a channel with noise variance (per dimension) $\sigma_n^2$. This is merely the Gaussian pdf with mean $x$ and... |
6,938 | <ASSISTANT_TASK:>
Python Code:
def sum_p(X):
y = 0
for x_i in range(int(X)):
y += x_i
return y
from numba import jit
@jit
def sum_j(X):
y = 0
for x_i in range(int(X)):
y += x_i
return y
import os
import time
import pandas as pd
import matplotlib
%matplotlib inline
# Different 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: Then we define $sum_j(x)$ that is identical but just with decorator @jit in the definition.
Step2: Lets benchmark them!
Step3: Benchmark resul... |
6,939 | <ASSISTANT_TASK:>
Python Code:
data_in_shape = (3, 5)
L = ZeroPadding1D(padding=1)
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(240)
data_in = 2 * np.random.random(data_in_shape) - 1
result ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: [convolutional.ZeroPadding1D.1] padding 3 on 4x4 input
Step2: [convolutional.ZeroPadding1D.2] padding (3,2) on 4x4 input
Step3: export for Ker... |
6,940 | <ASSISTANT_TASK:>
Python Code:
#Begin spark session
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
#Create pysplice context. Allows you to create a Spark dataframe using our Native Spark DataSource
from splicemachine.spark import PySpliceContext
splice = PySpliceContext(spark)
#Initia... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Write any SQL to get your label. The label doesn't have to be apart of the Feature Store
Step3: Create a Training View
Step4: Easily extract a... |
6,941 | <ASSISTANT_TASK:>
Python Code:
import os
import ml_metadata
import tensorflow_data_validation as tfdv
import tensorflow_model_analysis as tfma
from ml_metadata.metadata_store import metadata_store
from ml_metadata.proto import metadata_store_pb2
from tfx.orchestration import metadata
from tfx.types import standard_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: Option 1
Step2: The pipeline source can be found in the pipeline folder. Switch to the pipeline folder and compile the pipeline.
Step3: 2.1 Cr... |
6,942 | <ASSISTANT_TASK:>
Python Code:
# Work in a temporary directory
import tempfile
import os
os.chdir(tempfile.mkdtemp())
# Since this is running from an IPython notebook,
# we prefix all our commands with "!"
# When running on the command line, omit the leading "!"
! msmb -h
! msmb FsPeptide --data_home ./
! tree
# Reme... | <SYSTEM_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 example data
Step2: Featurization
Step3: Preprocessing
Step4: Intermediate kinetic model
Step5: tICA Histogram
Step6: Clustering
Step7:... |
6,943 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
def pas_de_voyelle(mot):
s = ""
for c in mot :
if c not in "aeiouy" :
s += c
return s
pas_de_voyelle("bonjour"), pas_de_voyelle("au revoir")
mat = [[0,1,0],[0,0,1]]
mat_dict = { }
for i,line... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Enoncé 1
Step2: Cette réponse n'est qu'une réponse parmi d'autres. Certains utilisaient la méthode replace, d'autres un test c == "a" or c == "... |
6,944 | <ASSISTANT_TASK:>
Python Code:
import os
import matplotlib.pyplot as plt
import torch
import pyro
import pyro.contrib.gp as gp
import pyro.distributions as dist
smoke_test = ('CI' in os.environ) # ignore; used to check code integrity in the Pyro repo
assert pyro.__version__.startswith('1.7.0')
pyro.set_rng_seed(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: Throughout the tutorial we'll want to visualize GPs. So we define a helper function for plotting
Step2: Data
Step3: Define model
Step4: Let's... |
6,945 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
sns.set_style("white")
filename="burrito_current.csv"
df = pd.read_csv(filename)
N = df.shape[0]
m_best = ['V... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: Find the best location for each dimension
|
6,946 | <ASSISTANT_TASK:>
Python Code:
for i in ['a','b','c']:
try:
result = i**2
except TypeError:
print("Type error attempting to run on {i}".format(i=i))
else:
print result
x = 5
y = 0
try:
z = x/y
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print 'all ... | <SYSTEM_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 2
Step2: Problem 3
|
6,947 | <ASSISTANT_TASK:>
Python Code:
from yargy import Parser, rule, and_
from yargy.predicates import gram, is_capitalized, dictionary
GEO = rule(
and_(
gram('ADJF'), # так помечается прилагательное, остальные пометки описаны в
# http://pymorphy2.readthedocs.io/en/latest/user/grammemes.ht... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Настоящие сложные грамматики для топонимов собраны в репозитории <a href="https
Step2: Грамматики для имён собраны в репозитории Natasha
Step3:... |
6,948 | <ASSISTANT_TASK:>
Python Code:
data_in_shape = (5, 5, 2)
conv = SeparableConv2D(4, (3,3), strides=(1,1),
padding='valid', data_format='channels_last',
depth_multiplier=1, activation='linear', use_bias=True)
layer_0 = Input(shape=data_in_shape)
layer_1 = conv(layer_0)
model ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: [convolutional.SeparableConv2D.1] 4 3x3 filters on 5x5x2 input, strides=(1,1), padding='valid', data_format='channels_last', depth_multiplier=2,... |
6,949 | <ASSISTANT_TASK:>
Python Code:
%reload_ext rpy2.ipython
import pandas as pd
%%R
# help()
# help(function)
# help(package='package-name)
%%R
# install
# install.packages('package-name')
# already installed with conda
#install.packages("foreign")
#install.packages("Rcmdr", dependencies = TRUE)
# new installs
install.pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Aide
Step2: Autres ressources
Step3: Espace de travail
Step4: Import fichier externe
|
6,950 | <ASSISTANT_TASK:>
Python Code:
from dolfin import *
from rbnics import *
from problems import *
from reduction_methods import *
@OnlineStabilization()
class AdvectionDominated(EllipticCoerciveProblem):
# Default initialization of members
def __init__(self, V, **kwargs):
# Call the standard initializati... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 3. Affine decomposition
Step2: 4. Main program
Step3: 4.2. Create Finite Element space (Lagrange P2)
Step4: 4.3. Allocate an object of the Ad... |
6,951 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import h5py
from sklearn import svm, cross_validation
from sklearn.naive_bayes import MultinomialNB
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
# First we load the file
file_location = '../results_database/text_wall_street_big.hdf5'
f = h5... | <SYSTEM_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 all the data
Step2: Latency analysis
Step3: Plot it
|
6,952 | <ASSISTANT_TASK:>
Python Code:
# Package imports
import numpy as np
import matplotlib.pyplot as plt
from testCases import *
import sklearn
import sklearn.datasets
import sklearn.linear_model
from planar_utils import plot_decision_boundary, sigmoid, load_planar_dataset, load_extra_datasets
%matplotlib inline
np.random.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: 2 - Dataset
Step2: Visualize the dataset using matplotlib. The data looks like a "flower" with some red (label y=0) and some blue (y=1) points.... |
6,953 | <ASSISTANT_TASK:>
Python Code:
# Standard
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
# Dimensionality reduction and Clustering
from sklearn.decomposition import PCA
from sklearn.cluster import KMeans
from sklearn.cluster import MeanShift, estimate_bandwidth
from sklearn 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: we've now dropped the last of the discrete numerical inexplicable data, and removed children from the mix
Step2: Clustering and other grouping ... |
6,954 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-lm', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "emai... | <SYSTEM_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,955 | <ASSISTANT_TASK:>
Python Code:
energy = 6
applicator = 10
ssd = 100
x = [0.99, -0.14, -1.0, -1.73, -2.56, -3.17, -3.49, -3.57, -3.17, -2.52, -1.76,
-1.04, -0.17, 0.77, 1.63, 2.36, 2.79, 2.91, 3.04, 3.22, 3.34, 3.37, 3.08, 2.54,
1.88, 1.02, 0.99]
y = [5.05, 4.98, 4.42, 3.24, 1.68, 0.6, -0.64, -1.48, -2.38, -3.77... | <SYSTEM_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 model data
Step2: Only use the data for the specified energy, applicator, and ssd
Step3: Calculate the factor
Step4: Display the model
|
6,956 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'snu', 'sandbox-2', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
6,957 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import tensorflow_addons as tfa
num_classes = 100
input_shape = (32, 32, 3)
(x_train, y_train), (x_test, y_test) = keras.datasets.cifar100.load_data()
print(f"x_train shape: {x_tra... | <SYSTEM_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: Configure the hyperparameters
Step3: Build a classification model
Step4: Define an experiment
Step5: Use data augmen... |
6,958 | <ASSISTANT_TASK:>
Python Code:
import warnings
import scipy as sp
import numpy as np
import porespy as ps
import openpnm as op
import matplotlib.pyplot as plt
ws = op.Workspace()
ws.settings["loglevel"] = 40
warnings.filterwarnings('ignore')
%matplotlib inline
np.random.seed(10)
# NBVAL_IGNORE_OUTPUT
im = ps.generators... | <SYSTEM_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 check out the porosity of the generated image!
Step2: Let's visualize the image using porespy's 3D visualizer
Step3: OpenPNM has an IO c... |
6,959 | <ASSISTANT_TASK:>
Python Code:
# Import the MetPy unit registry
from metpy.units import units
length = 10.4 * units.inches
width = 20 * units.meters
print(length, width)
area = length * width
print(area)
area.to('m^2')
# Your code goes here
# %load solutions/distance.py
10 * units.degC - 5 * units.degC
25 * units... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Don't forget that you can use tab completion to see what units are available! Just about every imaginable quantity is there, but if you find one... |
6,960 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
import matplotlib as mpl
mpl.rcParams['font.size'] = 8
figsize =(8,4)
mpl.rcParams['figure.figsize'] = figsize
import numpy as np
from scipy.optimize import fsolve
import matplotlib.pyplot as plt
from utils import riemann_tool... | <SYSTEM_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 chapter we investigate a nonlinear model of elastic strain in heterogeneous materials. This system is equivalent to the $p$-system of g... |
6,961 | <ASSISTANT_TASK:>
Python Code:
import datetime as dt
import graphlab as gl
sf = gl.SFrame.read_csv('raw_data/global_earthquakes.csv', verbose=False)
sf.show()
useful_columns = ['time', 'latitude', 'longitude', 'mag', 'type', 'location']
sf = sf[useful_columns]
mask = sf['type'] == 'nuclear explosion'
sf[mask]
mask = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Inspect the data visually
Step2: A small bit of data cleaning
Step3: 2. Convert to a TimeSeries object
Step4: Convert from SFrame to TimeSeri... |
6,962 | <ASSISTANT_TASK:>
Python Code:
traj = md.load('ala2.h5')
atoms, bonds = traj.topology.to_dataframe()
atoms
psi_indices, phi_indices = [6, 8, 14, 16], [4, 6, 8, 14]
angles = md.compute_dihedrals(traj, [phi_indices, psi_indices])
from pylab import *
from math import pi
figure()
title('Dihedral Map: Alanine dipeptide')
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Because alanine dipeptide is a little nonstandard in the sense that it's basically dominated by the ACE and NME capping residues, we need to fin... |
6,963 | <ASSISTANT_TASK:>
Python Code:
# Importar Librerías
import numpy as np
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD
# Guardar semilla para numeros aleatorios
seed = 21
np.random.seed(seed)
def generate_data(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: El problema se considera XOR, o or exclusivo debido a que [(-),(-)] y [(+),(+)] son etiquetados con con circulos y [(-),(+)] y [(+),(-)] son eti... |
6,964 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
init_printing()
pi.evalf(10)
alpha, beta, gamma, x, y = symbols('alpha beta gamma x y')
alpha, beta
f= Function('f')
diff(sin(x+1)*cos(y), x, y)
test = diff(f(x)+1,x)
test
Md = Function('M_d')(x)
Md
q1, q2, q3 = symbols('q_1 q_2 q_3')
q = Matrix([q1, q2, q3])
q
acol = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Code printing
|
6,965 | <ASSISTANT_TASK:>
Python Code:
print("Exemplo 9.1")
import numpy as np
Vm = 12
phi = 10
omega = 50
T = 2*np.pi/omega
f = 1/T
print("Amplitude:",Vm,"V")
print("Fase:",phi,"º")
print("Frequência angular:",omega,"rad/s")
print("Período:",T,"s")
print("Frequência:",f,"Hz")
print("Problema Prático 9.1")
Vm = 30
#30sin(4*pi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problema Prático 9.1
Step2: Exemplo 9.2
Step3: Problema Prático 9.2
Step4: Fasores
Step5: Problema Prático 9.4
Step6: Exemplo 9.5
Step7: P... |
6,966 | <ASSISTANT_TASK:>
Python Code:
import datetime
import json
import os
import time
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
%matplotlib inline
import pandas as pd
import scipy.sparse
import seaborn as sns
sns.set(context="paper", font_scale=1.5, rc={"lines.linewidth": 2},... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Confirmed the timestamps are ordered
Step2: Now we select the data from 1995-01-01 to the last day as the dataset (i.e., all the dataset)
Step3... |
6,967 | <ASSISTANT_TASK:>
Python Code:
def pretty_print_review_and_label(i):
print(labels[i] + "\t:\t" + reviews[i][:80] + "...")
g = open('reviews.txt','r') # What we know!
reviews = list(map(lambda x:x[:-1],g.readlines()))
g.close()
g = open('labels.txt','r') # What we WANT to know!
labels = list(map(lambda x:x[:-1].uppe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lesson
Step2: Project 1
Step3: Transforming Text into Numbers
Step4: Project 2
Step5: Project 3
Step6: Understanding Neural Noise
|
6,968 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import glob
import os
import numpy as np
from time import time
import logging
import gensim
import bz2
import re
from stop_words import get_stop_words
def getTopicForQuery (question,stoplist,dictionary,lda):
Returns the topic probability distribution 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:
Step2: 1. initialisation of function for topic determination
Step3: Now we load the lda model we use along with the stop words, in order to have them ... |
6,969 | <ASSISTANT_TASK:>
Python Code:
def zero_args():
# code goes here
pass
def one_arg(a):
# code goes here
pass
def two_args(a, b):
# code goes here
pass
def optional_arg(a, b=0): # <--- please note, optional arguments are listed LAST
# code goes here
pass
def two_options(a=True, b=False... | <SYSTEM_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 stuff right? Okay lets move on and look at the body and return statement. I’m going to create a function that calculates the hypotenuse o... |
6,970 | <ASSISTANT_TASK:>
Python Code:
# egrep.py
import sys, re
# sys.argv is the list of command-line arguments
# sys.argv[0] is the name of the program itself
# sys.argv[1] will be the regex specified at the command line
regex = sys.argv[1]
# for every line passed into the script
for line in sys.stdin:
# if it matches 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: Reading Files
Step2: Use a with block to ensure that files are closed
Step3: Delimited Files
Step5: HTML And The Parsing Thereof
Step7: Usin... |
6,971 | <ASSISTANT_TASK:>
Python Code:
!ls
import sha
# Our first commit
data1 = 'This is the start of my paper2.'
meta1 = 'date: 1/1/12'
hash1 = sha.sha(data1 + meta1).hexdigest()
print('Hash:', hash1)
# Our second commit, linked to the first
data2 = 'Some more text in my paper...'
meta2 = 'date: 1/2/12'
# Note we add the pa... | <SYSTEM_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 repository
Step2: And this is pretty much the essence of Git!
Step3: Other settings
Step4: Password memory
Step5: Github offers in its hel... |
6,972 | <ASSISTANT_TASK:>
Python Code:
# Load regex package
import re
# Create a variable containing a text string
text = 'The quick brown fox jumped over the lazy brown bear.'
# Find any of fox, snake, or bear
re.findall(r'\b(fox|snake|bear)\b', text)
<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: Create some text
Step2: Apply regex
|
6,973 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
df = pd.read_csv('output/embedded_1k_reviews.csv')
df['text-similarity-babbage-001'] = df.babbage_similarity.apply(eval).apply(np.array)
matrix = np.vstack(df.babbage_similarity.values)
matrix.shape
from sklearn.cluster import KMeans
n_clusters = 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: 1. Find the clusters using K-means
Step2: It looks like cluster 2 focused on negative reviews, while cluster 0 and 1 focused on positive review... |
6,974 | <ASSISTANT_TASK:>
Python Code:
WORKING_DIR = u"/path/to/folder/to/music"
FILENAME_PREFIX = u"filename_without_ext"
FILENAME_EXTENSION = u"wav"
OUTPUT_PATTERN = u"/path/to/your/music/<%(prefix)s >%(album)s< (%(suffix)s)>/<<%(discnumber)s->%(tracknumber)s >%(title)s.flac"
PICTURE = u"Folder.jpg"
ANSI_ENCODING = "gbk"
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Filename
Step2: Output Prefix
Step3: Others
Step4: Parse CUE
Step5: Covert Files
|
6,975 | <ASSISTANT_TASK:>
Python Code:
import numpy
N = 30 # number of points along each axis
X = numpy.linspace(-2, 2, N) # computes a 1D-array for x
Y = numpy.linspace(-2, 2, N) # computes a 1D-array for y
x, y = numpy.meshgrid(X, Y) # generates a mesh grid
from matplotlib import pyplot
%m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lets visualize the grid to see what we made. We need to import pyplot which has a large set of plotting functions similar to matlab, such as a s... |
6,976 | <ASSISTANT_TASK:>
Python Code:
# Author: Olaf Hauk <olaf.hauk@mrc-cbu.cam.ac.uk>
#
# License: BSD (3-clause)
import mne
from mne.datasets import sample
from mne.minimum_norm.resolution_matrix import make_inverse_resolution_matrix
from mne.minimum_norm.spatial_resolution import resolution_metrics
print(__doc__)
data_pat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: EEGMEG
Step2: MEG
Step3: Visualization
Step4: These plots show that with respect to peak localization error, adding EEG to
|
6,977 | <ASSISTANT_TASK:>
Python Code:
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
mnist = input_data.read_data_sets('MNIST_data', one_hot = True)
################## build a softmax regression model
# input data
x = tf.placeholder(tf.float32, shape = [None, 784])
# real label
y_ = tf.plac... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Build a Multilayer Convolutional Network
Step2: Convolution and Pooling
Step3: First Convolutional Layer
Step4: To apply the layer, we first ... |
6,978 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Joan Massich <mailsik@gmail.com>
#
# License: BSD Style.
import os.path as op
import mne
from mne.datasets import eegbci
from mne.datasets import fetch_fsaverage
# Download fsaverage files
fs_dir = fetch_fsaverage(verb... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the data
Step2: Setup source space and compute forward
|
6,979 | <ASSISTANT_TASK:>
Python Code:
from libtools import *
training = pd.read_csv('data-test.csv')
training.head()
training.describe()
training = training.fillna(-99999)
blind = pd.read_csv('blind.csv')
blind.head()
blind.describe()
training_SH = divisao_sh(training)
training_LM = divisao_lm(training)
blind_SH = divisao_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: Loading the data training data without Shankle well
Step2: Loading the SHANKLE well
Step3: Using the complete training data
Step4: Applying ... |
6,980 | <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')
pos = mne.chpi.read_head_pos(op.join(dat... | <SYSTEM_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 (traces)
Step2: Process our simulated raw data (taking into account head movements)
|
6,981 | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import basename, exists
def download(url):
filename = basename(url)
if not exists(filename):
from urllib.request import urlretrieve
... | <SYSTEM_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 following cells download and read the data.
Step2: In Chapter 17 I present the glucose minimal model; in Chapter 18 we implemented it using... |
6,982 | <ASSISTANT_TASK:>
Python Code:
assert duplicates((1, 1, 2, 3, 4, 5, 6, 8, 2, 4, -7, 12, -7)) == (1, 2, 4, -7)
assert duplicates([1, 1, 2, 3, 4, 5, "asd", 8, "asd", 4, -7, 12, -7]) == (1, 2, 4, "asd", -7)
assert square_collection([1, 2, 3, 4, 5, 6]) == [1, 4, 9, 16, 25, 36]
a = [12, 1, 2, 3, 4, 7, 8, 10]
b = [1, 12, 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: Napisz generator liczb pseudolosowych z czestotliwosciami 0,25 dla zakresu 1-50 i 0,75 dla zakresu 51-100.
Step2: Zaimplementuj linked liste w ... |
6,983 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import matplotlib as mpl
from ase.io import read
from pyqstem.util import atoms_plot
from pyqstem import PyQSTEM
from ase.bui... | <SYSTEM_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 create an orthorhombic unit cell of MoS2. The unit cell is repeated 3x3 times, in order to accomodate the size of the probe at all scan posit... |
6,984 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
from mpl_toolkits.mplot3d import Axes3D
from numpy.linalg import eigvals
def Lorenz(state,t,sigma,r,b):
'''
Returns the RHS of the Lorenz equations
'''
# unpack the state vect... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exploring the Lorenz Equations
Step2: Subcritical behavior $r<1$
Step3: Damped Oscillation $r=10$
Step4: Chaos and the strange attractor $r=2... |
6,985 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
# personal packages
from xlearn.cluster import KMeans
from pyingrid import Ingrid
import geoxarray
%matplotlib inline
ig = Ingrid('http://iridl.ldeo.columbia.edu',
'SOURCES/.NOAA/.NCEP-NCAR/.CDAS-1/.MONTHL... | <SYSTEM_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 is from the Columbia University IRI data library
Step2: Convert the data from the library into an xarray Dataset
Step3: Get the DataA... |
6,986 | <ASSISTANT_TASK:>
Python Code:
import pods, GPy, itertools
%matplotlib inline
from matplotlib import pyplot as plt
s = pods.datasets.singlecell()
Ydf = s['Y']
Y = Ydf.values
labels = s['labels']
marker = '<>^vsd'
Ydf.describe()
import numpy as np
# obtain a centred version of data.
centredY = Y - Y.mean()
# compute 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: Next we load in the data. We've provided a convenience function for loading in the data with GPy. It is loaded in as a pandas DataFrame. This al... |
6,987 | <ASSISTANT_TASK:>
Python Code:
EUCLIDEAN = 'euclidean'
MANHATTAN = 'manhattan'
PEARSON = 'pearson'
def read_ratings_df():
date_parser = lambda time_in_secs: datetime.utcfromtimestamp(float(time_in_secs))
return pd.read_csv('ml-latest-small/ratings.csv', parse_dates=['timestamp'], date_parser=date_parser)
class ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Explore shared ratings
Step2: We are looking at 30 random user pairs. We can notice how small on average is the intersection of the movies they... |
6,988 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.spatial import distance
shape = (6, 6)
xs, ys = np.indices(shape)
xs = xs.reshape(shape[0] * shape[1], 1)
ys = ys.reshape(shape[0] * shape[1], 1)
X = np.hstack((xs, ys))
mid_x, mid_y = (shape[0]-1)/2.0, (shape[1]-1)/2.0
result = distance.cdist(X, np.atleast_2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
6,989 | <ASSISTANT_TASK:>
Python Code:
x = 1
y = 2
x + y
x
def add_numbers(x, y):
return x + y
add_numbers(x, y)
def add_numbers(x,y,z=None):
if (z==None):
return x+y
else:
return x+y+z
print(add_numbers(1, 2))
print(add_numbers(1, 2, 3))
def add_numbers(x, y, z=None, flag=False):
if (flag):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <br>
Step2: <br>
Step3: <br>
Step4: <br>
Step5: <br>
Step6: <br>
Step7: <br>
Step8: <br>
Step9: <br>
Step10: <br>
Step11: <br>
Step12:... |
6,990 | <ASSISTANT_TASK:>
Python Code:
# Set up the exercise
import math
from learntools.core import binder
binder.bind(globals())
from learntools.intro_to_programming.ex2 import *
print('Setup complete.')
# TODO: Complete the function
def get_expected_cost(beds, baths):
value = ____
return value
# Check your answer
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question 1
Step2: Question 2
Step3: Question 3
Step4: Question 4
Step5: 🌶️ Question 5
Step6: Use the next code cell to define the function... |
6,991 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("white")
#Note the new use of the dtype option here. We can directly tell pandas to use the Speed column as a category in one step.
speeddf = pd.read_csv("../Class04/Class04_speed_data.csv",dtype={'Spe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We'll import the DecisionTreeClassifier and use all of the default values except for the random_state. We'll provide that so that the output is ... |
6,992 | <ASSISTANT_TASK:>
Python Code:
from keras.applications import inception_v3
from keras import backend as K
# We will not be training our model,
# so we use this command to disable all training-specific operations
K.set_learning_phase(0)
# Build the InceptionV3 network.
# The model will be loaded with pre-trained ImageNe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, we compute the "loss", the quantity that we will seek to maximize during the gradient ascent process. In Chapter 5, for filter
Step2: No... |
6,993 | <ASSISTANT_TASK:>
Python Code:
# access yelp.csv using a relative path
import pandas as pd
import seaborn as sns
yelp = pd.read_csv('C:/Users/Joshuaw/Documents/GA_Data_Science/data/yelp.csv')
yelp.head()
# read the data from yelp.json into a list of rows
# each row is decoded into a dictionary using using json.loads()... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Task 1 (Bonus)
Step2: Task 2
Step3: Task 3
Step4: Task 4
Step5: Task 5
Step6: Task 6
Step7: Task 7 (Bonus)
Step8: Task 8 (Bonus)
Step9: ... |
6,994 | <ASSISTANT_TASK:>
Python Code:
full_survey = ds.cadence_plot(fieldID=1427, mjd_center=61404, mjd_range=[-1825, 1825],
observedOnly=False, colorbar=True);
plt.close()
full_survey[0]
half_survey = ds.cadence_plot(fieldID=1427, mjd_center=61404, mjd_range=[-1825, 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: List of obsHistIDs with unique nights
Step2: How much does it help our airmass distribution by choosing the lowest airmass of the available one... |
6,995 | <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... |
6,996 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import scipy.optimize as spo
def parab(X):
## X = 2 is the min
Y = (X - 2)**2 + 1.5
return Y
initial_guess = 3
opt_methods_no_Jacobian = ['Nelder-Mead','Powell','CG','BFGS','L-BFGS-B','TNC','COBYLA','SLS... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Non-Convex example
Step2: The problem with such function is the fact it is not convex. Hence, starting from initial guess
Step3: We can see t... |
6,997 | <ASSISTANT_TASK:>
Python Code:
# Start by importing torch
import torch
# Construct a bunch of ones
some_ones = torch.ones(2, 2)
print(some_ones)
# Construct a bunch of zeros
some_zeros = torch.zeros(2, 2)
print(some_zeros)
# Construct some normally distributed values
some_normals = torch.randn(2, 2)
print(some_normals... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Tensors
Step2: PyTorch tensors and NumPy ndarrays even share the same memory handles, so you can switch between the two types essentially for f... |
6,998 | <ASSISTANT_TASK:>
Python Code:
import json
from pyspark.streaming import StreamingContext
from pyspark.streaming.kafka import KafkaUtils
from pyspark import SparkContext
from pyspark.sql import SQLContext
from pyspark.sql.functions import explode
from pyspark.ml.feature import VectorAssembler
from pyspark.mllib.tree 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: Script to Process the Sensor Readings - ProcessSensorReadings.py
Step2: The "writeLumbarReadings" method takes the rdd received from Spark Stre... |
6,999 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import pandas as pd
pd.set_option('display.width', 500)
pd.set_option('display.max_columns', 100)
pd.set_option('display.notebook_repr_html', True)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Settings
Step2: Skipped step
Step3: Mobile analytics
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.