Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
9,100 | <ASSISTANT_TASK:>
Python Code:
# Plots will be show inside the notebook
%matplotlib notebook
import matplotlib.pyplot as plt
# High-level package for creating and training artificial neural networks
import keras
# NumPy is a package for manipulating N-dimensional array objects
import numpy as np
# Pandas is a data ana... | <SYSTEM_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 features for training
Step2: Load targets for training
Step3: Load features for testing
Step4: Load targets for testing
Step5: Unpack t... |
9,101 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.io
import math
import sklearn
import sklearn.datasets
from opt_utils import load_params_and_grads, initialize_parameters, forward_propagation, backward_propagation
from opt_utils import compute_cost, predict, predict_dec, plo... | <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 - Gradient Descent
Step4: Expected Output
Step6: Expected Output
Step8: Expected Output
Step10: Expected Output
Step12: Expected Output
S... |
9,102 | <ASSISTANT_TASK:>
Python Code:
from itertools import combinations
import numpy as np
import pandas as pd
import seaborn as sns
from string import ascii_uppercase
import time as time
%matplotlib inline
maximum_superleave_length = 5
ev_calculator_max_length = 5
log_file = 'log_games.csv'
tilebag = ['A']*9+['B']*2+['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: Create a dictionary of all possible 1 to 6-tile leaves. Also, add functionality for sorting by an arbitrary key - allowing us to put rarest lett... |
9,103 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import num... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
9,104 | <ASSISTANT_TASK:>
Python Code:
# Python 3.6
!pip install verta
!pip install matplotlib==3.1.1
!pip install tensorflow==2.0.0-beta1
!pip install tensorflow-hub==0.5.0
!pip install tensorflow-datasets==1.0.2
HOST = 'app.verta.ai'
PROJECT_NAME = 'Text-Classification'
EXPERIMENT_NAME = 'RNN'
# import os
# os.environ['VERT... | <SYSTEM_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 Verta
Step2: Imports
Step3: Create a helper function to plot graphs
Step4: Setup input pipeline
Step5: As this is a subwords tokenize... |
9,105 | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
CLOUD_PROJECT = 'PASTE PROJECT ID HERE'
print("Cloud Project Set To: %s" % CLOUD_PROJECT)
CLIENT_CREDENTIALS = 'PASTE CREDENTIALS HERE'
print("Client Credentials Set To: %s" % CLIENT_CREDENTIALS)
FIELDS = {
'dcm_account': '',
'... | <SYSTEM_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. Get Cloud Project ID
Step2: 3. Get Client Credentials
Step3: 4. Enter CM360 Conversion Upload From Sheets Parameters
Step4: 5. Execute CM3... |
9,106 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import re
import gc
import numpy as np
from scipy import sparse
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.preprocessing import MinMaxScaler
from sklearn.feature_selection import SelectPercentile, chi2
from sklearn.externals import joblib
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Feature engineering
Step2: Eventually, we will tokenize the bid information on spaces, so we remove any additional spaces from the data.
Step3:... |
9,107 | <ASSISTANT_TASK:>
Python Code:
# make a list
students = ['boy', 'boy', 'girl', 'boy', 'girl', 'girl', 'boy', 'boy', 'girl', 'girl', 'boy', 'boy']
boys = 0; girls = 0
for s in students:
if s == 'boy':
boys = boys +1
else:
girls+=1
print("boys:", boys)
print("girls:", girls)
print("Hello... | <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: Hello World! in other language
Step3: The magic command (used in jupyte notebook)
Step4: Import package and library
Step6: Comments Are Marke... |
9,108 | <ASSISTANT_TASK:>
Python Code:
workDir = '/home/nick/notebook/SIPSim/dev/bac_genome1210/'
genomeDir = '/home/nick/notebook/SIPSim/dev/bac_genome1210/genomes/'
R_dir = '/home/nick/notebook/SIPSim/lib/R/'
import glob
from os.path import abspath
import nestly
import itertools
%load_ext rpy2.ipython
%%R
library(ggplot2)
l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Init
Step2: Using nestly
Step3: Plotting results
Step4: SANDBOX
|
9,109 | <ASSISTANT_TASK:>
Python Code:
def square(x):
return x*x
def cube(x):
return x*x*x
# This is custom-built map function which is going to behave like in-bulit map function.
def my_map(func, arg_list):
result = []
for i in arg_list:
result.append(func(i))
return result
squares = my_map(square,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Closures
Step2: Decorators
Step3: Some practical applications of decorators
Step4: Chaining of Decorators
Step5: Let's see if switching the ... |
9,110 | <ASSISTANT_TASK:>
Python Code:
# libraries
import numpy as np # numpy
import sys # sys to add py_matrix to the path
# matplotlib inline plots
import matplotlib.pylab as plt
%matplotlib inline
# adding py_matrix parent folder to python path
sys.path.append('../../')
import py_matrix as pm # importing py... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Inputs
Step2: Computation
Step3: Plot of the reflectance spectrum at $\lambda$ = 633 nm
Step4: Plot of the local fields at $\lambda=633$ nm a... |
9,111 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-2', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,112 | <ASSISTANT_TASK:>
Python Code:
# Initialize third-party libraries and the OpenMC Python API
import matplotlib.pyplot as plt
import numpy as np
import openmc
import openmc.model
%matplotlib inline
# Create the model. `ppm_Boron` will be the parametric variable.
def build_model(ppm_Boron):
# Create the pin mate... | <SYSTEM_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 Parametrized Model
Step2: Search for the Critical Boron Concentration
Step3: Finally, the openmc.search_for_keff function also provided... |
9,113 | <ASSISTANT_TASK:>
Python Code:
import psycopg2 as pg
import pandas as pd
import os
conn = pg.connect('service=parcels')
conn_str = os.environ.get('PARCELS_CONNECTION')
def chunks(l, n):
Yield successive n-sized chunks from l.
for i in range(0, len(l), n):
yield l[i:i + n]
with conn.cursor() as cur:
... | <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: Load into individual parcel tables in chunks
Step3: Validate loading
Step15: Consolidate into single table
|
9,114 | <ASSISTANT_TASK:>
Python Code:
import xml.etree.ElementTree as ET # Use cElementTree or lxml if too slow
OSM_FILE = "/Users/yangrenqin/udacity/P3/san-francisco.osm" # Replace this with your osm file
SAMPLE_FILE = "/Users/yangrenqin/udacity/P3/sample1.osm"
k = 30 # Parameter: take every k-th top level element
def get_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: However, since the original full size osm file is too big, I didn't use this sample file in the later part. In the whole wrangling, audit and cl... |
9,115 | <ASSISTANT_TASK:>
Python Code:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline
# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'
# import functions from the modsim.py module
from modsim import *
m = UNITS... | <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: Throwing axe
Step3: Let's make a System
Step5: As a simple starting place, I ignore drag, so vx and omega are constant, and ay is just -g.
Ste... |
9,116 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
from menpo.shape import PointCloud
import menpo.io as mio
from menpofit.transform import DifferentiableThinPlateSplines
src_landmarks = PointCloud(np.array([[-1, -1],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We start by defining the source and target landmarks. Notice that, in this first example source = target!!!
Step2: The warp can be effectively ... |
9,117 | <ASSISTANT_TASK:>
Python Code:
ckey = ''
csecret = ''
atoken = ''
asecret = ''
import tweepy
# create "keychain"
auth = tweepy.OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
# create the API "object"
api = tweepy.API(auth, wait_on_rate_limit = True, wait_on_rate_limit_notify = True)
# testing connec... | <SYSTEM_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: Example
Step3: And here's a script for CSVs (with errorhandling etc.)
|
9,118 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-hm', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("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: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
9,119 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
pd.DataFrame({'Yes': [50, 21], 'No': [131, 2]})
pd.DataFrame({'Bob': ['I liked it.', 'It was awful.'], 'Sue': ['Pretty good.', 'Bland.']})
pd.DataFrame({'Bob': ['I loved it.', 'I hated it.'],
'Sue': ['That was okay.', 'That was not okay.']},
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Creating data
Step2: DataFrame entries aren't limited to integers.
Step3: We are using the pd.DataFrame constructor to generate these DataFram... |
9,120 | <ASSISTANT_TASK:>
Python Code:
!cat Grammar.g4
!type Grammar.g4
!cat c-grammar.g
!type c-grammar.g
!antlr4 -Dlanguage=Python3 Grammar.g4
from GrammarLexer import GrammarLexer
from GrammarParser import GrammarParser
import antlr4
def grammar_2_string(grammar):
result = ''
result += '<html>\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: The file c-grammar.g contains a context-free grammar for the language C.
Step2: Our goal is to convert this grammar into an <span style="font-v... |
9,121 | <ASSISTANT_TASK:>
Python Code:
import time
import numpy as np
import tensorflow as tf
import utils
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import zipfile
dataset_folder_path = 'data'
dataset_filename = 'text8.zip'
dataset_name = 'Text8 Dataset'
class DLProgress(tq... | <SYSTEM_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 text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ... |
9,122 | <ASSISTANT_TASK:>
Python Code:
import sys, os
import numpy as np
import matplotlib
%matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
n = 10 # number of samples
p = 3 # number of features
X = np.random.random([n, p]) # random data for illustration
y = [1]*5 + [2]*5 # random labels ...
np.set_pri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Almost all the machine learning toolboxes take their input in this form
Step2: The only major difference between the above two data structures ... |
9,123 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('rv', times=np.linspace(0,1,101), dataset='rv01')
b.set_value_all('ld_mode', 'manual')
b.se... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new bundle.
Step2: Relevant Parameters
Step3: Note that gravitational redshift effec... |
9,124 | <ASSISTANT_TASK:>
Python Code:
from landlab.io import read_esri_ascii
from landlab.components import FlowAccumulator
from landlab.plot import imshow_grid
from matplotlib.pyplot import figure
%matplotlib inline
from landlab.utils import watershed
import numpy as np
from landlab.utils.flow__distance import calculate_flow... | <SYSTEM_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 a square DEM that includes the watershed
Step2: Run the FlowAccumulator and the DepressionFinderAndRouter components to find depressions... |
9,125 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd # data handeling
import numpy as np # numeriacal computing
import matplotlib.pyplot as plt # plotting core
import seaborn as sns # higher level plotting tools
%matplotlib inline
pd.set_option('display.float_format', lambda x: '%.2f' % x)
pd.set_option('display.max... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: After you have "un-zipped" the data file you have a file named kc_house_data.csv" We will load that into a pandas data frame and take a look at ... |
9,126 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
%run __init__.py
from exotk.utils.misc import fold
from src.extcore import *
lpf = LPFTM()
pv0 = pd.read_hdf(RFILE_EXT, 'ckwn/fc').median().values
fluxes_m = lpf.compute_transit(pv0)
residuals = [fo-fm for fo,fm in zip(lpf.fluxes, fluxes_m)]
gps = [GPTime(time, res) for 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: Compute residuals
Step2: Plot the light curves
Step3: Fit the Hyperparameters and plot the GP mean with the data
Step4: Create a Pandas dataf... |
9,127 | <ASSISTANT_TASK:>
Python Code:
import os
import urllib
import hashlib
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats import pearsonr,spearmanr
from sklearn.preprocessing import scale
from gimmemotifs.maelstrom import run_maelstrom
%matplotlib inline
# Ignor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get the data!
Step2: Read human ATAC-seq table
Step3: Extract relevant data
Step4: Read mouse ATAC-seq table
Step5: Inspect the data
Step6: ... |
9,128 | <ASSISTANT_TASK:>
Python Code:
def rungekutta(fn, y0, ti=0, tf=10, h=0.01):
h = np.float(h)
x = np.arange(ti, tf, h)
Y = np.zeros((len(x), len(y0)))
Y[0] = y0
for i in range(0, len(x)-1):
yi = Y[i]
xi = x[i]
k1 = h * fn(xi, yi)
k2 = h * fn(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Second Order Linear System with 1 degree of freedom
Step2: Now let's consider the following initial conditions
Step3: Analytic solution
Step4:... |
9,129 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
fname = "Untitled Experiment Trial 1.csv"
!head "$fname"
tc = lambda x: int(x)-1463893627134
df = pd.read_csv(fname, index_col=0, converters={0:tc}, names=["time", "lux"], header=0)
df.head()
df.describe()
df.plot(logy=True);
<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: Let's have a quick peek at the data, it's always a good idea to do this, to know how to best load it
Step2: OK, the timestamps look like milise... |
9,130 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
from matplotlib import pyplot as plt
import numpy as np
import scipy as sp
%matplotlib inline
from scipy.stats import norm
FWHM=1.2
x=np.linspace(-3,3,50)
rv = norm(scale=FWHM/2.35)
starone=rv.pdf(x)*1000.
rv = norm(scale=FWHM/2.35)
startwo=(rv.pdf(x-1.0))*500.
fig=plt.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's create two stars as if their point spread functions (PSFs) are one-d gaussians with full width half maximum (FWHM) of 1.2 pixels, which me... |
9,131 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import glob
import numpy as np
from scipy import io
import matplotlib.pyplot as plt
import pandas as pd
train_filename = 'data/train.csv'
data = pd.read_csv(train_filename)
y_train = data['Survived'].values
X_train = data.drop(['Survived', 'PassengerId'], axi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exploratory data analysis
Step2: The original training data frame has 891 rows. In the starting kit, we give you a subset of 445 rows. Some pas... |
9,132 | <ASSISTANT_TASK:>
Python Code:
from symbulate import *
%matplotlib inline
def f(omega, t):
return omega[0] + omega[1] * t
X = RandomProcess(Bernoulli(0.9) * Bernoulli(0.7), TimeIndex(fs=inf), f)
X.sim(1).plot(alpha = 1)
X.sim(100).plot(tmin=0, tmax=2)
def f(omega, t):
return omega[0] * t + omega[1]
X = Rand... | <SYSTEM_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='process'></a>
Step2: Like RV, RandomProcess only defines the random process. Values of the process can be simulated using the usual sim... |
9,133 | <ASSISTANT_TASK:>
Python Code:
# feature descriptives table
desc_file = join(output_dir, '{}_feature_descriptives.{}'.format(experiment_id, file_format))
df_desc = DataReader.read_from_file(desc_file, index_col=0)
HTML(df_desc.to_html(classes=['sortable'], float_format=float_format_func))
outliers_file = join(output_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: Prevalence of recoded cases
Step2: Feature value distribution
|
9,134 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import num... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
9,135 | <ASSISTANT_TASK:>
Python Code:
# You may need to Reconnect (more than Restart) the Kernel to pick up changes to these sett
import os
master = '--master spark://127.0.0.1:47077'
conf = '--conf spark.cores.max=1 --conf spark.executor.memory=512m'
packages = '--packages com.amazonaws:aws-java-sdk:1.7.4,org.apache.hadoop: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:
Step 0
Step1: Step 2
Step2: Step 3
Step3: Deployment Option 1
Step4: Model Server Dashboard
Step5: TODO
|
9,136 | <ASSISTANT_TASK:>
Python Code:
# coding: utf-8
import os
from cheshire3.baseObjects import Session
from cheshire3.document import StringDocument
from cheshire3.internal import cheshire3Root
from cheshire3.server import SimpleServer
session = Session()
session.database = 'db_dickens'
serv = SimpleServer(session, os.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:
Step4: The problems
Step6: Solving problem 1
Step8: Properly structuring the OR clause takes away the problem of having different results for
Step11:... |
9,137 | <ASSISTANT_TASK:>
Python Code:
# Author: Padma Sundaram <tottochan@gmail.com>
# Kaisu Lankinen <klankinen@mgh.harvard.edu>
#
# License: BSD (3-clause)
import mne
from mne.datasets import sample
from mne.minimum_norm import make_inverse_operator, apply_inverse
import numpy as np
import matplotlib.pyplot as plt
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: EEG
|
9,138 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import csv
fn = "/home/huilyu2/work/Trees_Owned_by_the_City_of_Champaign.csv"
# /home/huilyu2/work/Trees_Owned_by_the_City_of_Champaign.csv
# YOUR CODE HERE
data = {}
with open(fn, "r") as f:
reader = csv.reader(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: In the next cell, read in the data using CSV. You do not (yet) need to apply any data-type conversions; what needs to come out of this is a dic... |
9,139 | <ASSISTANT_TASK:>
Python Code:
$ unzip kocham.zip
$ cd kocham
$ python setup.py install
a toy password cracker
import time
import itertools
from multiprocess.dummy import Pool
import kocham.imap as imap
import kocham.corpus as corpus
stopwords = corpus.stopwords
ipassword = corpus.ipassword
compare = imap.login
# turn ... | <SYSTEM_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
Step3: (this takes a long time...)
|
9,140 | <ASSISTANT_TASK:>
Python Code:
# Spike images
from mpl_toolkits.mplot3d import axes3d
import numpy as np
import urllib2
import scipy.stats as stats
import matplotlib.pyplot as plt
from image_builder import get_image
np.set_printoptions(precision=3, suppress=True)
url = ('https://raw.githubusercontent.com/Upward-Spiral-... | <SYSTEM_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 extract images of representing the bins in the spike
Step2: <img src='spike0_0.bmp' style="width
|
9,141 | <ASSISTANT_TASK:>
Python Code:
numbers_str = '496,258,332,550,506,699,7,985,171,581,436,804,736,528,65,855,68,279,721,120'
values = numbers_str.split(",")
numbers = [int(i) for i in values]
# numbers
max(numbers)
#test
print(sorted(numbers))
sorted(numbers)[10:]
[i for i in sorted(numbers) if i%3 == 0]
import math
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the following cell, complete the code with an expression that evaluates to a list of integers derived from the raw numbers in numbers_str, as... |
9,142 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sqlite3
import pandas as pd
import numpy as np
import nltk
import string
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from sklearn 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: Let's first check whether we have the dataset available
Step3: Let's select only what's of interest to us
Step4: Let's see what we've got
Step... |
9,143 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
def np_fact(n):
Compute n! = n*(n-1)*...*1 using Numpy.
if n==0:
return 1
vals = np.arange(1,n+1,1)
fact = vals.cumprod()
return fact[-1]
np_fact(3)
assert np_fact(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:
Step2: Factorial
Step4: Write a function that computes the factorial of small numbers using a Python loop.
Step5: Use the %timeit magic to time both ... |
9,144 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat
import tensorflow as tf
!mkdir data
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
data_dir = 'data/'
if not isdir(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: Getting the data
Step2: These SVHN files are .mat files typically used with Matlab. However, we can load them in with scipy.io.loadmat which we... |
9,145 | <ASSISTANT_TASK:>
Python Code:
import gpytorch
import torch
import math
grid_bounds = [(0, 1), (0, 2)]
grid_size = 25
grid = torch.zeros(grid_size, len(grid_bounds))
for i in range(len(grid_bounds)):
grid_diff = float(grid_bounds[i][1] - grid_bounds[i][0]) / (grid_size - 2)
grid[:, i] = torch.linspace(grid_bou... | <SYSTEM_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 the grid and training data
Step2: Creating the Grid GP Model
Step3: In the next cell, we create a set of 400 test examples and make predi... |
9,146 | <ASSISTANT_TASK:>
Python Code:
#api KEY = c9d64e80aa02ca113562a075e57256d7
https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036
import requests
response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036")
forecast = response.json()
print(fore... | <SYSTEM_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) What's the current wind speed? How much warmer does it feel than it actually is?
Step2: 3) The first daily forecast is the forecast for toda... |
9,147 | <ASSISTANT_TASK:>
Python Code:
# generating some data points
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
# creating a figure
fig = plt.figure(figsize=(4,3), dpi=120)
#plotting
plt.plot(X, C, linestyle='--')
plt.plot(X, S)
# plotting
plt.show()
# creating a figure
fig = plt.figure(figs... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Adding one more sub plot
Step2: another way to add subplots
Step3: One more way to add subplots
Step4: Adding some samples plots
Step5: Sett... |
9,148 | <ASSISTANT_TASK:>
Python Code:
from astropy.utils.data import download_file
from astropy.io import fits
image_file = download_file('http://data.astropy.org/tutorials/FITS-images/HorseHead.fits', cache=True )
hdu_list = fits.open(image_file)
hdu_list.info()
image_data = hdu_list[0].data
print(type(image_data))
print... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Viewing and manipulating FITS images
Step2: Opening FITS files and loading the image data
Step3: Generally the image information is located in... |
9,149 | <ASSISTANT_TASK:>
Python Code:
l = [1, 1, 1, 2, 1]
m = [[p( 2/3, 0), p(-1/3, 1), p(1, 0), p(2/3, 0), p(4/3, 0)],
[p(-2/3, 0), p(-2/3, 0), p(0, 0), p(1/3, 0), p(2/3, 0)]]
F = array([[vw(emme, chi, l) for emme in m] for chi in m])
K = inv(F)
M = eye(2)
dl(dmat(r'\boldsymbol{F}=\frac{1}{27}\frac{L^3}{EJ}', F*27, 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: The eigenvalues problem
Step2: Mass Displacements and Inertial Forces
Step3: Initialization
|
9,150 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# Imports from Python packages.
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import pandas as pd
import numpy as np
import os
# Imports from FinanceOps.
from curve_fit import CurveFitReciprocal
from data_keys import *
from data import load... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Data
Step4: Plotting Functions
Step5: Case Study
Step6: We can forecast the future long-term returns using the fitted "return curve" fro... |
9,151 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-1', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_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... |
9,152 | <ASSISTANT_TASK:>
Python Code:
!pip install hanlp_restful -U
from hanlp_restful import HanLPClient
HanLP = HanLPClient('https://www.hanlp.com/api', auth=None, language='zh') # auth不填则匿名,zh中文,mul多语种
graphs = HanLP.abstract_meaning_representation('男孩希望女孩相信他。')
len(graphs)
graph = graphs[0]
graph
from IPython.display ... | <SYSTEM_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: 返回值为每个句子相应的AMR图的Meaning Representation格式:
Step4: 注意上面“男孩”有2个anchor,分别对应“男孩”和“他”。也就是说,MR格式其实包含了指代消解的结果。
Step5: 多语种支持... |
9,153 | <ASSISTANT_TASK:>
Python Code:
# Make imports
import opcsim
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticks
import seaborn as sns
%matplotlib inline
# turn off warnings temporarily
import warnings
warnings.simplefilter('ignore')
# Let's set some default seaborn settings
sns.set(con... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Nephelometer Representation
Step2: Calibration
Step3: We can explore the calibration factors that were just determined - the units are a bit a... |
9,154 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import tensorflow.keras as keras
import tensorflow.keras.layers as layers
from tensorflow_io.bigquery import BigQueryClient
import functools
GCP_PROJECT_ID = 'qwiklabs-gcp-00-b1e00ce17168' # Replace with your Project-ID
DATASET_GCP_PROJECT_ID = GCP_PROJECT_ID # 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:
Step 1
Step1: Step 2
Step2: Step 3
Step3: Step 4
Step4: Build the model
Step 1
Step5: Step 2
Step6: Step 3
Step7: Step 4
|
9,155 | <ASSISTANT_TASK:>
Python Code:
# Import packages
%run startup.py
bf = Session(host="localhost")
NETWORK_NAME = "example_network"
SNAPSHOT_NAME = "example_snapshot"
SNAPSHOT_PATH = "networks/example"
bf.set_network(NETWORK_NAME)
bf.init_snapshot(SNAPSHOT_PATH, name=SNAPSHOT_NAME, overwrite=True)
# start the traceroute... | <SYSTEM_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: The network snapshot that we initialized above is illustrated below. You can view or download the devices' configuration files her... |
9,156 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import glob
import os
import numpy as np
import matplotlib.pyplot as plt
import sklearn
import sklearn.ensemble
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import cross_val_score, train_test_split, cross_val_predict, learning_curve
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the next step, we create a new dataframe with people as indexes, and all the voting Bill / Business title as column.
Step2: We observe that... |
9,157 | <ASSISTANT_TASK:>
Python Code:
def findMinSum(arr , n ) :
sum = 0
for i in range(0 , n ) :
sum += arr[i ] *(n - i )
return sum
arr =[3 , 5 , 7 , 8 ]
n = len(arr )
print(findMinSum(arr , n ) )
<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:
|
9,158 | <ASSISTANT_TASK:>
Python Code:
from theano.sandbox import cuda
cuda.use('gpu2')
%matplotlib inline
import utils; reload(utils)
from utils import *
from __future__ import division, print_function
path="data/mnist/"
model_path = path + 'models/'
results_path = path + 'results/'
submissions_path = path + 'submissions/'
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: Setup
Step2: Reading Data
Step3: Normalize
Step4: To match the axis that theano expects (channel on axis 1)
Step5: As expected from theano
S... |
9,159 | <ASSISTANT_TASK:>
Python Code:
import os
from google.cloud import bigquery
import pandas as pd
%load_ext google.cloud.bigquery
PROJECT = "cloud-training-demos" # Replace with your PROJECT
BUCKET = PROJECT # defaults to PROJECT
REGION = "us-central1" # Replace with your REGION
SEED = 0
%%bigquery --project $PROJECT... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Replace the variable values in the cell below
Step2: Create a Dataset from BigQuery
Step3: Let's do some regular expression parsing in BigQuer... |
9,160 | <ASSISTANT_TASK:>
Python Code:
from bubble_popper_model import twitter_profile,twitter_links,twitter_articles
from bubble_popper_model import clean_articles,article_topics,publication_scores
from bubble_popper_model import define_bubble,burst_bubble
import tweepy
from sqlalchemy import create_engine
from sqlalchemy_uti... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Modified recommendation functions to perform leave-one-out validation
Step2: Ran recommendation algorithm for the first 10 followers (with 1,00... |
9,161 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.axes as ax
%matplotlib inline
notifs = pd.read_table("./notifications_per_user.tsv")
unreads = pd.read_table("./unread_notifications_per_user.tsv")
wikis = set(notifs["wiki"])
notifs.tail()
def filter... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Total notifications
Step2: 5 or more?
Step3: And what percent of users got 25 notifications or more—becoming more or less "daily notified"?
St... |
9,162 | <ASSISTANT_TASK:>
Python Code:
### Load libraries
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
help(plt.legend)
%%time
df = pd.read_excel('/home/data/APD/COBRA083016_2015.xlsx', sheetname='Query')
df.shape
for c in df.columns:
print(c)
df.head()
df.describe()
df.offense... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data (don't change this if you're running the notebook on the cluster)
Step2: Exploring Dates
Step3: Convert into date-time type
Step4: ... |
9,163 | <ASSISTANT_TASK:>
Python Code:
#%matplotlib inline
import numpy as np
import pylab as pl
from scipy import linalg as sl
def cov_kernel(x1,x2,h,lam):
Squared-Exponential covariance kernel
k12 = h**2*np.exp(-1.*(x1 - x2)**2/lam**2)
return k12
def make_K(x, h, lam):
Make covaria... | <SYSTEM_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 let's import all the libraries we need...
Step3: Make the covariance kernel a squared-exponential,
Step5: We can use this kernel to calcu... |
9,164 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import csv
import scipy.misc
import time
import collections
import os
import utils as ut
import importlib
import copy
importlib.reload(ut)
%matplotlib inline
plt.rcParams['figure.figsize'] = (20.0, 20... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the data from *.csv file
Step2: Explore the correct data
Step3: Prepare the Data for CNN
Step4: As we can see, the number of training im... |
9,165 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
data = pd.read_csv('https://raw.githubusercontent.com/albahnsen/PracticalMachineLearningClass/master/datasets/phishing.csv')
data.head()
data.tail()
keywords = ['https', 'login', '.php', '.html', '@', 'sign']
for keyword in keywords:
data['keyword_' + keyword] = 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: Model using RF
Step2: Using LSTM
Step3: Create vocabulary
Step4: Create embeeding
Step5: Create the network
|
9,166 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cccma', 'sandbox-2', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,167 | <ASSISTANT_TASK:>
Python Code:
# Cluster number, e.g. 100000
cluster = ''
# Cluster username
username = ''
# Cluster password
password = ''
# file path in HDFS
webhdfs_filepath = 'yourpath/yourfile.txt'
# where to save the file in the spark service file system
local_filepath = 'yourfile.txt'
host = 'ehaasp-{0}-maste... | <SYSTEM_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 your custom code to read_csv_lines for processing your datafile
Step2: Code to connect to BigInsights on Cloud via WebHDFS - don't change t... |
9,168 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'dwd', 'mpi-esm-1-2-hr', 'toplevel')
# 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: 2... |
9,169 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
x, y = load_data()
maxs = torch.max(torch.abs(x), torch.abs(y))
xSigns = (maxs == torch.abs(x)) * torch.sign(x)
ySigns = (maxs == torch.abs(y)) * torch.sign(y)
finalSigns = xSigns.int() | ySigns.int()
signed_max = maxs * finalSigns
<END_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
9,170 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import math
from numba import jit, njit, vectorize
def add(x, y):
return x + y # add code here
add(1, 2) # add code here
a = np.arange(0,10) # add code here
b = np.arange(1,11) # add code here
add(a, b) # add code 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: What is Numba?
Step2: Now, test the function, first with two scalar integers
Step3: 1b) With Numpy, we can use our function to add not just sc... |
9,171 | <ASSISTANT_TASK:>
Python Code:
workDir = '/home/nick/t/SIPSim/'
nprocs = 3
import os
import glob
%load_ext rpy2.ipython
%%R
library(ggplot2)
library(dplyr)
library(tidyr)
if not os.path.isdir(workDir):
os.makedirs(workDir)
%cd $workDir
genomeDir = os.path.join(workDir, 'genomes_rn')
# this file
!SIPSim incorp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Init
Step2: Experimental design
Step3: Pre-fractionation communities
Step4: Note
Step6: Simulating fragments
Step7: Simulation
Step8: Plot... |
9,172 | <ASSISTANT_TASK:>
Python Code:
from landlab.components import LinearDiffuser
from landlab.plot import imshow_grid
from landlab import RasterModelGrid
import matplotlib as mpl
import matplotlib.cm as cm
from matplotlib.pyplot import figure, show, plot, xlabel, ylabel, title
import numpy as np
mg = RasterModelGrid((80, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's start by creating the grid that we'll do the first part of this exercise with, and putting some data into its fields. Note that you need t... |
9,173 | <ASSISTANT_TASK:>
Python Code:
from sklearn import datasets
diabetes = datasets.load_diabetes()
iris = datasets.load_iris()
print(iris.DESCR)
digits = datasets.load_digits()
print(digits)
print(digits.data)
print(digits.target)
print(digits.DESCR)
print(0, '\n', digits.images[0])
print()
print(1, '\n', digits.ima... | <SYSTEM_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 load a dataset using the following function
Step2: Some datasets provide a description in the DESCR field
Step3: We can see the content... |
9,174 | <ASSISTANT_TASK:>
Python Code:
from pysismo.pspreprocess import Preprocess
from obspy import read
from obspy.core import Stream
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
# list of example variables for Preprocess class
FREQMAX = 1./1 # bandpass parameters
FREQMI... | <SYSTEM_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 Preprocess class requires many input parameters to function. Below is a list of examples.
Step2: The following processing examples are in o... |
9,175 | <ASSISTANT_TASK:>
Python Code:
import os
import larch # !conda install larch -c conda-forge # for estimation
import pandas as pd
os.chdir('test')
modelname = "trip_mode_choice"
from activitysim.estimation.larch import component_model
model, data = component_model(modelname, return_data=True)
data.coefficients
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: We'll work in our test directory, where ActivitySim has saved the estimation data bundles.
Step2: Load data and prep model for estimation
Step3... |
9,176 | <ASSISTANT_TASK:>
Python Code:
# import the software packages needed
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
inline_rc = dict(mpl.rcParams)
# Combined land and ocean temperature averages (LOTI: Land Ocean Temperature Index)
data1 = pd.read_csv(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Importing a data set
Step2: We can view the first few rows of the file we just imported.
Step3: Plotting the data
Step4: Edit and re-plot
|
9,177 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format = 'retina'
import matplotlib.pyplot as plt
import numpy as np
from uncertainties import unumpy as unp
import pytheos as eos
eta = np.linspace(0., 0.18, 37)
jamieson_pt = eos.platinum.Jamieson1982()
jamieson_pt.print_equations()
jamieson_pt.print_param... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 0. General note
Step2: 3. Compare
Step3: <img src='./tables/Jamieson_Pt_1.png'>
|
9,178 | <ASSISTANT_TASK:>
Python Code:
xs=linspace(-3,3,100)
plt.plot(xs,tanh(xs)); plt.grid()
def funny_tanh(x):
return 1.7159 * tanh(x*2/3) + 0.001 * x
xs=linspace(-3,3,100)
plt.plot(xs,funny_tanh(xs)); plt.grid()
from numpy.random import standard_normal
X=standard_normal(10000)
print("X.std() is %f" % X.std()) # should... | <SYSTEM_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 we may want to use the "funny tanh" function instead, because (a) $f(\pm 1) = \pm 1$, (b) the second derivative is a maximum at $x=1$,... |
9,179 | <ASSISTANT_TASK:>
Python Code:
!pip install hanlp_restful -U
from hanlp_restful import HanLPClient
HanLP = HanLPClient('https://www.hanlp.com/api', auth=None, language='zh') # auth不填则匿名,zh中文,mul多语种
text = '''
据DigiTimes报道,在上海疫情趋缓,防疫管控开始放松后,苹果供应商广达正在逐步恢复其中国工厂的MacBook产品生产。
据供应链消息人士称,生产厂的订单拉动情况正在慢慢转强,这会提高MacBook Pro机型的供... | <SYSTEM_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: 返回值为最多topk个摘要句子以及相应的权重,权重取值区间为$[0, 1]$。由于Trigram Blocking技巧,实际返回的摘要句数量可能小于topk。
Step4: 繁体中文
|
9,180 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import numpy as np
from datetime import datetime
import random
import pandas as pd
import os
from scipy.interpolate import interp1d
import statsmodels.api as sm
## load Harris catalog
GCpG=pd.read_csv("/Users/domi/Dropbox/Research/Local_universe/data/GCpG.csv") # read csv v... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Harris Catalog
Step2: GW Galaxy catalog with $d<30Mpc$ -> VGG
Step3: VGG
Step4: Compute Ngc for VGG
Step5: Estimate GC age based on 55 MWGCs... |
9,181 | <ASSISTANT_TASK:>
Python Code:
import os
ENDPOINT = '' # Enter your ENDPOINT here.
PATH=%env PATH
%env PATH={PATH}:/home/jupyter/.local/bin
shell_output=!gcloud config list --format 'value(core.project)' 2>/dev/null
GOOGLE_CLOUD_PROJECT=shell_output[0]
%env GOOGLE_CLOUD_PROJECT={GOOGLE_CLOUD_PROJECT}
# Docker image na... | <SYSTEM_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: You may need to restart the kernel at this point.
Step3: Modify the PATH environment variable so that skaffol... |
9,182 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
DON'T MODIFY 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: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
9,183 | <ASSISTANT_TASK:>
Python Code:
# %load signal_signal.py
import signal
import os
import time
def receive_signal(signum, stack):
print('Received:', signum)
# Register signal handlers
signal.signal(signal.SIGUSR1, receive_signal)
signal.signal(signal.SIGUSR2, receive_signal)
# Print the process ID so it can be used wi... | <SYSTEM_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 example script loops indefinitely, pausing for a few seconds each time. When a signal comes in, the sleep() call is interrupted and the sig... |
9,184 | <ASSISTANT_TASK:>
Python Code:
x = Variable(torch.ones(2,2), requires_grad=True) # requires_grad: calculate gradients
print(x)
print(x.data)
print(x.grad)
y = x + 2
print(y)
z = y * y * 3
out = z.sum()
print(z, out)
out.backward() # backpropagation
print(x.grad)
Q = torch.eye(3)
Q
<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: $z = (x + 2)^2 * 3$
|
9,185 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
import numpy as np
import thinkbayes2
from thinkbayes2 import Pmf, Cdf, Suite, Beta
import thinkplot
% matplotlib inline
class Euro(Suite):
def Likelihood(self, data, hypo):
Computes the likelihood of `data` given `hypo`.
... | <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 Euro problem
Step3: We can make a uniform prior and update it with 140 heads and 110 tails
Step4: And here's what the posterior looks like... |
9,186 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo("B36fzChfyGU")
# Execute this cell
import numpy as np
from sklearn.mixture import GMM
X = np.random.normal(size=(1000,2)) #1000 points in 2D
gmm = GMM(3) #three components
gmm.fit(X)
log_dens = gmm.score(X)
BIC = gmm.bic(X)
# Execut... | <SYSTEM_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 typical call to the Gaussian Mixture Model algorithm looks like this
Step2: Let's start with the 1-D example given in Ivezic, Figure 6.8, whi... |
9,187 | <ASSISTANT_TASK:>
Python Code:
resume_sorted3 = sorted(resume, key=lambda data: data[11])
resume_sorted6 = sorted(resume, key=lambda data: data[12])
resume_sorted7 = sorted(resume, key=lambda data: data[13])
res3 = np.array(resume_sorted3)
res6 = np.array(resume_sorted6)
res7 = np.array(resume_sorted7)
plt.figure(figsi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sorted based on total integration in 3 Band (3+6+7)
Step2: The correlation is seen on all plot, however the last plot has better variance (I th... |
9,188 | <ASSISTANT_TASK:>
Python Code:
# Which is easily implemented on python :
def _convolve(x, w, type='valid'):
# x and w are np vectors
conv = []
for i in range(len(x)):
if type == 'valid':
conv.append((x[i: i+len(w)] * w).sum())
return np.array(conv)
def convolve(X, w):
# Convolves... | <SYSTEM_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. Derive the Convolution !!
Step2: Train a convolutional neural net
Step3: Applied to image
|
9,189 | <ASSISTANT_TASK:>
Python Code:
import os
import cea
import geopandas
import pandas as pd
from packaging import version
import cea.inputlocator
from cea.utilities.dbf import dbf_to_dataframe, dataframe_to_dbf
# Constants
SCENARIO_TO_MIGRATE = r"c:\Users\darthoma\Documents\CityEnergyAnalyst\projects\2.29.0\kleinalbis"
EX... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Migrate building-geometry files
Step2: The zone.shp file is the the same! (repeated this procedure with site.shp and surroundings.shp)
Step3: ... |
9,190 | <ASSISTANT_TASK:>
Python Code:
# Imports
import csv
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from itertools import groupby
from operator import itemgetter
# Load the series data
info = pd.read_csv('../data/bls/series.csv')
def series_info(blsid, info=info):
... | <SYSTEM_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 Loading
|
9,191 | <ASSISTANT_TASK:>
Python Code:
from mlens.parallel import ParallelProcessing, Job, Learner
from mlens.index import FoldIndex
from mlens.utils.dummy import OLS
import numpy as np
np.random.seed(2)
X = np.arange(20).reshape(10, 2)
y = np.random.rand(10)
indexer = FoldIndex(folds=2)
learner = Learner(estimator=OLS(),
... | <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: Stacking a set of parallel jobs
Step3: Now, we construct a sequence of tasks to compute, where the output of one
Step4: To fit the stack, we c... |
9,192 | <ASSISTANT_TASK:>
Python Code:
a = 1 + 2
a
a + 1
_
? sum
! ps -xa | grep python
import time
%time time.sleep(1)
import numpy as np
np.array([[1,2,3], [7,1,2]])
data = np.array([1,2,3,4,5])
data
data[1:-2]
data + 1
data * 2
data * data
np.sum(data * data)
data.dot(data)
data > 2
data[data > 2]
replaces = data[:]
replac... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Markdown
Step2: Pandas
Step3: Matplotlib
|
9,193 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append("../..")
import numpy as np
import yellowbrick as yb
import matplotlib.pyplot as plt
from functools import partial
from sklearn.datasets import make_blobs as sk_make_blobs
from sklearn.datasets import make_circles, make_moons
# Helpers for easy dataset creati... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Elbow Method
Step2: 8 Blobs Dataset
Step3: Datasets without Centers
Step4: Silhouette Score
Step6: Intercluster Distance Map
|
9,194 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import numpy as np
from mayavi import mlab
import mne
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
subjects_dir = op.join(data_path, 'subjects')
raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif')
trans_fname = op.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Understanding coordinate frames
Step2: Coordinate frame definitions
Step3: It is quite clear that the MRI surfaces (head, brain) are not well ... |
9,195 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'miroc', 'sandbox-1', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_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... |
9,196 | <ASSISTANT_TASK:>
Python Code:
import scipy.linalg as la
LL = np.zeros(N)
for rr in range(N):
ss = s*np.ones(N)
ss[rr] = q
D_r = np.diag(1/ss)
V_r = np.dot(np.sqrt(D_r), W)
b = y/np.sqrt(ss)
a_r,re,ra, cond = la.lstsq(V_r, b)
e = (y-np.dot(W, a_r))/np.sqrt(ss)
LL[rr] = -0.5*np.dot(e.T, 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: Todo
Step2: SUppose we are given a data set $(y_i, x_i)$ for $i=1\dots N$
|
9,197 | <ASSISTANT_TASK:>
Python Code:
# Import required libraries
from tpot import TPOT
from sklearn.cross_validation import train_test_split
import pandas as pd
import numpy as np
# Load the data
titanic = pd.read_csv('data/titanic_train.csv')
titanic.head(5)
titanic.groupby('Sex').Survived.value_counts()
titanic.groupby([... | <SYSTEM_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 Exploration
Step2: Data Munging
Step3: At present, TPOT requires all the data to be in numerical format. As we can see below, our data se... |
9,198 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'miroc', 'sandbox-1', 'landice')
# 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... |
9,199 | <ASSISTANT_TASK:>
Python Code:
def pretty_print_review_and_label(i):
print(labels[i] + "\t:\t" + reviews[i][:80] + "...")
g = open('reviews.txt','r') # What we know!
reviews = list(map(lambda x:x[:-1],g.readlines()))
g.close()
g = open('labels.txt','r') # What we WANT to know!
labels = list(map(lambda x:x[:-1].uppe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lesson
Step2: Project 1
Step5: Transforming Text into Numbers
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.