Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
14,700 | <ASSISTANT_TASK:>
Python Code:
corpus = [[(0, 1.0), (1, 1.0), (2, 1.0)],
[(2, 1.0), (3, 1.0), (4, 1.0), (5, 1.0), (6, 1.0), (8, 1.0)],
[(1, 1.0), (3, 1.0), (4, 1.0), (7, 1.0)],
[(0, 1.0), (4, 2.0), (7, 1.0)],
[(3, 1.0), (5, 1.0), (6, 1.0)],
[(9, 1.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: transformation則是用來將一種representation轉換成另一種。
Step2: 如果要取得原本corpus的vector,需要用tfidf model轉換一次。
Step3: 這個結果表示(0,2)-(2,3)的document,與文件[0]具有80%的相似度,和... |
14,701 | <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: tf.string 데이터 타입
Step3: tf.string 텐서는 바이트 문자열을 최소 단위로 다루기 때문에 다양한 길이의 바이트 문자열을 다룰 수 있습니다. 문자열 길이는 텐서 차원(dimensions)에 포함되지 않습니다... |
14,702 | <ASSISTANT_TASK:>
Python Code:
try:
import tinygp
except ImportError:
!pip install -q tinygp
from jax.config import config
config.update("jax_enable_x64", True)
import numpy as np
import matplotlib.pyplot as plt
try:
from statsmodels.datasets import co2
except ModuleNotFoundError:
%pip install -qq stat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data
Step2: Kernel
Step3: Model fitting
Step4: Using our loss function defined above, we'll run a gradient based optimization routine from sc... |
14,703 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset if ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
14,704 | <ASSISTANT_TASK:>
Python Code:
#Load necessary libraries
import tensorflow as tf
import numpy as np
import tensorflow.contrib.slim as slim
import input_data
import matplotlib.pyplot as plt
%matplotlib inline
def unpickle(file):
import cPickle
fo = open(file, 'rb')
dict = cPickle.load(fo)
fo.close()
... | <SYSTEM_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 Dataset
Step2: RegularNet
Step3: ResNet
Step4: HighwayNet
Step5: DenseNet
Step10: Visualize the network graph
Step11: Training
... |
14,705 | <ASSISTANT_TASK:>
Python Code:
# Import modules
import sys
import math
import numpy as np
from matplotlib import pyplot as plt
from scipy import linalg
def newton_divided_diff(X, Y, n):
V = {}
for j in range(n):
V[j, 0] = Y[j]
for i in range(1,n):
for j in range(n-i):
V[j, ... | <SYSTEM_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.1 Data And Interpolating Functions
Step2: Example
Step3: $$
Step4: Example
Step5: 3.4 Cubic Splines
Step6: Example
Step7: Example
Step9:... |
14,706 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas import Series, DataFrame
from numpy.random import normal
def create_dataset(num):
data_x = np.linspace(0,1,num)
data_y = np.sin(2*np.pi*data_x) + normal(loc=0, scale=0.3, size=num)
return data_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 練習問題
Step2: (2) (1)の関数について、xの値と、対応する「y = sin(2πx) + 正規分布の乱数(平均0, 標準偏差0.3)」の値を列に持つDataFrameを返すように修正してください。(列の名前は、それぞれ 'x' および 'y' とします。)
Step3: ... |
14,707 | <ASSISTANT_TASK:>
Python Code:
import ipywidgets
import IPython.display
import iris
import iris.plot as iplt
import matplotlib.pyplot as plt
from cube_browser import Contour, Browser, Contourf, Pcolormesh
cube = iris.load_cube(iris.sample_data_path('GloSea4/ensemble_001.pp'))
print cube
go_button = ipywidgets.Button(... | <SYSTEM_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 cube.
Step2: Construct button and display it. Then define what happens when you press the button and relate the function to the button-pr... |
14,708 | <ASSISTANT_TASK:>
Python Code:
var1 = 1 # interger
var2 = 2.34 # floating point numbers
var3 = 5.6 + 7.8j # complex numbers
var4 = "Hello World" # strings
var5 = True # booleans
var6 = None # special value to indicate the absence of a value
print("var1 value:", var1, "ty... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Containers
Step2: The elements of a list do not need to be of the same type
Step3: Elements can be added or removed from a list
Step4: Elemen... |
14,709 | <ASSISTANT_TASK:>
Python Code:
from statsmodels.tsa.stattools import coint, adfuller
import pandas as pd
fundamentals = init_fundamentals()
data = get_fundamentals(query(fundamentals.income_statement.total_revenue)
.filter((fundamentals.company_reference.primary_symbol == 'MCD') |
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Since $p > 0.05$, we cannot reject the hypothesis that the series has a unit root in any of these cases.
|
14,710 | <ASSISTANT_TASK:>
Python Code:
# Import TF 2.
%tensorflow_version 2.x
import tensorflow as tf
import numpy as np
import tensorflow.keras.backend as K
# Fix seed so that the results are reproducable.
tf.random.set_seed(0)
np.random.seed(0)
try:
import t3f
except ImportError:
# Install T3F if it's not already ins... | <SYSTEM_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 TT-Matrices we can compactly represent densely connected layers in neural networks, which allows us to greatly reduce number of parameters... |
14,711 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import tellurium as te
te.setDefaultPlottingEngine('matplotlib')
%matplotlib inline
import numpy as np
r = te.loada('S1 -> S2; k1*S1; k1 = 0.1; S1 = 40')
r.integrator = 'gillespie'
r.integrator.seed = 1234
results = []
for k in range(1, 50):
r.res... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Seed
Step2: Combining Simulations
|
14,712 | <ASSISTANT_TASK:>
Python Code:
1+1
?print
import time
tekst = "Matematika in Python"
for znak in tekst:
time.sleep(0.2)
print(znak,end='')
import disqus
%reload_ext disqus
%disqus matpy
<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: 3. naloga
Step2: Polje za diskusijo
|
14,713 | <ASSISTANT_TASK:>
Python Code:
palPhrase = ['r', 'i', 's', 'e', 't', 'o', 'v', 'o', 't', 'e', 's', 'i', 'r']
newLoopCnt = 0
print "==" * 2 + "direct (in-place modification) operations on the list" + "==" * 2
print "Length of the list : %d" %(len(palPhrase))
for ee in palPhrase:
print "Counter {0}".format(newLoopCnt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: *Scenario 2
|
14,714 | <ASSISTANT_TASK:>
Python Code:
import hail as hl
hl.init()
from hail.plot import show
from pprint import pprint
hl.plot.output_notebook()
hl.utils.get_1kg('data/')
hl.import_vcf('data/1kg.vcf.bgz').write('data/1kg.mt', overwrite=True)
mt = hl.read_matrix_table('data/1kg.mt')
mt.rows().select().show(5)
mt.row_key.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If the above cell ran without error, we're ready to go!
Step2: Download public 1000 Genomes data
Step3: Importing data from VCF
Step4: Next ... |
14,715 | <ASSISTANT_TASK:>
Python Code:
import pandas
from datetime import date
github = pandas.DataFrame.from_csv('../data/RPackage-Repositories-150101-150601.csv')
repositories = github[['owner.login', 'name']].rename(columns={'owner.login': 'owner', 'name': 'repositories'})
FILENAME = '../data/github-raw-150601.csv'
# Root ... | <SYSTEM_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 make use of the following commands
Step2: We will retrieve a lot of data, we can benefit from IPython's parallel computation tool.
|
14,716 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
np.random.seed(1234)
from scipy.ndimage.filters import convolve1d, gaussian_filter1d
from twpca import TWPCA
from twpca.regularizers import curvature
import itertools as itr
import seaborn as sns
sns.set_style("ticks")
%load_ext autoreload
%autoreload 2
n_time = 130
n_trial... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dataset options
Step2: Generate synthetic data
Step3: twPCA options
Step4: Construct and fit twPCA model
Step5: Visualize learned warping fu... |
14,717 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-2', 'aerosol')
# 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... |
14,718 | <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: tf.distribute.Strategy を使ってデータとモデルを準備します。
Step3: モデルをトレーニングします。
Step4: モデルを保存して読み込む
Step5: tf.distribute.Str... |
14,719 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
step = 10**(-3)
tol = 10**(-6)
length = 1/step
mouse = np.vstack((np.zeros(length-1), np.arange(0, 1-step, step)))
cat = np.zeros((2, length))
cat[0, 0] = 1 # x-Koordinate der Katze zum Zeitpunkt 0, Anfangswert
for 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: Die Differentialgleichung lautet
Step2: vstack schachtelt zwei arrays übereinander. Die Maus hat in der x-Koordinate (1. Zeile) immer 0 und die... |
14,720 | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
from starthinker.util.configuration import Configuration
CONFIG = Configuration(
project="",
client={},
service={},
user="/content/user.json",
verbose=True
)
FIELDS = {
'auth_write':'service', # Credentials used for wri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Set Configuration
Step2: 3. Enter BigQuery Query Run Recipe Parameters
Step3: 4. Execute BigQuery Query Run
|
14,721 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import rcParams
import matplotlib.pyplot as plt
%matplotlib inline
rcParams['figure.figsize'] = (13, 6)
plt.style.use('ggplot')
from nilmtk import DataSet
gjw = DataSet('/Users/GJWood/nilm_gjw_data/HDF5/nilm_gjw_data.hdf5') #load the data from HDF5 file
gjw.set_window(sta... | <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 Imports and graph setup
Step1: Step-2 Import the data and extract the part you are interested in
Step2: Step-3 Plot the data from the dataframe... |
14,722 | <ASSISTANT_TASK:>
Python Code:
# Author: Roman Goj <roman.goj@gmail.com>
# Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import mne
from mne.datasets import sample
from mne.time_frequency import csd_epochs
from mne.beamformer import dics_source_power
print(__doc__)
data_path = sample.dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read raw data
|
14,723 | <ASSISTANT_TASK:>
Python Code:
newsgroups = datasets.fetch_20newsgroups(
subset='all',
categories=['alt.atheism', 'sci.space']
)
X = newsgroups.data
y = newsgroups.target
print("targets: ", y)
print("target_names: ", newsgroups.target_names)
print("Extracting feat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. После выполнения этого кода массив с текстами будет находиться в поле newsgroups.data, номер класса — в поле newsgroups.target.
Step2: 3. Од... |
14,724 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import numpy as np
import keras
from keras.datasets import mnist
from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, Flatten, Activation, Input
from keras.layers import Conv2D, MaxPooling2D
from keras import backend 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: Saliency
Step2: Time for saliency visualization.
Step3: To used guided saliency, we need to set backprop_modifier='guided'. For rectified sali... |
14,725 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.version
import warnings
warnings.simplefilter('ignore', FutureWarning)
from pandas import *
show_versions()
YEAR = 2013
GDP_INDICATOR = 'NY.GDP.MKTP.CD'
LIFE_INDICATOR = 'SP.DYN.LE00.IN'
gdpReset = read_csv('WB GDP 2013.csv')
gdpReset.head()
lifeReset = read_csv('WB LE 201... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting the data
Step2: Cleaning the data
Step3: Transforming the data
Step4: The unnecessary columns can be dropped.
Step5: The World Bank ... |
14,726 | <ASSISTANT_TASK:>
Python Code:
%cd -q '..'
import mido
import copy
from commons import mido_util
from commons import timers
from commons.messages import controlstate, controls
def collector(state=None):
if state is None:
newstate = controlstate.MidiControlState()
else:
newstate = copy.deepcopy(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We want a way to grab the messages with the appropriate time, put them in a list, also print them out as they arrive, except for the clock ones,... |
14,727 | <ASSISTANT_TASK:>
Python Code:
%%bq query --name texi_query_eval
SELECT
unique_key,
fare,
CAST(EXTRACT(DAYOFWEEK FROM trip_start_timestamp) AS STRING) as weekday,
CAST(EXTRACT(DAYOFYEAR FROM trip_start_timestamp) AS STRING) as day,
CAST(EXTRACT(HOUR FROM trip_start_timestamp) AS STRING) as hour,
pickup_lati... | <SYSTEM_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 "chicago_taxi.train" and "chicago_taxi.eval" BQ tables to store results.
Step2: Sanity check on the data.
Step3: Explore Data
Step4: S... |
14,728 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install -U google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if not os.getenv("IS_TESTING... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
14,729 | <ASSISTANT_TASK:>
Python Code:
import MySQLdb
conn = MySQLdb.connect(user = 'root',passwd = 'root',host = '127.0.0.1')
cur = conn.cursor()
conn.select_db('info')
sql = 'insert into person(name,age) values("Zhangsan",34)' # 组装sql
cur.execute(sql) # 执行sql
conn.commit() # 提交,如果没有这句,更改不会生效
cur.close()
conn.close() ... | <SYSTEM_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: 注:MySQLdb.connect()函数可以接收的常用的几个参数:
Step3: 设置当前数据库为info:
Step4: 注:不建议在python中操作数据库创建表。
Step5: 此时去mysql中,进入info数据库,查询:select... |
14,730 | <ASSISTANT_TASK:>
Python Code:
# Run some setup code for this notebook.
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
from __future__ import print_function
# This is a bit of magic to make matplotlib figures appear inline in the notebook
# rather than in a 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: We would now like to classify the test data with the kNN classifier. Recall that we can break down this process into two steps
Step2: Inline Qu... |
14,731 | <ASSISTANT_TASK:>
Python Code:
import wsynphot
# wsynphot.download_filter_data()
# wsynphot.update_filter_data()
wsynphot.list_filters()
filter = wsynphot.FilterCurve.load_filter('Keck/NIRC2/Kp')
filter
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (9,6)
filter.plot(plt.gca())... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting filter data ready to use
Step2: This will cache the filter data on your disk so that everytime you call any wsynphot function like list... |
14,732 | <ASSISTANT_TASK:>
Python Code:
st = p.Storage('mstis.nc', mode='r')
scheme = st.schemes.first
reload(vis)
builder = vis.MoveTreeBuilder.from_scheme(scheme)
builder.options.analysis['only_canonical'] = False
SVG(builder.svg())
minimal = dict(scheme.root_mover.in_out.ins_minimal)
minimal
all(ens in minimal for ens ... | <SYSTEM_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 first (and only) scheme we used in the process. We want to have a look at what it does.
Step2: Create the builder using a factory func... |
14,733 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as sp
from numpy import pi, sin, cos, linspace, exp, real, imag, abs, conj, meshgrid, log, log10, angle, zeros, complex128, random
from numpy.fft import fft, fftshift, ifft
from mpl_toolkits.mplot3d import axes3d
import... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: Double-slit correlation model
Step5: Define a single function to explore the FFT
Step6: Replace with Gaussian LO
Step7: Adding different phas... |
14,734 | <ASSISTANT_TASK:>
Python Code:
import git
GIT_REPO_PATH = r'../../spring-petclinic/'
repo = git.Repo(GIT_REPO_PATH)
git_bin = repo.git
git_bin
git_log = git_bin.execute('git log --numstat --pretty=format:"\t\t\t%h\t%at\t%aN"')
git_log[:80]
import pandas as pd
from io import StringIO
commits_raw = pd.read_csv(StringI... | <SYSTEM_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 the <tt>git_bin</tt>, we can execute almost any Git command we like directly. In our hypothetical use case, we want to retrieve some inform... |
14,735 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input 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: The base catalog
Step2: Target_Name is the name of the (central) object at each observation, from that we see we have 681 unique sources out of... |
14,736 | <ASSISTANT_TASK:>
Python Code:
%pycat demoslave.py
!pythonfmu build -f ./demoslave.py --no-external-tool
!pythonfmu build -h
%matplotlib inline
from pyfmi import load_fmu
import matplotlib.pyplot as p
import numpy
model = load_fmu('Resistor.fmu')
inputs = ('positive_pin_v', lambda t: 20 + 5. * numpy.cos(t))
res = mo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate the FMU
Step2: The mandatory information to pass to the builder is the Python script file through the -f option.
Step3: Use the FMU
... |
14,737 | <ASSISTANT_TASK:>
Python Code:
# first, let's import the packages we need
import requests
from io import StringIO
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import model_selection
# import the Civis Python API client
import civis
# ModelPipeline is the clas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Downloading data
Step2: Data Munging
Step3: Some of these columns are duplicates, or contain information we don't want to use in our model (li... |
14,738 | <ASSISTANT_TASK:>
Python Code:
## Constants used by this program
CONSONANTS = "bcdfghjklmnpqrstvwyz"
VOWELS = "aeiou"
def convert_pin(pin):
pin1 = pin.pop()
pass
pin1 = pi
pin = '2363'
pin1 = list(pin)
def remove_end(g):
# %load test_foo.py
from nose.tools import assert_equal
class Testconvert_pin(obje... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Unit Test
|
14,739 | <ASSISTANT_TASK:>
Python Code:
import diplib as dip
import random
import numpy as np
def generate_images(overlap):
sd = 0.001 # noise std. dev.
sz = 5.0 # size of dot (sigma of Gaussian)
scale = sz*sz*2*3.14159
channel1 = dip.Image([256,256], 1, 'SFLOAT')
channel2 = dip.Image([256,256], 1, 'SFLOAT'... | <SYSTEM_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 function creates two test images composed of blobs, with a fraction overlap of the dots overlapping.
Step2: Let's test see what these imag... |
14,740 | <ASSISTANT_TASK:>
Python Code:
from astropy.io import ascii, fits
import pylab as plt
%matplotlib inline
from astropy import wcs
import numpy as np
import xidplus
from xidplus import moc_routines
import pickle
xidplus.__path__[0]
#Folder containing maps
imfolder=xidplus.__path__[0]+'/../test_files/'
pswfits=imfolder+'... | <SYSTEM_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 image and catalogue filenames
Step2: Load in images, noise maps, header info and WCS information
Step3: Load in catalogue you want to fit ... |
14,741 | <ASSISTANT_TASK:>
Python Code:
import json
import requests
# URL
URL = 'https://information.stpaul.gov/resource/rfbb-x7za.json'
# use the json() method, which converts the json into Python objects
vb_data = requests.get(URL).json()
# print to see what we're working with
print(vb_data)
sfr_vb = [x for x in vb_data if ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fetch the page and get the JSON
Step2: Filter the data
|
14,742 | <ASSISTANT_TASK:>
Python Code:
a = ['abc', 'hdok', 'banc', 'xkm', 'pckdax']
#b = a[::-1]
b= []
for i in a:
if (len(i) > 3):
b.append(i)
b = b[::-1]
b
a = [[1,2,3], [4,5], [6]]
numpy.hstack((a[0],a[1],a[2]))
d = {'a': 'b', 'c': 'd', 'e': 'f'}
{v: k for k, v in d.items()}
a = numpy.array([[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: Задача 2
Step2: Задача 3
Step3: Задача 4
Step4: Задача 5
|
14,743 | <ASSISTANT_TASK:>
Python Code:
5 / 3
5 % 3
import numpy as np
value = 4
is_prime = True
upper = int(np.ceil(np.sqrt(value)))
for divisor in range(2, upper+1):
if value % divisor == 0:
is_prime = False
break
print(is_prime)
value = 4
def isPrime(value):
is_prime = True
upper = int(np.ceil(np.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Put the function in a python module
|
14,744 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bcc', 'sandbox-1', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
14,745 | <ASSISTANT_TASK:>
Python Code:
%%capture
#@title
import os
import sys
import tensorflow as tf
# Download source code.
if "efficientdet" not in os.getcwd():
!git clone --depth 1 https://github.com/google/automl
os.chdir('automl/efficientdet')
sys.path.append('.')
!pip install -r requirements.txt
!pip install -... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 0.2 View graph in TensorBoard
Step2: 1. inference
Step3: 1.2 Benchmark end-to-end latency
Step4: 1.3 Inference images.
Step5: 1.4 Inference ... |
14,746 | <ASSISTANT_TASK:>
Python Code:
workDir = '/home/nick/notebook/SIPSim/dev/bac_genome1147/validation_rep3/'
genomeDir = '/var/seq_data/ncbi_db/genome/Jan2016/bac_complete_spec-rep1_rn/'
R_dir = '/home/nick/notebook/SIPSim/lib/R/'
figureDir = '/home/nick/notebook/SIPSim/figures/bac_genome_n1147/'
bandwidth = 0.8
DBL_scali... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Init
Step2: Simulating fragments
Step3: Number of amplicons per taxon
Step4: Converting fragments to kde object
Step5: Checking ampfrag info... |
14,747 | <ASSISTANT_TASK:>
Python Code:
DATA = "data/ieee-xplore.csv"
def load_data(path=DATA):
with open(path, 'r') as f:
reader = csv.DictReader(f)
for row in reader:
row['Tokenized Abstract'] = tokenize(row['Abstract'])
yield row
def tokenize(text):
return [
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: Key Phrase Extraction
Step4: Clustering Documents
Step5: LDA
|
14,748 | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import exists
filename = 'modsim.py'
if not exists(filename):
from urllib.request import urlretrieve
url = 'https://raw.githubusercontent.com/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: This chapter presents a simple model of a bike share system and
Step2: The expressions in parentheses are keyword arguments.
Step3: And this
S... |
14,749 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from scipy import io as spio
a = np.ones((3, 3)) # creamos una matriz de 3x3
spio.savemat('archivo.mat', # nombre del archivo
{'a': a}) # asignamos y referenciamos el nombre con un diccionario
%ls *.mat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: File input/output
Step2: Así de sencillo, ya hemos "exportado" los valores de la variable 'a' a un archivo en formato *.mat.
Step3: Imaginemos... |
14,750 | <ASSISTANT_TASK:>
Python Code:
def align_to_lb_score(df):
# https://www.kaggle.com/c/sberbank-russian-housing-market/discussion/32717
df = df.copy()
trainsub = df[df.timestamp < '2015-01-01']
trainsub = trainsub[trainsub.product_type=="Investment"]
ind_1m = trainsub[trainsub.price_doc <= 1000000].in... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Обучение моделей
Step2: XGBoost
Step3: LightGBM
Step4: Vowpal Wabbit
Step5: Lasso
Step6: Submission
Step7: XGBoost
Step8: LightGBM
Step9:... |
14,751 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
data_path = mne.datasets.sample.data_path()
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)
print(evoked)
evoked_l_aud ... | <SYSTEM_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 tutorial we focus on plotting functions of
Step2: Notice that evoked is a list of evoked instances. You can read only one
Step3: Let'... |
14,752 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
diva=np.load('borg_sdss_diva.npz')
#3D probabilistic maps for DIVA structures
voids=diva['voids']
sheets=diva['sheets']
filaments=diva['filaments']
clusters=diva['clusters']
k=10;j=127;i=243
voids_ijk=voids[k,j,i]
#Minimum and maximum position along the x-axis in Mpc... | <SYSTEM_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 access the 3D structure maps use
Step2: Individual voxels in this 3D volumetric data cube can be accessed as follows
Step3: where i,j and k... |
14,753 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
#%config InlineBackend.figure_format = 'pdf'
import freqopttest.util as util
import freqopttest.data as data
import freqopttest.ex.exglobal as exglo
import freqopttest.kernel as kernel
impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plot simple 2d data
Step2: Plot blobs dataset
Step3: Oral presentation
Step4: $H_0/H_1$ distributions
Step5: Test power highlight
Step6: Ty... |
14,754 | <ASSISTANT_TASK:>
Python Code:
from pynq import Overlay
from pynq.drivers import Frame, HDMI
from IPython.display import Image
Overlay('base.bit').download()
hdmi=HDMI('in')
hdmi.start()
frame = hdmi.frame()
orig_img_path = '/home/xilinx/jupyter_notebooks/examples/data/orig.jpg'
frame.save_as_jpeg(orig_img_path)
Image... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Save frame and display JPG
Step2: 3. Gray Scale filter
Step3: 4. Sobel filter
Step4: 5
|
14,755 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-3', 'ocnbgchem')
# 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... |
14,756 | <ASSISTANT_TASK:>
Python Code:
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import pandas as pd
from metpy.calc import wind_components
from metpy.cbook import get_test_data
from metpy.plots import (add_metpy_logo, simple_layout, StationPlot, StationPlotLayout,
... | <SYSTEM_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 setup
Step2: This sample data has way too many stations to plot all of them. Instead, we just select
Step3: Next grab the simple variables... |
14,757 | <ASSISTANT_TASK:>
Python Code:
%sx ls html/
file = "html/article1.html"
print(open(file, "r").readlines())
from bs4 import BeautifulSoup
with open(file, "r") as f:
soup = BeautifulSoup(f, "html.parser")
for div in soup.find_all("div", id="article-body"):
for p in div.find_all("p"):
print(p.get_text(), "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Select one of those files to use as an example, and take a look at its HTML content.
Step2: Next, use Beautiful Soup to extract text out of the... |
14,758 | <ASSISTANT_TASK:>
Python Code:
x = [i for i in range(-10,10)]
#print(x)
def sigmoid(num):
return 1.0 / (1.0 + np.exp(-num))
plt.plot(range(-10,10), [sigmoid(i) for i in x])
plt.show()
from IPython.display import YouTubeVideo
YouTubeVideo('29PmNG7fuuM', width="560")
# Defining the sigmoid function for activations
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: Gradient descent
Step3: simple Gradient descent exercise
Step4: Implementing gradient descent
Step6: the actual implmentation
Step8: Multila... |
14,759 | <ASSISTANT_TASK:>
Python Code:
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
cloudantdata = spark.read.format("org.apache.bahir.cloudant")\
.option("cloudant.host","xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-bluemix.cloudant.com")\
.option("cloudant.username", "xxxxxxxx-xxxx-xxxx-xx... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Work with a Cloudant database
Step2: 3. Work with a Dataframe
Step3: 4. Generate visualizations
|
14,760 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
# RMS Titanic data visualization code
from titanic_visualizations import survival_stats
from IPython.display import display
%matplotlib inline
# Load the dataset
in_file = 'titanic_data.csv'
full_data = pd.read_csv(in_file)
# Print the first few ent... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship
Step3: The very same sample of th... |
14,761 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pylab as pl
import ot
import ot.plot
#%% parameters
n = 100 # nb bins
# bin positions
x = np.arange(n, dtype=np.float64)
# Gaussian distributions
a = ot.datasets.make_1D_gauss(n, m=20, s=5) # m= mean, s= std
b = ot.datasets.make_1D_gauss(n, m=60, 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: Generate data
Step2: Solve EMD
Step3: Solve EMD with Frobenius norm regularization
Step4: Solve EMD with entropic regularization
Step5: Solv... |
14,762 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import re
import matplotlib.pyplot as plt
def memory_function(infile, dataset):
with open(infile, 'r') as mem:
lines = mem.readlines()
testar = np.asarray([line.strip() for line in lines]).astype(float)/1000
fig=plt.figure()
ax... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: HNU Dataset
Step2: DC1 Dataset
|
14,763 | <ASSISTANT_TASK:>
Python Code:
import lipd
lipd.quit()
# Read File - GUI
lipd.readLipd()
lipd.readExcel()
lipd.readNoaa()
# Read File - with path argument - no GUI
lipd.readLipd("/path/to/file.lpd")
lipd.readExcel("/path/to/file.xls")
lipd.readNoaa("/path/to/file.txt")
# Read Directory - GUI
lipd.readLipds()
lipd.rea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Quitting <a id="lipdquit"></a>
Step2: Reading Files<a id="lipdread"></a>
Step3: Excel Spreadsheet Converter <a id="excel"></a>
Step4: NOAA Co... |
14,764 | <ASSISTANT_TASK:>
Python Code:
# importing
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import matplotlib
# showing figures inline
%matplotlib inline
# plotting options
font = {'size' : 22}
plt.rc('font', **font)
plt.rc('text', usetex=matplotlib.checkdep_usetex(True))
matplotlib.rc('fig... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Function for determining the impulse response of an RRC filter
Step2: Parameters
Step3: Define channel characteristics and get channel impulse... |
14,765 | <ASSISTANT_TASK:>
Python Code:
import random
def single_die():
Outcome of a single die roll
return random.randint(1,6)
for _ in range(50):
print(single_die(),end=' ')
def dice_roll(dice_count):
Outcome of a rolling dice_count dice
Args:
dice_count (int): number of dice to roll
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dice Simulaiton
Step2: Check
Step4: Multiple Dice Roll
Step5: Check
Step7: Capture the outcome of multiple rolls
Step9: Plot Result
Step10:... |
14,766 | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import exists
filename = 'modsim.py'
if not exists(filename):
from urllib.request import urlretrieve
url = 'https://raw.githubusercontent.com/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:
Step4: Code from previous chapters
Step5: In the previous chapters I presented an SIR model of infectious disease, specifically the Kermack-McKendrick... |
14,767 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import NMF
from sklearn.pipeline import Pipeline
import pandas as pd
data = load_data()
pipe = Pipeline([
("tf_idf", TfidfVectorizer()),
("nmf", NMF())
])
pipe.fit_transform(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:
|
14,768 | <ASSISTANT_TASK:>
Python Code:
from sklearn.cluster import KMeans
import numpy as np
import bokeh.plotting
from bokeh.plotting import figure
from sklearn import datasets
# the iris dataset is 150 samples, each with four features
# we only want petal length and petal width
iris = datasets.load_iris()
# get only petal 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: Let's load our Iris data set
Step2: Perform k-means analysis on iris data
Step3: Let's initialize Bokeh
|
14,769 | <ASSISTANT_TASK:>
Python Code:
import subprocess
import ipyrad as ip
import shutil
import glob
import sys
import os
## Set the default directories for exec and data.
WORK_DIR="/home/iovercast/manuscript-analysis/"
REFMAP_EMPIRICAL_DIR=os.path.join(WORK_DIR, "Phocoena_empirical/")
REFMAP_FASTQS=os.path.join(REFMAP_EMPI... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simulated reference sequence mapping
Step2: Do ipyrad simulated reference mapping
Step3: Do ipyrad denovo+reference
Step4: Do ipyrad denovo-r... |
14,770 | <ASSISTANT_TASK:>
Python Code:
import wicked as w
from IPython.display import display, Math, Latex
def latex(expr):
Function to render any object that has a member latex() function
display(Math(expr.latex()))
w.reset_space()
w.add_space("o", "fermion", "occupied", ['i','j','k','l','m'])
w.add_space("v", "fermio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Algebraic expressions and the inner workings of Wick&d
Step2: Orbital indices
Step3: Indices have two attributes, the orbital space and positi... |
14,771 | <ASSISTANT_TASK:>
Python Code:
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
from collections import defaultdict
from gensim import corpora
documents = [
"Human machine interface for lab abc computer applications",
"A survey of user opinion of comput... | <SYSTEM_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 tutorial, I will show how to transform documents from one vector representation
Step2: Creating a transformation
Step3: We used our ol... |
14,772 | <ASSISTANT_TASK:>
Python Code:
pip_arg_xp_man = '-e git+https://github.com/wschuell/experiment_manager.git@origin/master#egg=experiment_manager'
#ssh: pip_arg_xp_man = '-e git+ssh://git@github.com/wschuell/experiment_manager.git@master#egg=experiment_manager'
try:
import experiment_manager as xp_man
except ImportEr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Job Queues
Step2: The requirements section tells job queues to install a version of the library on the cluster if it does not exist yet. You ca... |
14,773 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
import os
import googleapiclient.discovery
import shutil
from google.cloud import bigquery
from google.api_core.client_options import ClientOptions
from matplotlib import pyplot as plt
import numpy as np
import tensorflow ... | <SYSTEM_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... |
14,774 | <ASSISTANT_TASK:>
Python Code:
import openpathsampling as paths
import openmmtools as omt
import simtk.openmm as omm
import simtk.unit as u
import mdtraj as md
import openpathsampling.engines.openmm as eng
from __future__ import print_function
testsystem = omt.testsystems.AlanineDipeptideVacuum()
#! skip
{ key: type(... | <SYSTEM_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 Alanine in Vacuum and run it using OPS.
Step2: Let's have a look at the content
Step3: An OpenMM simulation in OPS needs 3 ingredients ... |
14,775 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
vp_path = os.path.abspath('../../')
if not vp_path in sys.path:
sys.path.append(vp_path)
import vampyre as vp
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
# Parameters
nz = 1000 # number of components of z
ny = 500 ... | <SYSTEM_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 also load the other packages we will use in this demo. This could be done before the above import.
Step2: Generating Synthetic Data
St... |
14,776 | <ASSISTANT_TASK:>
Python Code:
# Import the libraries and set random seed
from torch import nn
import torch
import numpy as np
import matplotlib.pyplot as plt
from torch import nn,optim
from torch.utils.data import Dataset, DataLoader
torch.manual_seed(1)
# Create Data Class
class Data(Dataset):
# Constructor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <!--Empty Space for separating topics-->
Step2: We create two objects, one that contains training data and a second that contains validation da... |
14,777 | <ASSISTANT_TASK:>
Python Code:
text_root = '../../data/EmbryoProjectTexts/files'
try:
assert os.path.exists(text_root)
except AssertionError:
print "That directory doesn't exist!"
documents = nltk.corpus.PlaintextCorpusReader(text_root, 'https.+')
documents.words()
wordnet = nltk.WordNetLemmatizer()
from nltk.... | <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: Normalization and Filtering
Step4: Simple frequency distributions
Step5: In the figure above, we can see that the top ~40 words occur in aroun... |
14,778 | <ASSISTANT_TASK:>
Python Code:
from minimal_example_interface import *
def multiplicative_term(kappa_val,r_array,cue_array):
assert(type(kappa_val)==float or type(kappa_val)==int)
assert(type(r_array)==np.ndarray)
assert(type(cue_array)==np.ndarray)
return({"kappa": kappa_val, "r": r_array,"cue": c... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can then create variables to represent each term and then calculate their value
Step2: We can write this out mathematically
Step3: You can ... |
14,779 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sys
import os
import shutil
import numpy as np
from subprocess import check_output
# Import flopy
import flopy
# Set the name of the path to the model working directory
dirname = "P4-1_Toth"
datapath = os.getcwd()
modelpath = os.path.join(datapath, dirname)
prin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup a New Directory and Change Paths
Step2: Define the Model Extent, Grid Resolution, and Characteristics
Step3: Create the MODFLOW Model Ob... |
14,780 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.linalg as spla
%matplotlib inline
# https://scikit-learn.org/stable/modules/classes.html#module-sklearn.datasets
from sklearn import datasets
import ipywidgets as widgets
from ipywidgets import interact, interact_manual
impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <div id='intro' />
Step2: We clearly observe that the least square solutions are different!
|
14,781 | <ASSISTANT_TASK:>
Python Code:
# coding: utf-8
import re
def getwords(doc):
splitter = re.compile('\\W*')
# Split the words by non-alpha characters
words = [s.lower() for s in splitter.split(doc) if len(s) > 2 and len(s) < 20]
#print words # usamos isso para checar o split depois
# retorn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step11: Esta função divide um string partindo em cada coisa que não é uma letra e convertendo para minúsculo.
Step12: Vamos checar os helpers?
Step13:... |
14,782 | <ASSISTANT_TASK:>
Python Code:
def sort(L):
if L == []:
return []
x = min(L)
return [x] + sort(delete(x, L))
def delete(x, L):
assert L != [], f'delete({x}, [])'
y, *R = L
if y == x:
return R
return [y] + delete(x, R)
L = [3, 5, 7, 4, 8, 1, 2, 3, 11, 13, 2]
sort(L)
<END_TAS... | <SYSTEM_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 algorithm to delete an element $x$ from a list $L$ is formulated recursively. There are three
|
14,783 | <ASSISTANT_TASK:>
Python Code:
!sudo pip install deap update_checker tqdm xgboost tpot
import pandas as pd
import numpy as np
import psycopg2
import os
import json
from tpot import TPOTClassifier
from sklearn.metrics import classification_report
conn = psycopg2.connect(
user = os.environ['REDSHIFT_USER']
,pas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TPOT uses a genetic algorithm (implemented with DEAP library) to pick an optimal pipeline for a regression task.
Step2: Sklearn model
Step3: T... |
14,784 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, absolute_import, division
import ionize
# We'll also import numpy to set up some of our inputs.
# And pprint to prettily print some lists.
import numpy
import pprint
# And set up inline plotting.
from matplotlib.pyplot import *
%matplotlib inline
# ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ion
Step2: Once an ion species is initialized, you can call the properties of the ion, typically as a function of pH, ionic strength, and tempe... |
14,785 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("whitegrid")
from IPython.display import Image
Image(filename='batcheactor.png', width=300)
#The model consist of differential equations, which needs integration... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Case study
Step2: <i><b>Caption
Step3: Observations
Step4: Emcee hammer
Step7: Applying emcee Hammer
Step8: Likelihood function (probabilit... |
14,786 | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
from starthinker.util.configuration import Configuration
CONFIG = Configuration(
project="",
client={},
service={},
user="/content/user.json",
verbose=True
)
FIELDS = {
'auth_read':'user', # Credentials used for reading... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Set Configuration
Step2: 3. Enter CM360 Report To Storage Recipe Parameters
Step3: 4. Execute CM360 Report To Storage
|
14,787 | <ASSISTANT_TASK:>
Python Code:
import pints
import pints.toy
import numpy as np
import matplotlib.pyplot as plt
# Create log pdf
log_pdf = pints.toy.TwistedGaussianLogPDF(dimension=2)
# Contour plot of pdf
levels = np.linspace(-50, -1, 20)
x = np.linspace(-50, 50, 250)
y = np.linspace(-100, 20, 250)
X, Y = np.meshgrid(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can also sample independently from this toy LogPDF, and add that to the visualisation
Step2: We now try to sample from the distribution with... |
14,788 | <ASSISTANT_TASK:>
Python Code:
import os
try:
import cPickle as pickle
except ImportError:
import pickle
run_name = '2014-07-07'
fname = os.path.join(run_name, 'config.pkl')
with open(fname, 'rb') as f:
config = pickle.load(f)
import numpy as np
from pandas import DataFrame, read_csv
from utilities import (... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Skill 1
Step2: Skill 2
Step3: Skill 3
Step4: Skill 4
Step5: Skill 4
Step6: Save scores
Step7: Normalized Taylor diagrams
|
14,789 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
import os
filename = "bigdata/A201612_small.csv"
# pour travailler avec un fichier plus gros (4 Go)
# filename = "bigdata/A201612.csv"
xlsfile = "bigdata/Lexique_open-DAMIR.xls"
if not os.path.exists(filen... | <SYSTEM_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 données
Step2: Il est impossible de le charger en mémoire en entier. On regarde les premières lignes.
Step3: On calcule le nombre de ligne... |
14,790 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
# Create a Constant op that produces a 1x2 matrix. The op is
# added as a node to the default graph.
#
# The value returned by the constructor represents the output
# of the Constant op.
matrix1 = tf.constant([[3., 3.]])
# Create another Constant that produces a 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: Launching the graph in a session
Step2: Sessions should be closed to release resources. You can also enter a Session with a "with" block. The S... |
14,791 | <ASSISTANT_TASK:>
Python Code:
import ndio.remote.OCP as OCP
oo = OCP()
token = "kasthuri2015_ramon_v1"
mito_cutout = oo.get_cutout(token, 'mitochondria', 694, 1794, 1750, 2460, 1004, 1379, resolution=3)
import ndio.utils.stats as ndstats
c, f = ndstats.connected_components(mito_cutout)
print "There are {} mitochondr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can count annotated mitochondria by referencing the mitochondria channel
Step2: We can now use the built-in connected-components to count mi... |
14,792 | <ASSISTANT_TASK:>
Python Code:
kobe = pd.read_csv('../data/kobe.csv')
[(col, dtype) for col, dtype in zip(kobe.columns, kobe.dtypes) if dtype != 'object']
num_columns = [col for col, dtype in zip(kobe.columns, kobe.dtypes) if dtype != 'object']
num_columns
kobe = kobe
import seaborn as sns
import matplotlib.pyplot 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: For now, use just the numerical datatypes. They are below as num_columns
Step2: The shot_made_flag is the result (0 or 1) of the shot that Kobe... |
14,793 | <ASSISTANT_TASK:>
Python Code:
from rmtk.vulnerability.derivation_fragility.R_mu_T_no_dispersion.dolsek_fajfar import DF2004
from rmtk.vulnerability.common import utils
%matplotlib inline
capacity_curves_file = "../../../../../../rmtk_data/capacity_curves_Vb-dfloor.csv"
input_spectrum = "../../../../../../rmtk_data/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: Load capacity curves
Step2: Idealise pushover curves
Step3: Load damage state thresholds
Step4: Calculate fragility functions
Step5: Plot fr... |
14,794 | <ASSISTANT_TASK:>
Python Code:
# Load Biospytial modules and etc.
%matplotlib inline
import sys
sys.path.append('/apps')
sys.path.append('..')
sys.path.append('../spystats')
import django
django.setup()
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
## Use the ggplot style
plt.style.use('ggplot'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Use this to automate the process. Be carefull it can overwrite current results
Step2: Now we will obtain the data from the calculated empirical... |
14,795 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# your code here
# our solution
from solutions import *
decrypt_solution(solution_regression_1, 'foo')
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# your code here
# our solution
from solution... | <SYSTEM_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 linear regression for datapoint matrix $X$ ($D \times N$, D datapoints and N input dimensions) and target matrix $Y$ ($D \times M$, D datapoin... |
14,796 | <ASSISTANT_TASK:>
Python Code:
import theano
import os, sys
sys.path.insert(1, os.path.join('utils'))
%matplotlib inline
from __future__ import print_function, division
path = "data/statefarm/"
import utils; reload(utils)
from utils import *
from IPython.display import FileLink
# batch_size=32
batch_size=16
batches = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup Batches
Step2: Rather than using batches, we could just import all the data into an array to save some processing time. (In mose examples... |
14,797 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.html.widgets import interact
from sklearn.datasets import load_digits
from IPython.display import Image, display
digits = load_digits()
print(digits.data.shape)
def show_examples(i):
plt.matshow(digits.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Our network will be comprised of a list of numpy arrays with each array containing the weights and bias for that layer of perceptions.
Step2: C... |
14,798 | <ASSISTANT_TASK:>
Python Code:
plot_both(['bicultural', 'biracial', 'biethnic', 'interracial'])
plt.xlim(1910, 2015)
plot_both(['multicultural', 'multiracial', 'multiethnic', 'polycultural', 'polyracial', 'polyethnic'])
plt.xlim(1950, 2015)
plot_both(['mixed race', 'mixed ethnicity', 'other race', 'other ethnicity'])... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: biethnic has no frequency in NYT
Step2: polyracial and polyethnic have no frequencies in the NYT
Step3: mixed ethnicity barely has a frequency... |
14,799 | <ASSISTANT_TASK:>
Python Code:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(command_executor='http://192.168.99.101:4444/wd/hub',
desired_capabilities=DesiredCapabilities.CHROME)
driver.get("http://www.yelp.com")
image =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TD;DR
Step2: Here you can see that the render of the website is correct and in my case it pointed me to the Austin website.
Step3: So now I kn... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.