Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
11,900 | <ASSISTANT_TASK:>
Python Code:
### START CODE HERE ### (≈ 1 line of code)
test = "Hello World"
### END CODE HERE ###
print ("test: " + test)
# GRADED FUNCTION: basic_sigmoid
import math
import numpy as np
def basic_sigmoid(x):
Compute sigmoid of x.
Arguments:
x -- A scalar
Return:
s -- sigmoid... | <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: Expected output
Step3: Expected Output
Step4: In fact, if $ x = (x_1, x_2, ..., x_n)$ is a row vector then $np.exp(x)$ will apply the exponent... |
11,901 | <ASSISTANT_TASK:>
Python Code:
import sys
_CATAPULT_PATH=os.path.join(os.path.abspath(''), '..', '..', '..')
_DASHBOARD_PATH=os.path.join(_CATAPULT_PATH, 'dashboard')
# Set up the environment so that we can import the modules in the
# Dashboard codebase.
sys.path.insert(0, _CATAPULT_PATH)
sys.path.insert(0, _DASHBOARD_... | <SYSTEM_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 this point on we can use ccd to refer to our clustering change detector implementation in the Dashboard. Here we can use all sorts of utili... |
11,902 | <ASSISTANT_TASK:>
Python Code:
import seaborn as sns
import pandas as pd
import numpy as np
from pandasql import PandaSQL
pdsql = PandaSQL()
tips = sns.load_dataset('tips')
tips.head()
pdsql("SELECT * FROM tips LIMIT 5;")
pdsql("SELECT * FROM tips WHERE sex='Female' LIMIT 5;")
pdsql("SELECT tip, sex, size FROM tips WH... | <SYSTEM_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 SQL for Queries
Step3: Ordering
Step5: Aggregate queries
Step6: Joins
Step8: Matching students and majors
Step10: Left outer join
Ste... |
11,903 | <ASSISTANT_TASK:>
Python Code:
#------Library loading------
# numpy for matrix computations
import numpy as np; import numpy.ma as ma
# system libraries
import sys
# plotting libraries
%matplotlib inline
import matplotlib.pylab as plt
from matplotlib.patches import Circle, Ellipse
# Generalized Multiparticle Mie 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: Setting up the inputs
Step2: Plane wave incident field
Step3: Additional inputs for the simulation
Step4: Target plot
Step5: Performing the ... |
11,904 | <ASSISTANT_TASK:>
Python Code:
from itertools import repeat
from sympy import *
#from type_system import *
%run ../../src/commons.py
%run ./type-system.py
init_printing()
x,y,m,n,t,z = symbols('x y m n t z', commutative=True)
alpha, beta, gamma, eta = symbols(r'\alpha \beta \gamma \eta', commutative=True)
f,g = Functi... | <SYSTEM_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: Non-commutative symbols
Step3: Exponential gf recap
Step4: Linear types
Step5: occupancies
Step6:
Step7:
Step8:
Step9: Differ... |
11,905 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-2', 'seaice')
# 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: 2... |
11,906 | <ASSISTANT_TASK:>
Python Code:
# import libraries
import matplotlib
import IPython
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib as mpl
import pylab
import seaborn as sns
import sklearn as sk
%matplotlib inline
## Read the housing data! This time its not comma separated but 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:
Step2: Sci-Kit Learn, the machine learning library
Step5: It seems that the predictor LSTAT is correlated with our response and will be a good base mo... |
11,907 | <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: 기능적 API
Step2: 시작하기
Step3: 데이터의 모양은 784 차원 벡터로 설정됩니다. 각 샘플의 모양 만 지정되므로 배치 크기는 항상 생략됩니다.
Step4: 리턴되는 inputs 에는 모델에 공급하는 입력 데이터의 모양 및 dtype 에 대... |
11,908 | <ASSISTANT_TASK:>
Python Code:
# COMPLETARE LA FUNZIONE SEGUENTE
def RadiceCubica(x):
# DA COMPLETARE
# DA COMPLETARE
# DA COMPLETARE
# Se non si trova la radice cubica:
return "failed", ""
# Funzione di test per la funzione che dovete implementare
def UnitTest():
Xs = [27, -8, 57893, 195... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Esercizio 2
Step2: Esercizio 3
Step3: Il Metodo di Newton Raphson
|
11,909 | <ASSISTANT_TASK:>
Python Code:
import graphlab as gl
import pandas as pd
from datetime import datetime
from sklearn.cross_validation import StratifiedKFold
## load data set from a locally saved csv file
bank_marketing = gl.SFrame.read_csv('./../../../04.UCI.ML.REPO/Bank_Marketing/bank-additional/bank-additional-full.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: Data Dictionary
Step2: It is also important to note that the original data set has many more prospects (36548) than existent customers (4640). ... |
11,910 | <ASSISTANT_TASK:>
Python Code:
import IPython.display as ipd
ipd.Audio("../data/out_humannature_90s_stretched.mp3", rate=44100)
ipd.Audio("../data/tresillo_rhythm.mp3", rate=44100)
%matplotlib inline
import math # Standard library imports
import IPython.display as ipd, librosa, librosa.display, numpy as np, matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You can also jump to Part 6 for more audio examples.
Step2: ...and looks something like this in Western music notation
Step3: Briefly
Step4: ... |
11,911 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
Tp = 20.0
N = 50
step = Tp/N
dw = 2*pi/Tp
wny = dw*N/2
print("omega_1 =", dw)
print("Nyquist freq. =",wny,"rad/s =", wny/dw, '* omega_1')
M = 1000
t_n=linspace(0.0,Tp,N+1)
t_m=linspace(0.0,Tp,M+1)
hf = 47
lf = hf - N
c_hs_hf = cos(hf*dw*t_m)
c_hs_lf = cos(lf*dw*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: To be concrete, we'll use $\Delta t = 0.4$ s and a fundamental period $T_n=20$ s, hence a number of samples per period $N=50$, or $2.5$ samples ... |
11,912 | <ASSISTANT_TASK:>
Python Code:
paraderos_sinlatlong = frame_2['par_subida'][frame_2['lat_subida'].isnull()& frame_2['par_subida'].notnull()].unique()
paraderos_sinlatlong
frame_2 = frame_2[frame_2.lat_subida.notnull()]
from scipy.stats.mstats import mode
f = lambda x: mode(x, axis=None)[0][0]
g = lambda x: mode(x,axis=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Guardar en csv viajes de los correctos e incorrectos
Step2: Guardar en csv viajes de los correctos e incorrectos. sin transbordo
|
11,913 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
x = np.arange(-np.pi,np.pi,0.01) # Create an array of x values from -pi to pi with 0.01 interval
y = np.sin(x) # Apply sin function on all x
plt.plot(x,y)
plt.plot(y)
x = np.arange(0,10,1) # x = 1,2,3,4,5...
y = x*x ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Line Plots
Step2: Scatter Plots
Step3: Plot properties
Step4: Multiple plots
Step5: Save figure
|
11,914 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format = 'retina'
import matplotlib.pyplot as plt
import numpy as np
from uncertainties import unumpy as unp
import pytheos as eos
eta = np.linspace(1., 0.70, 7)
print(eta)
dorogokupets2007_pt = eos.platinum.Dorogokupets2007()
help(dorogokupets2007_pt)
dorog... | <SYSTEM_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. General note
Step2: 3. Compare
Step3: <img src='./tables/Dorogokupets2007_Pt.png'>
|
11,915 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
a = np.array([1,2,3,4])
b = np.array([5, 4, 3, 2])
result = np.correlate(a, np.hstack((b[1:], b)), mode='valid')
<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:
|
11,916 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np
x = np.linspace(0, 10, 50)
dy = 0.8
y = np.sin(x) + dy * np.random.randn(50)
plt.errorbar(x, y, yerr=dy, fmt='.k');
plt.errorbar(x, y, yerr=dy, fmt='o', color='black',
ec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here the fmt is a format code controlling the appearance of lines and points, and has the same syntax as the shorthand used in plt.plot, outline... |
11,917 | <ASSISTANT_TASK:>
Python Code:
from flask import Flask, Response, request, json, render_template
from kafka import KafkaProducer
import uuid
import datetime
app = Flask(__name__)
producer = KafkaProducer(bootstrap_servers='localhost:9092')
# Default end point
@app.route('/', methods = ['GET'])
def api_root():
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: The default end point is simply there to "document" the API if the root endpoint of the API is called with a get method. This will show the JSO... |
11,918 | <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: To paraphrase two Georges, "All models are wrong, but some models are
Step2: When this function is called, it modifies bikeshare. As long as th... |
11,919 | <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: Prometheus サーバーからメトリックを読み込む
Step2: CoreDNS と Prometheus のインストールとセットアップ
Step3: 次に、Prometheus サーバーをセットアップし、Prometheus を使用して、上記の9153番ポートで公開されている ... |
11,920 | <ASSISTANT_TASK:>
Python Code:
# Let's plot the data for each of the devices, from each of the base stations.
dfs = [(origin, 'origin'), (eastern, 'eastern'), (southern, 'southern')]
def plot_signal_vs_distance(device):
fig = plt.figure(figsize=(9,3))
ax1 = fig.add_subplot(131)
ax2 = fig.add_subplot(132)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preliminary Conclusions
Step2: Looking at the distribution of data points, it looks like it will be difficult for us to resolve distances less ... |
11,921 | <ASSISTANT_TASK:>
Python Code:
def numberOfLines(S , widths ) :
if(S == "") :
return 0 , 0
lines , width = 1 , 0
for c in S :
w = widths[ord(c ) - ord(' a ' ) ]
width += w
if width > 10 :
lines += 1
width = w
return lines , width
S = "bbbcccdddaa "
Widths =[4 , 1 , 1 , 1 , 1 , 1 , 1 ,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
11,922 | <ASSISTANT_TASK:>
Python Code:
A = np.array([[1, 3, -2], [3, 5, 6], [2, 4, 3]])
A
b = np.array([[5], [7], [8]])
b
Ainv = np.linalg.inv(A)
Ainv
x = np.dot(Ainv, b)
x
np.dot(A, x) - b
x, resid, rank, s = np.linalg.lstsq(A, b)
x
np.random.seed(0)
A = np.random.randn(3, 3)
A
np.linalg.det(A)
A = np.array([[2, 0], [-1, 1]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 위 해결 방법에는 두 가지 의문이 존재한다. 우선 역행렬이 존재하는지 어떻게 알 수 있는가? 또 두 번째 만약 미지수의 수와 방정식의 수가 다르다면 어떻게 되는가?
Step2: 행렬식과 역행렬 사이에는 다음의 관계가 있다.
|
11,923 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Instala o pacote
!pip install -q imdb-sqlite
# Instala o pacote
# https://pypi.org/project/pycountry/
!pip install -q pycountry
# 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: https
Step2: Agora executamos o pacote para download dos datasets.
Step3: Carregando os Dados
Step4: Agora começamos a Análise Exploratória d... |
11,924 | <ASSISTANT_TASK:>
Python Code:
import requests
lil_response = requests.get ('https://api.spotify.com/v1/search?query=Lil&type=artist&country=US&limit=50')
lil_data = lil_response.json()
print(type(lil_data))
lil_data.keys()
lil_data['artists'].keys()
lil_artists = lil_data['artists']['items']
#check on what elements ar... | <SYSTEM_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) With "Lil Wayne" and "Lil Kim" there are a lot of "Lil" musicians. Do a search and print a list of 50 that are playable in the USA (or the co... |
11,925 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
from sklearn.linear_model import LogisticRegression
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
# Load data with only two classes
iris = datasets.load_iris()
X = iris.data[:100,:]
y = iris.target[:100]
# Standarize features
scaler = 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:
Step1: Load Iris Flower Dataset
Step2: Standardize Features
Step3: Create Logistic Regression
Step4: Train Logistic Regression
Step5: Create Previo... |
11,926 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
my_series = pd.Series([1,3,5,np.nan,6,8])
my_series
my_dates_index = pd.date_range('20160101', periods=6)
my_dates_index
df_from_dictionary = pd.DataFrame({
'float' : 1.,
'time' : pd.Timestamp('20... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic series; default integer index
Step2: datetime index
Step3: sample NumPy data
|
11,927 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import os
from scipy import stats
lambp=10
dist= stats.poisson(lambp)
x= stats.poisson.rvs(mu=lambp, loc=0, size=1000000)
media= np.mean(x)
var= np.var(x)
media2=[]
for i in range (0,10001):
valo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Resultado
|
11,928 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
from __future__ import division
import numpy as np
from matplotlib import pyplot as plt
import cv2
import time
images = ['hist_pics/mario-1.png', 'hist_pics/mario-2.png', 'hist_pics/mario-3.png', 'hist_pics/mario-4.png', 'hist_pics... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Where's Mario?
Step6: Histograms
Step7: Test
|
11,929 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from astropy.io import ascii, votable, misc
#! mkdir ../data/Devor2008
#! curl http://iopscience.iop.org/1538-3881/135/3/850/suppdata/aj259648_mrt7.txt >> ../data/Devor2008/aj259648_mrt7.txt
! du -hs ../data/Devor2008/aj259648_mrt7.txt
dat = ascii.read('../data/Devor... | <SYSTEM_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 Data
Step2: Not too big at all.
Step3: Look for LkCa 4
Step4: The source is named T-Tau0-01262
Step5: The Devor et al. period is ju... |
11,930 | <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: Yo-yo
Step2: The results are
Step3: Rmin is the radius of the axle. Rmax is the radius of the axle plus rolled string.
Step4: Based on these... |
11,931 | <ASSISTANT_TASK:>
Python Code:
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", reshape=False)
X_train, y_train = mnist.train.images, mnist.train.labels
X_validation, y_validation = mnist.validation.images, mnist.validation.labels
X_test, y_test ... | <SYSTEM_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 MNIST data that TensorFlow pre-loads comes as 28x28x1 images.
Step2: Visualize Data
Step3: Preprocess Data
Step4: Setup TensorFlow
Step5:... |
11,932 | <ASSISTANT_TASK:>
Python Code:
!pip install datacommons_pandas datacommons --upgrade --quiet
# Import Data Commons libraries
import datacommons as dc
import datacommons_pandas as dcpd
# Gets all Superfund sites within USA
place_dcid = 'country/USA' # DCID of USA
site_list = dc.get_places_in([place_dcid], 'SuperfundS... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: List Superfund sites
Step2: In place of USA, you can specify any US state or county. You can use place search to find the corresponding DCID, a... |
11,933 | <ASSISTANT_TASK:>
Python Code:
NAME = "Michelle Appel"
NAME2 = "Verna Dankers"
NAME3 = "Yves van Montfort"
EMAIL = "michelle.appel@student.uva.nl"
EMAIL2 = "verna.dankers@student.uva.nl"
EMAIL3 = "yves.vanmontfort@student.uva.nl"
%pylab inline
plt.rcParams["figure.figsize"] = [9,5]
from sklearn.datasets import fetch_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lab 2
Step2: Part 1. Multiclass logistic regression
Step3: MNIST consists of small 28 by 28 pixel images of written digits (0-9). We split the... |
11,934 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
from scipy.spatial import cKDTree
from scipy.spatial.distance import cdist
from metpy.interpolate.geometry import dist_2
from metpy.interpolate.points import barnes_point, cressman_point
from metpy.interpolate.tools import calc_kappa
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: Generate random x and y coordinates, and observation values proportional to x * y.
Step2: Set up a cKDTree object and query all of the observat... |
11,935 | <ASSISTANT_TASK:>
Python Code:
from fbprophet import Prophet
from sklearn.metrics import r2_score
%run helper_functions.py
%autosave 120
%matplotlib inline
%run prophet_helper.py
%run prophet_baseline_btc.py
plt.style.use('fivethirtyeight')
plt.rcParams["figure.figsize"] = (15,10)
plt.rcParams["xtick.labelsize"] = 16
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: Forecasting BTC Price with Fb Prophet
Step2: Let's predict percentage change!
Step3: MSE IS 0.000488913299898903
Step4: we do terribly at pre... |
11,936 | <ASSISTANT_TASK:>
Python Code:
import math
import jax
import jax.lax as lax
import jax.numpy as jnp
import jax.random as jrandom
import optax # https://github.com/deepmind/optax
import equinox as eqx
def dataloader(arrays, batch_size, *, key):
dataset_size = arrays[0].shape[0]
assert all(array.shape[0] == 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: We begin by importing the usual libraries, setting up a very simple dataloader, and generating a toy dataset of spirals.
Step2: Now for our mod... |
11,937 | <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: TensorFlow Data Validation
Step2: Install Data Validation packages
Step3: Import TensorFlow and reload updated packages
Step4: Check the vers... |
11,938 | <ASSISTANT_TASK:>
Python Code:
from pred import Predictor
from pred import sequence_vector
y = Predictor()
y.load_data(file="Data/Training/clean_Y.csv")
y.process_data(vector_function="sequence", amino_acid="Y", imbalance_function="ADASYN", random_data=0)
y.supervised_training("mlp_adam")
y.benchmark("Data/Benchmar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next we are going to load our data and generate random negative data aka gibberish data. The clean data files has negatives created from the dat... |
11,939 | <ASSISTANT_TASK:>
Python Code:
def normalize(M):
M_norm = np.full_like(M, 0)
for i in range(np.shape(M)[0]):
rev = 1 - M[i, :]
if np.dot(M[i, :], M[i, :]) > np.dot(rev, rev):
M_norm[i, :] = rev
else:
M_norm[i, :] = M[i, :]
return M_norm
r = np.genfromtxt("LIC... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Данные для смеси 4 кишечных палочек в реальной пропорции. Выравнивали на референс не из данных.
Step2: Низкопокрытые образцы
Step3: Как видим,... |
11,940 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import sys,os
ia898path = os.path.abspath('../../')
if ia898path not in sys.path:
sys.path.append(ia898path)
import ia898.src as ia
fin = mpimg.imread('../data/lenina.pgm')
nb = ia.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading and ROI selection
Step2: DFT
Step3: Expansion by 4 without interpolation
Step4: DFT of the expansion without interpolation
Step5: Fi... |
11,941 | <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... |
11,942 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
%pylab inline
stroop_data = pd.read_csv('./stroopdata.csv')
stroop_data.head()
stroop_data.describe()
print "Median:\n", stroop_data.median()
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: Variables
Step2: Independent variable
Step3: The above visualizations clearly show that the response time for the congruent words condition is... |
11,943 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import time as tm
import matplotlib.pyplot as plt
# Discretization
c1=20 # Number of grid points per dominant wavelength
c2=0.5 # CFL-Number
nx=2000 # Number of grid points
T=10 # Total propagation time
# Source Signal
f0= 10 # Center fre... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Input Parameter
Step2: Preparation
Step3: Create space and time vector
Step4: Source signal - Ricker-wavelet
Step5: Time stepping
Step6: Sa... |
11,944 | <ASSISTANT_TASK:>
Python Code:
def fun(a,b):
x = a + b
print(fun(1,2))
def fun(a,b):
x = a+b
return(x)
print(fun(1,2))
def fun2():
print(a)
a=2
fun2()
def fun3():
x = a+2
return(x)
fun3()
def fun4():
a = a+2
return(a)
fun4()
<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: No es posible imprimir por pantalla el valor de "x" ya que solo existe dentro de la función. Para llevar a "x" a un scope superior, es decir que... |
11,945 | <ASSISTANT_TASK:>
Python Code:
complex_xml = os.path.join(PROJECT_ROOT, 'complex-events.xml.gz')
# get just "complex events"
# Q: what's complex? -- complex == no full coordinates
def complex_measures(x):
if x.measure:
return (
# smattering of all non SNV variants
(x.measure.variant_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dataframe
Step2: XML
|
11,946 | <ASSISTANT_TASK:>
Python Code:
score_data = pd.read_csv("../data/indico_nyt_bitcoin.csv", index_col='time',
parse_dates=[0], date_parser=lambda x: datetime.datetime.strptime(x, time_format))
score_data.head()
weekly_score = score_data.resample('w', how='mean').loc['2013':].fillna(0.5)
weekly_score.h... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Compute average sentiment score per week
Step2: read bitcoin price data
Step3: add news volume data
Step4: AlchemyAPI sentiment score
Step5: ... |
11,947 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
from __future__ import division
import numpy as np
from matplotlib import pyplot as plt
from sympy import symbols, sin, cos, simplify, trigsimp, pi
from math import radians as d2r
from math import degrees as r2d
from math import ata... | <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: Lynx Motion AL5D
Step8: The DH parameters are
Step11: Inverse Kinematics
Step12: Phasing
|
11,948 | <ASSISTANT_TASK:>
Python Code:
from cameo import models
model = models.bigg.e_coli_core.copy()
model.solver = "cplex"
from cameo import phenotypic_phase_plane
ppp = phenotypic_phase_plane(model, variables=[model.reactions.BIOMASS_Ecoli_core_w_GAM], objective=model.reactions.EX_ac_e)
ppp.plot()
from cameo.strain_design... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: OptGene
Step2: OptKnock
Step3: Running multiple knockouts with OptKnock can take a few hours or days...
|
11,949 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'sandbox-3', 'ocean')
# 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... |
11,950 | <ASSISTANT_TASK:>
Python Code:
a = [i*i for i in range(3)]
a
b = a
b[1] = 'hello'
b
a
a = [i*i for i in range(3)]
a
b = a[:]
b[1] = 'hello'
b
a
a = [i*i for i in range(3)]
a
b = a.copy()
b[1] = 'hello'
b
a
def foo(s):
return s + ' on the Beach.'
list(map(foo, ('sand', 'clams', 'dunes')))
a = (1, 2, 3)
b = (2, 3, 4... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Show what map() does.
Step2: fstrings can handle expressions, not just variable names.
|
11,951 | <ASSISTANT_TASK:>
Python Code:
import sys
print(sys.version)
import numpy as np
np.__version__
import matplotlib as mpl
from matplotlib import pyplot as plt
mpl.__version__
values = np.zeros((2,50))
size = values.shape
print(size)
for i in range(size[1]):
values[0,i] = i * 2
values[1,i] = np.sin(i / 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: At this point anything above python 3.5 should be ok.
Step2: Notes
Step3: Notes
Step4: Notes
Step5: Notes
Step6: Notes
Step7: Notes
Step8:... |
11,952 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import seaborn
%matplotlib inline
x = np.linspace(-6, 6, num = 1000)
plt.figure(figsize = (12,8))
plt.plot(x, 1 / (1 + np.exp(-x))); # Sigmoid Function
plt.title("Sigmoid Function");
tmp = [0, 0.4, 0.6, 0.8, 1.0]
tmp
np.round(tmp)
np.arr... | <SYSTEM_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 logistic regression equation has a very simiar representation like linear regression. The difference is that the output value being modelled... |
11,953 | <ASSISTANT_TASK:>
Python Code:
import pandas
import numpy
import toyplot
import toyplot.pdf
import toyplot.png
import toyplot.svg
print('Pandas version: ', pandas.__version__)
print('Numpy version: ', numpy.__version__)
print('Toyplot version: ', toyplot.__version__)
column_names = ['MPG',
'Cylinder... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in the "auto" dataset. This is a fun collection of data on cars manufactured between 1970 and 1982. The source for this data can be found a... |
11,954 | <ASSISTANT_TASK:>
Python Code:
devices = factorial_hmm.gen_devices()
T = 50
np.random.seed(20)
X, Y = factorial_hmm.gen_dataset(devices, T)
plt.figure(figsize=(15,3.5))
plt.plot(Y)
plt.figure(figsize=(15,10))
plt.imshow((X*devices).T, interpolation='None', aspect=1);
plt.yticks(np.arange(len(devices)), devices);
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: Test out learned distribution inside of SMC
Step2: Look at rate of path coalescence
|
11,955 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
#logger = phoebe.logger('error')
b = phoebe.default_binary()
print(b['irrad_frac_refl_bol'])
print(b['irrad_frac_lost_bol'])
print(b['irrad_frac_refl_bol@pri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new bundle.
Step2: Relevant Parameters
Step3: In order to see the effect of reflecti... |
11,956 | <ASSISTANT_TASK:>
Python Code:
from PyDSTool import *
icdict = {'x': 1, 'y': 0.4} # Initial conditions dictonnary
pardict = {'k': 0.1, 'm': 0.5} # Parameters values dictionnary
x_rhs = 'y'
y_rhs = '-k*x/m'
vardict = {'x': x_rhs, 'y': y_rhs}
DSargs = args() # create an empty object instance of 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: First we need to declare a name that we will use for the dictionnary containing initial conditions for two variables. In the same way we need to... |
11,957 | <ASSISTANT_TASK:>
Python Code:
import pandas
#create a dataframe called "df"
df = pandas.read_csv("BDHSI2016_music_reviews.csv", sep = '\t')
##I'm going to do a pre-processing step to remove digits in the text, for analytical purposes.
##If you don't understand this code right now it's ok. But challenge yourself to mak... | <SYSTEM_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. Explore the Data using Pandas
Step2: You can see that this provides summary statistics for numerical columns. In our case, our only numerica... |
11,958 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
%matplotlib inline
# import all Shogun classes
from modshogun import *
# use scipy for generating samples
from scipy.stats import norm, laplace
def sample_gaussian_vs_laplace(n=220, mu=0.0, sigma2=1, b=sqrt(0.5)):
# sample from both distributions
X=norm.rvs(size... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Some Formal Basics (skip if you just want code examples)
Step2: Now how to compare these two sets of samples? Clearly, a t-test would be a bad ... |
11,959 | <ASSISTANT_TASK:>
Python Code:
import pypsa, numpy as np
# marginal costs in EUR/MWh
marginal_costs = {"Wind": 0, "Hydro": 0, "Coal": 30, "Gas": 60, "Oil": 80}
# power plant capacities (nominal powers in MW) in each country (not necessarily realistic)
power_plant_p_nom = {
"South Africa": {"Coal": 35000, "Wind": 30... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Single bidding zone with fixed load, one period
Step2: Two bidding zones connected by transmission, one period
Step3: Three bidding zones conn... |
11,960 | <ASSISTANT_TASK:>
Python Code:
%run ../src/LinearRegression.py
%run ../src/PolynomialFeatures.py
# LINEAR REGRESSION
# Generate random data
X = np.linspace(0,20,10)[:,np.newaxis]
y = 0.1*(X**2) + np.random.normal(0,2,10)[:,np.newaxis] + 20
# Fit model to data
lr = LinearRegression()
lr.fit(X,y)
# Predict new data
x_tes... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Logistic regression
Step2: Non-parametric models
|
11,961 | <ASSISTANT_TASK:>
Python Code:
import json
from itertools import chain
from pprint import pprint
from time import time
import os
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn.metrics import accuracy_score
from gensim.models import Word2Vec
from gensim.corpora.dictionary import Dicti... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dane pochodzą z ręcznie tagowanego treebanku (korpusu anotowanego składniowo) opracowanego przez Zespół Inżynierii Lingwistycznej IPI PAN na baz... |
11,962 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'mpiesm-1-2-ham', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
11,963 | <ASSISTANT_TASK:>
Python Code:
import ee
# Trigger the authentication flow.
ee.Authenticate()
# Initialize the library.
ee.Initialize()
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm, gamma, f, chi2
import IPython.display as disp
%matplotlib inline
# Import the Folium library.
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: Datasets and Python modules
Step2: And to make use of interactive graphics, we import the folium package
Step3: Part 2. Hypothesis testing
Ste... |
11,964 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
a = np.array([1.5, -0.4, 1.3])
vals, idx = np.unique(a, return_inverse=True)
b = np.zeros((a.size, vals.size))
b[np.arange(a.size), idx] = 1
<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:
|
11,965 | <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: input_fn이 잘 구현되었는지 확인해봅니다.
Step6: ... |
11,966 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import os
import numpy as np
os.environ['DES_BACKEND'] = 'numpy'
import desolver as de
import desolver.backend as D
from desolver.backend import gdual_double as gdual
T = 1e-3
@de.rhs_prettifier(equ_repr="[vr, -1/r**2 + r*vt**2, vt, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: High Order Taylor Maps I
Step2: We perform the numerical integration using floats (the standard way)
Step3: We perform the numerical integrati... |
11,967 | <ASSISTANT_TASK:>
Python Code:
import sklearn
import scipy
import scipy.optimize
import matplotlib.pyplot as plt
import itertools
import time
from functools import partial
import os
import numpy as np
from scipy.special import logsumexp
np.set_printoptions(precision=3)
import torch
import torch.nn as nn
import torchvis... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example
Step2: Computing gradients by hand
Step3: PyTorch code
Step4: Autograd on a DNN
Step5: Let's visualize the model and all the paramet... |
11,968 | <ASSISTANT_TASK:>
Python Code:
! echo 'hello, world!'
!echo $t
%%bash
mkdir test_directory
cd test_directory/
ls -a
#удаление директории, если она не нужна
! rm -r test_directory
%%cmd
mkdir test_directory
cd test_directory
dir
%%cmd
rmdir test_directiory
%lsmagic
%pylab inline
y = range(11)
y
plot(y)
<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: Ниже аналоги команд для пользователей Windows
Step2: удаление директории, если она не нужна (windows)
|
11,969 | <ASSISTANT_TASK:>
Python Code:
import timeseries, TimeseriesDB, Similarity
import cs207rbtree.RedBlackTree as Database
dir(Database)
demoDB = Database.connect("/tmp/test1.dbdb")
demoDB.set("rahul", 81)
demoDB.set("pavlos", 20)
demoDB.set("sarah", 29)
demoDB.set("courtney", 11)
demoDB.set("andrew", 12)
demoDB... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using the Red-Black Tree
Step2: Multithreadedness
|
11,970 | <ASSISTANT_TASK:>
Python Code:
import mne
import numpy as np
from mne.datasets import sample
from mne.minimum_norm import make_inverse_operator, apply_inverse
data_path = sample.data_path()
evokeds = mne.read_evokeds(data_path + '/MEG/sample/sample_audvis-ave.fif')
left_auditory = evokeds[0].apply_baseline()
fwd = mne.... | <SYSTEM_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 source space
Step2: Fixed dipole orientations
Step3: Restricting the dipole orientations in this manner leads to the following
Step4: The... |
11,971 | <ASSISTANT_TASK:>
Python Code:
cd ..
!cat magical.freeze
!cat fresh.freeze
magical = []
with open("magical.freeze") as f:
for l in f:
magical.append(l)
fresh = []
with open("fresh.freeze") as f:
for l in f:
fresh.append(l)
set(magical) - set(fresh)
fresh = []
with open("fresh.freeze") as 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: Comparing line by line by eye is a bit annoying, so using Python
Step2: Then we can just use sets to compare
Step3: Installing just those in t... |
11,972 | <ASSISTANT_TASK:>
Python Code:
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
import torch
def softmax(mtx):
Compute softmax on 2D tensor alon the second dimension
e = np.exp(mtx)
s = np.sum(e, axis=1)
return e / s[:, None]
X = np.arange(18, dtype=np.float64).reshape(3, 6)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Masking PAD symbols in attention weights
Step2: Masked assignment
Step3: Let's create a mask for the 'valid' symbols
Step4: Now we want to co... |
11,973 | <ASSISTANT_TASK:>
Python Code:
import threading
import time
a = ''
def task_1():
global a
for i in range(10):
print('o', end='', flush=True)
a += 'o'
print(a)
time.sleep(1) # Blocking -> yield to other thread
def task_2():
global a
for i in range(20):
pri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Notice that both threads share the same process memory space.
Step2: But ... why a has not been modified? Why the processed do not share a?
Ste... |
11,974 | <ASSISTANT_TASK:>
Python Code:
datafile = open('./data/examp_data.txt', 'r')
data = []
for row in datafile:
data.append(row.strip().split(','))
data
import csv
datafile = open('./data/examp_data.txt', 'r')
datareader = csv.reader(datafile, delimiter=',')
data = []
for row in datareader:
data.append(row)
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: CSV Module
Step2: Using Numpy
Step3: Pandas
Step4: Pandas dataframes do behave a bit differently than a lot of list based structures in Pytho... |
11,975 | <ASSISTANT_TASK:>
Python Code:
import os
import mne
print(mne.get_config('MNE_USE_CUDA'))
print(type(mne.get_config('MNE_USE_CUDA')))
try:
mne.set_config('MNE_USE_CUDA', True)
except TypeError as err:
print(err)
print(mne.get_config('missing_config_key', default='fallback value'))
print(mne.get_config()) #... | <SYSTEM_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 and setting configuration variables
Step2: Note that the string values read from the JSON file are not parsed in any
Step3: If you're ... |
11,976 | <ASSISTANT_TASK:>
Python Code:
import vaex
import numpy as np
np.warnings.filterwarnings('ignore')
dstaxi = vaex.open('src/nyc_taxi2015.hdf5') # mmapped, doesn't cost extra memory
dstaxi.plot_widget("pickup_longitude", "pickup_latitude", f="log", backend="ipyleaflet", shape=600)
dstaxi.plot_widget("dropoff_longitude", ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ipyvolume
Step2: A Billion stars in the Jupyter notebook
|
11,977 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from ttim import *
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
H0 = 2.798 #initial displacement in m
b = -6.1 #aquifer thickness
rw1 = 0.102 #well radius of Ln-2 Well
rw2 = 0.071 #well radius of observation Ln-3 Well
rc1 = 0.051 #casing radiu... | <SYSTEM_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 background parameters
Step2: Slug
Step3: Load data
Step4: Create single layer conceptual model
Step5: Calibrate with two datasets simult... |
11,978 | <ASSISTANT_TASK:>
Python Code:
# Authors: Eric Larson <larson.eric.d@gmail.com>
# Chris Holdgraf <choldgraf@gmail.com>
# Adam Li <adam2392@gmail.com>
# Alex Rockhill <aprockhill@mailbox.org>
# Liberty Hamilton <libertyhamilton@gmail.com>
#
# License: BSD-3-Clause
import os.path as op... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in data and perform basic preprocessing
Step2: Explore the electrodes on a template brain
Step3: Compute frequency features of the data
S... |
11,979 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
# read CSV file directly from a URL and save the results
data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Advertising.csv', index_col=0)
# display the first 5 rows
data.head()
data.shape
# conventional way to import seaborn
import seaborn as sns
# allow plots ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: What are the features?
Step2: Linear regression
Step3: Splitting X and y into training and testing sets
Step4: Linear regression in scikit-le... |
11,980 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-3', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
11,981 | <ASSISTANT_TASK:>
Python Code:
import nltk
from nltk.corpus import brown
brown.words()[0:10]
brown.tagged_words()[0:10]
len(brown.words())
dir(brown)
from nltk.book import *
dir(text1)
len(text1)
from nltk import sent_tokenize, word_tokenize, pos_tag
text = "Machine learning is the science of getting computers to ac... | <SYSTEM_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. Test Brown Corpus
Step2: 2. Test NLTK Book Resources
Step3: 3. Sent Tokenize(sentence boundary detection, sentence segmentation), Word Toke... |
11,982 | <ASSISTANT_TASK:>
Python Code:
# Store even numbers from 0 to 20
even_lst = [num for num in range(21) if num % 2 == 0]
print(even_lst)
cash_value = 20
rsu_dict = {"Max":20, "Willie":13, "Joanna":14}
lst = [rsu_dict[name]*cash_value for name in rsu_dict]
print(lst)
my_dict = {"Ross":19, "Bernie":13, "Micah":15}
cash_va... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example 2 Convert the reserved stock units (RSUs) an employee has in a company to the current cash value.
Step2: Let's take a look at some valu... |
11,983 | <ASSISTANT_TASK:>
Python Code:
%env PROJECT_ID <YOUR_PROJECT_ID>
%env BUCKET_ID <YOUR_BUCKET_ID>
%env REGION <REGION>
%env TRAINER_PACKAGE_PATH ./census_training
%env MAIN_TRAINER_MODULE census_training.train
%env JOB_DIR <gs://YOUR_BUCKET_ID/xgb_job_dir>
%env RUNTIME_VERSION 1.9
%env PYTHON_VERSION 3.5
! mkdir census_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data
Step2: Part 2
Step3: Part 3
Step4: Submit the training job.
Step5: [Optional] StackDriver Logging
|
11,984 | <ASSISTANT_TASK:>
Python Code:
import hail as hl
hl.init()
ht = hl.import_table("gs://hail-datasets-tmp/dbSNP/GCF_000001405.25_GRCh37.p13_assembly_report.txt",
no_header=True,
comment="#",
delimiter="\t",
missing="na")
field_names =... | <SYSTEM_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 Hail Tables from GRCh37 and GRCh38 assembly reports
Step2: GRCh38
Step3: Create Hail Tables for dbSNP
Step4: Use the function and know... |
11,985 | <ASSISTANT_TASK:>
Python Code:
import cvxpy
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rc("text", usetex=True)
num_iters = 30
n = 20
m = 10
A = np.random.randn(m, n)
b = np.random.randn(m, 1)
# Initialize problem
x = cvxpy.Variable(shape=(n, 1))
f = cvxpy.norm(x, 2)
# Solve with CVXPY.
cv... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pro & Contra
Step2: Модельный пример
Step3: Метод модифицированной функции Лагранжа
Step4: Существенная проблема
Step5: Учтём, что все свойс... |
11,986 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('../data/tidy_who.csv')
df.head()
df.shape
df.sample(10)
df.describe()
df['g_whoregion'].unique()
df['country'].nunique()
df['country'].head(3)
df.country[1000:1003]
df.loc[0, 'country']
df.loc[df.shape[0] - 1, 'country']
df.iloc[0, 0]
df.iloc[df.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: Loading data
Step2: Selecting data
Step3: Columns can also be accessed as attributes (as long as they have a valid Python name).
Step4: We ca... |
11,987 | <ASSISTANT_TASK:>
Python Code:
from psychopy import visual, core, event
import numpy as np
win = visual.Window()
core.wait(1)
win.close()
# Create a window and a circle
win = visual.Window()
circle = visual.Circle(win, radius=0.1)
# Show the circle until keypress
circle.draw()
win.flip()
event.waitKeys()
# Close the... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example 1
Step2: Example 2
Step3: Example 3 - Reaction time test
Step4: Question from class
|
11,988 | <ASSISTANT_TASK:>
Python Code:
N_people = 500
ratio_female = 0.30
proba = 0.40
def the_sd(N, p, r):
N = float(N)
p = float(p)
r = float(r)
return sqrt(1.0/N*(p*(1.0-p))/(r*(1.0-r)))
def sd_func_factory(N,r):
def func(p):
return the_sd(N,p,r)
return func
f = sd_func_factor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Closed Form Approximation
Step2: Thats the one-standard deviation range about the estimator. For example
Step3: that's the same relationship a... |
11,989 | <ASSISTANT_TASK:>
Python Code:
import os
import time
import pandas as pd
from google.cloud import aiplatform, bigquery
from sklearn.compose import ColumnTransformer
from sklearn.linear_model import SGDClassifier
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler
REGIO... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configure environment settings
Step2: We now create the ARTIFACT_STORE bucket if it's not there. Note that this bucket should be created in the... |
11,990 | <ASSISTANT_TASK:>
Python Code:
from zipfile import ZipFile
fname = "../examples/force-save-2016.07.05-10.00.50.062.jpk-nt-force"
z = ZipFile(fname)
list_of_files = z.filelist
for f in list_of_files:
print f.filename
print list_of_files[0].filename
f = z.open(list_of_files[0].filename)
lines = f.readlines()
print 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: It you can get the list of files stored in the zip archive, and you can open files using the instance's open function
Step2: 2. Parse header fi... |
11,991 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import image_loader as im
from matplotlib import pyplot as plt
from skimage.transform import resize
%matplotlib inline
path=os.getcwd()+'/' # finds the path of the folder in which the notebook is
path_train=path+'images/train/'
path_test=path+'images/test/'
pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We first define a function to prepare the datas in the format of keras (theano). The function also reduces the size of the imagesfrom 100X100 to... |
11,992 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
import helper
import numpy as np
from sklearn.preprocessing import LabelBinarizer
import pickle
import tensorflow as tf
import random
%matplotlib... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get the Data
Step2: Explore the Data
Step4: Implement Preprocess Functions
Step6: One-hot encode
Step7: Randomize Data
Step8: Check Point
S... |
11,993 | <ASSISTANT_TASK:>
Python Code:
# import required modules for data preparation tasks
import requests, zipfile, StringIO
import pandas as pd
import random
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
import re
import json
import os
# reads all predefined months for a year and merge into one 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: 2.1 Get the Main Delay Data for 2014 from Downloaded zip Files
Step2: The columns we now have in the dataset are
Step3: However, we just need ... |
11,994 | <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: Post-training dynamic range quantization
Step2: Train a TensorFlow model
Step3: For the example, since you trained the model for just a single... |
11,995 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import cvxopt as opt
from cvxopt import blas, solvers
import pandas as pd
np.random.seed(123)
# Turn off progress printing
solvers.options['show_progress'] = False
## NUMBER OF ASSETS
n_assets = 4
## NUMBER OF OBSERVATIONS
n_obs = 1000
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Assume that we have 4 assets, each with a return series of length 1000. We can use numpy.random.randn to sample returns from a normal distributi... |
11,996 | <ASSISTANT_TASK:>
Python Code:
!pip install google-api-python-client
!pip install google-cloud-vision
import csv
import datetime
import io
import json
import pprint
from google.api_core import retry
from google.cloud import vision
from google.colab import files
from google_auth_oauthlib.flow import InstalledAppFlow
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: 0.2 Setup your GCP project
Step2: 0.4 Set DV360 account settings
Step4: Create a new 'sandbox' campaign to use with the rest of the exercises
... |
11,997 | <ASSISTANT_TASK:>
Python Code:
#This is a notebook containing the code of blogpost http://ataspinar.com/2017/05/26/classification-with-scikit-learn/
#Although I'll also give a short description in this notebook, for a full explanation you should read the blog.
# Lets import some modules for basic computation
import tim... | <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: http
Step4: 1. The glass - dataset
Step5: 1.3 Classification
Step6: 2. Mushroom dataset (containing categorical data)
Step7: 2.1 Preprocessi... |
11,998 | <ASSISTANT_TASK:>
Python Code:
from sklearn.decomposition import PCA
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # 3D Plotting
from scipy import stats
import ipywidgets # interactions
%matplotlib inline
np.random.seed(4) # Reproducible resul... | <SYSTEM_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 data
Step2: As you can see, most of the variation is in just one direction. We can formalize this intuition by using PCA to draw out the... |
11,999 | <ASSISTANT_TASK:>
Python Code:
running_id = 0
output = [[0]]
with open("E:/output.txt") as file_open:
for row in file_open.read().split("\n"):
cols = row.split(",")
if cols[0] == output[-1][0]:
output[-1].append(cols[1])
output[-1].append(True)
else:
outpu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problems
Step2: Problems
Step3: Problems
Step4: If we want to look at covariates, we need a new approach.
Step5: Once we've fit the data, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.