Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
13,400 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile
from tqdm import tqdm
class DLProgress(tqdm):
last_block = 0
def hook(self, block_num=1, block_size=1, total_size=None):
self.total = total_size
self.update((block_num - self.last_block) * block_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: Overview
Step2: Load the Data
Step3: Preprocess the Data
Step5: Normalize the features
Step6: One-Hot Encode the labels
Step7: Keras Sequen... |
13,401 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-2', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contribut... | <SYSTEM_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... |
13,402 | <ASSISTANT_TASK:>
Python Code:
import ibis.expr.datatypes as dt
import ibis.expr.rules as rlz
from ibis.expr.operations import ValueOp
class JulianDay(ValueOp):
arg = rlz.string
output_dtype = dt.float32
output_shape = rlz.shape_like('arg')
from ibis.expr.types import BinaryValue, StringValue
def julianday... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step 1
Step2: We just defined a JulianDay class that takes one argument of type string or binary, and returns a float.
Step 2
Step3: Interlude
Step4: ... |
13,403 | <ASSISTANT_TASK:>
Python Code:
from itertools import *
for i in chain([1, 2, 3], ['a', 'b', 'c']):
print(i, end=' ')
print()
from itertools import *
def make_iterables_to_chain():
yield [1, 2, 3]
yield ['a', 'b', 'c']
for i in chain.from_iterable(make_iterables_to_chain()):
print(i, end=' ')
print()
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: If the iterables to be combined are not all known in advance, or need to be evaluated lazily, chain.from_iterable() can be used to construct the... |
13,404 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%pylab inline
# Load the data
# TODO
# Normalize the data
from sklearn import preprocessing
X = preprocessing.normalize(X)
# Set up a stratified 10-fold cross-validation
from sklearn import cross_validation
folds = cross_validation.StratifiedKFold(y, 10, shuffle=True)
d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2016-11-04
Step2: 1. Decision trees
Step3: Question Compute the mean and standard deviation of the area under the ROC curve of these 5 trees. ... |
13,405 | <ASSISTANT_TASK:>
Python Code:
#For final version of report, remove warnings for aesthetics.
import warnings
warnings.filterwarnings('ignore')
#Libraries used for data analysis
import pandas as pd
import numpy as np
from sklearn import preprocessing
df = pd.read_csv('data/cleaned.csv') # read in the csv file
colsToIncl... | <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: Neural Network Embeddings
Step3: The following are descriptions of the remaining data columns in the play-by-play dataset. Note that the one-ho... |
13,406 | <ASSISTANT_TASK:>
Python Code:
# !pip install --quiet phiflow
from phi.flow import *
grid = StaggeredGrid(0, extrapolation.BOUNDARY, x=10, y=10)
grid.values
domain = dict(x=10, y=10, bounds=Box(x=1, y=1), extrapolation=extrapolation.ZERO)
grid = StaggeredGrid((1, -1), **domain) # from constant vector
grid = Staggered... | <SYSTEM_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, each component of the values tensor has one more sample point in the direction it is facing.
Step2: Staggered grids can also be created f... |
13,407 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import matplotlib.pyplot as plt
import torch
from torchvision import datasets, transforms
import helper
data_dir = 'Cat_Dog_data/train'
# TODO: compose transforms here
transform = transforms.Compose([transforms.Resize(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: The easiest way to load image data is with datasets.ImageFolder from torchvision (documentation). In general you'll use ImageFolder like so
Step... |
13,408 | <ASSISTANT_TASK:>
Python Code:
descripciones = {
'P0609': 'Usuarios Electricos'
}
# Librerias utilizadas
import pandas as pd
import sys
import urllib
import os
import csv
import zipfile
# Configuracion del sistema
print('Python {} on {}'.format(sys.version, sys.platform))
print('Pandas version: {}'.format(pd.__vers... | <SYSTEM_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. Descarga de datos
Step2: 3. Estandarizacion de datos de Parámetros
Step3: Exportar Dataset
|
13,409 | <ASSISTANT_TASK:>
Python Code:
xx = np.linspace(-3,5,100)
exp = np.exp(-xx)
qua = map(lambda x: (1-x)**2 if x<1 else 0,xx )
hin = map(lambda x: 1-x if x<1 else 0,xx )
sig = 1 - np.tanh(xx)
plt.figure(figsize=(10,7))
plt.plot(xx,sig,label='sigmoid loss')
plt.plot(xx,exp,label='exponential loss')
plt.plot(xx,qua,label='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: Exercise 1.2 (10 pts)
Step2: The following code reads the data, subselects the $y$ and $X$ variables, and makes a training and test split. Thi... |
13,410 | <ASSISTANT_TASK:>
Python Code:
import os
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if os.environ["IS_TESTING"]:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
13,411 | <ASSISTANT_TASK:>
Python Code:
import wicked as w
from IPython.display import display, Math, Latex
def latex(expr):
Function to render any object that has a member latex() function
display(Math(expr.latex()))
w.reset_space()
w.add_space("o", "fermion", "occupied", ['i','j','k','l','m'])
w.add_space("v", "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: Generating Wick's theorem contractions
Step2: Wick's theorem contractions
Step3: To apply Wick's theorem to this product, you need to create a... |
13,412 | <ASSISTANT_TASK:>
Python Code:
# Author: Eric Larson <larson.eric.d@gmail.com>
# Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import mne
Brain = mne.viz.get_brain_class()
subjects_dir = mne.datasets.sample.data_path() + '/subjects'
mne.datasets.fetch_hcp_mmp_parcellation(subjects_dir=su... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can also plot a combined set of labels (23 per hemisphere).
Step2: We can add another custom parcellation
|
13,413 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras import layers
from keras.layers import Input, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D
from keras.layers import AveragePooling2D, MaxPooling2D, Dropout, GlobalMaxPooling2D, GlobalAveragePooling2D
from keras.models import Model
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: Note
Step3: Details of the "Happy" dataset
Step4: You have now built a function to describe your model. To train and test this model, there ar... |
13,414 | <ASSISTANT_TASK:>
Python Code:
# put your code here, and add additional cells as necessary.
%matplotlib inline
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
alldata = np.loadtxt('datafile_1.csv',comments='#',unpack=True,delimiter=',')
xval = alldata[0]
xerr = alldata[1]
yval... | <SYSTEM_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 2
Step3: In the cell below, describe some of the conclusions that you've drawn from the data you have just explored!
|
13,415 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
import statsmodels.sandbox.stats.multicomp as mc
colors = ('#377eb8', '#ff7f00', '#4daf4a', '#f781bf', '#a65628', '#984ea3', '#999999', '#e41a1c') # , '#dede00')
df = pd.re... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set up a color palette reputed to be color blind friendly. From
Step2: Read in the data. I am using a modified version of the UCI Auto MPG da... |
13,416 | <ASSISTANT_TASK:>
Python Code:
# Run this cell to set up the notebook, but please don't change it.
# These lines import the Numpy and Datascience modules.
import numpy as np
from datascience import *
# These lines do some fancy plotting magic.
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
plt.sty... | <SYSTEM_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. Functions and CEO Incomes
Step2: Question 1. When we first loaded this dataset, we tried to compute the average of the CEOs' pay like this
S... |
13,417 | <ASSISTANT_TASK:>
Python Code:
#這行是在ipython notebook的介面裏專用,如果在其他介面則可以拿掉
%matplotlib inline
from sklearn import datasets
import matplotlib.pyplot as plt
#載入數字資料集
digits = datasets.load_digits()
#畫出第一個圖片
plt.figure(1, figsize=(3, 3))
plt.imshow(digits.images[-1], cmap=plt.cm.gray_r, interpolation='nearest')
plt.show()
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: (二)資料集介紹
Step2: | 顯示 | 說明 |
Step3:
|
13,418 | <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 time constant functions of original model
Step3: Activation gate ($r$) calibration
Step4: Set up ... |
13,419 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('iris.csv')
df.head()
df.groupby(df.Species).PetalLength.mean() # Average petal length per species
from odo import odo
import numpy as np
import pandas as pd
odo("iris.csv", pd.DataFrame)
odo("iris.csv", list)
odo("iris.csv", np.ndarray)
odo("iris.c... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <hr/>
Step2: <hr/>
Step3: What kind of object did you get receive as output? Call type on your result.
Step4: <hr/>
Step5: <hr/>
Step6: <h... |
13,420 | <ASSISTANT_TASK:>
Python Code:
x = (1, 2, 3, 4)
y = (5, 6, 7, 8)
n = len(x)
if n == len(y):
result = 0
for i in range(n):
result += x[i] * y[i]
print(result)
import numpy as np
x = np.array([1, 2, 3, 4])
y = np.array([5, 6, 7, 8])
print("x:", x)
print("y:", y)
np.dot(x, y)
np.dot(y, x)
print("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: It is clear that in the code above we could change line 7 to result += y[i] * x[i] without affecting the result.
Step2: We define the vectors $... |
13,421 | <ASSISTANT_TASK:>
Python Code:
import arviz as az
import pystan
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(26)
xdata = np.linspace(0, 50, 100)
b0, b1, sigma = -2, 1, 3
ydata = np.random.normal(loc=b1 * xdata + b0, scale=sigma)
plt.plot(xdata, ydata)
refit_lr_code =
data {
// Define data for ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For the example, we will use a linear regression model.
Step3: Now we will write the Stan code, keeping in mind that it must be able to compute... |
13,422 | <ASSISTANT_TASK:>
Python Code:
import os, sys
sys.path.append(os.path.abspath("../../../"))
import numpy as np
import pandas as pd
import dowhy.api
N = 5000
z = np.random.uniform(size=N)
d = np.random.binomial(1., p=1./(1. + np.exp(-5. * z)))
y = 2. * z + d + 0.1 * np.random.normal(size=N)
df = pd.DataFrame({'Z': z, 'D... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: So the naive effect is around 60% high. Now, let's build a causal model for this data.
Step2: Now that we have a model, we can try to identify ... |
13,423 | <ASSISTANT_TASK:>
Python Code:
# This is to change logging level of jupyter notebook
try:
from importlib import reload # for python 3
except:
pass
import logging
reload(logging)
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO, datefmt='%I:%M:%S')
# This is to show matplotlib output in... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sample Info
Step2: The read mapping output from STAR is a BAM file. We convert the BAM file to BED file. You can do this using bedtools bamtobe... |
13,424 | <ASSISTANT_TASK:>
Python Code:
# This cell has to be run to prepare the Jupyter notebook
# The %... is an Jupyter thing, and is not part of the Python language.
# In this case we're just telling the plotting library to draw things on
# the notebook, instead of on a separate window.
%matplotlib inline
# See all the "as ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Agenda
Step2: Clusterhypothese
Step3: Vorkommenshäufigkeit des Terms im Dokument
Step4: Trennschärfe des Terms
Step5: Bewertung des Vektorra... |
13,425 | <ASSISTANT_TASK:>
Python Code:
%tensorflow_version 1.x
!curl -Lo deepchem_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import deepchem_installer
%time deepchem_installer.install(version='2.3.0')
import os
import unittest
import numpy as np
import deepchem as dc
impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: With our setup in place, let's do a few standard imports to get the ball rolling.
Step2: The ntext step we want to do is load our dataset. We'r... |
13,426 | <ASSISTANT_TASK:>
Python Code:
# Authors: Marijn van Vliet <w.m.vanvliet@gmail.com>
#
# License: BSD (3-clause)
from matplotlib import pyplot as plt
import mne
from mne.datasets import sample
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(raw_fname)... | <SYSTEM_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 data paths and loading raw data (skip some data for speed)
Step2: Since downsampling reduces the timing precision of events, we reco... |
13,427 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
def soliton(x, t, c, a):
Return phi(x, t) for a soliton wave with constants c and a.
phi = 0.5/(np.cosh((c*... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Using interact for animation with data
Step3: To create an animation of a soliton propagating in time, we are going to precompute the soliton d... |
13,428 | <ASSISTANT_TASK:>
Python Code:
# imports
from pyspark import SparkContext
from pyspark.sql import SQLContext
from pyspark.sql.types import *
from pyspark.sql import functions as F
from graphframes import *
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
# make graphs beautif... | <SYSTEM_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, I want to find the percentance of people that survived based on their class
Step2: As expected, most of the upper class survived, while t... |
13,429 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_formats = ['svg']
from qutip import *
from qutip.ui.progressbar import BaseProgressBar
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
y_sse = None
import time
def arccoth(x):
return 0.5*np.log((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: Just check that analytical solution coincides with the solution of ODE for the variance
Step2: Test of different SME solvers
Step3: Plotting t... |
13,430 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras import layers
from keras.layers import Input, Add, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D, AveragePooling2D, MaxPooling2D, GlobalMaxPooling2D
from keras.models import Model, load_model
from keras.preprocessing import image
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: 1 - The problem of very deep neural networks
Step4: Expected Output
Step6: Expected Output
Step7: Run the following code to build the model's... |
13,431 | <ASSISTANT_TASK:>
Python Code:
hsts = hosts.get_saga_hosts_from_google(clientsecretjsonorfn='client_secrets.json', useobservingsummary=False)
anak = [h for h in hsts if h.name=='AnaK']
assert len(anak)==1
anak = anak[0]
bricknames = []
with open('decals_dr3/anakbricks') as f:
for l in f:
l = l.strip()
... | <SYSTEM_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 photometric addtions to the catalogs
Step2: Basic residual comparisons
Step3: Inspect objects with failed residuals
Step4: ???? Why are... |
13,432 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Eric Larson <larson.eric.d@gmail.com>
# Denis Engemannn <denis.engemann@gmail.com>
#
# License: BSD-3-Clause
import os.path as op
import numpy as np
from numpy.random import randn
import matplotlib.pyplot as 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: Set parameters
Step2: Read epochs for all channels, removing a bad one
Step3: Transform to source space
Step4: Transform to common cortical s... |
13,433 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
import numpy as np
from scipy.interpolate import griddata
import matplotlib.pyplot as plt
from matplotlib import rcParams
from solidspy.preprocesor import rect_grid
import solidspy.postprocesor as pos
import solidspy.assemutil as ass
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: Convergence analysis for a cantilever beam
Step2: The particular solution for parameters $E=1000.0$, $P=-50$ $\nu=0.30$, $I=42.67$,
Step3: We ... |
13,434 | <ASSISTANT_TASK:>
Python Code:
def encode_cyclic(s: str):
# split string to groups. Each of length 3.
groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
# cycle elements in each group. Unless group has fewer elements than 3.
groups = [(group[1:] + group[0]) if len(grou... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
13,435 | <ASSISTANT_TASK:>
Python Code:
from QGL import *
cl = ChannelLibrary("example")
# This would be a temporary, in memory database
# cl = ChannelLibrary(":memory:")
q1 = cl.new_qubit("q1")
# Most calls required label and address. Let's define
# an AWG for control pulse generation
aps2_1 = cl.new_APS2("BBNAPS1", addre... | <SYSTEM_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 instantiate the channel library. By default bbndb will use an sqlite database at the location specified by the BBN_DB environment variab... |
13,436 | <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: Basic classification
Step2: Import the Fashion MNIST dataset
Step3: Loading the dataset returns four NumPy arrays
Step4: Explore the data
Ste... |
13,437 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.insert(0,'..')
import folium
import branca
print (folium.__file__)
print (folium.__version__)
m = folium.Map([45,0], zoom_start=4)
folium.Marker([45,-30], popup="inline implicit popup").add_to(m)
folium.CircleMarker([45,-10], radius=1e5, popup=folium.Popup("inline exp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simple popups
Step2: Vega Popup
Step4: Fancy HTML popup
Step5: Note that you can put another Figure into an IFrame ; this should let you do s... |
13,438 | <ASSISTANT_TASK:>
Python Code:
class Vector:
"A point in space"
pass
class Edge:
"A pair of vectors"
pass
class Face:
"A set of vectors in clockwise or counter-clockwise order"
pass
class Polyhedron:
"A set of faces"
pass
<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: We're going to want to see our vectors rendered in some way. Visual Python, or VPython, provides an excellent solution. However, we're going t... |
13,439 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
from torchvision import datasets, transforms
from torch.autograd import Variable
import matplotlib.pyplot as plt
is_cuda = torch.cuda.is_available() # cuda 사용가능시, True
checkpoint_file... | <SYSTEM_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. 입력DataLoader 설정
Step2: 2. 사전 설정
Step3: 3. Restore model paramter from saved file
Step4: 6. Predict & Evaluate
Step5: 5. plot weights
|
13,440 | <ASSISTANT_TASK:>
Python Code:
ourList = [0,1,2,3,4,5,6,7,8,9]
i = 0
while i < 10:
num = ourList[i] *10
print(num)
i = i+1
i = 0
while (i<10):
num = ourList[i]
if num < 5:
print(num)
else:
print("The number is not less than 5")
i = i+1
import matplotlib.pyplot as ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Remember, we can use loops with dummy variables to iterate over lists and perform operations on each element. For example, say we want to print ... |
13,441 | <ASSISTANT_TASK:>
Python Code:
# Imports the functionality that we need to display YouTube videos in a Jupyter Notebook.
# You need to run this cell before you run ANY of the YouTube videos.
from IPython.display import YouTubeVideo
# WATCH THE VIDEO IN FULL-SCREEN MODE
YouTubeVideo("fF841G53fGo",width=640,height=360... | <SYSTEM_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 possibly useful links
Step2: Tutorial on functions in python
Step3: Question 3
Step5: Assignment wrapup
|
13,442 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
l1 = [1,2,3,4,5]
array1 = np.array(l1) # rank 1 array
print (array1) # [1 2 3 4 5]
print (array1.shape) # (5,)
print ('array1:', array1) # [1 2 3 4 5]
print ('array1.shape: ', array1.shape) # (5,)
print ('array1[0]:', array1[0]) # 1
print ('array1[1]:', array1[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: Array operations are very similar to that of the Python list. For example, the following code snippet creates a Python list and then converts it... |
13,443 | <ASSISTANT_TASK:>
Python Code:
import quail
%matplotlib inline
egg = quail.load_example_data()
egg.get_pres_items().head()
egg.get_rec_items().head()
acc = egg.analyze('accuracy')
acc.get_data().head()
accuracy_avg = egg.analyze('accuracy', listgroup=['average']*8)
accuracy_avg.get_data().head()
accuracy_split = 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: This dataset is comprised of 30 subjects, who each performed 8 study/test blocks of 16 words each. Here are some of the presented words
Step2: ... |
13,444 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nuist', 'sandbox-1', 'ocnbgchem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
13,445 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
s = "this is a test\n here it is"
print(s.splitlines())
s.split(" ")
def tokenize(s, stop_words=None, punctuation='`~!@#$%^&*()_-+={[}]|\:;"<,>.?/}\t\n'):
Split a string into a list of words, removing punctuat... | <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: Word counting
Step5: Write a function count_words that takes a list of words and returns a dictionary where the keys in the dictionary are the ... |
13,446 | <ASSISTANT_TASK:>
Python Code:
import time
import numpy as np
from cycleindex.sampling import nrsampling, vxsampling
from cycleindex import clean_matrix, cycle_count, balance_ratio
gama_pos = np.array(
[[0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
[0,0,0,1,0,1,1,1,0,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: Now, define the network
Step2: Preprocess
Step3: Counting cycles
Step4: The first list shows $N_l^+ - N_l^-$ and the second list shows $N_l^+... |
13,447 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
%pylab inline
import matplotlib.pylab as plt
import numpy as np
from distutils.version import StrictVersion
import sklearn
print(sklearn.__version__)
assert StrictVersion(sklearn.__version__ ) >= StrictVersion('0.18.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: One of the Classics
Step2: https
Step3: This is the output of all 3 hidden neurons, but what we really want is a category for iris category
S... |
13,448 | <ASSISTANT_TASK:>
Python Code:
# Author: Annalisa Pascarella <a.pascarella@iac.cnr.it>
#
# License: BSD-3-Clause
import os.path as op
import matplotlib.pyplot as plt
from nilearn import plotting
import mne
from mne.minimum_norm import make_inverse_operator, apply_inverse
# Set dir
data_path = mne.datasets.sample.data_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: Set up our source space
Step2: Get a surface-based source space, here with few source points for speed
Step3: Now we create a mixed src space ... |
13,449 | <ASSISTANT_TASK:>
Python Code:
import sys
print(sys.version)
import numpy as np
print(np.__version__)
npa = np.arange(25)
npa
print(type(npa))
print(npa.dtype)
np.array(range(20))
np.array([1.0,0,2,3])
np.array([1.0,0,2,3]).dtype
np.array([True,2,2.0]).dtype
True == 1
np.array([True,2,2.0])
np.array([True, 1, 2.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: Now we’ve got our array and we’ve got a method or two that we can use to create them. Let’s learn a bit more about some of the functions that ar... |
13,450 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
# integers (int)
x = 100
type(x)
# floating-point numbers (float)
x = 100.5
type(x)
# sequence of characters (str)
x = 'Los Angeles, CA 90089'
len(x)
# list of items
x = [1, 2, 3, 'USC']
len(x)
# sets are unique
x = {2, 2, 3, 3, 1}
x
# tuples are im... | <SYSTEM_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. Quick Python Refresher
Step2: 2. pandas Series and DataFrames
Step3: 2b. pandas DataFrames
Step4: 3. Loading data
Step5: 4. Selecting and... |
13,451 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
import shutil
import numpy as np
import matplotlib
%matplotlib inline
os.environ["CUDA_VISIBLE_DEVICES"] = "6"
sys.path.append('../../..')
from batchflow import Pipeline, B, C, V, D, L
from batchflow.opensets import CIFAR10
from batchflow.models.torch import VGG7, VGG... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let us solve the following problem
Step2: Firstly, define initial domain.
Step3: To update domain we can define some function which return new... |
13,452 | <ASSISTANT_TASK:>
Python Code:
import stable_baselines
stable_baselines.__version__
import os
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import gym
from stable_baselines.common.policies import MlpPolicy
from stable_baselines.common.vec_env import DummyVecEnv
from stable_baselines import 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: Import Policy, RL agent, ...
Step3: Define a Callback Function
Step5: Create and wrap the environment
Step6: Define and train the PPO agent
S... |
13,453 | <ASSISTANT_TASK:>
Python Code:
from imp import reload
import re
import numpy as np
from scipy.integrate import ode
import NetworkComponents
chassagnole = NetworkComponents.Network("chassagnole2002")
chassagnole.readSBML("./published_models/Chassagnole2002.xml")
chassagnole.readInformations("./published_models/Chassagn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model Chassagnole2002
Step2: A Network object containts other objects stored in arrays
Step3: The following calls are required before generat... |
13,454 | <ASSISTANT_TASK:>
Python Code:
import csv
data = list(csv.reader(open('guns.csv', 'r')))
print(data[:5])
#removing header row
headers = data[:1]
data = data[1:]
print(data[:5])
#count in the dictionary of how many times each element occurs in the year column
years = [each[1] for each in data]
years
year_counts = {}
for... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The sex and race columns contain potentially interesting information on how gun deaths in the US vary by gender and race. Exploring both of thes... |
13,455 | <ASSISTANT_TASK:>
Python Code:
def insertion_sort(data):
# TODO: Implement me
pass
# %load test_insertion_sort.py
from nose.tools import assert_equal
class TestInsertionSort(object):
def test_insertion_sort(self):
print('Empty input')
data = []
insertion_sort(data)
assert_eq... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Unit Test
|
13,456 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv("provstore/data.csv")
df.head()
df.describe()
# The number of each label in the dataset
df.label.value_counts()
from analytics import balance_smote, test_classification
df = balance_smote(df)
results, importances = test_classification(df)
results.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: ## Experiment
Step2: Balancing the data
Step3: Cross Validation tests
Step4: Result
Step5: Next time, we can reload the results as follows
S... |
13,457 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pylab as py
v1 = np.array([3,2,1])
v1
v1.sort()
v1
v2 = np.empty([2,2])
v2
class Complex:
def __init__(x, realpart, imagpart): # este "x" só pertence ao escopo deste bloco de definição de classe
x.r = realpart
x.i = imagpar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exemplo 2
Step2: Exemplo 3
Step3: A função linspace(a,b,c) retorna um vetor de c elementos, iniciando em a, terminando em b, igualmente espaça... |
13,458 | <ASSISTANT_TASK:>
Python Code:
import geopandas
states = geopandas.read_file(
"https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json",
driver="GeoJSON",
)
cities = geopandas.read_file(
"https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_50m_populated_places_si... | <SYSTEM_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 take a look at what our data looks like
Step2: Look how far the minimum and maximum values for the density are from the top and bottom quar... |
13,459 | <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: Manipulating an Image in Python
Step2: We can now take a look at our image to see if we uploaded it properly. To do this we will use Matplotlib... |
13,460 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
np.random.seed(1)
X = np.dot(np.random.random(size=(2, 2)), np.random.normal(size=(2, 200))).T
plt.plot(X[:, 0], X[:, 1], 'o')
plt.axis('equal');
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introducing Principal Component Analysis
Step2: We can see that there is a definite trend in the data. What PCA seeks to do is to find the Prin... |
13,461 | <ASSISTANT_TASK:>
Python Code:
import hashlib
import os
import pickle
from urllib.request import urlretrieve
import numpy as np
from PIL import Image
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
from sklearn.utils import resample
from tqdm import tqdm
from zipfil... | <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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this... |
13,462 | <ASSISTANT_TASK:>
Python Code:
import arviz as az
import bambi as bmb
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
az.style.use("arviz-darkgrid")
np.random.seed(1111)
size = 100
true_intercept = 1
true_slope = 2
x = np.linspace(0, 1, size)
# y = a + b*x
true_regression_line = true_intercept +... | <SYSTEM_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, generate pseudodata. The bulk of the data will be linear with noise distributed normally, but additionally several outliers will be interj... |
13,463 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
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')
def model_inputs(real_dim, z_dim):
inputs_real = tf.placeholde... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model Inputs
Step2: Generator network
Step3: Discriminator
Step4: Hyperparameters
Step5: Build network
Step6: Discriminator and Generator L... |
13,464 | <ASSISTANT_TASK:>
Python Code:
#|export
imagenet_stats = ([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
cifar_stats = ([0.491, 0.482, 0.447], [0.247, 0.243, 0.261])
mnist_stats = ([0.131], [0.308])
im = Image.open(TEST_IMAGE).resize((30,20))
#|export
if not hasattr(Image,'_patched'):
_old_sz = Image.Image.siz... | <SYSTEM_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.n_px
Step2: Image.shape
Step3: Image.aspect
Step4: Basic types
Step5: Images
Step6: Segmentation masks
Step7: Points
Step8: Points ... |
13,465 | <ASSISTANT_TASK:>
Python Code:
from textblob import TextBlob
import pandas as pd
import pylab as plt
import collections
import re
%matplotlib inline
with open (r'lovecraft.txt', 'r') as myfile:
shunned = myfile.read()
ushunned = unicode(shunned, 'utf-8')
tb = TextBlob(ushunned)
paragraph = tb.sentences
i = -1
for... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I've already pulled down The Sunned House from Project Gutenberg (https
Step2: Now we'll go through every sentence in the story and get the 'se... |
13,466 | <ASSISTANT_TASK:>
Python Code:
import cPickle as pickle
with open('GPD1_seq.fasta', 'r') as f:
lines = f.readlines()
a = 0
t = 0
g = 0
c = 0
for line in lines:
if line.startswith('>'):
continue
else:
a = a + line.count('A')
t = t + line.count('T')
g = g + line.count('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: Exercise 2
Step2: Exercise 3
|
13,467 | <ASSISTANT_TASK:>
Python Code:
primzweibissieben = [2, 3, 5, 7]
for prime in primzweibissieben:
print(prime)
for x in range(5):
print(x)
for x in range(3, 6):
print(x)
numbers = [
951, 402, 984, 651, 360, 69, 408, 319, 601, 485, 980, 507, 725, 547, 544,
615, 83, 165, 141, 501, 263, 617, 865, 575, ... | <SYSTEM_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.Drucke alle die Zahlen von 0 bis 4 aus
Step2: 4.Baue einen For-Loop, indem Du alle geraden Zahlen ausdruckst, die tiefer sind als 237.
Step3:... |
13,468 | <ASSISTANT_TASK:>
Python Code:
x1=0.4
L1=100
X_L1=x1*L1
x2=0.4
L2=80
X_L2=x2*L2
#T1 SF7-16000/110
Sn_T1=16 #MVA
Uk1=10.5 #%
Un_T1=121#KV
X_T1=Uk1*Un_T1**2/(100*Sn_T1)
#T2 S
Sn_T2=31.5 #MVA
Uk2=10.5 #%
Un_T2=121#KV
X_T2=Uk2*Un_T2**2/(100*Sn_T2)
X_T1
k1=6.3/121
k2=110/11
imp_reduction=lambda z,k:z*(k**2)
X_L2x=imp_redu... | <SYSTEM_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: 将实际值归算成6kv为基准的归算值:
Step3: 2.10kv为基准,因为之前算出了实际值,因此只需要重算k
Step4: 3.以110kv为基值
Step5: 10. 对上题所示电力系统,试作以标幺值表示的阻抗图。并将参数注在图上。取基准功率... |
13,469 | <ASSISTANT_TASK:>
Python Code:
try:
import requests
except:
!pip install requests
try:
from bs4 import BeautifulSoup
except:
!pip install bs4
page = requests.get("http://pbs.dartmouth.edu/people")
print(page)
print(page.content)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.prettify())... | <SYSTEM_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 data using requests
Step2: Here the response '200' indicates that the get request was successful. Now let's look at the actual text th... |
13,470 | <ASSISTANT_TASK:>
Python Code:
import pattern.web
url = 'http://rss.nytimes.com/services/xml/rss/nyt/World.xml'
results = pattern.web.Newsfeed().search(url, count=5)
results
print '%s \n\n %s \n\n %s \n\n' % (results[0].url, results[0].title, results[0].description)
print '%s \n\n %s \n\n %s \n\n' % (results[0].url, r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: That looks pretty good, but the description looks nastier than we would generally prefer. Luckily, pattern provides functions to get rid of the ... |
13,471 | <ASSISTANT_TASK:>
Python Code:
pd.DataFrame(series).plot(kind='bar',figsize=(15,10), subplots=True, layout=(5,2), legend=False, sharey=True)
lat = top10.LATITUDE.values
lon = top10.LONGITUDE.values
glp.dot({'lat': lat, 'lon': lon}, color="r")
glp.inline()
lat
top10Injuries = collisions.groupby(['LOCATION'])['NUMBER O... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here we see the location of these 10 intersection
Step2: That the intersections with the most collions
Step3: Lets save them
Step4: Finding o... |
13,472 | <ASSISTANT_TASK:>
Python Code:
# Import modules
import numpy as np
import pandas as pd
# Read the data set; print the first few rows
files = ['data\\Youtube01-Psy.csv', 'data\\Youtube02-KatyPerry.csv', 'data\\Youtube03-LMFAO.csv',
'data\\Youtube04-Eminem.csv', 'data\\Youtube05-Shakira.csv']
df = pd.DataFrame... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a id='section3b'></a>
Step2: <a id='section3c'></a>
Step3: <a id='section3d'></a>
Step4: <a id='section3e'></a>
Step5: <a id='section3f'></... |
13,473 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
def L(x):
return x**2 - 2*x + 1
def L_prime(x):
return 2*x - 2
def converged(x_prev, x, epsilon):
"Return True if the abs value of all elements in x-x_prev are <= epsilon."
absdiff = np.abs(x-x_prev)
return np.all(absdiff <= 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: Batch Gradient Descent
Step2: The Softmax Function
Step3: Non-linear Perceptron With SoftMax
Step4: Cross Entropy Error
Step11: Gradient of ... |
13,474 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
from tableone import TableOne
import pandas as pd
import matplotlib.pyplot as plt
import psycopg2
import getpass
%matplotlib inline
plt.style.use('ggplot')
# Create a database connection
user = 'postgres'
host = 'localhost'
dbname = 'mimic'
schema = 'mimiciii_demo'
# ... | <SYSTEM_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 the database connection
Step3: Select data on the first hospital stay
Step4: Display the first few rows of the data
Step5: Create Tabl... |
13,475 | <ASSISTANT_TASK:>
Python Code:
def plot_donation_amounts(counts):
keys = list(counts.keys())
values = list(counts.values())
fig = plt.figure(figsize=(15, 6))
ind = 1.5*np.arange(len(keys)) # the x locations for the groups
a_rects = plt.bar(ind, values, align='center', facec... | <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: A clear choice for modeling the distribution over fixed donation amounts is the multinomial distribution. For modeling custom donations amounts,... |
13,476 | <ASSISTANT_TASK:>
Python Code:
import py_entitymatching as em
import profiler
import pandas as pd
## Read input tables
A = em.read_csv_metadata('dblp_demo.csv', key='id')
B = em.read_csv_metadata('acm_demo.csv', key='id')
len(A), len(B), len(A) * len(B)
A.head(2)
B.head(2)
# If the tables are large we can downsample 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: Read input tables
Step2: Block tables to get candidate set
Step3: From the plot we can see that 20003 is definitely an error. We will replace ... |
13,477 | <ASSISTANT_TASK:>
Python Code:
import matta
# we do this to load the required libraries when viewing on NBViewer
matta.init_javascript(path='https://rawgit.com/carnby/matta/master/matta/libs')
import pandas as pd
df = pd.read_csv('http://bl.ocks.org/mbostock/raw/3885304/964f9100166627a89c7e6c23ce8128f5aefd5510/data.ts... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data
Step2: Sketching the Visualization
Step3: Note that the keyword arguments are keys from the VISUALIZATION_CONFIG dictionary. If you use a... |
13,478 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from astropy.io import fits
plt.style.use('ggplot')
%matplotlib inline
om10_cat = fits.open('../../data/twinkles_lenses_v2.fits')[1].data
sprinkled_lens_gals = pd.read_csv('../../data/sprinkled_lens_galaxies_230.txt')
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This file loaded contains extra information to a normal instance catalog output. During the sprinkling process as new id numbers are given to th... |
13,479 | <ASSISTANT_TASK:>
Python Code:
from pprint import pprint
from datetime import datetime
import xarray as xr
import matplotlib
import matplotlib.image
%matplotlib inline
import datacube
from datacube.api import API, geo_xarray
from datacube.analytics.analytics_engine import AnalyticsEngine
from datacube.execution.executi... | <SYSTEM_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 make a query to the datacube to find out what datasets we have.
Step2: Landsat Ecosystem Disturbance Adaptive Processing System (LEDA... |
13,480 | <ASSISTANT_TASK:>
Python Code:
# change these to try this notebook out
PROJECT = <YOUR PROJECT>
BUCKET = <YOUR PROJECT>
REGION = <YOUR REGION>
import os
os.environ['PROJECT'] = PROJECT
os.environ['BUCKET'] = BUCKET
os.environ['REGION'] = REGION
os.environ['TFVERSION'] = "2.1"
%%bash
gcloud config set project $PROJECT
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: Make code compatible with AI Platform Training Service
Step2: Move code into a python package
Step3: Paste existing code into model.py
Step4: ... |
13,481 | <ASSISTANT_TASK:>
Python Code:
import random
import pandas as pd
from plotly.graph_objs import *
from plotly.offline import init_notebook_mode, iplot, plot
init_notebook_mode(connected=True)
dataset = pd.read_csv('finalDataset.csv')
dataset.head(3)
monthList = ['Mar|Apr|May', 'Jun|Jul|Aug', 'Sep|Oct|Nov', 'Dec|Jan|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: Using plotly offline mode
Step2: Reading the final dataset
Step3: List of Seasons [Spring, Summer, Fall(Autum), Winter] with corresponding mon... |
13,482 | <ASSISTANT_TASK:>
Python Code:
import auspex.config as config
config.auspex_dummy_mode = True
from QGL import *
from auspex.qubit import *
import matplotlib.pyplot as plt
%matplotlib inline
cl = ChannelLibrary(":memory:")
pl = PipelineManager()
q1 = cl.new_qubit("q1")
aps2_1 = cl.new_APS2("BBNAPSa", address="192.168.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: Channel library setup
Step2: Pipeline setup
Step3:
Step4: Initialize software demodulation parameters. If these are not properly configured ... |
13,483 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
# Standard libraries
import logging
import os
import pathlib
import sys
# 3rd party libraries
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import pandas as pd
import seaborn as sns
import sqlalchemy as sa
# Local libraries
... | <SYSTEM_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 Display Parameters
Step2: Use Python Logging facilities
Step5: Define Functions
Step6: Define Notebook Parameters
Step7: Load Data... |
13,484 | <ASSISTANT_TASK:>
Python Code:
def compute_sum(n):
i=0
sum=0
while i<n:
i=i+1
sum+=i
return sum
m=int(input('plz input m: '))
n=int(input('plz input n: '))
k=int(input('plz input k: '))
print(compute_sum(m) + compute_sum(n) + compute_sum(k))
def compute_sum(n):
i=0
total=0
w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 写函数可返回1 - 1/3 + 1/5 - 1/7...的前n项的和。在主程序中,分别令n=1000及100000,打印4倍该函数的和。
Step2: 将task3中的练习1及练习4改写为函数,并进行调用。
Step3: 挑战性练习:写程序,可以求从整数m到整数n累加的和,间隔为k,... |
13,485 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import urllib2
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
plt.rcParams['figure.figsize'] = (10.0, 8.0)
def load_data(unique_id):
data = pd.read_csv(urllib2.urlopen("http://opennex/dataset/... | <SYSTEM_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. Load the data
Step2: Replace the argument below with the unique ID of the dataset that you've chosen in the web UI.
Step3: 3. Examine the d... |
13,486 | <ASSISTANT_TASK:>
Python Code:
# Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import mne
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
fname = data_path + '/subjects/sample/bem/sample-5120-5120-5120-bem-sol.fif'
surfaces = mne.read_bem_... | <SYSTEM_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 result
|
13,487 | <ASSISTANT_TASK:>
Python Code:
import matplotlib as mpl
mpl.rcParams['figure.dpi'] = 500
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
ls adiab/*.out
def read_file(fname):
with open(fname) as fp:
lines = 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: 1. Adiabatic batch reactor
Step2: Data Files
Step3: Reactor State Comparison
|
13,488 | <ASSISTANT_TASK:>
Python Code:
plt.imshow(plt.imread('./res/fig18_3.png'))
plt.figure(figsize=(15,10))
plt.imshow(plt.imread('./res/fig18_4.png'))
#todo: code
#todo: code
plt.imshow(plt.imread('./res/fig18_5.png'))
plt.imshow(plt.imread('./res/fig18_6.png'))
#todo: exercises
plt.figure(figsize=(10,20))
plt.subpl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 18.1 Definition of B-trees
Step2: the number $n$ of keys statisfies the inequality
Step3: Creating an empty B-tree
Step4: Inserting a key int... |
13,489 | <ASSISTANT_TASK:>
Python Code:
import ipyvolume
import numpy as np
ds = ipyvolume.datasets.aquariusA2.fetch()
ipyvolume.quickvolshow(ds.data, lighting=True)
stream = ipyvolume.datasets.animated_stream.fetch()
fig = ipyvolume.figure()
q = ipyvolume.quiver(*stream.data[:,0:50,:200], color="red", size=7)
ipyvolume.animat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Animations
Step2: Clean
|
13,490 | <ASSISTANT_TASK:>
Python Code:
s= 'wordsmith'
vowels = {'a','e','i','o','u'}
count = 0
for char in s:
if char in vowels:
count+=1
print "Number of vowels: " + str(count)
s = 'azcbobobegghakl'
pattern = 'bob'
count =0
for position in range(0,len(s)):
if s[position:position+3]==pattern:
count+=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: 2. COUNTING BOBS
Step2: 3. Counting and Grouping
Step3: Problem Set 02
Step4: 2. PAYING DEBT OFF IN A YEAR
Step5: 3. USING BISECTION SEARCH ... |
13,491 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
train_data,test_data = sales.random_split(.8,seed=0)
example_features = ['sqft_living', 'bedrooms', 'bathrooms']
example_model = graphlab.linear_regression.create(train_data, target = 'price', features = example_features,
... | <SYSTEM_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 house sales data
Step2: Split data into training and testing.
Step3: Learning a multiple regression model
Step4: Now that we have fit... |
13,492 | <ASSISTANT_TASK:>
Python Code:
# start by importing necessary modules
import matplotlib.pyplot as plt
import numpy as np
from landlab import HexModelGrid, RasterModelGrid
from landlab.components import (
FastscapeEroder,
FlowAccumulator,
NormalFault,
StreamPowerEroder,
)
from landlab.plot import imshow_... | <SYSTEM_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 will make a default NormalFault.
Step2: This fault has a strike of NE and dips to the SE. Thus the uplifted nodes (shown in yellow) ar... |
13,493 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nerc', 'sandbox-1', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
13,494 | <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: 그래프 및 tf.function 소개
Step2: 그래프 이용하기
Step3: 겉보기에 Function은 TensorFlow 연산을 사용하여 작성하는 일반 함수처럼 보입니다. 그러나 그 안을 들여다 보면 매우 다릅니다. Function는 하나의 API 뒤... |
13,495 | <ASSISTANT_TASK:>
Python Code:
%%bash
git clone -b online-w2v git@github.com:isohyt/gensim.git
from gensim.corpora.wikicorpus import WikiCorpus
from gensim.models.word2vec import Word2Vec, LineSentence
from pprint import pprint
from copy import deepcopy
from multiprocessing import cpu_count
%%bash
wget https://dumps.w... | <SYSTEM_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 wikipedia dump files
Step2: Convert two wikipedia dump files
Step3: Initial training
Step4: Japanese new idol group, "Babymetal", we... |
13,496 | <ASSISTANT_TASK:>
Python Code:
# Enter your username:
YOUR_GMAIL_ACCOUNT = '******' # Whatever is before @gmail.com in your email address
# Libraries for this section:
import os
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import pandas as pd
import cv2
import warnings
warnings.fi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Eyes on the data!
Step4: Check out the colors at rapidtables.com/web/color/RGB_Color, but don't forget to flip order of the channels to BGR.
St... |
13,497 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from sympy import *
init_printing()
Ex, Ey, Ez = symbols("E_x, E_y, E_z")
Bx, By, Bz, B = symbols("B_x, B_y, B_z, B")
x, y, z = symbols("x, y, z")
vx, vy, vz, v = symbols("v_x, v_y, v_z, v")
t = symbols("t")
q, m = symbols("q, m")
c, eps0... | <SYSTEM_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 equation of motion
Step2: For the case of a uniform magnetic field
Step3: Assuming $E_z = 0$ and $E_y = 0$
Step4: Motion is uniform alon... |
13,498 | <ASSISTANT_TASK:>
Python Code:
import gym
import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import matplotlib.pyplot as plt
problem = "Pendulum-v0"
env = gym.make(problem)
num_states = env.observation_space.shape[0]
print("Size of State Space -> {}".format(num_states))
num_actions = env.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: We use OpenAIGym to create the environment.
Step2: To implement better exploration by the Actor network, we use noisy perturbations,
Step3: Th... |
13,499 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.linalg as la
np.set_printoptions(suppress=True)
A = np.array([[1,3,4],[2,1,3],[4,1,2]])
L = np.array([[1,0,0],[2,1,0],[4,11/5,1]])
U = np.array([[1,3,4],[0,-5,-5],[0,0,-3]])
print(L.dot(U))
print(L)
print(U)
import numpy as np
import scipy.linalg as la
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: We can solve the system by solving two back-substitution problems
Step2: Note that the numpy decomposition uses partial pivoting (matrix rows a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.