Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
8,900 | <ASSISTANT_TASK:>
Python Code::
important_values = values.merge(labels, on="building_id")
important_values.drop(columns=["building_id"], inplace = True)
important_values["geo_level_1_id"] = important_values["geo_level_1_id"].astype("category")
important_values
X_train, X_test, y_train, y_test = train_test_split(importa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
8,901 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
mask, clean_input_spectrogram, output= load_data()
output[:, mask[0].to(torch.bool), :] = clean_input_spectrogram[:, mask[0].to(torch.bool), :]
<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:
|
8,902 | <ASSISTANT_TASK:>
Python Code:
data_in_shape = (4, 4, 4, 2)
L = AveragePooling3D(pool_size=(2, 2, 2), strides=None, padding='valid', data_format='channels_last')
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... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: [pooling.AveragePooling3D.1] input 4x4x4x2, pool_size=(2, 2, 2), strides=(1, 1, 1), padding='valid', data_format='channels_last'
Step2: [poolin... |
8,903 | <ASSISTANT_TASK:>
Python Code:
### Notebook 6
### Data set 6 (Finches)
### Authors: DaCosta & Sorenson (2016)
### Data Location: SRP059199
%%bash
## make a new directory for this analysis
mkdir -p empirical_6/fastq/
## IPython code
import pandas as pd
import numpy as np
import urllib2
import os
## open the SRA run ta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download the sequence data
Step3: For each ERS (individuals) get all of the ERR (sequence file accessions).
Step4: Here we pass the SRR number... |
8,904 | <ASSISTANT_TASK:>
Python Code:
def equilibrium_temperature(luminosity, distance, albedo=0):
Calculates the equilibrium temperature of a planet, assuming blackbody radiation
and thermodynamic equilibrium.
Parameters
----------
luminosity : float
luminosity of the host star [ergs 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: Activity Description
Step2: Test equilibrium_temperature
Step4: Mass-luminosity relation
Step5: test luminosity_from_mass
Step6: Equilibrium... |
8,905 | <ASSISTANT_TASK:>
Python Code:
from polara.recommender.data import RecommenderData
from polara.datasets.movielens import get_movielens_data
data = get_movielens_data() # will automatically download it, or you can specify a path to the local copy
data.head()
data.shape
data_model = RecommenderData(data, 'userid', 'movie... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Standard scenario with known users
Step2: Let's check for demonstration purposes that all test users are present in the training set
Step3: Pu... |
8,906 | <ASSISTANT_TASK:>
Python Code:
from pylab import *
from ase.build import graphene_nanoribbon
from thermo.gpumd.data import load_dos, load_vac
from thermo.gpumd.io import ase_atoms_to_gpumd
gnr = graphene_nanoribbon(60, 36, type='armchair', sheet=True, vacuum=3.35/2, C_C=1.44)
gnr.euler_rotate(theta=90)
l = gnr.cell.le... | <SYSTEM_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. Preparing the Inputs
Step2: The first few lines of the xyz.in file are
Step3: Plot DOS and VAC
Step4: (a) Normalized VAC for individual di... |
8,907 | <ASSISTANT_TASK:>
Python Code:
import autograd.numpy as np
np.set_printoptions(precision=2)
import matplotlib.pyplot as plt
%matplotlib inline
# Number of data points
N = 1000
# Dimension of each data point
D = 2
# Number of clusters
K = 3
pi = [0.1, 0.6, 0.3]
mu = [np.array([-4, 1]), np.array([0, 0]), np.array([2, -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: Given a data sample the de facto standard method to infer the parameters is the expectation maximisation (EM) algorithm that, in alternating so-... |
8,908 | <ASSISTANT_TASK:>
Python Code:
# import packages
from openpiv import windef # <---- see windef.py for details
from openpiv import tools, scaling, validation, filters, preprocess
import openpiv.pyprocess as process
from openpiv import pyprocess
import numpy as np
import os
from time import time
import warnings
import 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: Set up all the settings
Step2: Run the windef.py function, called piv with these settings
Step3: Run the extended search area PIV for comparis... |
8,909 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from sklearn.linear_model import Ridge
from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 12, 10
# Define input array with angles from 60° to 300° in radians
x = np.array([i*np.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: Data simulating a sine-curve between 60°-300° with random noise
Step2: Adding a column for each power up to 15
Step3: Generic function for rid... |
8,910 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline
#x = np.array(np.random.normal(0,1,size=(1000,1))).reshape(-1, 1)
#y = np.array(np.random.normal(0,1,size=(1000,1))).reshape(-1, 1)
x = np.array([0, 0, 1, 1, 2, 4, 2, 1, 2, 0]).reshape(-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: Let's see what the path looks like on top of the accumulative cost matrix (and, because we can, let's also plot the local cost matrix)
Step2: N... |
8,911 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
init_printing()
from sympsi import *
from sympsi.boson import *
from sympsi.pauli import *
# CPW, qubit and NR energies
omega_r, omega_q, omega_nr = symbols("omega_r, omega_q, omega_{NR}")
# Coupling CPW-qubit, NR_qubit
g, L, chi, eps = symbols("g, lambda, chi, epsil... | <SYSTEM_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 Jaynes-Cummings model
Step2: Unitary transformation to interaction picture
Step3: Nanoresonator - b
Step4: Qubit - Sigma_z
Step5: Now, i... |
8,912 | <ASSISTANT_TASK:>
Python Code:
# Personality Embeddings: What are you like?
jay = [-0.4, 0.8, 0.5, -0.2, 0.3]
john = [-0.3, 0.2, 0.3, -0.4, 0.9]
mike = [-0.5, -0.4, -0.2, 0.7, -0.1]
from numpy import dot
from numpy.linalg import norm
def cos_sim(a, b):
return dot(a, b)/(norm(a)*norm(b))
cos_sim([1, 0, -1], [-1,-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: Cosine Similarity
Step2: $$CosineDistance = 1- CosineSimilarity$$
Step3: Cosine similarity works for any number of dimensions.
Step5: $$King... |
8,913 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bnu', 'sandbox-1', 'ocnbgchem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,914 | <ASSISTANT_TASK:>
Python Code:
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
autorizar = tweepy.OAuthHandler(consumer_key, consumer_secret)
autorizar.set_access_token(access_token, access_token_secret)
api = tweepy.API(autorizar)
print(api)
api.update_status(status="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: Com as chaves e tokens de acesso, iremos criar a autenticação e definir o token de acesso.
Step2: Com a autorização criada, vamos passar as cre... |
8,915 | <ASSISTANT_TASK:>
Python Code:
# code for loading the format for the notebook
import os
# path : store the current path to convert back to it later
path = os.getcwd()
os.chdir(os.path.join('..', '..', 'notebook_format'))
from formats import load_style
load_style(plot_style=False)
os.chdir(path)
# 1. magic for inline pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Causal Inference
Step2: Usually, our treatment group will be smaller than the control group.
Step3: Given all of these covariates and our colu... |
8,916 | <ASSISTANT_TASK:>
Python Code:
# Dollar volume factor
dollar_volume = AverageDollarVolume(window_length=30)
# High dollar volume filter
high_dollar_volume = (dollar_volume > 10000000)
# Average close price factors
mean_close_10 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=10, mask=high_dollar_vol... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Applying the mask to SimpleMovingAverage restricts the average close price factors to a computation over the ~2000 securities passing the high_d... |
8,917 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import numpy as np
import pylab as pb
import GPy
np.random.seed(1)
# Domain Parameters
a = 0. # lower bound of the space
b = 20 # upper bound
# kernel parameters
per = 2*np.pi # period
#var = 1. # variance
#lenscl=10. # lengthscale
... | <SYSTEM_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 boundary limits for the plots are set to $[0,20]$, and we consider a period of $2 \pi$. The test function for this example is $f_{test}=\sin... |
8,918 | <ASSISTANT_TASK:>
Python Code:
import sys
import scipy.io as sio
import glob
import numpy as np
import matplotlib.pyplot as plt
from skimage.filters import threshold_otsu
sys.path.append('../code/functions')
import qaLib as qLib
sys.path.append('../../pipeline_1/code/functions')
import connectLib as cLib
from IPython.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: Algorithm
Step2: Actual Code
Step3: Algorithm Conditions
Step4: Good Data
Step5: Prediction on Good Data
Step6: Prediction on Challenging D... |
8,919 | <ASSISTANT_TASK:>
Python Code:
cd /notebooks/exercise-06/
!cat ssh_config
fmt=r'{{.NetworkSettings.IPAddress}}'
!docker -H tcp://172.17.0.1:2375 inspect ansible101_bastion_1 --format {fmt} # pass variables *before* commands ;)
# Use this cell to create the pin file and then encrypt the vault
# Use this cell to tes... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ssh_config
Step2: If we don't use it, we can turn off GSSApiAuthentication which attempts may slow down the connection.
Step3: Exercise
Step4:... |
8,920 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
import thinkbayes2
import thinkplot
import numpy as np
from scipy import stats
%matplotlib inline
data = {
2008: ['Gardiner', 'McNatt', 'Terry'],
2009: ['McNatt', 'Ryan', 'Partridge', 'Turner', 'Demers'],
2010: ['Gardiner', 'Bar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Almost every year since 2008 I have participated in the Great Bear Run, a 5K road race in Needham MA. I usually finish in the top 20 or so, and... |
8,921 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact
def char_probs(s):
Find the probabilities of the unique characters in the string s.
Parameters
----------
s : str
A string of characters.
... | <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: Character counting and entropy
Step4: The entropy is a quantiative measure of the disorder of a probability distribution. It is used extensivel... |
8,922 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
n = 100
# Random
# A = np.random.randn(n, n)
# A = A.T.dot(A)
# Clustered eigenvalues
A = np.diagflat([np.ones(n//4), 10 * np.ones(n//4), 100*np.ones(n//4), 1000* np.ones(n//4)])
U = np.random.rand(n, n)
Q, _ = np.linalg.qr(U)
A = Q.dot(A).dot(Q.T)
A = (A + A.T) * 0.5
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: Распределение собственных значений
Step2: Правильный ответ
Step3: Реализация метода сопряжённых градиентов
Step4: График сходимости
Step5: Н... |
8,923 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from trasferencia_calor import solve_explicit, pretty_plot
import time
a = time.time()
t_out, dic = solve_explicit(metodo='explicit_py')
print('Explicito python puro demoro ',time.time() - a, 'segundos')
pretty_plot(t_out, dic)
a = time.time()
t_out, dic = solve_explic... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Copiamos la implementación de python en un archivo separado que termina en .pyx y lo compilamos usando el scrip setup.py haciendo
Step2: Notar ... |
8,924 | <ASSISTANT_TASK:>
Python Code:
# Import matplotlib (plotting) and numpy (numerical arrays).
# This enables their use in the Notebook.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
# Create an array of 30 values for x equally spaced from 0 to 5.
x = np.linspace(0, 5, 30)
y = x**2
# Plot y versu... | <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: Above, you should see a plot of $y=x^2$.
Step4: Counting galaxies in the Hubble deep field
|
8,925 | <ASSISTANT_TASK:>
Python Code:
import espressomd
espressomd.assert_features('DIPOLES', 'LENNARD_JONES')
from espressomd.magnetostatics import DipolarP3M
from espressomd.magnetostatic_extensions import DLC
from espressomd.cluster_analysis import ClusterStructure
from espressomd.pair_criteria import DistanceCriterion
imp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we set up all simulation parameters.
Step2: Note that we declared a <tt>lj_cut</tt>. This will be used as the cut-off radius of the Lennard... |
8,926 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from sympy import *
import matplotlib.pyplot as plt
import numpy as np
init_printing(use_unicode=True)
r, u, v, c, r_c, u_c, v_c, E, p, r_p, u_p, v_p, e, a, b, q, b_0, b_1, b_2, b_3, q_0, q_1, q_2, q_3, q_4, q_5, beta, rho, epsilon, delta, d, K_3, Omega, Lambda, lamda, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generalized Landau Model of Ferroelectric Liquid Crystals
Step2: $f(c,p) = \dfrac{1}{2}r_{c}c^{2}+\dfrac{1}{4}u_{c}c^{4}+\dfrac{1}{6}v_{c}c^{6}... |
8,927 | <ASSISTANT_TASK:>
Python Code:
import pints
import pints.toy as toy
import numpy as np
import matplotlib.pyplot as plt
# Load a forward model
model = toy.LogisticModel()
# Create some toy data
r = 0.015
k = 500
real_parameters = [r, k]
times = np.linspace(0, 1000, 100)
signal_values = model.simulate(real_parameters, ti... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create the nested sampler that will be used to sample from the posterior.
Step2: Run the sampler!
Step3: Plot posterior samples versus true pa... |
8,928 | <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))
encoded = np.array([vocab_to_int[c] 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: First we'll load the text file and convert it into integers for our network to use. Here I'm creating a couple dictionaries to convert the chara... |
8,929 | <ASSISTANT_TASK:>
Python Code:
# Pure python modules and jupyter notebook functionality
# first you should import the third-party python modules which you'll use later on
# the first line enables that figures are shown inline, directly in the notebook
%pylab inline
import os
import datetime as dt
from os import path
im... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. The key classes within the api and being "pythonic"
Step2: Note, however, that these containers are very basic lists. They don't have method... |
8,930 | <ASSISTANT_TASK:>
Python Code:
# The Developer Key is used to retrieve a discovery document containing the
# non-public Full Circle Query v2 API. This is used to build the service used
# in the samples to make API requests. Please see the README for instructions
# on how to configure your Google Cloud Project for acces... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install Dependencies
Step2: Define function to enable charting library
Step11: Authenticate against the ADH API
Step12: Frequency Analysis
St... |
8,931 | <ASSISTANT_TASK:>
Python Code:
def say_hello():
print('hello, world!')
say_hello()
def hi(name):
print('hi', name)
hi("pythonistas")
def double(value):
return value*2
print(double(4))
"abcde"[:2]
empty_list = []
list_with_numbers = [0, 1, 2, 3, 4, 5, 6]
list_with_mixed = ["zero", 1, "TWO", 3, 4, "FIVE",... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Functions are invoked using parenthesis (). Argumements are passed between the parenthesis.
Step2: Functions can use the return keyword to stop... |
8,932 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nasa-giss', 'sandbox-2', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,933 | <ASSISTANT_TASK:>
Python Code:
demo_tb = Table()
demo_tb['Study_Hours'] = [2.0, 6.9, 1.6, 7.8, 3.1, 5.8, 3.4, 8.5, 6.7, 1.6, 8.6, 3.4, 9.4, 5.6, 9.6, 3.2, 3.5, 5.9, 9.7, 6.5]
demo_tb['Grade'] = [67.0, 83.6, 35.4, 79.2, 42.4, 98.2, 67.6, 84.0, 93.8, 64.4, 100.0, 61.6, 100.0, 98.4, 98.4, 41.8, 72.0, 48.6, 90.8, 100.0]
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: Intuiting the Linear Regression Model
Step2: In the example above, we're interested in Study_Hours and Grade. This is a natural "input" "output... |
8,934 | <ASSISTANT_TASK:>
Python Code:
import cv2
import numpy as np
import pandas as pd
import urllib
import math
import boto3
import os
import copy
from tqdm import tqdm
from matplotlib import pyplot as plt
%matplotlib inline
# Temporarily load from np arrays
chi_photos_np = np.load('chi_photos_np_0.03_compress.npy')
lars_ph... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Scaling Inputs
Step2: Reshaping 3D Array To 4D Array
Step3: Putting It All Together
Step4: Now let's reshape.
Step5: Preparing Labels
Step6:... |
8,935 | <ASSISTANT_TASK:>
Python Code:
def make_a_pile(n):
return [n + 2*i for i in range(n)]
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
8,936 | <ASSISTANT_TASK:>
Python Code:
from os.path import join, expandvars
from tax_credit.simulated_communities import generate_simulated_communities
# Project directory
project_dir = expandvars("$HOME/Desktop/projects/short-read-tax-assignment/")
# Directory containing reference sequence databases
reference_database_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: In the following cell, we define the natural datasets that we want to use for simulated community generation. The directory for each dataset is ... |
8,937 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
from sympy.vector import CoordSys3D
N = CoordSys3D('N')
x1, x2, x3 = symbols("x_1 x_2 x_3")
alpha1, alpha2, alpha3 = symbols("alpha_1 alpha_2 alpha3")
R, L, ga, gv = symbols("R L g_a g_v")
init_printing()
a1 = pi / 2 + (L / 2 - alpha1)/R
x = R * cos(a1)
y = alpha2
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: Cylindrical coordinates
Step2: Mid-surface coordinates is defined with the following vector $\vec{r}=\vec{r}(\alpha_1, \alpha_2)$
Step3: Tange... |
8,938 | <ASSISTANT_TASK:>
Python Code:
header =
My President Was Black
A history of the first African American White House—and of what came next
By Ta-Nehisi Coates
Photograph by Ian Allen
?repr
print(repr(header))
header_list = header.split('\n')
print(header_list)
#Removing extra white spaces in each... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: DC Python Lab - Class 02/18/2017
Step2: Let's use the hint
Step3: Splitting the header
Step4: Let's clean up a little this data.
Step5: You ... |
8,939 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
x = np.linspace(0,10,23)
f = np.sin(x)
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(x,f,'o-')
plt.plot(4,0,'ro')
# f1 = f[1:-1] * f[:]
print(np.shape(f[:-1]))
print(np.shape(f[1:]))
ff = f[:-1] * f[1:]
print(ff.shape)
x_zero = x[np.where(ff < 0)]
x_zero2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 9. Utwórz macierz 3x3
Step2: 12. Siatka 2d.
|
8,940 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
from phoebe import u
import numpy as np
import matplotlib.pyplot as plt
phoebe.devel_on() # needed to use WD-style meshing, which isn't fully supported yet
logger = phoebe.logger()
b = phoebe.default_binary()
b['q'] = 0.7
b['requiv@secon... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new bundle.
Step2: Adding Datasets and Compute Options
Step3: Let's add compute opti... |
8,941 | <ASSISTANT_TASK:>
Python Code:
# numpy provides python tools to easily load comma separated files.
import numpy as np
# use numpy to load disease #1 data
d1 = np.loadtxt(open("../31_Data_ML-IV/D1.csv", "rb"), delimiter=",")
# features are all rows for columns before 200
# The canonical way to name this is that X is our... | <SYSTEM_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 classifiers
Step2: Evaluate your classifiers
|
8,942 | <ASSISTANT_TASK:>
Python Code:
from sympy import init_session
init_session()
%matplotlib notebook
f=sin(x)*sin(y)
f
from sympy.simplify.fu import *
g=TR8(f) # TR8 is a trigonometric expression function from Fu paper
Eq(f, g)
s = 0.03 # slip
fs = 50 # stator frequency in Hz
fr = (1-s)*fs # rotor ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Look at a superposition of two sinusoidal signals
Step2: This product can be rewritten as a sum using trigonometric equalities. SymPy has a spe... |
8,943 | <ASSISTANT_TASK:>
Python Code:
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
import base64 # to produce human readable encoding of the bytes
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
digest.update(b"PyCon")
digest.update(b"2017")
msg_di... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: *<font color=" #6495ED">Exercise</font> *
Step2: *<font color=" #6495ED">Exercise</font> *
Step3: HMAC Verification
|
8,944 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import math
import matplotlib.pyplot as plt
%matplotlib inline
import torch
assert torch.__version__ >= '1.0.0'
import tqdm
help(torch.sqrt)
# to close the Jupyter help bar, press `Esc` or `q`
?torch.cat
theta = torch.linspace(-math.pi, math.pi, 1000)
assert theta.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: To learn best practices $-$ for example,
Step2: Task 1 (3 points)
Step4: Task 2 (7 points)
Step5: More fun with Game of Life
Step7: The cell... |
8,945 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
from sklearn import __version__ as sklearn_version
print('Sklearn version:', sklearn_version)
from sklearn import datasets
iris = datasets.load_iris()
print(iris.DESCR)
# Print some data lines
print(iris.data[:10])
print(iris.target)
#Randomize and s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: Linear model
Step3: Decision tree
Step4: Test another clasifier
Step5: ROC area
|
8,946 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def conv(f, h):
f, h = np.asarray(f), np.asarray(h,float)
if len(f.shape) == 1: f = f[np.newaxis,:]
if len(h.shape) == 1: h = h[np.newaxis,:]
if f.size < h.size:
f, h = h, f
g = np.zeros(np.array(f.shape) + np.array(h.shape) - 1)
if f.ndi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Description
Step2: Example 1
Step3: Example 2
Step4: Example 3
Step5: Example 4
Step6: Limitations
|
8,947 | <ASSISTANT_TASK:>
Python Code:
# pycl imports
from pycl import *
#Std lib imports
import datetime
from glob import glob
from pprint import pprint as pp
from os.path import basename
from os import listdir, remove, rename
from os.path import abspath, basename, isdir
from collections import OrderedDict
# Third party 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: Overview of the datasets
Step2: DARNED is a little messy and hard to convert since the position with the same PMID/OR sample types where fused ... |
8,948 | <ASSISTANT_TASK:>
Python Code:
import os, sys, inspect, io
cmd_folder = os.path.realpath(
os.path.dirname(
os.path.abspath(os.path.split(inspect.getfile( inspect.currentframe() ))[0])))
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)
from transitions import *
from transitions.extensio... | <SYSTEM_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 Matter graph
Step2: Hide auto transitions
Step3: Previous state and transition notation
Step4: One Machine and multiple models
Step5: Sh... |
8,949 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
sys.path.append(os.environ.get('NOTEBOOK_ROOT'))
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def bathymetry_index(df, m0 = 1, m1 = 0):
return m0*(np.log(df.blue)/np.log(df.green))+m1
from datacube.utils.aws import ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <span id="Shallow_Water_Bathymetry_import">Import Dependencies and Connect to the Data Cube ▴</span>
Step2: <span id="Shallow_Water_Bathy... |
8,950 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
poeme =
A noir, E blanc, I rouge, U vert, O bleu, voyelles,
Je dirai quelque jour vos naissances latentes.
A, noir corset velu des mouches éclatantes
Qui bombillent autour des puanteurs cruelles,
Golfe d'ombre; E, candeur 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:
Step2: Enoncé
Step3: Exercice 1
Step4: Exercice 2
Step5: Exercice 3
Step6: Exercice 4
Step7: Exercice 5
Step8: C'est illisible. On ne montre... |
8,951 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import tensorflow as tf
import numpy as np
from datetime import date
date.today()
author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises"
tf.__version__
np.__version__
sess = tf.InteractiveSession()
out = tf.zeros([2, 3])
print(out.eval... | <SYSTEM_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 on notation
Step2: Q2. Let X be a tensor of [[1,2,3], [4,5,6]]. <br />Create a tensor of the same shape and dtype as X with all elements s... |
8,952 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import networkx as nx
K_5=nx.complete_graph(5)
nx.draw(K_5)
def complete_deg(n):
Return the integer valued degree matrix D for the complete graph K_n.
kn=np.eye((n),dtype=np.int)
kn=k... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Complete graph Laplacian
Step3: The Laplacian Matrix is a matrix that is extremely important in graph theory and numerical analysis. It is defi... |
8,953 | <ASSISTANT_TASK:>
Python Code:
setup_sum='sum=0'
run_sum=
for i in range(1,1000):
if i % 3 ==0:
sum = sum + i
print(timeit.Timer(run_sum, setup="sum=0").repeat(1,10000))
t=timeit.timeit(run_sum,setup_sum,number=10000)
print("Time for built-in sum(): {}".format(t))
start=time.time()
sum=0
for i in range(1,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: repeat(1,10000)重复一次,每次10000遍
Step2: 这个就没有重复多少次,就一次,一次10000遍
|
8,954 | <ASSISTANT_TASK:>
Python Code:
import urllib3
import pandas as pd
url = "https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat"
#load the csv
airports = pd.read_csv(url,header=None)
print("Check DataFrame types")
display(airports.dtypes)
import numpy as np
print("-> Original DF")
display(airp... | <SYSTEM_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 you can find an explanation of each variable
Step2: Convert alt to m
Step3: Check if we have nans.
Step4: Let's check errors.
Step5: We... |
8,955 | <ASSISTANT_TASK:>
Python Code:
print('hello world!')
import json
# hit Tab at end of this to see all methods
json.
# hit Shift-Tab within parenthesis of method to see full docstring
json.loads()
?sum()
import json
?json
<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: In this figure are a few labels of notebook parts I will refer to
|
8,956 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import pyplot as plt #plotting library (lets us draw graphs)
%matplotlib inline
from sklearn import datasets #the datasets from sklearn
digits = datasets.load_digits() #load the digits into the variable 'digits'
digits.data.shape
digits.data[35,:]
#code to reshape the 6... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To get an idea of the data we are going to be classifying we'll ask what shape the 'data' matrix is
Step2: This tells us that it has 1797 rows ... |
8,957 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
def bscall(strike=100,mat=1,fwd=100,sig=0.1,df=1):
lnfs = log(1.0*fwd/strike)
sig2t = sig*sig*mat
sigsqrt = sig*sqrt(mat)
d1 = (lnfs + 0.5 * sig2t) / sigsqrt
d2 = (lnfs - 0.5 * sig2t) / 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: Black Scholes Pricing - Simple
Step2: European Put Option
Step3: European Digital
Step4: The reverse European digital call option pays one un... |
8,958 | <ASSISTANT_TASK:>
Python Code:
import sys,os
%matplotlib inline
ia898path = os.path.abspath('/etc/jupyterhub/ia898_1s2017/')
if ia898path not in sys.path:
sys.path.append(ia898path)
import ia898.src as ia
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from numpy.fft import fft2
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Constant image
Step2: Square image
Step3: Pyramid image
Step4: Gaussian image
Step5: Impulse image
|
8,959 | <ASSISTANT_TASK:>
Python Code:
name = "YOUR NAME HERE"
print("Hello {0}!".format(name))
%matplotlib inline
from matplotlib import rcParams
rcParams["savefig.dpi"] = 100 # This makes all the plots a little bigger.
import numpy as np
import matplotlib.pyplot as plt
# Load the data from the CSV file.
x, y, yerr = np.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: If this works, the output should greet you without throwing any errors. If so, that's pretty much all we need so let's get started with some MCM... |
8,960 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
#Como vamos a trabajar con imagenes blanco y negro, tomamos una imagen a color y la convertimos a BW.
im = Image.open("C:/Users/Zuraya/Pictures/Rossum.jpg", 'r').convert('LA')
mat = np.array(list(im.getdata(band=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: La imagen original en blanco y negro
Step2: (a) Observar que pasa si b esta en la imagen de A (contestar cuál es la imagen) y si no está (ej. b... |
8,961 | <ASSISTANT_TASK:>
Python Code:
from enoslib import *
import logging
import sys
log = logging.getLogger()
log.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fileHandler = logging.FileHandler("debug.log", 'a')
fileHandler.setLevel(logging.DEBUG)
fileHandler.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configuring logging
Step2: Getting resources
Step3: Grid'5000 provider configuration
Step4: We still need a Static provider to interact with ... |
8,962 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import Image, HTML, SVG, display
s =
<svg width="100" height="100">
<circle cx="50" cy="50" r="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:
Step2: Interact with SVG display
Step5: Write a function named draw_circle that draws a circle using SVG. Your function should take the parameters of ... |
8,963 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import sys
from sklearn import linear_model
import matplotlib.pyplot as plt
%matplotlib inline
dtype_dict = {'bathrooms':float, 'waterfront':int, 'sqft_above':int, 'sqft_living15':float, 'grade':int, 'yr_renovated':int, 'price':float, 'bedrooms':flo... | <SYSTEM_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 in house sales data
Step2: If we want to do any "feature engineering" like creating new features or adjusting existing ones we should do t... |
8,964 | <ASSISTANT_TASK:>
Python Code:
from math import pi
def mult_dec_pi(a, b):
# Add the solution here
result = ''
return result
mult_dec_pi(a=2, b=4)
# 20.0
mult_dec_pi(a=5, b=10)
# 45.0
mult_dec_pi(a=14, b=1)
# 9.0
mult_dec_pi(a=6, b=8)
# 10.0
# Bonus
mult_dec_pi(a=16, b=4)
# 'Error'
%matplotlib inl... | <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: Exercise 02.2
Step3: Exercise 02.3
Step4: segment the data into boy and girl names
Step5: Analyzing the popularity of a name over time
|
8,965 | <ASSISTANT_TASK:>
Python Code:
# Import NumPy and seed random number generator to make generated matrices deterministic
import numpy as np
np.random.seed(1)
# Create a matrix with random entries
A = np.random.rand(4, 4)
# Use QR factorisation of A to create an orthogonal matrix Q (QR is covered in IB)
Q, R = np.linalg.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can now verify that Q is an orthognal matrix. We first check that $\boldsymbol{Q}^{-1} = \boldsymbol{Q}^{T}$ by computing $\boldsymbol{Q}\bol... |
8,966 | <ASSISTANT_TASK:>
Python Code:
# import stuffs
%matplotlib inline
import numpy as np
import pandas as pd
from pyplotthemes import get_savefig, classictheme as plt
plt.latex = True
from datasets import get_pbc
d = get_pbc(prints=True, norm_in=True, norm_out=False)
durcol = d.columns[0]
eventcol = d.columns[1]
if np.any... | <SYSTEM_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 some data
Step2: Create an ANN model
Step3: Train the ANNs
Step4: Plot grouping
|
8,967 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.2,<2.3"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_star()
b.add_spot(radius=30, colat=80, long=0, relteff=0.9)
print(b['spot'])
times = np.linspace(0, 10, 11)
b.se... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details.
Step2: Adding Spots
Step3: Spot... |
8,968 | <ASSISTANT_TASK:>
Python Code:
import moldesign as mdt
from moldesign import units as u
%matplotlib inline
from matplotlib.pyplot import *
# seaborn is optional -- it makes plots nicer
try: import seaborn
except ImportError: pass
dna_structure = mdt.build_dna_helix('ACTGACTG', helix_type='b')
dna_structure.draw()
dn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Contents
Step2: 2. Forcefield
Step3: 3. Constraints
Step4: Of course, fixing the positions of the terminal base pairs is a fairly extreme ste... |
8,969 | <ASSISTANT_TASK:>
Python Code:
import astropy.table as at
from astropy.time import Time
import astropy.units as u
from astropy.visualization.units import quantity_support
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
import pymc3 as pm
import exoplanet.units as xu
import thejoker as tj
# set up ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Changing one or a few priors from the default prior
Step2: Let's now plot the period samples to make sure they look Gaussian
Step3: Indeed, it... |
8,970 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import tensorflow as tf
import numpy as np
# Let's use the seaborn library to easily get some data and plot it
import seaborn as sns
sns.set()
# Load 'tips' dataset, only plot 'total_bill', and 'tip' and features (there's a bunch more features in this dataset)
tips = sn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Clearly there's a linear relationship between the amount of top and the total bill. Let's try to find the trend line here using linear regressio... |
8,971 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# execute dummy code here
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
iris = datasets.load_iris()
RFclf = RandomForestClassifier().fit(iris.data, iris.target)
type(iris)
iris.keys... | <SYSTEM_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... |
8,972 | <ASSISTANT_TASK:>
Python Code:
from lingpy import *
seq1, seq2, seq3, seq4, seq5 = "th o x t a", "thoxta", "apfəl", "tʰoxtɐ", "dɔːtər"
print(seq1, "\t->\t", '\t'.join(ipa2tokens(seq1)))
print(seq2, " \t->\t", '\t'.join(ipa2tokens(seq2)))
print(seq2, " \t->\t", '\t'.join(ipa2tokens(seq2, semi_diacritics="h")))
print(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: You can see from these examples, that LingPy's ipa2tokens function automatically identifies diacritics and the like, but that you can also tweak... |
8,973 | <ASSISTANT_TASK:>
Python Code:
import essentia.streaming as ess
import essentia
audio_file = '../../../test/audio/recorded/dubstep.flac'
# Initialize algorithms we will use.
loader = ess.MonoLoader(filename=audio_file)
framecutter = ess.FrameCutter(frameSize=4096, hopSize=2048, silentFrames='noise')
windowing = ess.Win... | <SYSTEM_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 audio we have just analyzed
Step2: Let's plot the resulting HPCP
Step3: Here we have plotted a 12-bin HPCPgram with default parameters and... |
8,974 | <ASSISTANT_TASK:>
Python Code:
#example
example_data_do_not_use = [4,3,6,3]
print(sum(example_data_do_not_use))
data=[13,13,11,11,12,10,14,14,8,11,14,10,16,11,11,15,12,13,12,11,13,12,14,10,9,12,13,14,14,10,15,13,12,12,13,10,12,10,13,13,14,8,14,11,9,13,10,11,9,9,15,12,14,10,16,14,9,10,12,13,8,11,16,13,10,10,13,10,11,11... | <SYSTEM_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
Step2: Problem 1
Step3: Problem 2
Step4: Problem 3
|
8,975 | <ASSISTANT_TASK:>
Python Code:
import math
import matplotlib.pyplot as plt
import numpy as np
import scipy
import scipy.stats
TRUE_MEAN = 40
TRUE_STD = 10
X = numpy.random.normal(TRUE_MEAN, TRUE_STD, 1000)
def normal_mu_MLE(X):
# Get the number of observations
T = len(data)
# Sum the observations
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: Normal Distribution
Step2: Now we'll define functions that given our data, will compute the MLE for the $\mu$ and $\sigma$ parameters of the no... |
8,976 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt, numpy as np
import dismod_mr
models = {}
#iter=101; burn=0; thin=1 # use these settings to run faster
iter=10_000; burn=5_000; thin=5 # use these settings to make sure MCMC converges
model = dismod_mr.load('pd_sim_data/')
model.keep(areas=['GBR'], sexes... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Consistent fit with all data
Step2: Consistent fit without incidence
Step3: Consistent fit without incidence or mortality
Step4: Consistent f... |
8,977 | <ASSISTANT_TASK:>
Python Code:
data = np.random.rand(3)
fig = plt.figure(animation_duration=1000)
pie = plt.pie(data, display_labels="outside", labels=list(string.ascii_uppercase))
fig
n = np.random.randint(1, 10)
pie.sizes = np.random.rand(n)
with pie.hold_sync():
pie.display_values = True
pie.values_format ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Update Data
Step2: Display Values
Step3: Enable sort
Step4: Set different styles for selected slices
Step5: For more on piechart interaction... |
8,978 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-2', 'seaice')
# 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: 2... |
8,979 | <ASSISTANT_TASK:>
Python Code:
## don't forget to
import numpy as np
## Q10 code
def change(item):
item = 100
print("before", list1)
change(list1[0])
print("after", list1)
## Q11 code
def change_first(collection):
collection[0] = 100
print("before", list1)
change_first(list1)
print("after", list1)
## Q12 cod... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 4b. Repeat Question 2a and 2b for a NumPy array
Step2: 10b. Now run the code, did the contents of list1 change?
Step3: 11b. Now run the code, ... |
8,980 | <ASSISTANT_TASK:>
Python Code:
!conda install -c conda-forge google-cloud-bigquery google-cloud-bigquery-storage pyarrow pandas numpy matplotlib bokeh -y
!gradle -p ../../timeseries-java-applications forex_example --args='--resampleSec=5 --windowSec=60 --runner=DataflowRunner --workerMachineType=n1-standard-4 --projec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using the new Apache Beam time series java framework in Java to compute metrics at scale in GCP Dataflow
Step4: --resampleSec and --windowSec p... |
8,981 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
pd.options.display.max_rows = 8
import datetime
dt = datetime.datetime(year=2016, month=12, day=19, hour=13, minute=30)
dt
print(dt) # .day,...
print(dt.strftime("%d %B %Y"))
ts = pd.Timestamp('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: Introduction
Step2: Dates and times in pandas
Step3: Like with datetime.datetime objects, there are several useful attributes available on the... |
8,982 | <ASSISTANT_TASK:>
Python Code:
#Import libraries
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import time
import csv
import sys
# Create a streamer object
class StdOutListener(StreamListener):
# Define a function that is initialized when the miner is ca... | <SYSTEM_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 Twitter Stream Miner
Step2: Create A Wrapper For The Miner
Step3: Run The Stream Miner
|
8,983 | <ASSISTANT_TASK:>
Python Code:
# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
import mne
from mne.datasets import sample
from mne.minimum_norm import read_inverse_operator
from mne.viz import set_3d_view
print(__doc__)
data_path = sample.data_path()
subjects_dir = data_path / 'subj... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Show the 3D source space
|
8,984 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cas', 'sandbox-2', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,985 | <ASSISTANT_TASK:>
Python Code:
#read data using pandas
import pandas as pd
import numpy as np
boston_df = pd.read_csv('boston.csv')
#verify whether ther exisits NaN
print np.sum(boston_df.isnull())
boston_df
boston_df.describe()
#get names
x_var_names = list(boston_df)[:-1]
print x_var_names
y_var_names = list(boston... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ejercicio 1
|
8,986 | <ASSISTANT_TASK:>
Python Code:
from phievo.Networks import mutation,deriv2
import random
g = random.Random(20160225) # This define a new random number generator
L = mutation.Mutable_Network(g) # Create an empty network
parameters=[['Degradable',0.5]] ## The species is degradable with a rate 0.5
parameters.append(['In... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create an empty network
Step2: Create a new species S0
Step3: Adding a gene
Step4: ### Add complexation between S0 and S1.
Step5: Add a pho... |
8,987 | <ASSISTANT_TASK:>
Python Code:
import numpy
import os
import pydot
import graphviz
seed = 7
numpy.random.seed(seed)
dataset = numpy.genfromtxt('dataset.csv', delimiter=',', skip_header=1)
X = dataset[:,0:31]
Y = dataset[:,31]
mask = ~numpy.any(numpy.isnan(X), axis=1)
X = X[mask]
Y = Y[mask]
from keras.models import... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fix seed for reproducibility
Step2: Load dataset
Step3: Split dataset into two variables, X for datas and Y for labels
Step4: Create model
St... |
8,988 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv('LAB_3_large_data_set_cleaned.csv')
ax = sns.violinplot(data=df, palette="pastel")
plt.show()
fig = ax.get_figure()
fig.savefig('sns_violin_plot.png', dpi=300)
import pandas 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: Read in the data
Step2: Make the violin plot
Step3: Save the figure
Step4: The whole script
|
8,989 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pylab as plt
import seaborn as sns
np.set_printoptions(precision=4, suppress=True)
sns.set_context('notebook')
%matplotlib inline
# True parameter
theta = .5
# Sample size
n = int(1e2)
# Independent variable, N(0,1)
X = np.random.normal(0, 1, n)
# Err... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate data
Step2: Plot the data and the model
Step3: Maximize log-likelihood
Step4: Plot objective function, true parameter, and the estim... |
8,990 | <ASSISTANT_TASK:>
Python Code:
# Učitaj osnovne biblioteke...
import numpy as np
import sklearn
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
%pylab inline
X = np.array([[0],[1],[2],[4]])
y = np.array([4,1,2,5])
X1 = X
y1 = y
from sklearn.preprocessing import PolynomialFeatures
pol... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Zadatci
Step2: (a)
Step3: (b)
Step4: Radi jasnoće, u nastavku je vektor $\mathbf{x}$ s dodanom dummy jedinicom $x_0=1$ označen kao $\tilde{\m... |
8,991 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import gammainc, gammaincinv
import pandas as pd
import pastas as ps
ps.show_versions()
rain = ps.read.read_knmi('../examples/data/etmgeg_260.txt', variables='RH').series
evap = ps.read.read_knmi('../examples/data/etmg... | <SYSTEM_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 and define functions
Step2: The Gamma response function requires 3 input arguments; A, n and a. The values for these parameters are d... |
8,992 | <ASSISTANT_TASK:>
Python Code:
# you would normaly install eppy by doing #
# python setup.py install
# or
# pip install eppy
# or
# easy_install eppy
# if you have not done so, uncomment the following three lines
import sys
# pathnameto_eppy = 'c:/eppy'
pathnameto_eppy = '../'
sys.path.append(pathnameto_eppy)
from ep... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: When things go wrong in your eppy script, you get "Errors and Exceptions".
Step2: Now let us open file fname1 without setting the idd file
Ste... |
8,993 | <ASSISTANT_TASK:>
Python Code:
# Serialising.
with open(path, 'wb') as proto_file:
proto_file.write(proto.SerializeToString())
# Deserialising. (from acton.proto.io)
proto = Proto()
with open(path, 'rb') as proto_file:
proto.ParseFromString(proto_file.read())
for proto in protos:
proto = proto.SerializeToS... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To serialise multiple protobufs into one file, we serialise each to a string, write the length of this string to a file, then write the string t... |
8,994 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
matplotlib.style.use('ggplot')
%matplotlib inline
np.__version__
data = pd.read_csv('data.csv')
data.shape
X = data.drop('Grant.Status', 1)
y = data['Grant.Status']
data.head()
numeric_cols =... | <SYSTEM_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: Выделим из датасета целевую переменную Grant.Status и обозначим её за y
Step3: Теория по логистической регрессии
Step... |
8,995 | <ASSISTANT_TASK:>
Python Code:
# Comentário de uma linha
# Função:
print('Hello World!')
help(print)
3 + 3
# Operações básicas:
print('Soma: ', '3 + 3 = ', 3 + 3)
print('Subtração: ', '3 - 3 = ', 3 - 3)
print('Multiplicação: ', '3 * 3 = ', 3 * 3)
print('Divisão: ', '3 / 3 = ', 3 / 3)
print('\n', '-'*30, '\n')
print('Q... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Outra possibilidade é escrever a função com um sinal de interrogação ao final
Step2: 4. Tipos de dados
Step3: 5. Atribuindo valores a objetos
... |
8,996 | <ASSISTANT_TASK:>
Python Code:
# Testando se a biblioteca está instalada corretamente e consegue ser importada
import pandas as pd
# Carregue o arquivo 'datasets/boston.csv' usando o pandas
boston_housing_data = pd.read_csv('../datasets/boston.csv')
# Use o método head() para exibir as primeiras cinco linhas do datas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Neste exercício, usaremos o dataset [Boston Housinh]((http
Step2: Pandas permite a leitura de nossos dados a partir de diferentes formatos. Vej... |
8,997 | <ASSISTANT_TASK:>
Python Code:
import re
str_pat = re.compile(r"\"(.*)\"")
text1 = 'Computer says "no."'
str_pat.findall(text1)
text2 = 'Computer says "no." Phone says "yes."'
str_pat.findall(text2)
str_pat = re.compile(r"\"(.*?)\"")
str_pat.findall(text2)
<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: 在这个例子中,模式 r'\"(.*)\"' 的意图是匹配被双引号包含的文本。 但是在正则表达式中 * 操作符是贪婪的,因此匹配操作会查找最长的可能匹配。 于是在第二个例子中搜索 text2 的时候返回结果并不是我们想要的。
|
8,998 | <ASSISTANT_TASK:>
Python Code:
import graphviz as gv
class CodingTree:
sNodeCount = 0
def __init__(self):
CodingTree.sNodeCount += 1
self.mID = CodingTree.sNodeCount
def count(self):
"compute the number of characters"
pass
def cost(self):
"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This notebook presents <em style="color
Step2: The function make_string is a helper function that is used to simplify the implementation of __s... |
8,999 | <ASSISTANT_TASK:>
Python Code:
config_params.py -m peakfilter
config_params.py -m peakfilter -p my_parameters.json
from LipidFinder.Configuration.LFParametersGUI import LFParametersGUI
LFParametersGUI(module='amalgamator');
run_peakfilter.py -i tests/XCMS/negative.csv -o results -p tests/XCMS/params_peakfilter_negat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Additionally, if you already have a parameters JSON file, you can load its values instead of LipidFinder's defaults (see example below). Once la... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.