Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
5,100 | <ASSISTANT_TASK:>
Python Code:
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
import numpy
import pickle
from dscribe.descriptors import MBTR
from visualise import view
dataIn = numpy.genfromtxt('./data/wineInputs.txt', delimiter=',')
dataOut = numpy.genfromtxt('./data/wineOutputs.txt', delimiter=',... | <SYSTEM_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 are going to apply this technique to a database of wine samples. The inputs are 13 chemical descriptors, the output is the index of its class... |
5,101 | <ASSISTANT_TASK:>
Python Code:
import deltascope.alignment as ut
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import h5py
import os
import re
import time
import tqdm
# --------------------------------
# -------- User input ------------
# --------------------------------
param = {
'gthresh... | <SYSTEM_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
Step2: Directories
Step3: Extract list of files
Step4: Import raw data and perform preprocessing
Step5: Example alignment
Step6: Proc... |
5,102 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings("ignore")
import pandas as pd
import numpy as np
from scipy.stats import spearmanr, pearsonr
from statsmodels.sandbox.stats.multicomp import multipletests
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LassoLar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Spearman correlation
Step2: correlation
Step3: OHVD3
Step4: OHV1D3
Step5: OHV24D3
Step6: ratio_activation
Step7: ratio_catabolism
Step8: ... |
5,103 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
from LAPM import *
from LAPM.linear_autonomous_pool_model import LinearAutonomousPoolModel
B=Matrix([[-2.927714, 0, 0, 0, 0, 0, 0.000000],
[0, -14.560, 0, 0, 0, 0, 0],
[0, 0, -3.6211195, 0, 0, 0, 0],
[0, 0, 0, -... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the second line above, we imported also the linear_autonomous_pool_model module which contains most of the functions required for the example... |
5,104 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
E = [10, 15, 7, 19, 2, 5, 7, 16, 3, 9, 15, 0, 1, 15, 6, 11, 0, 14, 7, 9]
E
def plus_grande_sequence_position_k(E, k=None):
if k is None:
k = len(E)-1
if k == 0:
return [[0]]
else :
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: L'algorithme optimal est exposé en dernier, la correction propose un cheminement jusqu'à cette solution en introduisant au fur et à mesure les i... |
5,105 | <ASSISTANT_TASK:>
Python Code:
# Import python modules
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
# Import the NuPyCEE codes
from NuPyCEE import sygma
from NuPyCEE import omega
# Number of timesteps in the simulaton.
# See https://github.com/NuGrid/NuPyCEE/blob/master/DOC/Capabilities/Timeste... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Input Parameters
Step2: Run SYGMA
Step3: Plot results
Step4: 3. Multiple Decay Channels
Step5: Example with U-238
Step6: In the case of ... |
5,106 | <ASSISTANT_TASK:>
Python Code:
import rdflib
import networkx as nx
import os
rdf_path = 'data/example.rdf'
with open(rdf_path, 'r') as f:
corrected = f.read().replace('rdf:resource rdf:resource',
'link:link rdf:resource')
# The corrected graph will be saved to a file with `_correct... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Correct Zotero RDF
Step2: Parse RDF
Step3: Create a GraphML file
Step4: The code-cell below will create a new GraphML file that we can import... |
5,107 | <ASSISTANT_TASK:>
Python Code:
#@title Imports & Utils
!pip install -q git+https://www.github.com/google/jax-md
import time
from functools import partial
import numpy as onp
import jax.numpy as np
from jax import jit
from jax import grad
from jax import vmap
from jax import random
from jax import lax
from jax.experime... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a href="https
Step2: Optimization Through Dynamics
Step3: Next we need to posit interactions between our model bubbles. We'll assume that we ... |
5,108 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display, Latex, HTML
display(HTML(open('01.css').read()))
import numpy as np
from numpy import array, cos, diag, eye, linspace, pi
from numpy import poly1d, sign, sin, sqrt, where, zeros
from scipy.linalg import eigh, inv, det
%matplotlib inline
import matplo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Numpy and Scipy
Step2: Matplotlib
Step3: Miscellaneous definitions
Step4: 3 DOF System
Step5: The plots
Step6: Equation of Motion
Step7: T... |
5,109 | <ASSISTANT_TASK:>
Python Code:
import mxnet as mx
import numpy as np
#Training data
train_data = np.array([[1,2],[3,4],[5,6],[3,2],[7,1],[6,9]])
train_label = np.array([5,11,17,7,9,24])
batch_size = 1
#Evaluation Data
eval_data = np.array([[7,2],[6,10],[12,2]])
eval_label = np.array([11,26,16])
train_iter = mx.io.NDA... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preparing the Data
Step2: Once we have the data ready, we need to put it into an iterator and specify parameters such as the 'batch_size', and ... |
5,110 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
from mySSA import mySSA # private lib
from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 11, 4
df = pd.read_csv(r'data\NH.Ts.csv', parse_dates=True, index_col='Year', skiprows=1)
df = df['1881':'2016']
df.drop(['S... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Read data
Step2: Convert data to monthly time series
Step3: Have a quick plot
Step4: 3. Carry out SSA analysis
Step5: We can view the con... |
5,111 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import pandas_datareader.data as web
import datetime
start = datetime.datetime(2015, 1, 1)
end = datetime.datetime(2018, 8, 31)
spy_data = web.DataReader('SPY', 'yahoo', start, end)
spy_data = spy_data.drop(['Volume', 'Adj Close'], axis=1) # sloupce 'Volume' a 'Adj Clo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Každý řádek představuje cenu pro daný den a to nejvyšší (High), nejnižší (Low), otevírací (Open - začátek dne) a uzavírací (Close - konec dne). ... |
5,112 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.optimize as opt
data = np.load('decay_osc.npz')
tdata = data['tdata']
ydata = data['ydata']
dy = data['dy']
plt.errorbar(tdata, ydata, dy, fmt='.k', ecolor='grey')
plt.xlabel('t')
plt.ylabel('y');
assert 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: Fitting a decaying oscillation
Step2: Now, using curve_fit to fit this model and determine the estimates and uncertainties for the parameters
|
5,113 | <ASSISTANT_TASK:>
Python Code:
from pymongo import MongoClient
client = MongoClient('mongodb://localhost:27017/')
db = client.phonebook
print db.collection_names()
data = {'name': 'Alessandro', 'phone': '+39123456789'}
db.people.insert(data)
print db.collection_names()
db.people.insert({'name': 'Puria', 'phone': '+39... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Once the database is retrieved, collections can be accessed as attributes of the database itself.
Step2: Each inserted document will receive an... |
5,114 | <ASSISTANT_TASK:>
Python Code:
import numpy.random as rand
import matplotlib.pyplot as plt
import pandas as pd
import sys
%matplotlib inline
print('Python version: ', sys.version)
print('Pandas version: ', pd.__version__)
plt.style.use('seaborn-dark-palette')
variance = .25 #sets variance of epsil... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The model depicts an economy with multiple periods and an infinite number of producers, all of whom are trying to set prices as close as possibl... |
5,115 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
%matplotlib inline
import os
SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data')
# import all Shogun classes
from shogun import *
from matplotlib.patches import Ellipse
# a tool for visualisation
def get_gaussian_ellipse_artist(mean, cov, nstd=1.96, color="red", li... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Gaussian Mixture Models and Expectation Maximisation in Shogun
Step2: Set up the model in Shogun
Step3: Sampling from mixture models
Step4: E... |
5,116 | <ASSISTANT_TASK:>
Python Code:
from google.cloud import bigquery
compute_alpha =
#standardSQL
SELECT
SAFE_DIVIDE(
SUM(arrival_delay * departure_delay),
SUM(departure_delay * departure_delay)) AS alpha
FROM
(
SELECT
RAND() AS splitfield,
arrival_delay,
departure_delay
FROM
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: <h3> Create a simple machine learning model </h3>
Step4: <h3> What is wrong with calculating RMSE on the training and test data as follows? </h... |
5,117 | <ASSISTANT_TASK:>
Python Code:
import qspectra as qs
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
electronic_fmo = np.array(np.mat(
12400 -87.7 5.5 -5.9 6.7 -13.7 -9.9;
-87.7 12520 30.8 8.2 0.7 11.8 4.3;
5.5 30.8 12200 -53.5 -2.2 -9.6 6.;
-5.9 8.2 -53.5 12310 -70.7 -17. -63.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: FMO dynamics simulated with Redfield theory
Step2: Excited state dynamics
Step3: The long-time evolution indeed approaches thermal equilibrium... |
5,118 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
X, y, true_coefficient = make_regression(n_samples=80, n_features=30, n_informative=10, noise=100, coef=True, random_state=5)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linear Regression
Step2: Ridge Regression (L2 penalty)
Step3: Lasso (L1 penalty)
Step4: Linear models for classification
Step5: Multi-Class ... |
5,119 | <ASSISTANT_TASK:>
Python Code:
def mm(x, k):
if x.shape[0] > 1:
x=x.T
r = np.random.rand(x.shape[1],k)
print(r)
#print(x.dot(r))
return(x.dot(r))
mm(np.array([[1,2, 1,132, 1,2]]), 5)
from sklearn.preprocessing import scale
X_train_draw = scale(X_train[::, 0:2])
X_test_draw = scale(X_te... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Вытаскивание даных из файла!
|
5,120 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import random
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
matplotlib.rcParams.update({'font.size': 14})
L = 1024 # Anzahl Punkte in der DFT
K = 3*L//4 # Anzahl belegter Unterträger, muss gerade sein
n_CP = L//4 # Länge des Cyclic Prefix
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: Präambel generieren (BPSK)
Step2: IFFT
Step3: Cyclic Prefix einfügen
Step4: Kanal
Step5: Synchronisation
Step6: Entzerrung
|
5,121 | <ASSISTANT_TASK:>
Python Code:
%%bash
rm -rf petro
git clone git@github.com:steinwurf/petro.git
%%bash
ls petro
%%bash
cd petro
./waf configure --bundle-path=~/dev/bundle_dependencies
%%bash
cd petro
./waf build
%%bash
wget http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4
%%bash
./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: Lets see which files we have
Step2: First step is to run the configure step (--bundle-path refers to where external dependencies are downloaded... |
5,122 | <ASSISTANT_TASK:>
Python Code:
from scipy.stats import norm # properties of the distribution
from numpy.random import normal # samples from the distribution
import numpy as np
import scipy
from matplotlib import pyplot as plt
%matplotlib inline
x = np.arange(-10, 10, 0.001)
plt.plot(x,norm.pdf(x,0,1)) # final argument... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: All hypotheses discussed herein will be expressed with Gaussian / normal distributions. Let's look at the properties of this distribution.
Step2... |
5,123 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.linspace(0,10,11)
def myFib(a,b):
return a+b
fibLength = 10 #the length we want for our Fibonacci sequence
fibSeq = np.zeros(fibLength) #make a numpy array of 10 zeros
# Let's define the first 2 elements of the Fibonacci sequence
fibSeq[0] = 0
fibSeq[1] = 1
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: You can do a lot with the numpy module. Below is an example to jog your memory
Step2: Do you remember the Fibonacci sequence from yesterday's L... |
5,124 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
%matplotlib inline
import numpy as np
import dh_py_access.lib.datahub as datahub
import xarray as xr
import matplotlib.pyplot as plt
import ipywidgets as widgets
from mpl_toolkits.basemap import Basemap,shiftgrid
import dh_py_access.package_api as package_api
import m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font color='red'>Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly ... |
5,125 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import time
from PIL import Image
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
import keras
from keras import backend as K
from keras.models import Model
from keras import metrics
from keras.applications.vgg1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Data
Step2: Recreate Input
Step3: Recreate Style
Step4: Style Transfer
Step5: Different Approach (TOFIX)
|
5,126 | <ASSISTANT_TASK:>
Python Code:
import os
#os 모듈을 통해서
#운영체제 레벨(서버는 ex.우분투)에서 다루는 파일 폴더 생성하고 삭제하기가 가능
#기존에는 ("../../~~") 이런 식으로 경로를 직접 입력 했으나
os.listdir()
#현재 폴더 안에 있는 파일들을 리스트로 뽑는 것
os.listdir("../")
for csv_file in os.listdir("../"):
pass
[
file_name
for file_name
in os.listdir("../01일차.수_입문/")
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: ipynb 라는 확장자로 끝나는 파일들만 가지고 오려면
Step2: 파일에 대한 경로를 생성할 때
Step3: os.curdir #current directory
Step4: 폴더를 만들 때, os.listdir()로 특정 폴더가 있는지 확인한 ... |
5,127 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
f = open("parkinsons.data","r")
header = f.readline()
names = header.strip().split(',')[1:]
data = np.loadtxt(f ,delimiter=',', usecols=1 + np.arange(23))
data.shape
names
x=np.arange(10).reshape((2, 5))
x
np.delete?
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: Two indicator variables is equivalent to using single variable, so we
Step2: That's about the same ratio of 0's and 1's.
Step3: and in the ori... |
5,128 | <ASSISTANT_TASK:>
Python Code:
import hdbscan
import debacl
import fastcluster
import sklearn.cluster
import scipy.cluster
import sklearn.datasets
import numpy as np
import pandas as pd
import time
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
sns.set_context('poster')
sns.set_palette('Paired... | <SYSTEM_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 need some benchmarking code at various dataset sizes. Because some clustering algorithms have performance that can vary quite a lot depen... |
5,129 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.linalg as lg
from scipy.spatial.distance import cosine
import matplotlib.pyplot as plt
import pandas as pd
np.set_printoptions(precision=2)
pd.set_option('precision', 2)
%matplotlib inline
%precision 2
def sim(v1,v2): #コサイン類似度
return 1-cosine(v1,v2)
# ... | <SYSTEM_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: 文書$d1$と$d2$の特徴空間上での類似度を計算してみよう.
Step5: このように,次元削減された文書ベクトル${{\bf d}_i^{(k)}}$間のコサイン類似度が,低ランク近似... |
5,130 | <ASSISTANT_TASK:>
Python Code:
!pip install --pre deepchem
import deepchem as dc
import tensorflow as tf
keras_model = tf.keras.Sequential([
tf.keras.layers.Dense(1000, activation='relu'),
tf.keras.layers.Dropout(rate=0.5),
tf.keras.layers.Dense(1)
])
model = dc.models.KerasModel(keras_model, dc.models.los... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: There are actually two different approaches you can take to using TensorFlow or PyTorch models with DeepChem. It depends on whether you want to... |
5,131 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from IPython.display import Image
import numpy as np
import matplotlib.pyplot as plt
import openmc
# 1.6 enriched fuel
fuel = openmc.Material(name='1.6% Fuel')
fuel.set_density('g/cm3', 10.31341)
fuel.add_nuclide('U235', 3.7503e-4)
fuel.add_nuclide('U238', 2.2625e-2)
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: Generate Input Files
Step2: With our three materials, we can now create a materials file object that can be exported to an actual XML file.
Ste... |
5,132 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd #data munging
import numpy as np #number functions
import os #directory and file functions
import pylab as plt #graphing functions
import socket #machine id
import seaborn as sns
from matplotlib.font_manager import FontProperties
print "working directory = " + os.getc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Player ratings predict outcome
Step2: A note about standard errors
Step3: See how the change in player average rating changs the sharpness of ... |
5,133 | <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: 每个标签都分别与一个字符串名称(例如 “setosa” )相关联,但机器学习通常依赖于数字值。标签编号会映射到一个指定的表示法,例如:
Step... |
5,134 | <ASSISTANT_TASK:>
Python Code:
import tarfile
import time
import os
import getpass
import paramiko
import arrow
curtime = time.strftime("%d-%b-%Y-%H", time.gmtime())
sshgetdrn = paramiko.SSHClient()
sshgetdrn.set_missing_host_key_policy(paramiko.AutoAddPolicy())
usrg = getpass.getuser()
sshgetdrn.connect('128.199.60.12... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I want datetime printed as year-month-day-hour-min.
|
5,135 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import ABCPRC as prc
import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
def ibm(*ps):
lbda,delta,gamma = ps[0],ps[1],ps[2]
dt = 1.0 #time step
n = 100 #population number
T = 100 #total time simulation is run for.
class Pe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Define model
Step2: Let's run the model and plot the results for some values.
Step3: Setting up the model fitting
Step4: Fit tolerances to si... |
5,136 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from geoscilabs.mag import Mag, Simulator
%matplotlib inline
#Input parameters
fileName = 'https://github.com/geoscixyz/geosci-labs/raw/master/assets/mag/data/DO27_TMI.dat'
xyzd = np.genfromtxt(fileName, skip_header=3)
B = np.r_[60308, 83.8, 25.4]
survey, dobj = Mag.cr... | <SYSTEM_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 do we define direction of an earth magnetic field?
Step2: Magnetic applet
|
5,137 | <ASSISTANT_TASK:>
Python Code:
from owslib.csw import CatalogueServiceWeb
endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw'
csw = CatalogueServiceWeb(endpoint, timeout=30)
import pandas as pd
ioos_ras = ['AOOS', # Alaska
'CaRA', # Caribbean
'CeNCOOS', # Central and Northern Califo... | <SYSTEM_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 use the same list of all the Regional Associations as before,
Step2: The function below is similar to the one we used before.
Step3: C... |
5,138 | <ASSISTANT_TASK:>
Python Code:
# Adding module path to sys path if not there, so rl_coach submodules can be imported
import os
import sys
import tensorflow as tf
module_path = os.path.abspath(os.path.join('..'))
resources_path = os.path.abspath(os.path.join('Resources'))
if module_path not in sys.path:
sys.path.app... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preset based - using CoachInterface
Step2: Running each training or inference iteration manually
Step3: Sometimes we may want to track the age... |
5,139 | <ASSISTANT_TASK:>
Python Code:
# Prepare my slides
%pylab inline
%cd working
# ipython
!curl -kLO http://github.com/barronh/GCandPython/archive/master.zip
import zipfile
zf = zipfile.ZipFile('master.zip')
zf.extractall()
%mv GCandPython-master GCandPython
def foo(bar):
return 'foo.' + bar
print(foo('bar'))
try:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Objectives
Step2: Open Notebook
Step3: Basic Types
Step5: strings
Step6: slices
Step7: ANSWERS Hidden
Step8: Intro to numpy/scipy/matplotl... |
5,140 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from datetime import date
import time
import pandas as pd
import numpy as np
pd.options.display.max_colwidth = 60
from Curves.Corporates.CorporateDailyVasicek import CorporateRates
from Boostrappers.CDSBootstrapper.CDSVasicekBootstrapper import BootstrapperCDSLadder
fro... | <SYSTEM_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 forward bond future PV (Exposure) time profile
Step2: Data input for the CouponBond portfolio
Step3: Create Libor and portfolioSchedule... |
5,141 | <ASSISTANT_TASK:>
Python Code:
print('Hello, Wolrd!')
print('This is Python.')
def greet():
return 'Hello, World!'
message = greet()
print(message)
def sum_a_and_b(a, b):
return a + b
print(sum_a_and_b(5, 3))
def print_arguments(arg1, arg2, arg3='Foo', arg4='Bar', g=9.81):
print('arg1:\t', arg1)
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: group the two print statements into a print_all function
Step2: Rewrite welcome in the style of greet. It should substitute the user name and r... |
5,142 | <ASSISTANT_TASK:>
Python Code:
def GenerateBimodalData(muA, muB, sigmaA, sigmaB, p, N=1000):
dataA = np.random.normal(muA, sigmaA, int(p*N))
dataB = np.random.normal(muB, sigmaB, int((1-p)*N))
return np.concatenate([dataA, dataB])
data = GenerateBimodalData(-2, 2, 1, 1, 0.9)
test = BayesBimodalTest(data, nt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Firstly let's check that the MCMC chains have converged and that the resulting posteriors are sensible.
Step2: Okay so what is the Bayes factor... |
5,143 | <ASSISTANT_TASK:>
Python Code:
root_directory = 'D:/github/w_vattenstatus/ekostat_calculator'#"../" #os.getcwd()
workspace_directory = root_directory + '/workspaces'
resource_directory = root_directory + '/resources'
user_id = 'test_user'
# ## Initiate EventHandler
print(root_directory)
paths = {'user_id': user_id,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set subset filters
Step2: #####################################################################################################################... |
5,144 | <ASSISTANT_TASK:>
Python Code:
import mpslib as mps
import numpy as np
import matplotlib.pyplot as plt
O=mps.mpslib(method='mps_snesim_tree', parameter_filename='mps_snesim.txt')
#O=mps.mpslib(method='mps_genesim', parameter_filename='mps_genesim.txt')
TI1, TI_filename1 = mps.trainingimages.strebelle(3, coarse3d=1)
O.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: Hard data
Step2: Soft/uncertain data
Step3: Example 1
Step4: Example 2
Step5: Example 3
|
5,145 | <ASSISTANT_TASK:>
Python Code:
# For recording the model specification
from collections import OrderedDict
# For making plots pretty
import seaborn
# For file input/output
import pandas as pd
# For vectorized math operations
import numpy as np
# For plotting
import matplotlib.pyplot as plt
# For model estimation and 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: Load the dataset
Step2: Create the model specification
Step3: Estimate the various models to be used for prediction
Step4: Estimate the MNL m... |
5,146 | <ASSISTANT_TASK:>
Python Code:
#import packages
import pandas as pd
import glob
import csv
from xml.etree.ElementTree import ElementTree
import re
#function to load a csv file
#accepts folderpath and headerlist as parameter to load the data files
def file_csv(folderpath,addheader,headerlist):
#this reads all files... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Motivation
Step2: The blocks below contain functions to parse and count all entries in each loaded database. Since XML files have a table struc... |
5,147 | <ASSISTANT_TASK:>
Python Code:
rf = 0.04
np.random.seed(1)
mus = np.random.normal(loc=0.05,scale=0.02,size=5) + rf
sigmas = (mus - rf)/0.3 + np.random.normal(loc=0.,scale=0.01,size=5)
num_years = 10
num_months_per_year = 12
num_days_per_month = 21
num_days_per_year = num_months_per_year*num_days_per_month
rdf = pd.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: Create Trend signal over the last 12 months
Step2: Compare EW and 1/vol
|
5,148 | <ASSISTANT_TASK:>
Python Code:
from math import pi
def degrees_to_radians(theta_d):
Convert an angle from degrees to radians.
Parameters
----------
theta_d : float
The angle in degrees.
Returns
-------
theta_r : float
The angle in radians.
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loops
Step2: We showed above how to use this code to print the angles $(n \pi)/ 12$ for $n = 1, 2, \dots, 6$. We did this by calling the degree... |
5,149 | <ASSISTANT_TASK:>
Python Code:
urlpattern = {
"results": "https://materialsproject.org/molecules/results?query={spec}",
"mol_json": "https://materialsproject.org/molecules/{mol_id}/json",
"mol_svg": "https://materialsproject.org/molecules/{mol_id}/svg",
"mol_xyz": "https://materialsproject.org/molecules... | <SYSTEM_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
Step3: Getting a set of molecules
Step4: What if we just want "everything"? Let's use an empty spec.
Step5: The above request might tak... |
5,150 | <ASSISTANT_TASK:>
Python Code:
# Authors: Chris Holdgraf <choldgraf@gmail.com>
# Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.decoding import ReceptiveField, TimeDelayingRidge
from scipy.stats import multivariate_normal
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 audio data
Step2: Create a receptive field
Step3: Simulate a neural response
Step4: Fit a model to recover this receptive field
Step5: ... |
5,151 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
np.random.seed(10)
df = pd.DataFrame(np.random.randint(0, 20, (10, 10)).astype(float), columns=["c%d"%d for d in range(10)])
df.where(np.random.randint(0,2, df.shape).astype(bool), np.nan, inplace=True)
def g(df):
return df.columns[df.iloc[0,:].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:
|
5,152 | <ASSISTANT_TASK:>
Python Code:
!mkdir -p ../data
!wget -P ../data -qN ftp://sidads.colorado.edu/pub/DATASETS/NOAA/G02135/north/daily/data/NH_seaice_extent_final.csv
!wget -P ../data -qN ftp://sidads.colorado.edu/pub/DATASETS/NOAA/G02135/north/daily/data/NH_seaice_extent_nrt.csv
!wget -P ../data -qN ftp://sidads.colora... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: code to read the CSV files.
Step2: Read CSV data
Step3: Add columns for year and month
Step4: Add 5 day rolling mean to the timesereis.
Step5... |
5,153 | <ASSISTANT_TASK:>
Python Code:
!pip install tf-nightly
import numpy as np
import tensorflow as tf
model = tf.keras.models.Sequential([
tf.keras.layers.Input(shape=(28, 28), name='input'),
tf.keras.layers.LSTM(20, time_major=False, return_sequences=True),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1
Step2: Step 2
Step3: Step 3
Step4: Step 4
|
5,154 | <ASSISTANT_TASK:>
Python Code:
%reload_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import sys, subprocess, time, dendropy
import numpy as np
bindir="/home/leo/local/bin/"
localdir="/tmp/"
def run_uspr (tree1, tree2, fast = False):
localfile = localdir + "pair.tr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Function that generates random trees and calculates SPR (and others) distances
Step2: the figure above shows that the replug distance (from USP... |
5,155 | <ASSISTANT_TASK:>
Python Code:
!pip show systemml
from systemml import MLContext
ml = MLContext(sc)
print ("SystemML Built-Time:"+ ml.buildTime())
print(ml.info())
# Workaround for Python 2.7.13 to avoid certificate validation issue while downloading any file.
import ssl
try:
_create_unverified_https_context = ssl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SystemML Build information
Step2: Download model, proto files and convert them to SystemML format.
Step3: PrintTopK
Step4: Classify images
St... |
5,156 | <ASSISTANT_TASK:>
Python Code:
# conda install ipyrad -c bioconda
# conda install raxml -c bioconda
# conda install toytree -c eaton-lab
import ipyrad.analysis as ipa
import toytree
# the path to your HDF5 formatted seqs file
data = "/home/deren/Downloads/ref_pop2.seqs.hdf5"
# check scaffold idx (row) against scaffold... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the data
Step2: Quick full example
Step3: The results table (tree table)
Step4: Filter and examine the tree table
Step5: The tree infer... |
5,157 | <ASSISTANT_TASK:>
Python Code:
from dolfin import *
from rbnics import *
from sampling import LinearlyDependentUniformDistribution
@PullBackFormsToReferenceDomain()
@AffineShapeParametrization("data/t_bypass_vertices_mapping.vmp")
class Stokes(StokesProblem):
# Default initialization of members
def __init__(se... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 3. Affine decomposition
Step2: 4. Main program
Step3: 4.2. Create Finite Element space (Taylor-Hood P2-P1)
Step4: 4.3. Allocate an object of ... |
5,158 | <ASSISTANT_TASK:>
Python Code:
%pylab notebook
%precision 4
from scipy import constants as c # we like to use some constants
mu_r = 2000
mu = mu_r * c.mu_0
l1 = 1.08 # [m]
l2 = 0.34 # [m]
l3 = 0.0005 # [m]
l4 = 1.08 # [m]
A1 = 0.09 * 0.05 # [m²]
A2 = 0.15 * 0.05 # [m²]
A3 = 0.15 * 0.05 * ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Description
Step2: SOLUTION
Step3: The reluctances of the regions in core are
Step4: And the reluctances are hence
Step5: Then the total rel... |
5,159 | <ASSISTANT_TASK:>
Python Code:
# put your code here.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
x1 = np.arange(0.0,20.0,4.0)
y1 = np.sin(x1)
plt.plot(x1,y1,'r-')
# put your code here.
x2 = np.arange(0.0,20.0,1.0)
y2 = np.sin(x2)
plt.plot(x1,y1,'r-',x2,y2,'b-')
# put your code here
x3 = np.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: Does the plot above look like a sine function? Why or why not?
Step2: Question 3
Step3: How did your plot of sin(x) change appearance as you... |
5,160 | <ASSISTANT_TASK:>
Python Code:
from marvin import config
config.setRelease('MPL-4')
from marvin.tools.query import Query, Results, doQuery
# make a query
myquery = 'nsa.sersic_logmass > 10.3 AND nsa.z < 0.1'
q = Query(searchfilter=myquery)
# run a query
r = q.run()
print(r)
print('Total count', r.totalcount)
print('... | <SYSTEM_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 look at the Marvin Results object. We can see how many results were returned with r.count and r.totalcount
Step2: Queries returning more... |
5,161 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import HTML
import os
HTML(
<video width="320" height="240" controls>
<source src="btf.m4v" type="video/mp4">
</video>
)
import sqlite3
import pandas as pd
pd.set_option('display.max_colwidth', -1)
## Read sqlite query results into a pandas DataFrame
# conn = sqli... | <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: Data was collected using this method. It uses the Twitter API to go some days back in time, and then continuously streaming forward in real-time... |
5,162 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import math
import matplotlib.pyplot as plt
import seaborn
from astropy.io import fits
from astropy import units as u
from astropy.coordinates import SkyCoord
plt.rcParams['figure.figsize'] = (12, 8)
plt.rcParams['font.size'] = 14
plt.rcParams['lines.... | <SYSTEM_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 order to know the altitude and azimuth of a fixed target in the sky we will mainly need to know
Step2: You can also search by its name if it... |
5,163 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time
import numpy as np
import matplotlib.pyplot as plt
# from cs231n.classifiers.fc_net import *
# from cs231n.classifiers.fc_net import *
from cs231n.classifiers.fc_net import FullyConnectedNet
from cs231n.data_utils import get_CIFAR10_data
from cs231n.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Batch Normalization
Step2: Batch normalization
Step3: Batch Normalization
Step4: Test on simple example - Remove the mean only
Step5: The di... |
5,164 | <ASSISTANT_TASK:>
Python Code:
#Add all dependencies to PYTHON_PATH
import sys
sys.path.append("/usr/lib/spark/python")
sys.path.append("/usr/lib/spark/python/lib/py4j-0.10.4-src.zip")
sys.path.append("/usr/lib/python3/dist-packages")
#Define environment variables
import os
os.environ["HADOOP_CONF_DIR"] = "/etc/hadoop/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Connect to Spark
Step2: Read a GeoTiff file
Step3: Visualization
Step4: Interactive visualization
Step5: Histogram
|
5,165 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import networkx as nx
K_5=nx.complete_graph(5)
nx.draw(K_5)
def complete_deg(n):
Return the integer valued degree matrix D for the complete graph K_n.
f=np.zeros((n,n), dtype=int) #create... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Complete graph Laplacian
Step3: The Laplacian Matrix is a matrix that is extremely important in graph theory and numerical analysis. It is defi... |
5,166 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import datajoint as dj
from pipeline import mice, experiment, vis, preprocess, tuning
pylab.rcParams['figure.figsize'] = (8, 8) # make figures bigger
erd = dj.ERD(preprocess.Sync) - 2
erd += dj.ERD(preprocess.Spikes) - 3
erd += experiment.Session
erd += dj.ERD(tuning.Mon... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Below is the outline of processing chain.
Step2: The color code
Step3: For any tables or relational expressions derived from them, you may se... |
5,167 | <ASSISTANT_TASK:>
Python Code:
from pathlib import Path
import tempfile
import numpy as np
import scipy.ndimage
import matplotlib.pyplot as plt
import mne
data_path = Path(mne.datasets.sample.data_path(verbose=False))
sample_dir = data_path / 'MEG' / 'sample'
subjects_dir = data_path / 'subjects'
raw_path = sample_dir... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Before getting started with
Step2: Adding events
Step3: Adding ~mne.Epochs
Step4: Adding ~mne.Evoked
Step5: Adding ~mne.Covariance
Step6: ... |
5,168 | <ASSISTANT_TASK:>
Python Code:
%bash
rm -rf data
mkdir data
cd data
RADAR=KIWA
YEAR=2013
MONTH=07
DAY=23
HOUR=23
gsutil cp gs://gcp-public-data-nexrad-l2/$YEAR/$MONTH/$DAY/$RADAR/*_$RADAR_${YEAR}${MONTH}${DAY}${HOUR}0000_${YEAR}${MONTH}${DAY}${HOUR}5959.tar temp.tar
tar xvf temp.tar
rm *.tar
ls
# Based on
# http://arm... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h3> Install Py-ART </h3>
Step2: <h2> Plot into png </h2>
Step3: <h2> Create animating PNG </h2>
|
5,169 | <ASSISTANT_TASK:>
Python Code:
from nipype import Node, Workflow
from nipype.interfaces.fsl import BET, IsotropicSmooth
# Initiate a skull stripping Node with BET
skullstrip = Node(BET(mask=True,
in_file='/data/ds102/sub-01/anat/sub-01_T1w.nii.gz'),
name="skullstrip")
isosmooth ... | <SYSTEM_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 smoothing Node with IsotropicSmooth
Step2: Now, to use iterables and therefore smooth with different fwhm is as simple as that
Step3: ... |
5,170 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
x = np.linspace(0,4*np.pi,10)
x
f = np.sin(x)
print(f)
c = np.cos(x)
print (c)
plt.plot(x, f, marker='o')
plt.xlabel('x')
plt.ylabel('f(x)');
from scipy.interpolate import interp1d
x = np.linsp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Overview
Step2: This creates a new array of points that are the values of $\sin(x_i)$ at each point $x_i$
Step3: This plot shows that the poin... |
5,171 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
input = [10, 20, 30]
def g(input):
ds = tf.data.Dataset.from_tensor_slices(input)
ds = ds.flat_map(lambda x: tf.data.Dataset.from_tensor_slices([x, x + 1, x + 2]))
element = tf.compat.v1.data.make_one_shot_iterator... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
5,172 | <ASSISTANT_TASK:>
Python Code:
def modp(n: int, p: int):
ret = 1
for i in range(n):
ret = (2 * ret) % p
return ret
<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:
|
5,173 | <ASSISTANT_TASK:>
Python Code:
import cellpy
from cellpy.utils import plotutils
cell = cellpy.get("../testdata/hdf5/20160805_test001_45_cc.h5", mass=0.8)
plotutils.raw_plot(cell)
fig = plotutils.cycle_info_plot(
cell,
cycle=3,
use_bokeh=False,
)
<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: And let´s load a data-set
Step2: If you have holoviews installed, you can get an interactive figure
Step3: Sometimes it is necessary to have a... |
5,174 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
img = mnist.train.images[2]
plt.imshow(img.reshape((28, 28)), cmap='G... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Network Architecture
Step2: Training
Step3: Denoising
Step4: Checking out the performance
|
5,175 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import linear_model
import numpy as np
from math import ceil
dtype_dict = {'bathrooms':float, 'waterfront':int, 'sqft_above':int, 'sqft_living15':float, 'grade':int, 'yr_renovated':int, 'price':float, 'bedrooms':float, 'zip... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the data
Step2: Data exploration
Step3: Helper functions
Step4: Ridge regression model fitting
Step5: Ridge regression on subsets
Step6... |
5,176 | <ASSISTANT_TASK:>
Python Code:
# Ensure compatibility with Python 2 and 3
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import climlab
# create a zero-dimensional domain with a single surface temperature
state = climlab.surface_state(num_lat=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: Contents
Step2: <a id='section2'></a>
Step3: Here we have created a dictionary called state with a single item called Ts
Step4: This dictiona... |
5,177 | <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'
class DLProgress(tqdm):
last_b... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
5,178 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
from pandas.tools.plotting import scatter_matrix
from sklearn.datasets import load_boston
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_context('poster')
sns.set_style('whitegrid')
plt.rcPar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: BQPlot
Step2: ipyvolume
|
5,179 | <ASSISTANT_TASK:>
Python Code:
from fig_utils import *
import matplotlib.pyplot as plt
import time
%matplotlib inline
country_path = '../data/output/LSMS/pooled/'
percentiles = [0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35,
0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70,
0.75, 0.80, 0.85, 0.90, 0.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: Transfer learning vs. nightlights
Step2: Panel B
Step3: Randomization tests
Step4: Panel D
|
5,180 | <ASSISTANT_TASK:>
Python Code:
import os, tempfile
import logging
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from ionchannelABC import theoretical_population_size
from ionchannelABC import IonChannelDistance, EfficientMultivariateNormalTransition, IonChannelAccepto... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initial set-up
Step2: Plot steady-state and tau functions
Step3: Combine model and experiments to produce
Step4: Set up prior ranges for each... |
5,181 | <ASSISTANT_TASK:>
Python Code:
import featuretools as ft
import pandas as pd
import dask.dataframe as dd
id = [0, 1, 2, 3, 4]
values = [12, -35, 14, 103, -51]
df = pd.DataFrame({"id": id, "values": values})
dask_df = dd.from_pandas(df, npartitions=2)
dask_df
from woodwork.logical_types import Double, Integer
es = ft.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: Now that we have our Dask DataFrame, we can start to create the EntitySet. Inferring Woodwork logical types for the columns in a Dask dataframe ... |
5,182 | <ASSISTANT_TASK:>
Python Code:
model = LogisticRegression()
model.fit(dataset.data, dataset.target)
expected = dataset.target
predicted = model.predict(dataset.data)
# classification metrics report builds a text report showing the main classification metrics
# In pattern recognition and information retrieval with binar... | <SYSTEM_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 typically need the following libraries
|
5,183 | <ASSISTANT_TASK:>
Python Code:
import pymongo
from pymongo import MongoClient
import time
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import csv
Client = MongoClient("mongodb://bridges:readonly@nbi-mongo.admin/bridge")
db = Client.bridge
collection = db["bridges"]
def ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Connecting to National Data Service
Step2: Deterioration Curves of West United states
Step3: Filtering Null Values, Converting JSON format to ... |
5,184 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
a=np.random.randn(2,10)
x=a[0,:]
x
y=a[1,:]
y
plt.scatter(x,y,color='red')
plt.grid(True)
plt.box(False)
plt.xlabel('random x values')
plt.ylabel('random y values')
plt.title('TITLE')
a=np.random.randn(1,10)
x=a[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: Scatter plots
Step2: Histogram
|
5,185 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
print("Numpy:", np.__version__)
dir(np)
location = 'Bethesda'
zip_code = 20892
elevation = 71.9
print("We're in", location, "zip code", zip_code, ", ", elevation, "m above sea level")
print("We're in " + location + " zip code " + str(zip_code) + ", " + str(elevation) ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Python Summary
Step2: Variables
Step3: Types
Step4: Conditionals
Step5: Loops
Step6: Functions
Step7: Numpy
Step8: Exercises
Step9: Prin... |
5,186 | <ASSISTANT_TASK:>
Python Code::
import nltk
nltk.download('stopwords')
from nltk.corpus import stopwords
stop_words = stopwords.words('english')
df['tweet'] = df['tweet'].apply(lambda x: ' '.join([word for word in x.split() if word not in (stop_words)]))
<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:
|
5,187 | <ASSISTANT_TASK:>
Python Code:
#importieren sie die Bibliothek pandas
import pandas as pd
#importieren sie matplotlib.pyplot as plt
import matplotlib.pyplot as plt
%matplotlib inline
#laden Sie die Datei "daten.csv" auf Ihren Hub
#laden Sie die Datei "daten.csv" in einen Datframe df
#Einlesen der Dateien mit pd.read_cs... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h2> Erstes Neuronales Netz - Single Layer</h2>
Step2: <h2> Initialisierung eines zweiten Neuronalen Netzes - Multi Layer</h2>
Step3: <h2>Erze... |
5,188 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mpi-m', 'mpi-esm-1-2-hr', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
5,189 | <ASSISTANT_TASK:>
Python Code:
import sys
niftynet_path = '/Users/foo/Documents/Niftynet/'
sys.path.insert(0, niftynet_path)
from niftynet.utilities.download import download
download('mr_ct_regression_model_zoo_data')
!{sys.executable} -m pip install matplotlib
from niftynet.io.image_reader import ImageReader
from nif... | <SYSTEM_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 as 'window'
Step2: The sampler can be used as a numpy function, or a tensorflow operation.
Step3: Use the sampler as a tensorflow op
Ste... |
5,190 | <ASSISTANT_TASK:>
Python Code:
a = [5, 3, -2, 9, 1]
# Метод sort меняет существующий список
a.sort()
print(a)
a = [5, 3, -2, 9, 1]
a.sort(reverse=True)
print(a)
# Обычно строки сортируются в алфавитном порядке
a = ["bee", "all", "accessibility", "zen", "treasure"]
a.sort()
print(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: Сортировка в обратном порядке
Step2: Сортировка по ключу
Step3: В качестве параметра key можно указывать не только встроенные функции, но и са... |
5,191 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
5,192 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import os
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import chainer
train, val, test = chainer.datasets.get_ptb_words()
print('train type: ', type(train), train.shape, train)
print('val type: ', type(val), val.shape, val... | <SYSTEM_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 PTB dataset
Step2: The dataset structure is numpy.ndarray.
Step3: Word ID and word correspondence
Step4: Convert to word sequences
S... |
5,193 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.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 num... | <SYSTEM_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... |
5,194 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from pymatbridge import Octave
octave = Octave()
octave.start()
%load_ext pymatbridge
%%matlab
%% Définition du signal d'intêret
% fréquence du signal
freq = 0.3;
% on crée des blocs off/on de 15 secondes
bloc = repmat([zeros(1,15*freq) ones(1,15*freq)],[1 10]);
% l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Section 1
Step2: 3. Répétez les questions 1.1 et 1.2 avec un bruit dit blanc, généré ci dessous.
Step3: 4. Bruit respiratoire.
Step4: 5. Lign... |
5,195 | <ASSISTANT_TASK:>
Python Code:
import psas_packet
from psas_packet.io import BinFile
import csv
import matplotlib.pyplot as plt
from matplotlib import gridspec
%matplotlib inline
FPS2M = 0.3048
LBF2N = 4.44822
LBS2KG = 0.453592
# Extend PSAS Packet to include our state message
psas_packet.messages.MESSAGES["STAT"] = ps... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Message Receive Time
Step2: IMU Noisy Acceleration
Step3: State Tracking
|
5,196 | <ASSISTANT_TASK:>
Python Code:
# A program that calculates the final grade for each student.
# Scores for Assignment 1, Assignment 2, and Final Exam.
sam_scores = [90, 80, 90]
yuko_scores = [90, 100, 80]
sam_weighted_score = 0.2 * sam_scores[0] + 0.2 * sam_scores[1] + 0.6 * sam_scores[2]
sam_grade = 'PASS' if sam_weigh... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: lang
Step2: lang
Step3: lang
Step4: lang
Step5: lang
Step6: lang
Step7: lang
Step9: 5. Exercise
Step11: 5.2. Returning the First Item th... |
5,197 | <ASSISTANT_TASK:>
Python Code:
print('Hello, world')
# This is a code cell
my_variable = 5
print(my_variable)
import hail as hl
from bokeh.io import output_notebook, show
hl.init()
output_notebook()
hl.utils.get_1kg('data/')
! ls -1 data/
hl.import_vcf('data/1kg.vcf.bgz').write('data/1kg.mt', overwrite=True)
mt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Modes
Step2: This is a markdown cell, so even if something looks like code (as below), it won't get executed!
Step3: Common gotcha
Step4: Now... |
5,198 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
sys.path.append(os.getcwd().replace("notebooks/awsCluster", "src/awsCluster"))
from util import DesignFileLoader
## S3 input and output address.
s3_input_files_address = "s3://path/to/s3_input_files_address"
s3_output_files_address = "s3://path/to/s3_output_files_addr... | <SYSTEM_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. Create CFNCluster
Step2: After you verified the project information, you can execute the pipeline. When the job is done, you will see the lo... |
5,199 | <ASSISTANT_TASK:>
Python Code:
# 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 writing, sof... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Cat vs. Dog Image Classification
Step2: These are just a few of the options available (for more, see the Keras documentation. Let's quickly go ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.