Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k โ | cleaned_prompt stringlengths 168 30.3k โ |
|---|---|---|
6,500 | <ASSISTANT_TASK:>
Python Code:
import sys
try:
import docplex.cp
except:
if hasattr(sys, 'real_prefix'):
#we are in a virtual env.
!pip install docplex
else:
!pip install --user docplex
from docplex.cp.model import CpoModel
from sys import stdout
NB_QUEEN = 8
mdl = CpoModel(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: Note that the more global package <i>docplex</i> contains another subpackage <i>docplex.mp</i> that is dedicated to Mathematical Programming, an... |
6,501 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
6,502 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
with open('sounds/wavToTag.txt') as f:
labels = array([l.replace('\n', '') for l in f.readlines()])
print set(labels)
import librosa
mfccs = {}
for i in range(len(labels)):
y, sr = librosa.load('sounds/{}.wav'.format(i))
mfcc = librosa.feature.mfcc(y, sr, n... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Precompute all MFCCs
Step2: Leave P Out Cross Validation
Step3: The next plot may take a while to compute!
|
6,503 | <ASSISTANT_TASK:>
Python Code:
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
plt.imshow(mnist.train.images[..].reshape([.., ..]), cmap=plt.get_cmap('gray_r'))
mnist.train.labels[..]
x_image = ...
x_image
print(x_image.get_shape())
print(con... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: mnist.train.images์๋ ํ๋ จ์ฉ ์ด๋ฏธ์ง ๋ฐ์ดํฐ๊ฐ ์๊ณ mnist.test.images์๋ ํ
์คํธ์ฉ ์ด๋ฏธ์ง ๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค. ์ด ๋ฐ์ดํฐ์ ํฌ๊ธฐ๋ฅผ ํ์ธํด ๋ณด์ธ์.
Step2: mnist.train.labels์๋ ์ ๋ต๊ฐ y ๊ฐ ๋ค์ด ์์ต๋๋ค. ์... |
6,504 | <ASSISTANT_TASK:>
Python Code:
def doubler(input_number):
return input_number*2
doubler(45)
temp_fn = lambda arg : arg*2
temp_fn(55)
type(temp_fn)
l1 = [1,2,3,4,5,6,7]
#to double elements in this list using list comp
l1_double = [i*2 for i in l1]
l1_double
#double using map and a function
l1_double_2 = list(map(do... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: It looks silly now, but lambdas work great with map and other productivity functions. You can have other methods and functions that do the heavy... |
6,505 | <ASSISTANT_TASK:>
Python Code:
%tensorflow_version 1.x
!curl -Lo deepchem_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import deepchem_installer
%time deepchem_installer.install(version='2.3.0')
import deepchem as dc
import numpy as np
import matplotlib.pyplot as plo... | <SYSTEM_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 use the SAMPL dataset from the MoleculeNet suite to run our experiments in this tutorial. Let's load up our dataset for our experiments, a... |
6,506 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
# Load PyMT model(s)
import pymt.models
ec = pymt.models.ECSimpleSnow()
#Call setup to get default config and data files.
defaults = ec.setup('.')
print(defaults)
cfg_filename = defaults[0]
%cat $cfg_... | <SYSTEM_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 example configuration and inputs
Step2: initialize by using default example data
Step3: Implement the simple snow model for the first yea... |
6,507 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
import itertools
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
#from pyodesys.native.gsl import NativeGSLSys as SymbolicSys
from pyodesys.native.cvode import NativeCvodeSys as SymbolicSys
sp.init_printing()
%matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note that we imported NativeCvodeSys as SymbolicSys, this speed up the time of integration by more than an order of magnitude due to using compi... |
6,508 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
# mathematical routines are expecting 'array'
x = array([-10, -9, -8, -7, -6, -5, -4, -3, 0]);
y = array([2.65, 2.10, 1.90, 1.40, 1.00, 0.80, 0.60, 0.30, 0.00]);
ey = array([0.1, 0.1, 0.1, 0.1, 0.05, 0.05, 0.05, 0.05, 0.2]);
# Plot the data with error bars
errorbar(x,y,ey,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fitting function to the data
Step2: Here are the initial guesses for the parameters $a$, $b$, and $c$ to pass to the fitting function.
Step3: ... |
6,509 | <ASSISTANT_TASK:>
Python Code:
# from __future__ import exam_success
from __future__ import absolute_import
from __future__ import print_function
%matplotlib inline
import sklearn
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import random
import pandas as pd
import scipy.stats as stats
# Sk ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 13.765.202 lines in train.csv
Step2: Per wikipedia, a value of more than 421 mm/h is considered "Extreme/large hail"
Step3: Quick analysis f... |
6,510 | <ASSISTANT_TASK:>
Python Code:
from scipy.stats import binom
# Binomial probability mass function
yvals = range(10+1)
plt.plot(yvals, binom.pmf(yvals, 10, 0.5), 'ro')
# Binomial likelhood function
pvals = np.linspace(0, 1)
y = 4
plt.plot(pvals, binom.pmf(y, 10, pvals));
cancer = pd.read_csv('../data/cancer.csv')
cance... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bayesian Computation
Step2: If we use a simple binomial model, which assumes independent samples from a binomial distribution with probability ... |
6,511 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Black Scholes
Step2: Black Scholes pricing and implied volatility usage
Step3: We now show how to invert the Black Scholes pricing model in or... |
6,512 | <ASSISTANT_TASK:>
Python Code:
%%bash
sudo pip freeze | grep google-cloud-bigquery==1.6.1 || \
sudo pip install google-cloud-bigquery==1.6.1
%%bigquery
-- LIMIT 0 is a free query; this allows us to check that the table exists.
SELECT * FROM babyweight.babyweight_data_train
LIMIT 0
%%bigquery
-- LIMIT 0 is a free query... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Verify tables exist
Step2: Model 1
Step3: Create two SQL statements to evaluate the model.
Step4: Model 2
Step5: Let's now retrieve the trai... |
6,513 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
%matplotlib notebook
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
from matplotlib.colors import LogNorm
from copy import copy
import skbeam
from skbeam.core.image import find_ring_center_acorr_1D
from skbeam.core.utils import bin_1D, radial_grid,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Define some helpful functions
Step2: Setup data for Si standard sample
Step3: Setup data for LaB6 calibration standard
Step4: Calibrate Si da... |
6,514 | <ASSISTANT_TASK:>
Python Code:
# First, the imports
import os
import datetime as dt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display
np.random.seed(19760812)
%matplotlib inline
# read file 'mast.txt'
ipath = os.path.join('Datos', 'mast.txt')
def dateparse(date,... | <SYSTEM_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 read a file of wind data
Step2: We read a second file of simulated environmental data
Step3: We have data with a time frequency of 10 minut... |
6,515 | <ASSISTANT_TASK:>
Python Code:
def black_box_function(x, y):
Function with unknown internals we wish to maximize.
This is just serving as an example, for all intents and
purposes think of the internals of this function, i.e.: the process
which generates its output values, as unknown.
return -x ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic tour of the Bayesian Optimization package
Step2: 2. Getting Started
Step3: The BayesianOptimization object will work out of the box with... |
6,516 | <ASSISTANT_TASK:>
Python Code:
import time
import numpy as np
import tensorflow as tf
import utils
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import zipfile
dataset_folder_path = 'data'
dataset_filename = 'text8.zip'
dataset_name = 'Text8 Dataset'
class DLProgress(tq... | <SYSTEM_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 text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ... |
6,517 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ์ฌ์ ์ ์ Estimator
Step2: ๋ฐ์ดํฐ์ธํธ
Step3: ๊ทธ ๋ค์, Keras ๋ฐ Pandas๋ฅผ ์ฌ์ฉํ์ฌ Iris ๋ฐ์ดํฐ์ธํธ๋ฅผ ๋ค์ด๋ก๋ํ๊ณ ๊ตฌ๋ฌธ ๋ถ์ํฉ๋๋ค. ํ๋ จ ๋ฐ ํ
์คํธ๋ฅผ ์ํด ๋ณ๋์ ๋ฐ์ดํฐ์ธํธ๋ฅผ ์ ์งํฉ๋๋ค.
Step4: ๋ฐ์ดํฐ๋ฅผ ๊ฒ์ฌํ์ฌ ๋ค... |
6,518 | <ASSISTANT_TASK:>
Python Code:
import time
from collections import namedtuple
import numpy as np
import tensorflow as tf
with open('anna.txt', 'r') as f:
text=f.read()
vocab = set(text)
vocab_to_int = {c: i for i, c in enumerate(vocab)}
int_to_vocab = dict(enumerate(vocab))
chars = np.array([vocab_to_int[c] for c ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First we'll load the text file and convert it into integers for our network to use.
Step3: Now I need to split up the data into batches, and in... |
6,519 | <ASSISTANT_TASK:>
Python Code:
from dolfin import *
from rbnics import *
class UnsteadyThermalBlock(ParabolicCoerciveProblem):
# Default initialization of members
def __init__(self, V, **kwargs):
# Call the standard initialization
ParabolicCoerciveProblem.__init__(self, V, **kwargs)
# .... | <SYSTEM_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 P1, two components)
Step4: 4.3. Allocate an ... |
6,520 | <ASSISTANT_TASK:>
Python Code:
from tensorflow.keras import layers
import tensorflow_addons as tfa
from tensorflow import keras
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
import random
# Setting seeds for reproducibility.
SEED = 42
keras.utils.set_random_seed(SEED)
# DATA
BUFFER_SIZE = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Hyperparameters for pretraining
Step2: Load and prepare the CIFAR-10 dataset
Step3: Data augmentation
Step4: A layer for extracting patches f... |
6,521 | <ASSISTANT_TASK:>
Python Code:
import cashflows as cf
0.2 / (1 - 0.2)
0.36 / (1 + 0.36)
cf.iconv(nrate = 6.72, pyr = 2) ## Banco 1
cf.iconv(nrate = 6.70, pyr = 4) ##ย Banco 2 -- mejor opciรณn
cf.iconv(nrate = 6.65, pyr = 12) ##ย Banco 3
## Otra forma
cf.iconv(nrate = [6.72, 6.79, 6.65], pyr = [2, 4, 12])
erate, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Conversiรณn de tasas de interรฉs
Step2: Ejemplo.-- Si se desea obtener una tasa efectiva anual del 36%, ยฟcuรกnto se deberรก cobrar en forma anticip... |
6,522 | <ASSISTANT_TASK:>
Python Code:
# Load our 3 images using rasterio
import rasterio
img1 = rasterio.open('data/20170721_175836_103c/20170721_175836_103c_3B_Visual.tif')
img2 = rasterio.open('data/20170721_175837_103c/20170721_175837_103c_3B_Visual.tif')
img3 = rasterio.open('data/20170721_175838_103c/20170721_175838_103c... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step 1. Aquiring Imagery
Step 2. Inspecting Imagery
Step1: At this point we can use rasterio to inspect the metadata of these three images. Specificall... |
6,523 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import expon
from numpy import arange
import scipy.stats as stats
#Abrir o arquivo
df = pd.read_csv('earthquake.csv')
#listar colunas
print(list(df))
df.head()
df.loc[(df.Latitude ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Liste as primeiras linhas do DataFrame
Step2: Q1 - Manipulando o DataFrame
Step3: Q2 - Fit e Histograma
Step4: Faรงa o fit de uma distribuiรงรฃo... |
6,524 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo(id="BYOK12I9vgI", width="100%")
from nams import load_data as cf
G = cf.load_crime_network()
for n, d in G.nodes(data=True):
G.nodes[n]["degree"] = G.degree(n)
import nxviz as nv
import matplotlib.pyplot as plt
fig, ax = plt.subp... | <SYSTEM_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 will look at bipartite graphs and their applications.
Step2: If you inspect the nodes,
Step3: Exercise
Step4: Bipartite G... |
6,525 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from IPython.display import (
display_pretty, display_html, display_jpeg,
display_png, display_json, display_latex, display_svg
)
from IPython.display import Image
i = Image(filename='../images/ipython_logo.png')
i
display(i)
Image(url='htt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A few points
Step2: Images
Step3: Returning an Image object from an expression will automatically display it
Step4: Or you can pass an object... |
6,526 | <ASSISTANT_TASK:>
Python Code:
# Imports
import math
import seaborn
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import cm
from sklearn.neighbors import NearestNeighbors
from sklearn.preprocessing import normalize
# Loading xyz map
correct_map = pd.read_csv('correct_map.xyz', ... | <SYSTEM_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 points and creating the structured grid
Step2: Structured Grid
Step3: Cloud of Points
Step4: Applying KNN
Step5: Calculating the... |
6,527 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
from phoebe import u # units
import numpy as np
logger = phoebe.logger()
print(phoebe.list_available_solvers())
b = phoebe.default_binary()
b.add_dataset('lc', compute_phases=phoebe.linspace(0,1,101))
b.run_compute(irrad_method='none')
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: General "Fitting" Workflow
Step2: Solving an eclipsing binary is a very time-intensive task (both for you as well as your computer). There is ... |
6,528 | <ASSISTANT_TASK:>
Python Code:
from cobra.io import load_model
from cobra.flux_analysis import gapfill
model = load_model("iYS1720")
universal = cobra.Model("universal_reactions")
for i in [i.id for i in model.metabolites.f6p_c.reactions]:
reaction = model.reactions.get_by_id(i)
universal.add_reaction(reaction... | <SYSTEM_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 model D-Fructose-6-phosphate is an essential metabolite. We will remove all the reactions using it, and at them to a separate model.
Ste... |
6,529 | <ASSISTANT_TASK:>
Python Code:
import urllib
import zipfile
import StringIO
import string
import pandas
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import HTML
import json
county_name = ""
start_date = "20140101"
end_date = "20150101"
diag = False
## Retrieve the bounding box of the specif... | <SYSTEM_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 some initial variables
Step2: Options
|
6,530 | <ASSISTANT_TASK:>
Python Code:
def anti_shuffle(s):
return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
6,531 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', '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,532 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
from IPython.display import HTML
HTML('../style/code_toggle.html')
import ephem
import matplotlib
%pylab inline
pylab.rcParams['figure.fi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import section specific modules
Step2: Horizontal Coordinates (ALT/AZ)
Step3: Figure 3.3.3
Step4: Figure 3.3.4
|
6,533 | <ASSISTANT_TASK:>
Python Code:
import open_cp.sources.chicago as chicago
import geopandas as gpd
import sys, os, csv, lzma
filename = os.path.join("..", "..", "open_cp", "sources", "chicago.csv")
filename_all = os.path.join("..", "..", "open_cp", "sources", "chicago_all.csv.xz")
filename_all1 = os.path.join("..", "..",... | <SYSTEM_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 look at the snapshot of the last year, vs the total dataset. The data appears to be the same, though the exact format changes.
Step2: A... |
6,534 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot
# We have this here to trigger matplotlib's font cache stuff.
# This cell is hidden from the output
import pandas as pd
import numpy as np
np.random.seed(24)
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
df = pd.concat([df, pd.DataFrame(np.random.randn(10, 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: Here's a boring example of rendering a DataFrame, without any (visible) styles
Step2: Note
Step4: The row0_col2 is the identifier for that par... |
6,535 | <ASSISTANT_TASK:>
Python Code:
from pypot.creatures import PoppyErgo
ergo = PoppyErgo()
from pypot.creatures import PoppyErgoJr
ergo = PoppyErgoJr()
ergo
ergo.m2
ergo.m2.present_position
ergo.m2.present_temperature
for m in ergo.motors:
print 'Motor "{}" current position = {}'.format(m.name, m.present_position)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For a PoppyErgoJr
Step2: Get robot current status
Step3: Turn on/off the compliancy of a motor
Step4: Go to the zero position
Step5: Make a ... |
6,536 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('seaborn-whitegrid')
# %load _solutions/case2_observations_analysis1.py
# %load _solutions/case2_observations_analysis2.py
# %load _solutions/case2_observations_analysis3.py
# %loa... | <SYSTEM_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. Reading in the enriched observations data
Step2: 2. Tackle missing values (NaN) and duplicate values
Step3: <div class="alert alert-success... |
6,537 | <ASSISTANT_TASK:>
Python Code:
import logging
import random
import time
import matplotlib.pyplot as plt
import mxnet as mx
from mxnet import gluon, nd, autograd
import numpy as np
batch_size = 128
epochs = 5
ctx = mx.gpu() if mx.context.num_gpus() > 0 else mx.cpu()
lr = 0.01
train_dataset = gluon.data.vision.MNIST(tr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parameters
Step2: Data
Step3: We assign the transform to the original dataset
Step4: We load the datasets DataLoaders
Step5: Multi-task Netw... |
6,538 | <ASSISTANT_TASK:>
Python Code:
print("Happy Birthday to you!")
print("Happy Birthday to you!")
print("Happy Birthday, dear Emily.")
print("Happy Birthday to you!")
def happy_birthday_to_emily(): # Function definition
Print a birthday song to Emily.
print("Happy Birthday to you!")
print("Happy Bir... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: This could be the purpose of a function
Step4: If we execute the code above, we don't get any output. That's because we only told Python
Step7:... |
6,539 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import os
import shutil
import tensorflow as tf
from google.cloud import aiplatform
from google.cloud import bigquery
from google.protobuf import json_format
from google.protobuf.struct_pb2 import Value
from matplotlib import pyplot as plt
from tensorflow import keras
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: Re-train our model with trips_last_5min feature
Step2: Next, we create a table called traffic_realtime and set up the schema.
Step3: Launch St... |
6,540 | <ASSISTANT_TASK:>
Python Code:
import rebound
sim = rebound.Simulation()
sim.add(m=1.) # free floating particle
sim.integrator = "leapfrog"
sim.dt = 0.01
import reboundx
rebx = reboundx.Extras(sim)
sto = rebx.load_force("stochastic_forces")
rebx.add_force(sto)
sim.particles[0].params["kappa_x"] = 5.0
sim.particles[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: We will be using the Leap-Frog integrator with a fixed timestep. It's important to point out that the default IAS15 integrator is not well suite... |
6,541 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn.decomposition import PCA
import pandas as pd
from pylab import *
data = pd.read_hdf("swr_modth.h5")
figure()
plot(data)
xlabel("Time lag (ms)")
ylabel("Modulation (z-scored)")
show()
print(data.shape)
n = 6
pca = PCA(n_components = n)
new_data = pca.fit... | <SYSTEM_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 can be loaded with pandas
Step2: It's the responses of theta-modulated thalamic neurons to hippocampal sharp-waves ripples
Step3: T... |
6,542 | <ASSISTANT_TASK:>
Python Code:
# Imports
import numpy as np
import gurobipy as gbp
import datetime as dt
# Constants
Aij = np.random.randint(5, 50, 400)
Aij = Aij.reshape(20,20)
AijSum = np.sum(Aij)
Cj = np.random.randint(10, 20, 20)
CjSum = np.sum(Cj)
Bi = np.random.randint(10, 20, 20)
BiSum = np.sum(Bi)
# Matrix 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: <font size='7' face='Times New Roman'><b>1. <u>Primal</u></b></font>
Step2: <font size='7' face='Times New Roman'><b>2. <u>Dual</u></b></font>
|
6,543 | <ASSISTANT_TASK:>
Python Code:
# determine the specific enthalpies at the principal states of the cycle.
import seuif97 as if97
# State 1 is superheated vapor at 8MPa, 480C.
p1=8
t1=480
h1 = if97.pt2h(p1,t1)
s1 =if97.pt2s(p1,t1)
print(h1,s1)
# State 2 is fixed by p2 =2.0MPa and the specific entropy s2, which is the... | <SYSTEM_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 schematic diagram of the cycle is labeled with the fractions of the total flow into the turbine that remain
Step2: SOLUTION
Step3: (b) The... |
6,544 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'miroc', 'nicam16-9s', '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... |
6,545 | <ASSISTANT_TASK:>
Python Code:
!pip install --user --upgrade pip
!pip install kfp --upgrade --user --quiet
# confirm the kfp sdk
! pip show kfp
import kfp
import kfp.components as comp
import kfp.dsl as dsl
from kfp.components import InputPath, OutputPath
from typing import NamedTuple
# download data step
def downloa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import kubeflow pipeline libraries
Step2: Kubeflow pipeline component creation
Step3: Component 2
Step4: Component 3
Step5: Component 4
Step... |
6,546 | <ASSISTANT_TASK:>
Python Code:
# ๅบ็กๅบๅฏผๅ
ฅ
from __future__ import print_function
from __future__ import division
import warnings
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import os
import sys
# ไฝฟ็จinsert 0ๅณๅชไฝฟ็จgi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ๅฐ็ฎๅไธบๆญขๅทฒ็ป็คบไพไบๅพๅคไนฐๅ
ฅๅ ๅญ๏ผabupyไธญไธไธช็น็นๅณๆฏๅฏไปฅๅจไบคๆไธญไฝฟ็จๅคไธชไนฐๅ
ฅ๏ผๅๅบๅ ๅญๅนถ่กๆง่ก็ๆใ
Step4: ๆๅปบๅฎ็ญ็ฅๅ๏ผไธ้ขไฝฟ็จๆฒ็ๆฐๆฎ็พ่กๆฐๆฎ๏ผ็คบไพๅนถ่กๆง่กไธ่ฟฐ็ญ็ฅ่ฟ่กๅๆต๏ผๅฆไธ๏ผ
Step5: ไธ้ขๅฏ่งๅๅไธชไนฐๅ
ฅๅ ๅญ็็ๆๆฐ้ไปฅๅๆฏไพ๏ผๅฆไธ๏ผ
Step6: ไธ้ข... |
6,547 | <ASSISTANT_TASK:>
Python Code:
%%bash
export PROJECT=$(gcloud config list project --format "value(core.project)")
echo "Your current GCP Project Name is: "$PROJECT
import os, json, math
import numpy as np
import shutil
import tensorflow as tf
print("TensorFlow version: ",tf.version.VERSION)
PROJECT = "your-gcp-project-... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Locating the CSV files
Step2: Use tf.data to read the CSV files
Step3: Next, let's define our features we want to use and our label(s) and the... |
6,548 | <ASSISTANT_TASK:>
Python Code:
import vcsn
vcsn.B.trie('''foo
bar
baz''')
%%file words
hello
world
hell
word
vcsn.B.trie(filename='words')
vcsn.Q.trie('''
one
<2>two
<3>three
<13>thirteen
<30>thirty
<51>thirsty''')
vcsn.context('lat<law_char, law_char>, q').trie('''
<1>one|un
<2>two|deux
<3>three|trois
<4>four|quatre... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Weighted words (finite series)
Step2: Tuples of words
|
6,549 | <ASSISTANT_TASK:>
Python Code:
# Load regex package
import re
# Create a variable containing a text string
text = '3829 South Ave Street, Pheonix, AZ 34923'
# Find any ISBN-10 or ISBN-13 number
re.findall(r'[0-9]{5}(?:-[0-9]{4})?', 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,550 | <ASSISTANT_TASK:>
Python Code:
from collections import namedtuple
import copy
import json
import os
import pathlib
import shutil
import subprocess
import tempfile
import ipyleaflet as ipyl
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import rasterio
from shapely.geometry import shape, mapping
%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: Datasets
Step2: Test Scene
Step3: AOI and Ground Truth
Step5: Crop Ground Truth Data to AOI
Step6: Train Ground Truth Data
Step7: Test Grou... |
6,551 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
from pypvcell.solarcell import SQCell,MJCell,TransparentCell
from pypvcell.illumination import Illumination
from pypvcell.spectrum import Spectrum
from py... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the data into a NEDOLocation object
Step2: main_df adds the column names into the raw data and convert it to a pandas.DataFrame object
Ste... |
6,552 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
y = np.array([1,2,3])
x = np.array([2,3,4])
y + x
y-x
y/x
np.dot(y,x)
x * y
a = np.array([[1,2,3],[4,5,6]])
b = np.array([[1,2,3]])
a + 1
a = np.array([[1,2],[3,4]])
b = np.array([[3,4],[5,6]])
a + b
b-a
a*b
def get_derivative(func, x):
Compute the derivativ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1.1.1 Elementwise Operations
Step2: 1.1.2 Dot productions
Step3: 1.1.3 Hadamard product
Step4: 2. Matrices
Step5: 2.1 Scalar Operations
Ste... |
6,553 | <ASSISTANT_TASK:>
Python Code:
# DON'T FORGET TO RUN THIS CELL
import math
import numpy as np
import pandas as pd
import seaborn as sns
import datascience as ds
import matplotlib.pyplot as plt
sns.set_style('darkgrid')
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
timit = pd.read_csv('data/timit... | <SYSTEM_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 TIMIT Data <a id='timit'></a>
Step2: Look at the dataframe you created and try to figure out what each column measures. Each column r... |
6,554 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import os
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import nba_py
sns.set_context('poster')
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)
data_path = os.path.join(os.getcwd(), os.pardir, ... | <SYSTEM_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 NBA season starts at the end of October. I got my fitbit near the beginning of November, so there is a lot of overlap.
|
6,555 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-3', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
6,556 | <ASSISTANT_TASK:>
Python Code:
hymns = {}
for line in open('dimeter-mp.csv', 'r'):
comps = line.strip().split(',')
line, pada, meter = comps[0:3]
mps = comps[3:]
hymn_id = '-'.join(line.split('.')[:2])
if hymn_id not in hymns:
hymns[hymn_id] = []
hymns[hymn_id].append(mps)
print(len(hym... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How many hymns do we have in total?
Step2: How are their lengths distributed?
Step3: Most seem to have around 25 lines, consisting of 8 MPs (m... |
6,557 | <ASSISTANT_TASK:>
Python Code:
FIX =
def vowels_count(s):
Write a function vowels_count w vowels = "aeiouAEIOU"
n_vowels = sum(c in vowels for c in s)
if s[-1] == 'y' or s[-1] == 'Y':
n_vowels += 1
return n_vowels
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
6,558 | <ASSISTANT_TASK:>
Python Code:
pd.read_csv("data/demographie/pop_age_sexe_2016.csv").head()
pd.read_csv("data/travail/activite_2015.csv")
pd.read_csv("data/travail/chomage.csv")
pd.read_csv("data/travail/retraite_2012.csv")
pd.read_csv("data/demographie/etudes.csv")
pd.read_csv("data/demographie/handicap_pop.csv"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Les tables concernant le statut d'actif.ve
Step2: Les tables concernant le statut d'actif.ve occupรฉe
Step3: Tables concernant les pensions de ... |
6,559 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
alpha0 = 60.0 # fault dip at surface, degrees
z0 = 0.0 # elevation of surface trace
h = 10.0 # detachment depth, km
G0 = np.tan(np.deg2rad(60.0))
x = np.arange(0, 41.0)
z = z0 - h * (1.0 - np.exp(-x * G0 / h))
plt.plot(x, z, 'k')
plt.xlab... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Describing subsidence due to fault motion
Step2: Numerical implementation
Step3: Example 2
Step4: Example 3
Step5: Example 4
Step6: Example... |
6,560 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
%%bash
pip freeze | grep google-cloud-bigquery==1.6.1 || \
pip install google-cloud-bigquery==1.6.1
%%bigquery
-- LIMIT 0 is a free query; this allows us to check that the table exists.
SELECT * FROM babyweight.babyweight... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Verify tables exist
Step2: Lab Task #1
Step3: Get training information and evaluate
Step4: Now let's evaluate our trained model on our eval d... |
6,561 | <ASSISTANT_TASK:>
Python Code:
import pandas
import numpy
import toyplot
import toyplot.pdf
import toyplot.png
import toyplot.svg
print('Pandas version: ', pandas.__version__)
print('Numpy version: ', numpy.__version__)
print('Toyplot version: ', toyplot.__version__)
column_names = ['MPG',
'Cylinder... | <SYSTEM_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 the "auto" dataset. This is a fun collection of data on cars manufactured between 1970 and 1982. The source for this data can be found a... |
6,562 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import HTML
css_file = 'https://raw.githubusercontent.com/ngcm/training-public/master/ipython_notebook_styles/ngcmstyle.css'
HTML(url=css_file)
%matplotlib inline
import math
import numpy
from matplotlib import pyplot, animation
from matplotlib import rcParams
r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Flocking behaviour
Step2: Define a class called Agent. This should store the 2-dimensional ${\bf z} = (x, y)$ location of the individual, and i... |
6,563 | <ASSISTANT_TASK:>
Python Code:
from jax import grad, jit, vmap
import jax.numpy as np
import numpy as np2
#2D coordinates of locations of demand or supply
x_n = np.array([[-0.97,-80.7],
[-1.05, -80.45],
[-2.15, -79.92],
[-1.81, -79.53],
[-1.03, -79.47]])
#Qua... | <SYSTEM_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 mus define the function which we want to minimize
Step2: With the defined function we can calculate the gradient with JAX
Step3: Now le... |
6,564 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
from time import time
import re
import pickle
sys.path.append("ud120-projects/tools/")
sys.path.append("ud120-projects/final_project/")
#sys.path.append("ud120-projects/maildir/")
import numpy as np
import pandas as pd
#from matplotlib import pyplot as plt
#import sea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: sklearn imports
Step2: load data
Step3: original classifier
Step4: data-record snapshot
Step5: feature selection
Step6: data-format convers... |
6,565 | <ASSISTANT_TASK:>
Python Code:
import os
import re
import sys
import numpy as np
from eva_cttv_pipeline.clinvar_xml_utils import *
from eva_cttv_pipeline.clinvar_identifier_parsing import *
%matplotlib inline
import matplotlib.pyplot as plt
PROJECT_ROOT = '/home/april/projects/opentargets/complex-events'
# dump of 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:
Step2: Detailed stats of HGVS in ClinVar
Step3: Sequence types
Step4: Variant types
Step5: Ranges
Step7: Span lengths
Step8: Intronic numbering
|
6,566 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'sandbox-3', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributo... | <SYSTEM_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,567 | <ASSISTANT_TASK:>
Python Code:
# This whole business is totally unnecessary if you're path is setup right. But if it's not,
# this is probably easier than actually fixing it.
%load_ext autoreload
import os
wireshark_path = "C:\\Program Files\\Wireshark\\" + os.pathsep
# or, if it's under 'program files(x86)'...
# wir... | <SYSTEM_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 have a look at the file
Step2: Plotting
Step3: Set a figure size in inches
Step5: Pandas automatically uses Matplotlib for plotting. We... |
6,568 | <ASSISTANT_TASK:>
Python Code:
from typing import List
def intersperse(numbers: List[int], delimeter: int) -> List[int]:
if not numbers:
return []
result = []
for n in numbers[:-1]:
result.append(n)
result.append(delimeter)
result.append(numbers[-1])
return result
<END_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:
|
6,569 | <ASSISTANT_TASK:>
Python Code:
import geopy
from geopy.geocoders import Nominatim
geocoder = Nominatim()
adresse = "22 rue Saint Lo, Rouen, France"
location = geocoder.geocode(adresse, True, 30)
print("longitude = ",location.longitude,"latitude = ",location.latitude)
import geopy
from geopy.geocoders import Nominatim
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Localisation d' adresse quelconque.
Step2: Saisie des rรฉsultats dans un fichier csv
Step3: Saisie des rรฉsultats dans un fichier csv
Step5: ... |
6,570 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib
import sys
print(f'Python version {sys.version}')
print(f'Matplotlib version {matplotlib.__version__}')
print(f'NumPy version {np.__version__}')
x = np.arange(0,8*np.pi,0.1)
y1 = np.sin(x)
y2 = np.ex... | <SYSTEM_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 versions of Python, NumPy, and Matplotlib can be printed out using the following code
Step2: Data
Step3: Plot the two functions
Step4: Ab... |
6,571 | <ASSISTANT_TASK:>
Python Code:
# instantiate 2 exceptions
exc1 = Exception()
exc2 = Exception('Hier lief was schief.')
print('Type: ',type(exc1),'Str: ', str(exc1))
print('Type: ', type(exc2),'Str: ', str(exc2))
raise exc2
def divide_print(a, b):
if b == 0:
print('b must not be zero, idiot!')
return 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: There is one more key statement in Python that can only be used for Exceptions
Step2: You could use that to raise your own Exceptions in case t... |
6,572 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from utils import *
import random
data = open('dinos.txt', 'r').read()
data= data.lower()
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
print('There are %d total characters and %d unique characters in your data.' % (data_size, vocab_size))
char... | <SYSTEM_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 - Problem Statement
Step2: The characters are a-z (26 characters) plus the "\n" (or newline character), which in this assignment plays a role... |
6,573 | <ASSISTANT_TASK:>
Python Code:
from config import PYMICRO_EXAMPLES_DATA_DIR # import file directory path
import os
dataset_file = os.path.join(PYMICRO_EXAMPLES_DATA_DIR, 'example_microstructure') # test dataset file path
tar_file = os.path.join(PYMICRO_EXAMPLES_DATA_DIR, 'example_microstructure.tar.gz') # dataset archi... | <SYSTEM_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 file is zipped in the package to reduce its size. We will have to unzip it to use it and learn how to reduce its size with the SampleData m... |
6,574 | <ASSISTANT_TASK:>
Python Code:
import sys # system module
import pandas as pd # data package
import matplotlib.pyplot as plt # graphics module
import datetime as dt # date and time module
import numpy as np # foundation for 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 id=want></a>
Step2: Comment. Note that the variable item_price has dtype object. The reason is evidently the dollar sign. We want to have i... |
6,575 | <ASSISTANT_TASK:>
Python Code:
trospection or reflection is the ability of software to identify and report their own internal structures, such as types, variabl# Getting some information
# about global objects in the program
from types import ModuleType
def info(n_obj):
# Create a referรชnce to the object
obj = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Python also has a module called types, which has the definitions of the basic types of the interpreter.
Step2: Through introspection, it is pos... |
6,576 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('data/train.csv')
df.head()
df.tail()
df.shape
df['Fare'].head()
df[['Fare', 'Sex']].head()
df['Sex'].value_counts()
df['Age'].median()
%matplotlib inline
import seaborn
fig = df['Pclass'].hist()
fig = df.hist(figsize=(15,5))
df.head()
mask = df['... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Magic Pandas
Step2: Data at a glance
Step3: Plotting
Step4: Filtering
Step5: Boolean Masks
Step6: Filtering Dataframes
Step7: Memory Issue... |
6,577 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('../python')
from HTKFeat import MFCC_HTK
import numpy as np
%matplotlib inline
import matplotlib.pyplot as P
mfcc=MFCC_HTK()
signal = mfcc.load_raw_signal('../python-test/file.raw')
def draw_signal(signal, fs):
sig_len=signal.size/fs #in seconds
P.figu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here we load the file and display its waveform, spectrorgram and amplitude spectrum.
Step2: Here we also create an HTML5 audio widget to hear h... |
6,578 | <ASSISTANT_TASK:>
Python Code:
kmf = KaplanMeierFitter()
T = df['tenure'] #duration
C = df["b_Churn"] #censorship - 1 if death/churn is seen, 0 if censored
palette = ["windows blue", "amber"]
sns.set_palette(sns.xkcd_palette(palette))
##SET UP PLOT
ax = plt.subplot(111)
plt.title('Kaplan-Meier Estimate of Driver Retent... | <SYSTEM_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 graph clearly shows that there is a difference in tenure between "single line" and "multiple line" telco users. Since the confidence interal... |
6,579 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
X, y, true_coefficient = make_regression(n_samples=200, n_features=30, n_informative=10, noise=100, coef=True, random_state=5)
X_train, X_test, y_train, y_test = train_test_split(X, y, 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: Linear Regression
Step2: Ridge Regression (L2 penalty)
Step3: Tuning alpha is critical for performance.
Step4: Lasso (L1 penalty)
Step5: Ins... |
6,580 | <ASSISTANT_TASK:>
Python Code:
#contributions = pd.read_json(path_or_buf='../data/EGALITE4.brut.json', orient="columns")
def loadContributions(file, withsexe=False):
contributions = pd.read_json(path_or_buf=file, orient="columns")
rows = [];
rindex = [];
for i in range(0, contributions.shape[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: Build clustering model
Step2: Build the optimal model and apply it
Step3: Cluster Profiles
|
6,581 | <ASSISTANT_TASK:>
Python Code:
d = pd.read_csv("data/dataset_0.csv")
fig, ax = plt.subplots()
ax.plot(d.x,d.y,'o')
def linear(x,a,b):
return a + b*x
def linear(x,a,b):
return a + b*x
def linear_r(param,x,y):
return linear(x,param[0],param[1]) - y
def linear_r(param,x,y): # copied from... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: What does the following code do?
Step2: What does the following code do?
Step3: What does the following code do?
Step4: What does the followi... |
6,582 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pickle
%matplotlib inline
# Read in CBECS data
data = pd.DataFrame.from_csv('C:/F16-12-752-master/projects/thongyi_weijian1/data/CBECS.csv')
data.tail()
energydata=pd.DataFrame()
type_B=[2,13,16,26] # office,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Please download the dataset and change the file path.
Step2: In this time, four building types are selected which are office, pubilc assembly, ... |
6,583 | <ASSISTANT_TASK:>
Python Code:
data_path = "data/09/PdNiP_test.hspy"
%matplotlib inline
import pyxem as pxm
import hyperspy.api as hs
pxm.__version__
data = hs.load("./data/09/PdNiP_test.hspy")
data.set_signal_type("electron_diffraction")
data.beam_energy=200
data.unit = "k_nm^-1"
mask =data.get_direct_beam_mask(20)
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a id='s2'></a>
Step2: Note
Step3: <a id='s3'></a>
Step4: <a id='s4'></a>
|
6,584 | <ASSISTANT_TASK:>
Python Code:
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import sys
import os
from datetime import datetime
from tqdm import tqdm
from PIL import Image
import imageio
import warnings
warnings.filterwarnings('ignore', category=FutureWarning)
# ffmpeg installation locatio... | <SYSTEM_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 Network
Step2: Project
Step3: Encode
Step4: Generate Images
Step5: generate some random samples and save to disk
Step6: Projected Late... |
6,585 | <ASSISTANT_TASK:>
Python Code:
from pynq.overlays.base import BaseOverlay
from pynq.lib.video import *
base = BaseOverlay("base.bit")
# monitor configuration: 640*480 @ 60Hz
Mode = VideoMode(640,480,24)
hdmi_out = base.video.hdmi_out
hdmi_out.configure(Mode,PIXEL_BGR)
hdmi_out.start()
# monitor (output) frame buffer 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: Step 2
Step2: Step 3
Step3: Step 4
Step4: Step 5
Step5: Step 6
Step6: Step 7
Step7: Step 8
|
6,586 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import macrodensity as md
import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
extrema = md.vasp_tools.get_band_extrema('OUTCAR_ZnO')
print(extrema)
extrema = md.vasp_tools.get_band_extrema('OUTCAR_ZnS')
print(extrema)
input_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The code below is usually set in the PlanarAverage.py file; you don't need to edit it
Step2: The code below will prompt you to say which axis y... |
6,587 | <ASSISTANT_TASK:>
Python Code:
P = 1.2 # weight current errors more
I = 1
D = 0.0 # ignore future potential errors
L = 50 # number of iterations
pid = PID.PID(P, I, D)
pid.SetPoint=0.0
pid.setSampleTime(0.01)
END = L
feedback = 0
feedback_list = []
time_list = []
setpoint_list = []
for i in range(1, END):
pid.upda... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: how quickly does it converge?
|
6,588 | <ASSISTANT_TASK:>
Python Code:
import graphlab
people = graphlab.SFrame('people_wiki.gl/')
people.head()
len(people)
obama = people[people['name'] == 'Barack Obama']
obama
obama['text']
clooney = people[people['name'] == 'George Clooney']
clooney['text']
obama['word_count'] = graphlab.text_analytics.count_words(ob... | <SYSTEM_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 text data - from wikipedia, pages on people
Step2: Data contains
Step3: Explore the dataset and checkout the text it contains
Step4:... |
6,589 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
%pylab inline
import matplotlib.pyplot as plt
plt.xkcd()
# if this is true, all images are saved to disk
global_print_flag = False
!mkdir tmp_figures
# Choose one of the two following data sets, the larger one gives bet... | <SYSTEM_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 and exploring our data set
Step2: Logistic Regression using the one-vs-rest (OvR) scheme
Step3: Cross Validation splits the train data... |
6,590 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# spatial grid
nx = 41 # try changing from 41 to 81
dx = 2./(nx-1) #dx = delta x
nt = 20
dt = nt/1000. #dt = delta t
c = 1. # wavespeed
u = np.ones(nx)
u[.5/dx : 1./dx+1] = 2
print u
#visually
plt.plot(np.linspace(0, 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: We need to give an initial wave which is a function of $x$ (remember, $u(x,0)=u_0(x)$). We can easily choose a step-function for the velocity
St... |
6,591 | <ASSISTANT_TASK:>
Python Code:
import rebound
import numpy as np
def setupSimulation():
sim = rebound.Simulation()
sim.add(m=1., hash="Sun")
sim.add(x=0.4,vx=5., hash="Mercury")
sim.add(a=0.7, hash="Venus")
sim.add(a=1., hash="Earth")
sim.move_to_com()
return sim
sim = setupSimulation()
sim.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now let's run a simulation for 20 years (in default units where $G=1$, and thus AU, yr/2$\pi$, and $M_\odot$, see Units.ipynb for how to change ... |
6,592 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
from IPython.display import Image
from mpl_toolkits.mplot3d import Axes3D
import track_simulator
from astropy.io import fits
import aplpy... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import section specific modules
Step2: 5.5 The Break Down of the Small Angle Approximation and the W-Term
Step3: Figure
Step4: Figure
Step5: ... |
6,593 | <ASSISTANT_TASK:>
Python Code:
x = [1,2,3]
y = [4,5,6]
# Zip the lists together
zip(x,y)
x = [1,2,3]
y = [4,5,6,7,8]
# Zip the lists together
zip(x,y)
d1 = {'a':1,'b':2}
d2 = {'c':4,'d':5}
zip(d1,d2)
zip(d2,d1.itervalues())
def switcharoo(d1,d2):
dout = {}
for d1key,d2val in zip(d1,d2.itervalues()):
... | <SYSTEM_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 how tuples are returned. What if one iterabel is longer than the other?
Step2: Note how the zip is defined by the shortest iterable length... |
6,594 | <ASSISTANT_TASK:>
Python Code:
%%R
m <- prophet(df, interval.width = 0.95)
forecast <- predict(m, future)
forecast = Prophet(interval_width=0.95).fit(df).predict(future)
%%R
m <- prophet(df, mcmc.samples = 300)
forecast <- predict(m, future)
m = Prophet(mcmc_samples=300)
forecast = m.fit(df).predict(future)
%%R -w 9 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Again, these intervals assume that the future will see the same frequency and magnitude of rate changes as the past. This assumption is probably... |
6,595 | <ASSISTANT_TASK:>
Python Code:
%%bigquery df
WITH rawnumbers AS (
SELECT
departure_delay,
COUNT(1) AS num_flights,
COUNTIF(arrival_delay < 15) AS num_ontime
FROM
`bigquery-samples.airline_ontime_data.flights`
GROUP BY
departure_delay
HAVING
num_flights > 100
),
totals AS (
SELECT
SUM(num_flights) AS tot_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: But is it right, though? What's with the weird hump for early departures (departure_delay less than zero)?
Step2: Note the crazy non-linearity ... |
6,596 | <ASSISTANT_TASK:>
Python Code:
import gambit
g = gambit.Game.new_tree()
g.title = "A simple poker example"
alice = g.players.add("Alice")
bob = g.players.add("Bob")
move = g.root.append_move(g.players.chance, 2)
move.actions[0].label = "A"
move.actions[0].prob = gambit.Rational(1, 2)
move.actions[1].label = "K"
move... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: One can build up extensive games from scratch and manipulate them. This example shows one way to do that for the simple one-card poker game.
St... |
6,597 | <ASSISTANT_TASK:>
Python Code:
import graphistry
# To specify Graphistry account & server, use:
# graphistry.register(api=3, username='...', password='...', protocol='https', server='hub.graphistry.com')
# For more options, see https://github.com/graphistry/pygraphistry#configure
edges = [{'src': 0, 'dst': 1}, {'src':... | <SYSTEM_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. Backend APIs
Step2: REST
Step3: 2. Frontend APIs
|
6,598 | <ASSISTANT_TASK:>
Python Code:
import os, sys
currentdir = os.getcwd(); os.getcwd();
currentdir # I'm on a different computer now
sys.path.append('/home/topolo/PropD/Propulsion/')
import Physique
from Physique import FundConst
print Physique.FundConst.columns
Physique.FundConst
g_0pd = FundConst[ FundConst["Quantit... | <SYSTEM_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 the current directory
Step2: Then append the directory containing the Physique package/library (it's just a folder) with sys.path.append; t... |
6,599 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
np.random.seed(10)
A = tf.constant(np.random.randint(100,size=(5, 3)))
def g(A):
return tf.reduce_prod(A, 1)
result = g(A.__copy__())
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.