Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
8,000 | <ASSISTANT_TASK:>
Python Code:
import numpy as np # For numerical programming and multi-dimensional arrays
from pandas import date_range # For date-rate generation
from bqplot import LinearScale, Lines, Axis, Figure, DateScale, ColorScale
security_1 = np.cumsum(np.random.randn(150)) + 100.0
security_2 = np.cumsum(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: Random Data Generation
Step2: Basic Line Chart
Step3: The x attribute refers to the data represented horizontally, while the y attribute refer... |
8,001 | <ASSISTANT_TASK:>
Python Code:
# Level 3 example with multiple products
import numpy as np
import matplotlib.pyplot as plt
from numpy import ma
from metpy.cbook import get_test_data
from metpy.io.nexrad import Level3File
from metpy.plots import ctables
# Helper code for making sense of these products. This is hidden fr... | <SYSTEM_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 about the "data" content of the products?
Step2: Calculations
Step3: What does the LCL look like for that?
Step4: Given those conditions... |
8,002 | <ASSISTANT_TASK:>
Python Code:
import theano
%matplotlib inline
import sys, os
sys.path.insert(1, os.path.join('../utils'))
import utils; reload(utils)
from utils import *
from __future__ import division, print_function
path = get_file('nietzsche.txt', origin="https://s3.amazonaws.com/text-datasets/nietzsche.txt")
tex... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup
Step2: Sometimes it's useful to have a zero value in the dataset, eg. for padding
Step3: Map from chars to indices and back again
Step4:... |
8,003 | <ASSISTANT_TASK:>
Python Code:
import os
import s3fs
import pandas as pd
import dask.array as da
import dask.dataframe as dd
from distributed import Client
from dask import persist, compute
from dask_glm.estimators import LogisticRegression
client = Client()
if not os.path.exists('trip.csv'):
s3 = S3FileSystem(an... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We'll setup a distributed.Client locally. In the real world you could connect to a cluster of dask-workers.
Step2: For demonstration, we'll use... |
8,004 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate
def trapz(f, a, b, N):
Integrate the function f(x) over the range [a,b] with N points.
h=(b-a)/N
k=np.arange(1,N)
return h*(0.5*f(a)+0.5*f(b)+f(a+k*h).sum())
f = lambda 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:
Step2: Trapezoidal rule
Step3: Now use scipy.integrate.quad to integrate the f and g functions and see how the result compares with your trapz functio... |
8,005 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
from datetime import datetime
def cart2pol(x, y):
r = np.sqrt(x**2 + y**2)
phi = np.arctan2(y, x)
return(r, phi)
from IPython.core.display import Image
Image(url='https://upload.wikimedia.org/wikipedia/commons/thumb/7/78/Polar_to_cartesian.svg/... | <SYSTEM_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 the name suggest cart2pol converts a pair of cartesian coordinates [x, y] to polar coordinates [r, phi]
Step2: All well and good. However, w... |
8,006 | <ASSISTANT_TASK:>
Python Code:
st = 'Print only the words that start with s in this sentence'
#Code here
st = 'Print only the words that start with s in this sentence'
for word in st.split():
if word[0] == 's':
print(word )
#Code Here
for number in range(0,11):
if number % 2 == 0:
print(number)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Use range() to print all the even numbers from 0 to 10.
Step2: Use List comprehension to create a list of all numbers between 1 and 50 that are... |
8,007 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
np.set_printoptions(precision=4, suppress=True, linewidth=120)
from pandas_datareader.data import DataReader
# Get the datasets from FRED
start = '1979-01-01'
end = '2014... | <SYSTEM_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
Step2: Stock and Watson (1991) report that for their datasets, they could not reject the null hypothesis of a unit root in each series (so... |
8,008 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-dark')
import openmoc
import openmc
import openmc.mgxs as mgxs
import openmc.data
from openmc.openmoc_compatible import get_openmoc_geometry
%matplotlib inline
# 1.6% enriched fuel
fuel = openmc.Material(name='1.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: First we need to define materials that will be used in the problem. We'll create three distinct materials for water, clad and fuel.
Step2: With... |
8,009 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pylab
import matplotlib
import pandas
import numpy
dateparse = lambda x: pandas.datetime.strptime(x, '%Y-%m-%d')
sessoes = pandas.read_csv('sessoes_democratica_org.csv',index_col=0,parse_dates=['data'], date_parser=dateparse)
del sessoes['tamanho']
total0 = nump... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Temos ~800 MB de dados. O servidor onde o backend do site vai funcionar apenas têm 1GB de memória, o que cria um desafio técnico. Como a útilida... |
8,010 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import tensorflow as tf
import numpy as np
import time
import collections
import os
# Import MNIST data with TensorFlow
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets(os.path.join('datasets', 'mnist'), one_hot=True) # load 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: 1st Step
Step2: Question 2
Step3: Question 3
Step4: Question 4
Step5: Question 5
Step6: Question 6
Step7: Question 7
Step8: Question 8
St... |
8,011 | <ASSISTANT_TASK:>
Python Code:
import json, shapely, fiona, os
import seaborn as sns
import pandas as pd
import geopandas as gpd
import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
# load the sample dataset (iris)
iris = sns.load_dataset('iris')
#look at it:
print("Rows: ",len(iris))
iris.head()
i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Create a dataframe with Pandas
Step2: 2. GeoPandas
Step3: 3 Cities?
Step4: Let's compare some data?
Step5: Crime?
Step6: <br><br><hr><br... |
8,012 | <ASSISTANT_TASK:>
Python Code:
def format_fasta(header, sequence):
return header + '\n' + '\n'.join(re.findall('\w{,80}', sequence))
genetic_code_name = './genetic-code.txt'
input_file_name = './M10051.txt'
import re
with open(genetic_code_name, 'r') as input_file:
genetic_code_rows = input_file.readlines()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NOTA BENE
Step2: Importazione del modulo re per utilizzare le espressioni regolari.
Step3: Lettura del file del codice genetico in una lista d... |
8,013 | <ASSISTANT_TASK:>
Python Code:
# system functions that are always useful to have
import time, sys, os
import pickle
# basic numeric setup
import numpy as np
from numpy import linalg
from scipy import stats
# inline plotting
%matplotlib inline
# plotting
import matplotlib
from matplotlib import pyplot as plt
# seed 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:
Step4: Here we will quickly demonstrate that slice sampling is able to cope with very high-dimensional problems without the use of gradients. Our targe... |
8,014 | <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: scikit-learn Training on AI Platform
Step2: The data
Step3: Part 2
Step4: Part 3
Step5: Submit the training job.
Step6: [Optional] StackDri... |
8,015 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
star_wars = pd.read_csv('star_wars.csv', encoding='ISO=8859-1')
star_wars.head(10)
star_wars.columns
star_wars = star_wars[pd.notnull(star_wars['RespondentID'])]
star_wars.head()
bool_type = {
'Yes': True,
'No': False
}
star_wars['Have you seen any of the 6 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: We need to specify an encoding because the data set has some characters that aren't in Python's default utf-8 encoding. You can read more about ... |
8,016 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import bokeh.plotting as bkp
from mpl_toolkits.axes_grid1 import make_axes_locatable
# read in readmissions data provided
hospital_read_df = pd.read_csv('data/cms_hospital_readmissions.csv')
# deal ... | <SYSTEM_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 Analysis
Step2: Preliminary Report
Step3: Report statistical significance for α = .01
|
8,017 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False)
DO NOT MODIFY THIS CELL
def fully_connected(prev_layer, num_units):
Create a fully connectd layer with the given layer... | <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: Batch Normalization using tf.layers.batch_normalization<a id="example_1"></a>
Step6: We'll use the following function to create convolutional l... |
8,018 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from fasttext import FastVector
# from https://stackoverflow.com/questions/21030391/how-to-normalize-array-numpy
def normalized(a, axis=-1, order=2):
Utility function to normalize the rows of a numpy array.
l2 = np.atleast_1d(np.linalg.norm(a, order, 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:
Step3: So, show me how to align two vector spaces for myself!
Step4: Now we load the French and Russian word vectors, and evaluate the similarity of "... |
8,019 | <ASSISTANT_TASK:>
Python Code:
%run ../../code/version_check.py
%run ../../code/eoddata.py
from getpass import getpass
import requests as r
import xml.etree.cElementTree as etree
ws = 'http://ws.eoddata.com/data.asmx'
ns='http://ws.eoddata.com/Data'
session = r.Session()
username = getpass()
password = getpass()
call... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Change Log
Step2: Login()
Step3: Get data
Step4: Data inspection (Login)
Step5: Helper function
Step6: Usage
Step7: Client function
|
8,020 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from importlib import reload
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
from pandas_datareader.data import DataReader
endog = DataReader('CPIAPPNS', 'fred', start='1980').asfreq('MS')
endog.plot(figsize=(15, 3));... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To illustrate, we will use the Consumer Price Index for Apparel, which has a time-varying level and a strong seasonal component.
Step2: It is w... |
8,021 | <ASSISTANT_TASK:>
Python Code:
with open('./jeter.tsv', 'r') as file:
for i in range (10):
print (next(file))
%pylab inline
import csv
import matplotlib.pyplot as plt
res_s1_sup_s2 = [0 for i in range (26)]
res_s2_sup_s1 = [0 for i in range (26)]
res_s1_sup_other = [0 for i in range (26)]
res_s2_sup_other... | <SYSTEM_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 packages
Step2: Create lists to store results for different thresholds from 0 to 25%
Step3: parse file and populate the list
|
8,022 | <ASSISTANT_TASK:>
Python Code:
import os
import mne
from mne.datasets import sample
from mne.minimum_norm import apply_inverse, read_inverse_operator
from mne import read_evokeds
data_path = sample.data_path()
sample_dir = os.path.join(data_path, 'MEG', 'sample')
subjects_dir = os.path.join(data_path, 'subjects')
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: Then, we read the stc from file
Step2: This is a
Step3: The SourceEstimate object is in fact a surface source estimate. MNE also
Step4: Note... |
8,023 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
names = pd.DataFrame({"name" : ["Alice","Bob","Charlie","Dennis"],
"surname" : ["Doe","Smith","Sheen","Quaid"]})
names
names.name.str.match("A\w+")
debts = pd.DataFrame({"debtor":["D.Quaid","C.Sheen"],
"amount":[100,10000]})
de... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Imagine I want to have a list of my friends with the amount of money I borrowed to each other, toghether with their names and surnames.
Step2: ... |
8,024 | <ASSISTANT_TASK:>
Python Code:
from symbulate import *
%matplotlib inline
die = list(range(1, 6+1)) # this is just a list of the number 1 through 6
roll = BoxModel(die, size = 2)
roll.sim(100)
def spam_sim():
email_type = BoxModel(["spam", "not spam"], probs=[.1, .9]).draw()
if email_type == "spam":
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: <a id='sim'></a>
Step2: Caution
Step3: <a id='get'></a>
Step4: <a id='apply'></a>
Step5: User defined functions can also be applied.
Step6: ... |
8,025 | <ASSISTANT_TASK:>
Python Code:
import geopandas as gpd
import matplotlib.pyplot as plt
from shapely.geometry import Polygon
# X -coordinates
xcoords = [29.99671173095703, 31.58196258544922, 27.738052368164062, 26.50013542175293, 26.652359008789062, 25.921663284301758, 22.90027618408203, 23.257217407226562,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Primeiro, crie uma variável Polygon poly fora das coordenadas x e y
Step2: Por último
Step3: Problema 2
Step4: Próximo
Step5: Por último
Ste... |
8,026 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
from sktracker import data
from sktracker.trajectories import Trajectories
from sktracker.io import TiffFile
trajs = Trajectories(data.brownian_trajectories_generator())
trajs.show(groupby_args={'by': 'true_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: Generate brownian or directed trajectories
Step2: Get sample microscopy stack
Step3: Get sample H5 file stored by sktacker.io.ObjectsIO
Step4:... |
8,027 | <ASSISTANT_TASK:>
Python Code:
import autograd.numpy as np
np.set_printoptions(precision=2)
import matplotlib.pyplot as plt
%matplotlib inline
# Number of data points
N = 1000
# Dimension of each data point
D = 2
# Number of clusters
K = 3
pi = [0.1, 0.6, 0.3]
mu = [np.array([-4, 1]), np.array([0, 0]), np.array([2, -1]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Given a data sample the de facto standard method to infer the parameters is the expectation maximisation (EM) algorithm that, in alternating so-... |
8,028 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sys
import os
import platform
import numpy as np
import matplotlib.pyplot as plt
import flopy
import flopy.utils as fputl
#Set name of MODFLOW exe
# assumes executable is in users path statement
exe_name = 'mfusg'
if platform.system() == 'Windows':
exe_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: Model parameters
Step2: Create and run the MODFLOW-USG model
Step3: Read the simulated MODFLOW-USG model results
Step4: Plot MODFLOW-USG resu... |
8,029 | <ASSISTANT_TASK:>
Python Code:
import os, time
import numpy as np
import fitsio
from glob import glob
import matplotlib.pyplot as plt
from astropy.table import vstack, Table, hstack
MASKBITS = dict(
NPRIMARY = 0x1, # not PRIMARY
BRIGHT = 0x2,
SATUR_G = 0x4,
SATUR_R = 0x8,
SATUR_Z =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Check the masking
Step2: All DUPs should be in an LSLGA blob.
Step3: 1) Find all bright Gaia stars.
Step4: Make sure the MASKBITS values are ... |
8,030 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
from sklearn.cluster import MiniBatchKMeans
# Load data
iris = datasets.load_iris()
X = iris.data
# Standarize features
scaler = StandardScaler()
X_std = scaler.fit_transform(X)
# Create k-me... | <SYSTEM_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: Conduct k-Means Clustering
|
8,031 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import urllib.request
import numpy as np
import simplejson as json
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import warnings
import datetime
import dateutil.parser
import matplotlib.cbook
warnings.filterwarnings("ignore",category=matplotlib.cbo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font color='red'>Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly ... |
8,032 | <ASSISTANT_TASK:>
Python Code:
from src.parameters import ANIMALS
ANIMALS
from src.parameters import N_DAYS, SAMPLING_FREQUENCY
print('Days: {0}'.format(N_DAYS))
print('Sampling Frequency: {0}'.format(SAMPLING_FREQUENCY))
from src.data_processing import make_epochs_dataframe
days = range(1, N_DAYS + 1)
epoch_info = m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: N_DAYS corresponds to the number of days of recording and SAMPLING_FREQUENCY corresponds to the sampling rate of the tetrodes recording neural a... |
8,033 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 150
from skdaccess.framework.param_class import *
from skdaccess.geo.wyoming_sounding.cache import DataFetcher
sdf = DataFetcher(station_number='72493', year=2014, month=5, day_start=30, day_end=30, start_hou... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create a data fetcher
Step2: Access data
|
8,034 | <ASSISTANT_TASK:>
Python Code:
import time
import tempfile
import shutil
import os
import numpy as np
from joblib import Parallel, delayed
from joblib import load, dump
def griddata(gridpoints, tlayer, teff_logg_feh, method='linear', rescale=True):
Do what ever it does
# put a short wait.
time.sleep(0.5)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Joblib for Daniel
Step3: Parallel over both loops with memapping
Step5: Direct copy of Joblib memmaping example
|
8,035 | <ASSISTANT_TASK:>
Python Code:
from PIL import Image
import numpy as np
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
from sklearn import datasets, svm, linear_model
matplotlib.style.use('bmh')
matplotlib.rcParams['figure.figsize']=(10,7)
X = np.random.normal(5, 5, size=(50,1))
y0 = X[:,0]>0
y =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linear SVM
Step2: 簡易的 svm 實驗
Step3: Q
|
8,036 | <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
phoebe.devel_on() # CURRENTLY REQUIRED FOR WD-STYLE MESHING (WHICH IS EXPERIMENTAL)
logger = phoebe.logger()
b = phoebe.default_binary()
b.set_value_all('mes... | <SYSTEM_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: Changing Meshing Options
Step3: Adding Datasets
Step4: Running C... |
8,037 | <ASSISTANT_TASK:>
Python Code:
import Ngl,Nio
#-- define variables
fname = "/Users/k204045/NCL/general/data/new_data/rectilinear_grid_2D.nc" #-- data file name
#-- open file and read variables
f = Nio.open_file(fname,"r") #-- open data file
temp = f.variables["tsurf"][0,::-1,:] #-- first 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:
Step1: Add cyclic data. Set minimum and maximum contour values although the interval.
Step2: Open a workstation, here x11 window.
Step3: Set resource... |
8,038 | <ASSISTANT_TASK:>
Python Code:
import mne
import os.path as op
import numpy as np
from matplotlib import pyplot as plt
data_path = op.join(mne.datasets.sample.data_path(), 'MEG',
'sample', 'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(data_path, preload=True)
raw = raw.crop(0, 10)
print(raw)
... | <SYSTEM_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 an example dataset, the preload flag loads the data into memory now
Step2: Signal processing
Step3: In addition, there are functions for ... |
8,039 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# All the imports
from __future__ import print_function, division
from math import *
import random
import sys
import matplotlib.pyplot as plt
# TODO 1: Enter your unity ID here
__author__ = "<unity-id>"
class O:
Basic Class which
- Helps dynamic update... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Genetic Algorithm Workshop
Step11: The optimization problem
Step12: Great. Now that the class and its basic methods is defined, we move on to ... |
8,040 | <ASSISTANT_TASK:>
Python Code:
BATCH_SIZE = 64
LEARNING_RATE = 0.002
# GCS bucket for training logs and for saving the trained model
# You can leave this empty for local saving, unless you are using a TPU.
# TPUs do not have access to your local instance and can only write to GCS.
BUCKET="" # a valid bucket name must 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: Imports
Step3: TPU/GPU detection
Step4: Colab-only auth for this notebook and the TPU
Step5: tf.data.Dataset
Step6: Let's have a look at the... |
8,041 | <ASSISTANT_TASK:>
Python Code:
# enable showing matplotlib image inline
%matplotlib inline
# autoreload module
%load_ext autoreload
%autoreload 2
PROJECT_ROOT = "/"
def load_local_package():
import os
import sys
root = os.path.join(os.getcwd(), "./")
sys.path.append(root) # load project root
return... | <SYSTEM_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 Corpus
Step2: Make Topic Model
Step3: Evaluate/Visualize Topic Model
Step4: Check the topics in documents
Step5: Visualize words in top... |
8,042 | <ASSISTANT_TASK:>
Python Code:
#!/usr/bin/env python3
# @author: R. Gowers, S. Al-Izzi, T. Pollington, R. Hill & K. Briggs
import numpy as np
import cvxpy as cvx
def water_filling(n,a,sum_x=1):
'''
Boyd and Vandenberghe, Convex Optimization, example 5.2 page 145
Water-filling.
This problem arises in information th... | <SYSTEM_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: To illustrate the water filling principle, we will plot $\alpha_i + x_i$ and check that this level is flat where power has been ... |
8,043 | <ASSISTANT_TASK:>
Python Code:
# Authors: Eric Larson <larson.eric.d@gmail.com>
# Sheraz Khan <sheraz@khansheraz.com>
# Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import os.path as op
import mne
from mne.beamformer import make_lcmv, apply_lcmv_epochs
from mne.connectivity 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: Here we do some things in the name of speed, such as crop (which will
Step2: Now we band-pass filter our data and create epochs.
Step3: Comput... |
8,044 | <ASSISTANT_TASK:>
Python Code:
from sympy import Symbol, exp, I, pi, N, expand
from sympy import init_printing
init_printing()
expand(exp(2*pi*I/3), complex=True)
expand(exp(4*pi*I/3), complex=True)
plt.figure(figsize=(4,4))
roots = np.array([[1,0], [-0.5, np.sqrt(3)/2], [-0.5, -np.sqrt(3)/2]])
plt.scatter(roots[:,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:
Step4: 1. Newton's method for functions of complex variables - stability and basins of attraction. (30 points)
Step7: 2. Ill-conditioned linear prob... |
8,045 | <ASSISTANT_TASK:>
Python Code:
from picamera import PiCamera, Color
from time import sleep
camera = PiCamera()
camera.resolution = (480, 320)
camera.vflip = True
camera.hflip = True
camera.start_preview()
camera.annotate_foreground = Color('white')
camera.annotate_text = "Colorswap Effect"
camera.annotate_text_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: Set the camera to take a bit smaller photos (lower resolution). This will make our image processing a bit faster.
Step2: One can see all the av... |
8,046 | <ASSISTANT_TASK:>
Python Code:
!pip install "thinc>=8.0.0a0"
import numpy
from thinc.api import Linear, zero_init
n_in = numpy.zeros((128, 16), dtype="f")
n_out = numpy.zeros((128, 10), dtype="f")
model = Linear(nI=n_in.shape[1], nO=n_out.shape[1], init_W=zero_init)
nI = model.get_dim("nI")
nO = model.get_dim("nO")
pr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Thinc provides a variety of layers, functions that create Model instances. Thinc tries to avoid inheritance, preferring function composition. Th... |
8,047 | <ASSISTANT_TASK:>
Python Code:
df = spark.read.format("csv") \
.option("inferSchema", "true").option("header", "true") \
.load("s3a://datapalooza/airbnb/airbnb.csv.bz2")
df.registerTempTable("df")
print(df.head())
print(df.count())
df_filtered = df.filter("price >= 50 AND price <= 750 AND bathrooms > 0.0 AND bedro... | <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: Step 1
Step5: Step 2
Step6: Step 3
Step7: Step 4
Step8: Step 5
Step9: Step 6
Step10: Step 7
Step11: TODO
Step12: Deployment Option 1
Ste... |
8,048 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
img = mnist.train.images[200]
plt.imshow(img.reshape((28, 28)), cmap... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Below I'm plotting an example image from the MNIST dataset. These are 28x28 grayscale images of handwritten digits.
Step2: We'll train an autoe... |
8,049 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis Engemann <denis.engemann@gmail.com>
# Eric Larson <larson.eric.d@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.time_frequency i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: We have to make sure all conditions have the same counts, as the ANOVA
Step3: Create TFR representations for all conditi... |
8,050 | <ASSISTANT_TASK:>
Python Code:
import math, re, os
import numpy as np
import tensorflow as tf
print("Tensorflow version " + tf.__version__)
# Detect TPU, return appropriate distribution strategy
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()
print('Running on TPU ', tpu.master())
except ValueE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 2
Step2: We'll use the distribution strategy when we create our neural network model. Then, TensorFlow will distribute the training among ... |
8,051 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy
import matplotlib.pyplot as plt
import allantools
from allantools import noise
def plotallan_phase(plt,y,rate,taus, style):
(t2, ad, ade,adn) = allantools.mdev(y,rate=rate,taus=taus)
plt.loglog(t2, ad, style)
# plot a line with the slope alpha
def plotli... | <SYSTEM_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 some example data
Step2: Now, run three-cornered hat phase calculation
Step3: Plot results
|
8,052 | <ASSISTANT_TASK:>
Python Code:
from pybaseball import statcast
pitch_data = statcast(start_dt='2017-04-01', end_dt='2017-04-30')
pitch_data.shape
pitch_data.pitch_type.value_counts()
pitch_type = pitch_data.pop('pitch_type')
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_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: Extract columns to be used for prediction. Pitcher and year are probably not predictive, so I am leaving them out.
Step2: Relabel pitch types u... |
8,053 | <ASSISTANT_TASK:>
Python Code:
# Load pickled data
import pickle
import csv
import cv2
import numpy as np
import math
import matplotlib.pyplot as plt
signnames = []
with open("signnames.csv", 'r') as f:
next(f)
reader = csv.reader(f)
signnames = list(reader)
n_classes = len(signnames)
training_file = "./tra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preprocess Data
Step2: Step 1
Step3: Visualize the German Traffic Signs Dataset using the pickled file(s). This is open ended, suggestions inc... |
8,054 | <ASSISTANT_TASK:>
Python Code:
repo_uoa = 'explore-matrix-size-gemm-libs-dvdt-prof-firefly-rk3399-001'
import os
import sys
import json
import re
import IPython as ip
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib as mp
print ('IPython version: %s' % ip.__version__)
print ('Pandas 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: NB
Step2: Scientific
Step3: Collective Knowledge
Step4: Define helper functions
Step5: Plot experimental data
Step6: Access experimental da... |
8,055 | <ASSISTANT_TASK:>
Python Code:
!mkdir -p ~/agave
%cd ~/agave
!pip3 install --upgrade setvar
import re
import os
import sys
from setvar import *
from time import sleep
# This cell enables inline plotting in the notebook
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
writefile("i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: The parameter file for Funwave-TVD is called "input.txt". Here we create it using writefile. You don't need to understand the details of how thi... |
8,056 | <ASSISTANT_TASK:>
Python Code:
#$HIDE$
import pandas as pd
pd.plotting.register_matplotlib_converters()
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
print("Setup Complete")
# Path of the file to read
spotify_filepath = "../input/spotify.csv"
# Read the file into a variable spotify_data
spot... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Select a dataset
Step2: The end result of running both lines of code above is that we can now access the dataset by using spotify_data.
Step3: ... |
8,057 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import requests
import json
import numpy as np
TOKEN = '198f959a5f39a1c441c7c863423264'
base_url = "https://gatewayapi.prodam.sp.gov.br:443/financas/orcamento/sof/v2.1.0"
headers={'Authorization' : str('Bearer ' + TOKEN)}
url_orcado = '{base_url}/consultarDespesas?ano... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Orçamento
Step2: Empenhos
Step3: A API fornece apenas uma página na consulta. O script abaixo checa a quantidade de páginas nos metadados da c... |
8,058 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import sklearn.feature_selection as FS
data = pd.read_csv("./wine_dataset.csv", delimiter=";")
data.head()
data["Type"] = pd.Categorical.from_array(data["Type"]).codes
data["Type"].replace("A",0)
data["Type"].replace(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Se sustituye la columna Type por un valor categórico
Step2: Separamos la columna target del resto de variables predictoras
Step3: Mutual Infor... |
8,059 | <ASSISTANT_TASK:>
Python Code:
test = "Hello World"
print ("test: " + test)
#
#The function zeros creates an array full of zeros
# function ones creates an array full of ones
#function empty creates an array whose initial content is random and depends on the state of the memory
# To create sequences of numbers, N... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NumPy
Step2: shape
Step3: np.ones
Step4: np.empty
Step5: np.arange
|
8,060 | <ASSISTANT_TASK:>
Python Code:
ROMAN = [
(1000, "M"),
( 900, "CM"),
( 500, "D"),
( 400, "CD"),
( 100, "C"),
( 90, "XC"),
( 50, "L"),
( 40, "XL"),
( 10, "X"),
( 9, "IX"),
( 5, "V"),
( 4, "IV"),
( 1, "I"),
]
def to_roman(number: int):
result = ""
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: Snooping on execution
Step2: Snooping on referenced functions
Step3: pp - pretty print
Step4: Shortcut
Step5: How to use in Jupyter
|
8,061 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
import tarfile
from IPython.display import display, Image
from scipy i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: First, we'll download the dataset to our local machine. The data consists of characters rendered in a variety of fonts on a 28x28 image. The lab... |
8,062 | <ASSISTANT_TASK:>
Python Code:
import ROOT
h = ROOT.TH1F("my_histo", "Example histogram", 100, -4, 4)
ROOT.gInterpreter.ProcessLine(
double add(double a, double b) {
return a + b;
}
)
ROOT.add(3.14, 100)
ROOT.gInterpreter.ProcessLine("void print_integer(int i) { std::cout << i << std::endl; }")
ROOT.print_integ... | <SYSTEM_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 ROOT Python module is the entry point for all the ROOT C++ functionality.
Step3: Calling user-defined C++ code via PyROOT
Step4: and use i... |
8,063 | <ASSISTANT_TASK:>
Python Code:
from sklearn.feature_extraction import stop_words
from nltk.corpus import stopwords
import math
from textblob import TextBlob as tb
with open("scripts/script.txt", "r") as f:
data = f.read()
#with open("scripts/script.txt", "r") as f:
# data2 = f.readlines()
#for line in 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: PRE-PROCESSING!
Step2: TF-IDF
Step3: RAKE
|
8,064 | <ASSISTANT_TASK:>
Python Code:
import graphlab
loans = graphlab.SFrame('lending-club-data.gl/')
loans['safe_loans'] = loans['bad_loans'].apply(lambda x : +1 if x==0 else -1)
loans = loans.remove_column('bad_loans')
features = ['grade', # grade of the loan
'term', # the term of ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the lending club dataset
Step2: Like the previous assignment, we reassign the labels to have +1 for a safe loan, and -1 for a risky (bad) ... |
8,065 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.lookfor('weighted average')
a1d = np.array([3, 4, 5, 6])
a1d
a2d = np.array([[10., 20, 30], [9, 8, 7]])
a2d
print( type( a1d[0] ) )
print( type( a2d[0,0] ) )
type(a1d)
try:
a = np.array(1,2,3,4) # WRONG, only 2 non-keyword arguments accepted
except ValueEr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Vectorised
Step2: Creating an array from a list
Step3: The core class of NumPy is the ndarray (homogeneous n-dimensional array).
Step4: Funct... |
8,066 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'codes':[[71020], [77085], [36415], [99213, 99287], [99233, 99233, 99233]]})
def g(df):
return df.codes.apply(pd.Series).add_prefix('code_')
result = g(df.copy())
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
8,067 | <ASSISTANT_TASK:>
Python Code:
titles.tail()
len(titles)
titles.sort(columns='year', ascending=True).head()[:2]
titles[titles['title'].str.contains('Hamlet')].sort('year')
len(titles[titles.title == 'North by Northwest'])
titles[titles['title'] 'Hamlet'].sort('year')[:1]
titles[titles.title == 'Treasure Island'].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: What are the earliest two films listed in the titles dataframe?
Step2: How many movies have the title "Hamlet"?
Step3: How many movies are tit... |
8,068 | <ASSISTANT_TASK:>
Python Code:
###
# There is now a 'SparkContext' instance available as the named variable 'sc'
# and there is a HiveContext instance (for SQL-like queries) available as 'sqlCtx'
#
## Check that this simple code runs without error:
sc.parallelize([1,2,3,4,5]).take(2)
###
# Inspect the SparkContext [sc]... | <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: De Pie
Step3: The data
Step4: Scrape JobsAggregator
Step5: Load OES Data
Step6: Lightning-viz plots for inline D3.js in IPython
|
8,069 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
softmax_output = load_data()
def solve(softmax_output):
# def solve(softmax_output):
### BEGIN SOLUTION
y = torch.argmin(softmax_output, dim=1).detach()
### END SOLUTION
# return y
# y = solve(softmax_output)
<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:
|
8,070 | <ASSISTANT_TASK:>
Python Code:
def funcc(x,xo,g):
pr=[]
pi=[]
pr=gen(x)
for i in range(x):
pi.append(xo+g*math.tan(math.pi*(pr[i]-(1/2))))
return pi
fcc=funcc(x,0,1)
for i in range(len(fcc)):
print "{0:.2f}".format(fcc[i])
lambda_=1
def funexp(l,x):
lmda=[]
for i in range(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: Distribucion Exponencial
Step2: Distribuciones Discretas
Step3: Distribucion Geometrica
Step4: Distribucion Uniforme Discreta
|
8,071 | <ASSISTANT_TASK:>
Python Code:
from bedrock.client.client import BedrockAPI
import requests
import pandas
import pprint
SERVER = "http://localhost:81/"
api = BedrockAPI(SERVER)
resp = api.ingest("opals.spreadsheet.Spreadsheet.Spreadsheet")
if resp.json():
print("Spreadsheet Opal Installed!")
else:
print("Spre... | <SYSTEM_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 Connection to Bedrock Server
Step2: Check for Spreadsheet Opal
Step3: Check for STAN GLM Opal
Step4: Check for select-from-dataframe Opa... |
8,072 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras.models import Sequential
from keras.layers.embeddings import Embedding
from keras.layers import Flatten, Activation, Merge
from keras.preprocessing.text import Tokenizer
from keras.preprocessing.sequence import skipgrams, make_sampling_table
from glob 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: Then load in our data. We're actually going to define a generator to load our data in on-demand; this way we'll avoid having all our data sittin... |
8,073 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
vgg_dir = 'tensorflow_vgg/'
# Make sure vgg exists
if not isdir(vgg_dir):
raise Exception("VGG directory doesn't exist!")
class DLProgress(tqdm):
last_block = 0
def hook(self, block_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Flower power
Step2: ConvNet Codes
Step3: Below I'm running images through the VGG network in batches.
Step4: Building the Classifier
Step5: ... |
8,074 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 多言語ユニバーサルセンテンスエンコーダーの Q&A と取得
Step2: 次のコードブロックを実行して、SQuAD データセットを次のように抽出します。
Step3: 次のコードブロックは、Univeral Encoder Multilingual Q&A モデルの ... |
8,075 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mri', 'sandbox-1', 'atmoschem')
# 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... |
8,076 | <ASSISTANT_TASK:>
Python Code:
#|export
class MCDropoutCallback(Callback):
def before_validate(self):
for m in [m for m in flatten_model(self.model) if 'dropout' in m.__class__.__name__.lower()]:
m.train()
def after_validate(self):
for m in [m for m in flatten_model(self.model) ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Export -
|
8,077 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from matplotlib.pyplot import figure, plot, show, title, xlabel, ylabel
from landlab import RasterModelGrid
from landlab.components import FlowDirectorSteepest, TransportLengthHillslopeDiffuser
from landlab.plot import imshow_grid
# to plot figures in the notebook:
%mat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Make a grid and set boundary conditions
Step2: Set the initial and run conditions
Step3: Instantiate the components
Step4: Run the components... |
8,078 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import statsmodels.api as sm
import matplotlib.pyplot as plt
%matplotlib inline
df_adv = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Advertising.csv', index_col=0)
X = df_adv[['TV', 'Radio']]
y = df_adv['Sales']
df_adv.head()
X = df_adv[['TV', '... | <SYSTEM_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 multiple regression model describes the response as a weighted sum of the predictors
Step2: You can also use the formulaic interface of sta... |
8,079 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
iso_120_gas07 = np.genfromtxt('data/dmestar_00120.0myr_z+0.00_a+0.00_marcs.iso')
iso_600_gas07 = np.genfromtxt('data/isochrone_600.0myr_z+0.15_a+0.00_marcs.iso')
iso_120_mixed = np.genfromtxt('data/dmestar_00120.0myr_z... | <SYSTEM_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'll import isochrones for each cluster adopting nominal ages (Pleiades
Step2: Load data for Pleiades and Praesepe stars to demonstrate th... |
8,080 | <ASSISTANT_TASK:>
Python Code:
iris = load_iris()
X = iris.data[:,:2] #Choosing only the first two input-features
Y = iris.target
number_of_samples = len(Y)
#Splitting into training and test sets
random_indices = np.random.permutation(number_of_samples)
#Training set
num_training_samples = int(number_of_samples*0.75)
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: Note that the first class is linearly separable from the other two classes but the second and third classes are not linearly separable from each... |
8,081 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# Discretization
c1=30 # Number of grid points per dominant wavelength
c2=0.2 # CFL-Number
nx=300 # Number of grid points in X
ny=300 # Number of grid points in Y
T=1 # Total propagation time
# Source Signal
f0=... | <SYSTEM_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... |
8,082 | <ASSISTANT_TASK:>
Python Code:
import os
PATH=%env PATH
%env PATH={PATH}:/home/jupyter/.local/bin
%%bash
LOCAL_BIN="/home/jupyter/.local/bin"
SKAFFOLD_URI="https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64"
test -d $LOCAL_BIN || mkdir -p $LOCAL_BIN
which skaffold || (
curl -Lo skaffold $... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1. Environment setup
Step2: Modify the PATH environment variable so that skaffold is available
Step3: Environment variable setup
Step4: ... |
8,083 | <ASSISTANT_TASK:>
Python Code:
mtcars = spark.read.csv(path='../../data/mtcars.csv',
sep=',',
encoding='UTF-8',
comment=None,
header=True,
inferSchema=True)
mtcars.show(n=5)
# adjust first column nam... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Merge multiple columns
Step2: Then we create a new DataFrame from the obtained RDD.
Step3: Split one column
|
8,084 | <ASSISTANT_TASK:>
Python Code:
import math
#given an array of Y values at consecutive integral x abscissas,
#return array of corresponding derivatives to make a natural cubic spline
def naturalSpline(ys):
vs = [0.0] * len(ys)
if (len(ys) < 2):
return vs
DECAY = math.sqrt(3)-2;
endi = len(ys... | <SYSTEM_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 Kernel
|
8,085 | <ASSISTANT_TASK:>
Python Code:
def cube(x): return x*x*x
map(cube,range(1,11))
seq = range(8)
def add(x,y): return x+y
map(add, seq,seq)
result = map(add, seq,seq)
reduce(add, result) # adding each element of the result together
import re
import pandas as pd
import numpy as np
aliceFile = open('data/canterbury/alic... | <SYSTEM_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 there are more parameters then each could be an array, and they are applied together one element at a time
Step2: Python Reduce Function
Ste... |
8,086 | <ASSISTANT_TASK:>
Python Code:
# read in exported table for genus
fig4a_genus = pd.read_csv('../../../data/07-entropy-and-covariation/genus-level-distribution.csv', header=0)
# read in exported table for otu
fig4a_otu = pd.read_csv('../../../data/07-entropy-and-covariation/otu-level-distribution-400.csv', header=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: Figure 4b
Step2: Figure 4c
Step3: Figure 4bc
|
8,087 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 乱数の生成
Step2: tf.random.Generator クラス
Step3: ジェネレータオブジェクトには、さまざまな作成方法があります。最も簡単なのは、上記に示した Generator.from_seed で、シードからジェネレータを作成します。シードは、負でない整数値で... |
8,088 | <ASSISTANT_TASK:>
Python Code:
!pip install -q numpyro@git+https://github.com/pyro-ppl/numpyro
import os
from IPython.display import set_matplotlib_formats
import arviz as az
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.interpolate import BSpline
import seaborn as sns
import jax
imp... | <SYSTEM_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. Exploratory Data Analysis <a class="anchor" id="1"></a>
Step2: Next, we'll choose 200 observations to be part of our train set, and 1500 to ... |
8,089 | <ASSISTANT_TASK:>
Python Code:
import ipywidgets as widgets
from traitlets import Unicode
class HelloWidget(widgets.DOMWidget):
_view_name = Unicode('HelloView').tag(sync=True)
_view_module = Unicode('hello').tag(sync=True)
%%javascript
require.undef('hello');
define('hello', ["@jupyter-widgets/base"], functio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Front end (JavaScript)
Step2: Test
Step3: Making the widget stateful
Step4: Dynamic updates
Step5: An example including bidirectional commun... |
8,090 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
# This is needed to display the images.
%... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Env setup
Step2: Object detection imports
Step3: Model preparation
Step4: Download Model
Step5: Load a (frozen) Tensorflow model into memory... |
8,091 | <ASSISTANT_TASK:>
Python Code:
movie_reviews.categories()
documents = [(list(word for word in movie_reviews.words(fileid) if word not in stop_words), category)
for category in movie_reviews.categories()
for fileid in movie_reviews.fileids(category)
]
random.shuffle(documents)
all_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now I need to store it as
Step2: Getting the list of all words to store the most frequently occuring ones
Step3: Making a frequency distributi... |
8,092 | <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: Optimizing the Text Generation Model
Step2: Get the Dataset
Step3: 250 Songs
Step4: Create Sequences and Labels
Step5: Train a (Better) Text... |
8,093 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd # Importing necessary data package
import matplotlib.pyplot as plt # pyplot module
import numpy as np
Zillow = pd.ExcelFile("Properties_philly_Kraggle_v2.xlsx")
zz = Zillow.parse('Properties_philly_Kraggle_v2')
zz
print('Dimensions: ', zz.sha... | <SYSTEM_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 Soure
Step2: Crime rate, Walks and School score in each postal code
Step3: House sales price by zipcode
Step4: Calculating Average price... |
8,094 | <ASSISTANT_TASK:>
Python Code:
%run ../python-libs/inpututils.py
%run ../python-libs/graycodes.py
%run ../python-libs/bits.py
python_code(graycode_unrank)
print('\n'.join(list(binary_reflected_graycodes(3, justified=True))))
from itertools import count
example_graycodes = binary_reflected_graycodes(length=3)
for 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: Combinatorial Generation
Step2: The following is an iterable of Gray codes we saw in the example above, namely all of them of length 3, pretty-... |
8,095 | <ASSISTANT_TASK:>
Python Code:
id # id(obj: Any) -> int
int # int(obj: SupportsInt) -> int
list.append # list.append(self: List[T], obj: T) -> None
from typing import TypeVar # PEP 484
T = TypeVar('T')
def add(self: T, other: T) -> T: # PEP 3107
return self + other
from typing import List, Tuple
t0: int = add... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Round 1
Step2: Round 2
Step3: Round 3
Step4: K.O.
Step5: Pour avoir l'air savant
Step6: Quizz
Step7: Peut-on se mocker ?
Step8: Test de r... |
8,096 | <ASSISTANT_TASK:>
Python Code:
import fiona
from shapely.geometry import shape
import nhrc2
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from collections import defaultdict
import numpy as np
from matplotlib.patches import Polygon
from shapely.geometry import Point
%matplotlib inline
#the pr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read in neighborhood shapefiles
Step3: Now plot the shapefiles
Step4: Read in issues and determine the region
Step5: Remove issues that do no... |
8,097 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
from numpy.random import randn
import numpy as np
import os
import sys
import matplotlib.pyplot as plt
np.random.seed(12345)
plt.rc('figure', figsize=(10, 6))
from pandas import Series, DataFrame
import pandas as pd
np.set_printoptions(precision=4)
%pwd
!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: Reading and Writing Data in Text Format
Step2: A file will not always have a header row. Consider this file
Step3: To read this in, you have a... |
8,098 | <ASSISTANT_TASK:>
Python Code:
# Import libraries necessary for this project
import numpy as np
import pandas as pd
from time import time
from IPython.display import display # Allows the use of display() for DataFrames
# Import supplementary visualization code visuals.py
import visuals as vs
# Pretty display for notebo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementation
Step2: Preparing the Data
Step3: For highly-skewed feature distributions such as 'capital-gain' and 'capital-loss', it is commo... |
8,099 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os, sys
import numpy as np
import matplotlib
import pandas as pd
import requests
import StringIO
# set matplotlib style
matplotlib.style.use('ggplot')
sitename = 'alligatorriver'
roiname = 'DB_0001'
infile = "{}_{}_1day.csv".format(sitename, roiname)
print infil... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: While the data can be read directly from a URL we'll start by doing the simple thing of reading the CSV file directly from our local disk.
Step2... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.