Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k โ | cleaned_prompt stringlengths 168 30.3k โ |
|---|---|---|
12,400 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
from karabo_data import RunDirectory
sa1_data = RunDirectory('/gpfs/exfel/exp/XMPL/201750/p700000/raw/r0008')
sa1_data.info()
sa1_data.keys_for_source('SA1_XTD2_XGM/XGM/DOOCS:output')
sa1_flux = 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: SASE1
Step2: We are interested in fast, i.e. pulse-resolved data from the instrument source SA1_XTD2_XGM/DOOCS
Step3: We are particularly inte... |
12,401 | <ASSISTANT_TASK:>
Python Code:
from mcpi import minecraft
mc = minecraft.Minecraft.create(ip, port, my_name)
# send a chat message
mc.....
# teleport
mc.player.getPos() # returns a Vec3 instance; could also get pitch/orientation of player
mv.player.setPos(pos_vector)
# place blocks
from mcpi import block
mc.setBlock(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: Challenges
|
12,402 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
a = tf.constant(
[[0.3232, -0.2321, 0.2332, -0.1231, 0.2435, 0.6728],
[0.2323, -0.1231, -0.5321, -0.1452, 0.5435, 0.1722],
[0.9823, -0.1321, -0.6433, 0.1231, 0.023, 0.0711]]
)
def g(a):
return tf.argmin(a,axis=0)
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:
|
12,403 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame([[1,1,0,1],[0,0,0,0],[1,0,0,1],[0,1,0,0],[1,1,0,1]],columns=['A','B','C','D'])
def g(df):
return df.loc[(df.sum(axis=1) != 0), (df.sum(axis=0) != 0)]
result = g(df.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:
|
12,404 | <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, shutil
import datetime
import numpy as np
import logging
# SET TF ERROR LOG VERBOSITY
logging.getLogger("tensorflow").setLevel(loggin... | <SYSTEM_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 new Google Cloud Storage Bucket for ML model exports
Step2: Setup parameters for notebook scheduling
Step3: Locating the CSV files
St... |
12,405 | <ASSISTANT_TASK:>
Python Code:
animals = ['cat', 'dog', 'mouse']
for x in animals:
print("This is the {}.".format(x))
for x in animals:
print("{}!, this is the {}.".format("Hi", x))
for x in animals:
print("{1}!, you are {0}.".format("animals", x))
for letter in "Hello World":
print(letter)
a = rang... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ์์ ์๋ print ๋ฌธ
Step2: ์๋์ ๊ฐ์ด ์ธ๋ฑ์ฑ์ ์ด์ฉํ๋
Step3: ๋ฌธ์์ด ํ์ฉ
Step4: range ํจ์
Step5: ํ์ด์ฌ 2.x ๋ฒ์ ์์๋ range์ ๊ฑฐ์ ๋์ผํ ์ญํ ์ ์ํํ์ง๋ง ๋ฆฌ์คํธ ์ ์ฒด๋ฅผ ๋ณด์ฌ์ฃผ์ง ์๋ xrange๊ฐ ์๋ค.... |
12,406 | <ASSISTANT_TASK:>
Python Code:
import nltk, re
from nltk import word_tokenize
# NOTE if the data (corpora, example files) is not yet downloaded, this needs to be done first
# nltk.download()
print(nltk.corpus.gutenberg.fileids())
hamlet = nltk.corpus.gutenberg.words('shakespeare-hamlet.txt')
print(len(hamlet))
[w 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: Let's see which free resources are readily available. And then let's have a closer look at Shakespeare's Hamlet (to pretent we are literature fr... |
12,407 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-mh', 'atmoschem')
# 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... |
12,408 | <ASSISTANT_TASK:>
Python Code:
import spynner
import os, sys
from IPython.display import display, Image
# ็จ spynner ๆ้็่ฆฝๅจ
browser = spynner.Browser(debug_level=spynner.ERROR, debug_stream=sys.stderr)
browser.show() # ๅ่จด browser๏ผ่ฆๅฎไนๅพไธ่ฆ้ฑ่บซ
# ๅจ ?????? ๅกซๅ
ฅ้ฉ็ถ็ถฒๅ
base_url = 'http://v.??????.com/online/comic-7340.html?ch='
bo... | <SYSTEM_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: Q
Step3: ๅฆไฝๆ้ ?
Step4: ้ๅงๅๅไพๆๅๅง
Step5: ๅทฒ็ถๅฏไปฅๆไบ๏ผ้ๆไป้บผๅ้ก๏ผ
Step6: ็พๅจไพๅปบ็ซไธๅไป้ข
Step7: ๆๆๆดๅคๅปฃๅ
Step8: ๅฉ็จ thread
|
12,409 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
import seaborn as sns
from IPython.display import display, HTML
# Plot a sigmoid function
plt.figure(figsize=(5,5)) # open a figure base and determine the 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: Logistic regression analysis
Step2: Now we will load our sample data and create a 'Alcabuse' variable from 'Dalc' and 'Walc' (weekday and weeke... |
12,410 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from sklearn import linear_model
from matplotlib import pylab as plt
plt.style.use('bmh')
%matplotlib notebook
wine = pd.read_csv('data/winequality-white.csv',delimiter=';')
wine.describe()
fig = plt.figure(2)
ax = [fig.add_subplot(3,4,i) for i in ra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Poner NFQ en un mapa
Step2: Leer un archivo Excel
|
12,411 | <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: Wiki Talk Comments Toxicity Prediction
Step2: Note that depending on when you run the cell below, you may receive a warning about the default v... |
12,412 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
import mne
from mne.datasets import sample
from mne.decoding import (SlidingEstimator, General... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Transformation classes
Step2: PSDEstimator
Step3: Source power comodulation (SPoC)
Step4: Decoding over time
Step5: You can retrieve the spa... |
12,413 | <ASSISTANT_TASK:>
Python Code:
%run "../Functions/1. Google form analysis.ipynb"
binarized = getAllBinarized()
score = np.dot(binarized,np.ones(len(binarized.columns)))
dimensions = binarized.shape[1]
dimensions
binarized['class'] = 'default'
# split data table into data X and class labels y
X = binarized.iloc[:,0:dim... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: PCAs
Step2: Standardizing
Step3: 1 - Eigendecomposition - Computing Eigenvectors and Eigenvalues
Step4: eigendecomposition on the covariance ... |
12,414 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Better ML Engineering with ML Metadata
Step2: Install and import TFX
Step3: Import packages
Step4: Check the TFX, and MLMD versions.
Step5: ... |
12,415 | <ASSISTANT_TASK:>
Python Code:
def tronquer_1( l ):
return l[1:]
l=[1,2,3]
tronquer_1(l)
def tronquer_liste( ma_liste ):
try:
return ma_liste[1:]
except TypeError:
print("Cette fonction n'accepte que des listes ou des chaรฎnes de caractรจres")
l=[1,2,3]
tronquer_liste(l)
def extraire_avant_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: Donc attention aux nom donnรฉ aux paramรชtres formels, il peut รชtre aussi utile de se premunir contre des fautes, en utilisant la commande try qui... |
12,416 | <ASSISTANT_TASK:>
Python Code:
import torch
import numpy as np
# check if CUDA is available
train_on_gpu = torch.cuda.is_available()
if not train_on_gpu:
print('CUDA is not available. Training on CPU ...')
else:
print('CUDA is available! Training on GPU ...')
from torchvision import datasets
import torchvisi... | <SYSTEM_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 Augment the Data
Step2: Visualize a Batch of Training Data
Step3: View an Image in More Detail
Step4: Define the Network Architectur... |
12,417 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import rcParams, cycler
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
# Fixing random state for reproducibility
np.random.seed(19680801)
N = 10
data = [np.logspace(0, 1, 100) + np.random.randn(100) + ii for ii in range(N)]
data = np.array(data).T
cmap = plt.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note that the image above is captured and displayed by Jekyll.
Step2: You can also remove only the code so that images and other output still s... |
12,418 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
m = Basemap(projection='mill',
llcrnrlat=-90,
llcrnrlon=-180,
urcrnrlat=90,
urcrnrlon=180,
resolution='l')
m.drawcoastlines()
m.drawcountries(... | <SYSTEM_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 we have a map of the world, with bright blue state borders. This isn't exactly what we want.
Step2: Next, we'll plot some points on the map... |
12,419 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
pickle_file = 'notMNIST.pickle... | <SYSTEM_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 reload the data we generated in 1_notmnist.ipynb.
Step2: Reformat into a shape that's more adapted to the models we're going to train
Ste... |
12,420 | <ASSISTANT_TASK:>
Python Code:
!curl -Lo conda_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import conda_installer
conda_installer.install()
!/root/miniconda/bin/conda info -e
!pip install --pre deepchem
import deepchem
deepchem.__version__
import deepchem as dc
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: Make The Datasets
Step3: Because ScScore is trained on relative complexities, we want the X tensor in our dataset to have 3 dimensions (sample_... |
12,421 | <ASSISTANT_TASK:>
Python Code:
# .. your code here ..
# .. your code here ..
# .. your code here ..
# .. your code here ..
# .. your code here ..
def doKMeans(df):
# Let's plot your data with a '.' marker, a 0.3 alpha at the Longitude,
# and Latitude locations in your dataset. Longitude = x, Latitude = y
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How to Get The Dataset
Step2: Get rid of any rows that have nans in them
Step3: Display the dtypes of your dset
Step4: Coerce the Date featur... |
12,422 | <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: Create the baseline model
Step3: REMINDER
Step4: Lab Task #2
Step5: Resource for an explanation of the Regression... |
12,423 | <ASSISTANT_TASK:>
Python Code:
sys.path.insert(0, '/home/claudius/Downloads/dadi')
sys.path
import dadi
dir(dadi)
import pylab
%matplotlib inline
x = pylab.linspace(0, 4*pylab.pi, 1000)
pylab.plot(x, pylab.sin(x), '-r')
%%sh
# this allows me to execute a shell command
ls
fs_ery = dadi.Spectrum.from_file('ERY.FOLDED.... | <SYSTEM_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, I should be able to import $\delta$a$\delta$i
Step2: I have turned the 1D folded SFS's from realSFS into $\delta$d$\delta$i format by hand... |
12,424 | <ASSISTANT_TASK:>
Python Code:
ozone_daily['site'][ozone_daily['site'].isin([2778, 2783])]
len(ozone_daily['site'].unique())
#this was done once in the beginning to
#save data set as ".csv" file.
#ozone_daily.to_csv('daily_ozone_obs_1980_2014.csv', sep = ',')
locations = pd.read_excel('Location.xlsx')
def get_county_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: The number of unique sites in Location file is around 2100. However, as you can see below,
|
12,425 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os, sys
import inspect
import pydov
from pydov.search.interpretaties import HydrogeologischeStratigrafieSearch
ip_hydrogeo = HydrogeologischeStratigrafieSearch()
# information about the HydrogeologischeStratigrafie type (In Dutch):
print(ip_hydrogeo.get_descript... | <SYSTEM_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 information about code base
Step2: The cost is an arbitrary attribute to indicate if the information is retrieved from a wfs query (cost = ... |
12,426 | <ASSISTANT_TASK:>
Python Code:
# Note: Do not change this code!
import numpy as np
import pandas
import sys
import modin
pandas.__version__
modin.__version__
# Implement your answer here. You are also free to play with the size
# and shape of the DataFrame, but beware of exceeding your memory!
import pandas as pd
frame... | <SYSTEM_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 that we have created a toy example for playing around with the DataFrame, let's print it out in different ways.
|
12,427 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image('images/02_network_flowchart.png')
Image('images/02_convolution.png')
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from sklearn.metrics import confusion_matrix
import time
from datetime import timed... | <SYSTEM_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 input image is processed in the first convolutional layer using the filter-weights. This results in 16 new images, one for each filter in th... |
12,428 | <ASSISTANT_TASK:>
Python Code:
from ipyparallel import Client, error
cluster = Client()
view = cluster[:]
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
%%px
# MPI initialization, library imports and sanity checks on all engines
from mpi4py import MPI
# Load data publication API so engines can ... | <SYSTEM_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 also load the plotting and numerical libraries so we have them ready for visualization later on.
Step2: Now, we load the MPI libraries in... |
12,429 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from SeisCL import SeisCL
import matplotlib.pyplot as plt
import numpy as np
seis = SeisCL()
# Constants for the modeling
N = 200
seis.N = np.array([N, N])
seis.ND = 2
seis.dt = 0.25e-03
seis.NT = 1000
seis.dh = dh= 2
seis.f0 = 20
seis.freesurf = 0
# Source and receiver... | <SYSTEM_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 source is by default a Ricker wavelet with a central frequency of seis.csts['f0'], so 20 Hz here. We then generate a synthetic shot, w... |
12,430 | <ASSISTANT_TASK:>
Python Code:
def gen_periodic_data(x, period=1, amplitude=1, phase=0, noise=0):
'''Generate periodic data given the function inputs
y = A*cos(x/p - phase) + noise
Parameters
----------
x : array-like
input values to evaluate the array
period : float (defa... | <SYSTEM_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 1b
Step2: Problem 1c
Step3: Problem 1d
Step4: An important, but necessary, aside โโ
Step5: The common Fourier pairs are especially ... |
12,431 | <ASSISTANT_TASK:>
Python Code:
import requests
import pandas
endpoint = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/aggregate/{project}/{access}/{agent}/{granularity}/{start}/{end}'
headers={'User-Agent' : 'https://github.com/r1rajiv92', 'From' : 'rajiv92@uw.edu'}
yearMonthCombinations = { '2015' : [ 7, 8, 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: PageCount API
Step2: Summing up accross mobile-app and mobile-site for PageViews into a single access type called 'mobile'. Also, grouping by y... |
12,432 | <ASSISTANT_TASK:>
Python Code:
shoes_in_my_drawer = int(input("How many shoes do you have in your drawer? "))
if shoes_in_my_drawer % 2 == 1:
print("You have an odd number of shoes. Something is wrong!")
shoes_in_my_drawer = int(input("How many shoes do you have in your drawer? "))
if shoes_in_my_drawer % 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: <p style="text-align
Step2: <p style="text-align
Step3: <p style="text-align
Step4: <span style="text-align
Step5: <p style="text-align
Step... |
12,433 | <ASSISTANT_TASK:>
Python Code:
x = "I love cats." # <= x is a string...
print(x.upper()) # converts string to upper case
print(x.replace("c", "b")) # cats? I'm a bat kinda guy myself!
print(x.__add__(x)) # x.__add__(x) is EXACTLY the same as x + x.
print(x.__mul__(3)) # Equivalent to 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: In the above example we can see that we can replace the letter "c" with a "b" using the replace 'method'. What happens if I have the number 711 ... |
12,434 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from pycalphad import Database, binplot
db_alfe = Database('alfe_sei.TDB')
my_phases_alfe = ['LIQUID', 'B2_BCC', 'FCC_A1', 'HCP_A3', 'AL5FE2', 'AL2FE', 'AL13FE4', 'AL5FE4']
fig = plt.figure(figsize=(9,6))
pdens = [{'B2_BCC': 20000}, 2000]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Energy Surfaces of Al-Ni (N. Dupin et al., 2001)
Step2: Al-Zn (S. Mey et al., 1993)
Step4: Prototyping New Models (Advanced)
|
12,435 | <ASSISTANT_TASK:>
Python Code:
from noodles import schedule, run, run_parallel, gather
@schedule
def add(a, b):
return a+b
@schedule
def sub(a, b):
return a-b
@schedule
def mul(a, b):
return a*b
u = add(5, 4)
v = sub(u, 3)
w = sub(u, 2)
x = mul(v, w)
draw_workflow('callgraph1.png', x._workflow)
run_paral... | <SYSTEM_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, why?
Step2: Our fledgeling Python script kiddie then enters the following code
Step3: resulting in this workflow
Step4: How does it work... |
12,436 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
data = pd.read_csv('../data/hbv_s_data.csv', index_col=0, parse_dates=True)
evap_true = np.array([0.6,1.9,2.4,1.8,1.4,1.3,1.0,0.8,0.6,0.4,0.2,0.3])*1.2 #evapo for jan-dec
def romanenko(data):
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: Source
Step2: Kharrufa method. Kharrufa (1985) derived an equation through correlation of ET/p and T in the form of
|
12,437 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import numpy as np
import pandas as pd
X_df = pd.DataFrame(np.random.rand(100, 3))
w_actual = pd.Series(data=[2, 3, 5])
y_true = X_df.dot(w_actual)
# add a small noise to y
y_true += np.random.normal(scale=1E-6, 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: This is an example of applying learning rate decay in TensorFlow, using Gradient Descent to solve a simple Linear Regression.
Step2: Now we're ... |
12,438 | <ASSISTANT_TASK:>
Python Code:
cities = set([]) # initialize an empty set
import csv # we this module to handle csv files
with open('../data/Dalziel2016_data.csv', 'r') as f: # 'r' stands for reading
my_csv = csv.DictReader(f) # set up the csv reader
for line in my_csv: # loop over all lines
print(line... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we open the file for reading. We use the with statement that takes care of closing the file
Step2: In the code above, we have imported the ... |
12,439 | <ASSISTANT_TASK:>
Python Code:
act = Database("ecoinvent 3.2 cutoff").search("pineapple")
act
act = Database("ecoinvent 3.2 cutoff").search("pineapple")[1]
act
lca = LCA(
{act.key: 1},
method=('IPCC 2013', 'climate change', 'GWP 100a'),
)
lca.lci()
lca.lcia()
lca.score
bou = Database("bouillon").search("Paste... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: try now for bouillon
|
12,440 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
from pyensae.graphhelper import draw_diagram
draw_diagram("blockdiag { f0 -> f1 -> f3; f2 -> f3;}")
draw_diagram('blockdiag { f0 -> f1 -> f3; f2 -> f3; f2 -> f5 [color="red"]; f4 -> f5 [color="red"]; }')
def solve_polynom(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Petite histoire
Step2: Six mois plus tard, vous crรฉez une fonction f5 qui appelle une fonction f4 et la fonction f2.
Step3: Ah au fait, ce fai... |
12,441 | <ASSISTANT_TASK:>
Python Code:
import textwrap
sample_text = '''
The textwrap module can be used to format text for output in
situations where pretty-printing is desired. It offers
programmatic functionality similar to the paragraph wrapping
or filling features found in many text editors.
'''
wra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Structure of this module
Step2: Convinient functiones
Step3: textwrap.fill(text, width=70, **kwargs)
Step4: textwrap.dedent(text)
Step5: you... |
12,442 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ์ ๊ทํ
Step2: ๋ฐ์ดํฐ์ธํธ ์ค๋นํ๊ธฐ
Step3: ๊ทธ๋ฃน ์ ๊ทํ ํํ ๋ฆฌ์ผ
Step4: ์ธ์คํด์ค ์ ๊ทํ ํํ ๋ฆฌ์ผ
Step5: ๋ ์ด์ด ์ ๊ทํ ํํ ๋ฆฌ์ผ
|
12,443 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import rcParams
%matplotlib notebook
rcParams['mathtext.fontset'] = 'cm'
rcParams['font.size'] = 14
red = "#e41a1c"
blue = "#377eb8"
gray = "#eeeeee"
def heat_update(n):
ax0.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: Set up ...
Step2: Heat equation
Step3: Wave equation
|
12,444 | <ASSISTANT_TASK:>
Python Code:
dirName = "../lettersketch/assets/train_images/UpperCase/StraightLines/"
fileNames = []
fileLetters = []
for fileName in os.listdir(dirName):
if fileName.endswith(".png") and (not "__" in fileName):
fileNames.append(dirName+fileName)
letter = fileName.split("_")[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: Read in the letters saved by the lettersketch app after converting into grayscale and resizing
Step2: Reshape the image arrays
Step3: Convert ... |
12,445 | <ASSISTANT_TASK:>
Python Code:
for nu in range(5):
print('nu = '+str(nu)+': '+str(jn_zeros(nu,5)))
figure()
nmax = 20
numax = 10
for nu in range(numax):
scatter(nu*ones(nmax),jn_zeros(nu,nmax))
ylim(0,50)
xlim(-1,numax)
xlabel('$\\nu$', fontsize=15)
ylabel(r'$\alpha_{\nu,n}$', fontsize=15)
xticks(range(numax))... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Podemos graficar estas raรญces, de la forma siguiente
Step2: Note que estas raรญces no estรกn igualmente espaciadas, lo que se aprecia mejor al gr... |
12,446 | <ASSISTANT_TASK:>
Python Code:
import las_reader
l = las_reader.read("GT14574.LAS")
print(type(l))
print(l._text)
l.keys()
l['NEUT']
print(l['GCPS'][-12:])
print(l[1][-12:])
print(l['NEUT'][-12:])
print(l[-1][-12:])
print(l.data.shape)
print(l.data)
m = las_reader.las.Metadata(mnemonic="SPEED", unit='something?', v... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Curve data
Step2: You can also access curves by index (remembering that the first index is zero but the first curve is the depth). For example,... |
12,447 | <ASSISTANT_TASK:>
Python Code:
# Model parameters
A = 2.3
f = 1
X0 = 2.5
# Noise parameter
sigma = 0.6
N = 300
t = np.sort(np.random.uniform(0, 10, N))
X = X0 + A * np.sin(2 * np.pi * f * t) + np.random.normal(0, sigma, N)
plt.plot(t, X, "o")
plt.xlabel("$t$")
plt.ylabel(r"$X_{\mathrm{obs}}$")
plt.show()
def Generic_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:
Step3: Marginalisation
Step5: We now use pythons lambda functions to generate the specific prior and likelihoods
Step6: We now have a choice about ho... |
12,448 | <ASSISTANT_TASK:>
Python Code:
model.calibration
model.residuals()
exo_g = linspace(0.1,0,10) # this is a vector of size 10
exo_g = atleast_2d(exo_g).T # the solver expects a 1x10 vector
print(exo_g.shape)
exo_g
# Let's solve for the optimal adjustment by assuming that the
# economy returns to steady-state after T=50 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We want to compute the adjustment of the economy when this tax, goes back progressively from 10% to 0%, over 10 periods.
|
12,449 | <ASSISTANT_TASK:>
Python Code:
import os
from polyglotdb import CorpusContext
corpus_root = '/mnt/e/Data/pg_tutorial'
syllabics = ["ER0", "IH2", "EH1", "AE0", "UH1", "AY2", "AW2", "UW1", "OY2", "OY1", "AO0", "AH2", "ER1", "AW1",
"OW0", "IY1", "IY2", "UW0", "AA1", "EY0", "AE1", "AA0", "OW1", "AW0", "AO1", ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Encoding syllables
Step2: Once the syllabic segments have been marked as such in the phone inventory, the next step is to actually create the s... |
12,450 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import pulp
factories = pd.DataFrame.from_csv('csv/factory_variables.csv', index_col=['Month', 'Factory'])
factories
factories.index
demand = pd.DataFrame.from_csv('csv/monthly_demand.csv', index_col=['Month'])
demand
production = pulp.LpVariable.dicts("production",
... | <SYSTEM_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 also import our demand data
Step2: As we have fixed costs and variable costs, we'll need to model both production and the status of the f... |
12,451 | <ASSISTANT_TASK:>
Python Code:
## import statements
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn
from sklearn import datasets
from sklearn.cross_validation import cross_val_predict
from sklearn import linear_model... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: See UCI Data page
Step2: 3. Data Preparation
Step3: 4. Modeling
|
12,452 | <ASSISTANT_TASK:>
Python Code:
#@title Imports & Utils
!pip install jax-md
import numpy as onp
import jax.numpy as np
from jax.config import config
config.update('jax_enable_x64', True)
from jax import random
from jax import jit
from jax_md import space, smap, energy, minimize, quantity, simulate
from jax_md.colab_tool... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Harmonic Minimization
Step2: Next we need to generate some random positions as well as particle sizes.
Step3: Then we need to construct our FI... |
12,453 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
from clipper_admin import Clipper
# Change the username if necessary
user = ""
# Set the path to the SSH key
key = ""
# Set the SSH host
host = ""
clipper = Clipper(host, user, key)
cifar_loc = ""
import cifar_utils
train_x, train_y = cifar_utils.filter_data(
*ci... | <SYSTEM_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 Cifar
Step2: Train Logistic Regression Model
Step3: Deploy Logistic Regression Model
Step4: Link your app to your model
Step5: You can ... |
12,454 | <ASSISTANT_TASK:>
Python Code:
# HIDDEN
# For Tables reference see http://data8.org/datascience/tables.html
# This useful nonsense should just go at the top of your notebook.
from datascience import *
%matplotlib inline
import matplotlib.pyplot as plots
import numpy as np
from sklearn import linear_model
plots.style.us... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Acquiring and seeing trends in multidimensional data
Step2: FIGURE 3.1. For the Advertising data, the least squares fit for the regression of s... |
12,455 | <ASSISTANT_TASK:>
Python Code:
import meshcat
from meshcat.geometry import Box
vis = meshcat.Visualizer()
## To open the visualizer in a new browser tab, do:
# vis.open()
## To open the visualizer inside this jupyter notebook, do:
# vis.jupyter_cell()
vis["box1"].set_object(Box([0.1, 0.2, 0.3]))
from meshcat.animati... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Building an Animation
Step2: You should see the box slide 1 meter to the right in the viewer. If you missed the animation, you can run it again... |
12,456 | <ASSISTANT_TASK:>
Python Code:
p=Function('p')
b=Function('b')
m,s,h,r = symbols('m s h r')
m=M(x,y)
q=Q(x,y,t)
d=D(x,y,t)
e=E(x,y)
r=rho(x,y)
dtt=as_finite_diff(p(x,y,t).diff(t,t), [t-s,t, t+s])
dt=as_finite_diff(p(x,y,t).diff(t), [t-s, t+s])
# Spacial finite differences can easily be extended to higher order by incr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Time and space discretization as a Taylor expansion.
Step2: Solve forward in time
Step3: Define the discrete model
Step4: Create functions f... |
12,457 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy as scipy
import scipy.odr as odr
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import rc
# set to use tex, but make sure it is sans-serif fonts only
rc('text', usetex=True)
rc('text.latex', preamble=r'\usepac... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generating synthetic data
Step3: Fit a line of best fit using least squares (not ODR)
Step6: Line of best fit using ODR
Step7: Let's do it!
S... |
12,458 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-2', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
12,459 | <ASSISTANT_TASK:>
Python Code:
import networkx as netx
import numpy as np
import matplotlib.pyplot as plt
import warnings
import random
import itertools
def power_law_graph(G):
histo = netx.degree_histogram(G)
_ = plt.loglog(histo, 'b-', marker='o')
_ = plt.ylabel("k(x)")
_ = plt.xlabel("k")
plt.sh... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simulation
Step2: Experiment 1
Step3: Experiment 2
Step4: Experiment 3
Step5: Networkx
|
12,460 | <ASSISTANT_TASK:>
Python Code:
import os
import struct
import numpy as np
def load_mnist(path, which='train'):
if which == 'train':
labels_path = os.path.join(path, 'train-labels-idx1-ubyte')
images_path = os.path.join(path, 'train-images-idx3-ubyte')
elif which == 'test':
labels_pat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The returned images NumPy array will have the shape $n \times m$, where $n$ is the number of samples, and $m$ is the number of features. The ima... |
12,461 | <ASSISTANT_TASK:>
Python Code::
import matplotlib.pyplot as plt
fig, ax = plt.subplots(3, 3, sharex=True, sharey=True, figsize=(5,5))
for images, labels in ds.take(1):
for i in range(3):
for j in range(3):
ax[i][j].imshow(images[i*3+j].numpy().astype("uint8"))
ax[i][j].set_title(ds.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:
|
12,462 | <ASSISTANT_TASK:>
Python Code:
import json
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
def requests_retry_session(
retries=3,
backoff_factor=0.3,
status_forcelist=(500, 502, 504),
session=None,
):
session = session or requests.Sess... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: MMW staging (test) API Rapid Watershed Delineation (RWD) "watershed" endpoint
Step2: 2. Construct and issue the job request
Step3: 3. Fetch th... |
12,463 | <ASSISTANT_TASK:>
Python Code:
# Some general notebook setting
host = 'http://localhost:9200'
# IMPORTANT: create a file credentials.json with credentials for your Elasticsearch instance!
with open('credentials.json') as f:
data = json.load(f)
username = data['username']
password = data['password']
es = 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:
Step2: Choosing the class assignment objective
Step3: Balanced classes
Step4: Looking at the prediction results, we see that both class assignment ob... |
12,464 | <ASSISTANT_TASK:>
Python Code:
# Create an array with 5 draws from the normal(0,1) distribution and print
np.random.normal(size=5)
# Create an array with 5 draws from the normal(0,1) distribution and print
np.random.normal(size=5)
# Set the seed for the random number generator
np.random.seed(129)
# Create an array wit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Computers by definition cannot generate truly random numbers. The Mersenne Twister is a widely-used algorithm for generating pseudo random numbe... |
12,465 | <ASSISTANT_TASK:>
Python Code:
dinos.assign(Decimal = dinos.sha256.apply(lambda x: int(x, base=16)))
dinos.sort_values(by='sha256').head(10)
dinos.sort_values(by='sha256', ascending=False).head(10)
<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: LAB
Step2: How about in descending order?
|
12,466 | <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 mpl_toolkits.mplot3d import Axes3D
import plotBL
HTML('../style/code_toggle.html')
ant1 = np.array([-500e3,500e3,0]) # in m
ant2 ... | <SYSTEM_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: 4.5.1 UV coverage
Step3: Let's express the corresponding physical baseline in ENU coordinates.
Step4: ... |
12,467 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
import pandas
df = pandas.read_csv("data/housing.data", delim_whitespace=True, header=None)
df.head()
cols = "CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX PTRATIO B LSTAT MEDV".split()
df.columns = cols
df.head()
X = df.drop("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: Problรจme 1
Step2: Random Forest
Step3: On s'inspire de l'exemple Feature importances with forests of trees.
Step4: Modรจle linรฉaire
Step5: T... |
12,468 | <ASSISTANT_TASK:>
Python Code:
import os
import librosa
import itertools
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import kurtosis
from scipy.stats import skew
import sklearn
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score
from sk... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Visualization
Step3: Classical Machine Learning
Step4: Logistic Regression
Step5: ElasticNet
Step6: Decision Tree
Step7: Random Forest
Step... |
12,469 | <ASSISTANT_TASK:>
Python Code:
from keras.models import Sequential
from keras.layers.core import Dense, Dropout
from keras.optimizers import SGD
nb_classes = 10
# FC@512+relu -> DropOut(0.2) -> FC@512+relu -> DropOut(0.2) -> FC@nb_classes+softmax
# ... your Code Here
# Decomment and Execute this cell to get the solutio... | <SYSTEM_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 preparation (keras.dataset)
Step2: Training
Step3: Plotting Network Performance Trend
Step4: After 100 epochs, we get a 98.8% validation... |
12,470 | <ASSISTANT_TASK:>
Python Code:
a = symbols('a') #actual value
p = symbols('p') #predicted value
mse = lambda a,p: (a-p)**2
mse_plot = plot(mse(0, p),(p, -3, 3), show=False, legend=True, line_color="red")
mse_plot[0].label='MSE'
mse_plot.show()
# Let's see how to identify
np.random.seed(1000)
N = 10000
w = np.ones(5)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The problem with the squared error is that it makes small errors (< 1.0) even smaller and large large errors (>1.0) disproportionately larger.
S... |
12,471 | <ASSISTANT_TASK:>
Python Code:
import os
import matplotlib as mpl
mpl.rcParams['figure.dpi'] = 500
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
ls T-950K/
mole_df = pd.read_csv(os.path.join('T-950K','gas_mole_tr.csv'))
msdot_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: Influence of temperature
Step2: Mole fractions
Step3: Surface Production Rates
Step4: Comparison between temperatures
Step5: Effect of catal... |
12,472 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import nvg.ximu.ximudata as ximudata
%matplotlib notebook
reload(ximudata)
dbfilename = "/home/kjartan/Dropbox/Public/nvg201209.hdf5"
db = ximudata.NVGData(dbfilename);
dbfile = db.hdfFile;
print "Subjects: ", dbfile.keys()
print "Tria... | <SYSTEM_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 database
Step2: Explore contents of the database file
Step3: The content of the raw IMU file
Step4: Implemented analysis methods
Ste... |
12,473 | <ASSISTANT_TASK:>
Python Code:
from pathlib import Path
import numpy as np
import os
from urllib.request import urlretrieve
import matplotlib.pyplot as plt
%matplotlib inline
def download_mnist(path=Path('data/mnist')):
os.makedirs(path, exist_ok=True)
urls = ['http://yann.lecun.com/exdb/mnist/train-images-idx... | <SYSTEM_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 MNIST
Step3: Conversions
Step4: Sweet!
Step5: Okay, cool.
Step6: Alternate Conversion Method
|
12,474 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import freqopttest.util as util
import freqopttest.data as data
import freqopttest.kernel as kernel
import freqopttest.tst as tst
import freqopttest.glo as glo
import theano
# Full sa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Demo
Step2: A SampleSource can be sampled to get a TSTData (two-sample test data) object. A TSTData object is just an encapsulation of two $n\t... |
12,475 | <ASSISTANT_TASK:>
Python Code:
nmstoget = ('Dune', 'AnaK', 'Odyssey', 'Gilgamesh', 'OBrother', 'Narnia', 'Catch22')
hosts_to_target = [h for h in hsd.values() if h.name in nmstoget]
assert len(hosts_to_target)==len(nmstoget)
new_targets = [hosts.NSAHost(145729), hosts.NSAHost(21709)]
hosts_to_target.extend(new_targets)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prioritize
Step2: Note
Step3: Some special objects
Step4: http
Step5: The above object was put as SAT==2, but is at very close z to AnaK...?... |
12,476 | <ASSISTANT_TASK:>
Python Code:
import pulp
my_lp_problem = pulp.LpProblem("My LP Problem", pulp.LpMaximize)
x = pulp.LpVariable('x', lowBound=0, cat='Continuous')
y = pulp.LpVariable('y', lowBound=2, cat='Continuous')
# Objective function
my_lp_problem += 4 * x + 3 * y, "Z"
# Constraints
my_lp_problem += 2 * y <= 25... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then instantiate a problem class, we'll name it "My LP problem" and we're looking for an optimal maximum so we use LpMaximize
Step2: We then mo... |
12,477 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
incomes = np.random.normal(27000, 15000, 10000)
incomes = np.append(incomes, [1000000000])
import matplotlib.pyplot as plt
plt.hist(incomes, 50)
plt.show()
incomes.mean()
def reject_outliers(data):
u = np.median(data)
s = np.std(data)
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: That's not very helpful to look at. One billionaire ended up squeezing everybody else into a single line in my histogram. Plus it skewed my mean... |
12,478 | <ASSISTANT_TASK:>
Python Code:
df = pd.read_csv("../data/brazil_gdp_inflation_ir.csv", dtype={'Time':np.float64, 'GDP':np.float64, 'Inflation':np.float64, 'Interest':np.float64}, index_col="Time")
df['RInterest'] = df.Interest - df.Inflation
brazil = df.sort()
brazil
filter = brazil.Inflation < 11.0
sns.set(style="da... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exibimos sรฉrie histรณrica
Step2: Regressรฃo entre taxa de inflaรงรฃo e taxa de crescimento do PIB
Step3: Regressรฃo entre taxa de juros e inflaรงรฃo
... |
12,479 | <ASSISTANT_TASK:>
Python Code:
plt.plot(h1_phi - h2_phi[:3], h2_phi[:3])
plt.show()
from sklearn.linear_model import LinearRegression
LR = LinearRegression()
LR.fit(h2_phi[:3].reshape(3, 1), (h1_phi - h2_phi[:3]).reshape(3, 1))
h1_phi_4_predicted_delta = LR.predict([[h2_phi[3]]])
h1_phi_4_predicted = h2_phi[3] + h... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ะขะธะฟะฐ ะปะธะฝะธั, ัะธะฟะฐ ะฟััะผะฐั
Step3:
Step4: <img src="http
|
12,480 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%cd ..
import warnings; warnings.filterwarnings('ignore')
from utils import matparser, data_compiler
import glob
data_dir = 'data/controls/'
matparser.parse_dir(data_dir)
out_dir = "data/controls.csv"
data_compiler.compile_dir(data_dir, out_dir)
!cat data/controls.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: Start by parsing the .mat files from the matched controls
Step2: Clean up - remove nan entries as these cause hddm to fail
Step3: Merge patien... |
12,481 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.random.seed(1337)
import warnings
warnings.filterwarnings("ignore")
import time as tm
import pandas as pd
from keras.models import Sequential, Model
from keras.constraints import maxnorm
from keras.layers import Dense, Dropout, Activation
from keras.utils import np_u... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load dataset
Step2: Utilities function
Step3: Extract data
Step4: Modified imputation method using MLPRegressor
Step5: Feature Augmentation ... |
12,482 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from astropy.coordinates import SkyCoord
import astropy.coordinates as coord
import astropy.units as u
from gbmgeometry import *
data = GetGBMData("080916009")
data.set_destination("") # You can enter a folder here. If you want the CWD, you do not have to set
data.get_trigd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Making an interpolation from TRIGDAT
Step2: By default, GetGBMData will grad data from all detectors. However, one can set a subset to retrieve... |
12,483 | <ASSISTANT_TASK:>
Python Code:
a = np.array([[[ 0., 1., 2.],
[ 3., 4., 5.]],
[[ 6., 7., 8.],
[ 9., 10., 11.]],
[[ 12., 13., 14.],
[ 15., 16., 17.]]])
b = np.array([[ 0., 1.],
[ 2., 3.],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Merge to 2 arrays into 1 array
Step2: Extract the 2 arrays out
Step3: Shuffle and see the output.
|
12,484 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
tf.__version__
h = tf.constant('Hello World')
h
h.graph is tf.get_default_graph()
x = tf.constant(100)
x
# Create Session object in which we can run operations.
# A session object encapsulates 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: Constants
Step2: Operations
Step3: Placeholders
Step4: Variables
Step5: Classification using the MNIST dataset
Step6: The MNIST dataset con... |
12,485 | <ASSISTANT_TASK:>
Python Code:
from sklearn import datasets
data = datasets.load_breast_cancer()
data.data.shape
data.feature_names
data.target_names
import sklearn.model_selection as ms
X_train, X_test, y_train, y_test = ms.train_test_split(data.data, data.target, test_size=0.2, random_state=42)
X_train.shape, X_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: As in previous examples, all data is contained in a 2-D feature matrix data.data, where the rows represent data samples, and the columns are the... |
12,486 | <ASSISTANT_TASK:>
Python Code:
df = pd.read_csv(DATA_DIR + 'doc_index_filter.csv')
titles = list(df['title'].unique())
n_title = len(titles)
print('# unique titles: %d' % n_title)
title_stats = pd.read_csv(DATA_DIR + 'stats_job_titles.csv')
def parseBatch(b, start=None, end=None):
'''
@brief: parse a batch of ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parsing job titles
Step2: Check for duplicates in results
Step3: Save invalid titles
Step4: Rm dups due to invalid titles and replace NAs by ... |
12,487 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License")
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The AS... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Kvswap
Step2: Examples
|
12,488 | <ASSISTANT_TASK:>
Python Code:
# important stuff:
import os
import pandas as pd
import numpy as np
# morgan
import tissue_enrichment_analysis as tea
import epistasis as epi
import genpy
import gvars
# Graphics
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import rc
rc('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:
Step2: Finding HIF-1 direct target candidates
Step3: As a safety check, let's make a qPCR like plot to visualize our genes, and let's make sure they h... |
12,489 | <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: Using the Apache Beam Orchestrator for TFX
Step2: Import packages
Step3: Check the versions
Step4: Download example data
Step5: Take a quick... |
12,490 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import theano
import theano.tensor as T
import lasagne
seed = 1
lasagne.random.set_rng(np.random.RandomState(seed))
# Sequence Length
SEQ_LENGTH = 20
# Number of units in the hidden (LSTM) layers
DEPTH = 2
N_HIDDEN = 512
NON_LINEARITY = lasagne.nonlinearities.rectify
#... | <SYSTEM_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
Step2: An optimizer can be seen as a function that takes a gradient, obtained by backpropagation, and returns an update to be a... |
12,491 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
from math import sqrt
def soliton(x, t, c, a):
# make x and t arrays (if not already)
if type(t) != np.ndar... | <SYSTEM_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 interact for animation with data
Step2: To create an animation of a soliton propagating in time, we are going to precompute the soliton d... |
12,492 | <ASSISTANT_TASK:>
Python Code:
import maildaemon
cfg = maildaemon.load_config()
connections = cfg['connections']
from maildaemon.imap_daemon import IMAPDaemon
from maildaemon.smtp_connection import SMTPConnection
from maildaemon.pop_daemon import POPDaemon
one_and_one_imap = IMAPDaemon.from_dict(connections['1and1-i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: reading configuration
Step2: connecting, retrieving/sending messages
Step3: 1and1
Step4: Gmail
Step5: iTSCOM
Step6: WIP
|
12,493 | <ASSISTANT_TASK:>
Python Code:
import Ngl
wks = Ngl.open_wks('png', 'plot_xy')
import numpy as np
x = np.arange(0,5)
y = np.arange(0,10,2)
plot = Ngl.xy(wks, x, y)
from IPython.display import Image
Image(filename='plot_xy.png', retina=True)
Ngl.delete_wks(wks)
wks = Ngl.open_wks('png', 'plot_xy.png')
res = Ngl.Reso... | <SYSTEM_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 use Numpy arrays we need to import the module.
Step2: Hm, we created the plot but where is it? Unlike matplotlib PyNGL can't display inline... |
12,494 | <ASSISTANT_TASK:>
Python Code:
from random import randrange
lst = [randrange(1, 100) for _ in range(10)]
print(lst)
lst.sort()
print(lst)
lst = [randrange(1, 100) for _ in range(10)]
tup = tuple(lst)
print(sorted(tup)) # return List
print(tup)
tup = (randrange(1, 100) for _ in range(10))
print(sorted(tup))
for i in 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: sorted() ไธ้ไบๅ่กจ๏ผ่ไธไผ็ๆๅนถ่ฟๅไธไธชๆฐ็ๆๅบๅ็ๅ่กจ๏ผๅๆๅฏน่ฑกไธๅๅฝฑๅ๏ผ
Step2: ่ฝ็ถไธๆฏๅๅฐๆๅบ๏ผไฝๅฆๆๆฏไผ ๅ
ฅ็ๆๅจ๏ผ่ฟๆฏไผ่ขซๅพช็ฏๆ็๏ผ
Step3: Key
Step4: ๆ่
๏ผๅฝ่ฟญไปฃๅฏน่ฑก็ๅ
็ด ่พไธบๅคๆๆถ๏ผๅฏไปฅๅชๆ็
งๅ
ถไธญ็ๆไบๅฑๆง่ฟ่กๆๅบ๏ผ
Step5: ... |
12,495 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn import svm, cross_validation
import h5py
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
import sys
sys.path.append("../")
# Data to use
Ndata = 10000
# First we load the file
file_location = '../results_database/text_wall_street_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: With Spaces
Step2: Do the loop and calculate the scores
Step3: Now without spaces
Step4: Do the loop and calculate the scores
|
12,496 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/divina_commedia.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
#text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import numpy as np
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: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
12,497 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.optimize as opt
def hat(x,a,b):
return -a*x**2+b*x**4
assert hat(0.0, 1.0, 1.0)==0.0
assert hat(0.0, 1.0, 1.0)==0.0
assert hat(1.0, 10.0, 1.0)==-9.0
a = 5.0
b = 1.0
x=np.linspace(-3,3,100)
plt.figure(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Hat potential
Step2: Plot this function over the range $x\in\left[-3,3\right]$ with $b=1.0$ and $a=5.0$
Step3: Write code that finds the two l... |
12,498 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import skrf as rf
rf.stylely()
from skrf import Frequency
from skrf.media import CPW
freq = Frequency(75,110,101,'ghz')
cpw = CPW(freq, w=10e-6, s=5e-6, ep_r=10.6)
cpw
cpw.line(100*1e-6, name = '100um line')
freq = Frequency(75,110,101,'ghz')
cpw = CPW(freq, w=10e-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 create a transmission line of 100um
Step2: More detailed examples illustrating how to create various kinds of Media
Step3: For the purpose... |
12,499 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bcc', 'sandbox-3', '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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.