Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
11,700 | <ASSISTANT_TASK:>
Python Code:
sent = "Each of us is full of shit in our own special way"
# setup display for demo
%matplotlib inline
import os
os.environ['DISPLAY'] = 'localhost:1'
from stat_parser import Parser
parser = Parser()
parser.parse(sent)
tree = parser.parse(sent) # returns nltk Tree instance
tree
from 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: pyStatParser
Step2: TextBlob
Step3: MaltParser
Step4: Pattern
Step5: spaCy
Step6: <a href="https
Step7: Alice's Yelp Data
Step8: 1. parts... |
11,701 | <ASSISTANT_TASK:>
Python Code:
from threeML import *
import matplotlib.pyplot as plt
%matplotlib inline
%matplotlib notebook
triggerName = 'bn090217206'
ra = 204.9
dec = -8.4
#Data are in the current directory
datadir = os.path.abspath('.')
#Create an instance of the GBM plugin for each detector
#Data files
obsSpectru... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simple standard analysis
Step2: As we can see, the plugin probes the data to choose the appropriate likelihood for the given obseration and bac... |
11,702 | <ASSISTANT_TASK:>
Python Code:
# This is a sentence
sentence = 'This is a rather long sentence. I want to find the number of words with two letters'
# This is the code you need to find the number of words of length 2 (e.g., is, to, and of)
words = sentence.split(' ') # Split the sentence string into a list of words, 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: Imagine this is a task we do every day, wouldn't it be nice to have a way to perform this without re-typing all this code every time? Something ... |
11,703 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
from numpy import size
def Planckfunc_cgs(freq, temperature):
Calculate Planck function.
Inputs:
freq: frequency, in Hz
temperature: temperature in Kelvin
Return:
Intensity: in cgs unit ( erg s^-1 sr^-1 cm^-2 Hz-1 )
# 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:
Step3: Defining function
Step8: 2. Opacity
Step10: Motions
Step13: 2. Jeans Length and Jeans mass
Step14: 3. Toomore Q parameter
Step15: Plot Plan... |
11,704 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
import matplotlib
from scipy import optimize
import astropy.io.fits
matplotlib.rcParams.update({'font.size': 18})
matplotlib.rcParams.upda... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 6.5 Source Finding
Step2: Now, in reality the noise has to measured in the presence of astrophysical emission. Futhermore, radio iamges are als... |
11,705 | <ASSISTANT_TASK:>
Python Code:
import csv
from datetime import datetime
from IPython.display import display, Markdown, Latex, HTML
import json
import math
import pandas as pd
from pathlib import Path
site: str
arm: str
def get_special_columns(file_path):
f = open(file_path, "r")
data = json.load(f)
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: Parametrization
Step2: Create Special Columns
Step3: Create Data Dictionary
Step4: Functions to Style Table
Step5: Display Table
Step6: Mai... |
11,706 | <ASSISTANT_TASK:>
Python Code:
# BE SURE TO RUN THIS CELL BEFORE ANY OF THE OTHER CELLS
import psycopg2
import pandas as pd
# query database
statement =
SELECT DISTINCT text, COUNT(*)
FROM
(SELECT text
FROM twitter.hashtag
LIMIT 10000) AS hashtag_text
GROUP BY text
ORDER BY count DESC
try:
connect_str = "dbname=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Twitter
Step3: Now, lets find the most popular hashtags for the city of Provo, Utah!
Step4: Notice that we used lower(text) in our group by. A... |
11,707 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
%matplotlib inline
plt.style.use('ggplot')
plt.rcParams['figure.figsize']=15,10
df = pd.read_csv('data/data.csv')
df.head()
df.shape
df_model = pd.DataFrame(df.model.unique(),columns=['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: Let us take a sneak peek at the data
Step2: What is the size of the dataset?
Step3: Now we see that there are different models of hard disks, ... |
11,708 | <ASSISTANT_TASK:>
Python Code:
This code file creates homework assignment #2
Gary Gregg
DATA 512A
University of Washington
Autumn 2017
import numpy as np
import csv
import matplotlib.pyplot as plt
plt.rcdefaults()
import os.path
import requests
# Country Map
COUNTRY_MAP = {
"East Timorese" : "Timor-Leste",
"Ho... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Declare all required import packages.
Step2: Although they refer to the same country, some of the country names in the article data file do not... |
11,709 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from pathlib import Path
import menpo.io as mio
takeo = mio.import_builtin_asset.takeo_ppm()
takeo = takeo.as_greyscale(mode='luminosity')
# Use a bounding box rather than the facial shape
takeo.landmarks['bounding_box'] = takeo.landmarks['PTS'].lms.bounding_box()
takeo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lucas-Kanade methods align a given template onto a provided image. Therefore, we must create a template that we will seek within a given input i... |
11,710 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from fbprophet import Prophet
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize']=(20,10)
plt.style.use('ggplot')
sales_df = pd.read_csv('../examples/retail_sales.csv', index_col='date', parse_dates=True)
sales_df.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: Read in the data
Step2: Prepare for Prophet
Step3: Let's rename the columns as required by fbprophet. Additioinally, fbprophet doesn't like th... |
11,711 | <ASSISTANT_TASK:>
Python Code:
import os
print(os.getcwd())
os.chdir(os.getcwd() + "/Physique/") # change current working directory
print(os.getcwd())
%run -i ./Scripts/Refresh.py # this is the main, important, command to run
import Physique
import sys
sys.executable # Check which Python you are running in case you hav... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NIST Fundamental Constants
Step2: Find a Fundamental Constant you are interested in using the usual panda modules
Step3: NIST Official Convers... |
11,712 | <ASSISTANT_TASK:>
Python Code:
import graphlab
def polynomial_sframe(feature, degree):
# assume that degree >= 1
# initialize the SFrame:
poly_sframe = graphlab.SFrame()
# and set poly_sframe['power_1'] equal to the passed feature
poly_sframe['power_1'] = feature
# first check if degree > 1fea
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Polynomial regression, revisited
Step2: Let's use matplotlib to visualize what a polynomial regression looks like on the house data.
Step3: As... |
11,713 | <ASSISTANT_TASK:>
Python Code:
# Grab the NYT's homepage
response = requests.get("http://nytimes.com")
doc = BeautifulSoup(response.text)
# Snag all of the headlines (h3 tags with 'story-heading' class)
headlines = doc.find_all("h3", {'class': 'story-heading'})
# Getting the headline text out using list comprehensions
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: But... forms!
Step2: Submitting forms with requests
Step3: It's magic, I swear!
Step4: Closing the webdriver
|
11,714 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import logging
from scipy.io.matlab import loadmat
from scipy.sparse import csr_matrix
import matplotlib
import matplotlib.pyplot as plt
from sklearn.metrics import roc_auc_score
import rescal
from almc.bayesian_rescal import BayesianRescal
%matplotlib inline
#logger = ... | <SYSTEM_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. Splitting the kinship dataset into train/test sets
Step2: 3. Training BayesianRESCAL
Step3: 3.2. Training RESCAL
Step4: 3.3. Compare both ... |
11,715 | <ASSISTANT_TASK:>
Python Code:
import os
import csv
import pandas as pd
import numpy as np
from scipy import stats
data_path = '../../data'
tmp_path = '../../tmp'
feature_path = os.path.join(data_path, 'evaluation/semcor/tsvetkov_semcor.csv')
subset = pd.read_csv(feature_path, index_col=0)
subset.columns = [c.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: QVEC model
Step2: Learnt word embeddings
Step3: The Python variables S and X refer to $S$ and $X$ exactly as above.
Step4: Now we want the co... |
11,716 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
from astropy.time import Time
from toolkit import EchelleSpectrum
kic8462852_1_url = 'http://staff.washington.edu/bmmorris/docs/KIC8462852.0001.wfrmcpc.fits'
kic8462852_2_url = 'http://staff.w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download and cache spectra
Step2: Fit a polynomial of order polynomial_order to each spectral order of the spectrum of spectroscopic_standard, ... |
11,717 | <ASSISTANT_TASK:>
Python Code:
#Create references to important directories we will use over and over
import os, sys
DATA_HOME_DIR = '/home/nathan/olin/spring2017/line-follower/line-follower/data'
#import modules
import numpy as np
from glob import glob
from PIL import Image
from tqdm import tqdm
import bcolz
from matpl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Gather data
Step2: Network
Step3: Train the model
Step4: Analyze training
|
11,718 | <ASSISTANT_TASK:>
Python Code:
import json
import pandas as pd
import os
from os.path import join
import numpy as np
from joblib import Parallel, delayed
import sys
cwd = os.getcwd()
data_path = join(cwd, '..', 'Data storage')
file_date = '2018-03-06'
%load_ext watermark
%watermark -iv -v
# Load the "autoreload" exten... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Date string for filenames
Step2: Read ELEC.txt file
Step3: Filter lines to only include facility generation
Step4: Combine generation into o... |
11,719 | <ASSISTANT_TASK:>
Python Code:
import keras
import numpy as np
path = keras.utils.get_file(
'nietzsche.txt',
origin='https://s3.amazonaws.com/text-datasets/nietzsche.txt')
text = open(path).read().lower()
print('Corpus length:', len(text))
# Length of extracted character sequences
maxlen = 60
# We sample a new... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, we will extract partially-overlapping sequences of length maxlen, one-hot encode them and pack them in a 3D Numpy array x of
Step2: Buil... |
11,720 | <ASSISTANT_TASK:>
Python Code:
# To better match the math equations above, collection starts at index 1 instead of 0
def partition(collection, n, k):
if n == 0:
return "No elements in collection to partition"
# initialize matrix
m = [[float('inf')] * k for _ in range(n+1)]
d = [[-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: Less imperative
|
11,721 | <ASSISTANT_TASK:>
Python Code:
import processing_tools as pt
filepath = './example/example.h5'
data = pt.ParticleDistribution(filepath)
data.su2si
data.dict['x']
panda_data = data.DistFrame()
panda_data[0:5]
import matplotlib.pyplot as plt
matplotlib.style.use('ggplot') #optional
x_axis = 'py'
y_axis = 'px'
plot = 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: The module consists of a class 'ParticleDistribution' that initializes to a dictionary containing the following entries given a filepath
Step2: ... |
11,722 | <ASSISTANT_TASK:>
Python Code:
from shapely.geometry import Point
import pyproj
import geopandas as gpd
proj = pyproj.Proj(init='epsg:2263', preserve_units=True)
entr_points = sqlContext.read.load('../why_yellow_taxi/Data/2016_(May)_New_York_City_Subway_Station_Entrances.json', \
format=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: List
Step2: Identical or Not?
Step3: Detail
|
11,723 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pynucastro as pyrl
files = ["p-p-d-ec",
"d-pg-he3-de04",
"he3-he3pp-he4-nacr",
"c12-pg-n13-ls09",
"c13-pg-n14-nacr",
"n13--c13-wc12",
"n13-pg-o14-lg06",
"n14-pg-o15-im05",
"n15-pa-c12-nacr"... | <SYSTEM_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 collection of rates has the main CNO rates plus a breakout rate into the hot CNO cycle
Step2: To evaluate the rates, we need a composition... |
11,724 | <ASSISTANT_TASK:>
Python Code:
Tc_mf = meV_to_K(0.5*250)
print meV_to_K(pi/2.0)
print 1.0/0.89
print cst.physical_constants["Boltzmann constant"]
print '$T_c^{MF} = $', Tc_mf, "K"
T_KT = meV_to_K(0.1*250)
print r"$T_{KT} = $", T_KT, "K"
T_CST = 0.25
BCS_PARAMS = {"width":4, "chem_potential": 0.0,
"hoppi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: d Wave
Step2: Modification
Step3: MC Driver
Step4: Modification
|
11,725 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
import numpy as np
from ipywidgets import widgets, fixed
from ipywidgets import interact
from exact_solvers import nonconvex
from exact_solvers import nonconvex_demos
nonconvex_demos.demo1()
f = lambda q: q*(1-q)
q_left = 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: If you wish to examine the Python code for this chapter, please see
Step2: The plot on the left above shows a case where the solution is a rare... |
11,726 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.optimize as opt
a_true = 0.5
b_true = 2.0
c_true = -4.0
# YOUR CODE HERE
raise NotImplementedError()
assert True # leave this cell for grading the raw data generation and plot
# YOUR CODE HERE
raise NotI... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fitting a quadratic curve
Step2: First, generate a dataset using this model using these parameters and the following characteristics
Step3: No... |
11,727 | <ASSISTANT_TASK:>
Python Code:
from qrays import Vector # see Chapter 6
class Polyhedron:
def __init__(self, name, volume, faces : set,
vertexes : dict, center = Vector((0,0,0))):
self.name = name
self.vertexes = vertexes
self.volume = volume
self.faces... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step5: Oregon Curriculum Network <br />
Step6: The polyhedrons we've talked about will be instances of our Polyhedron class. Once instantiated, they ... |
11,728 | <ASSISTANT_TASK:>
Python Code:
from regraph import NXGraph, Rule
from regraph import plot_graph, plot_instance, plot_rule
%matplotlib inline
# Create an empty graph object
graph = NXGraph()
# Add a list of nodes, optionally with attributes
graph.add_nodes_from(
[
'Alice',
('Bob', {'age': 15, 'gende... | <SYSTEM_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. Creating and modifying a graph object
Step2: Note that the attributes of the nodes/edges are converted to regraph.attribute_sets.FiniteSet o... |
11,729 | <ASSISTANT_TASK:>
Python Code:
import urllib2
page = urllib2.urlopen("http://beans-r-us.appspot.com/prices.html")
text_str = page.read()
text_str
type(text_str)
text = text_str.decode("utf8")
type(text)
text
print(text)
a_food = "kebap"
a_food[0]
a_food[1]
a_food[2]
a_food[-1]
a_food[-2]
a_food[5]
len(a_food)... | <SYSTEM_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: 유니코드(unicode)
Step4: 주의
Step5: 위 문자열에서 원하는 정보인 커피콩의 가격을 어떻게 추출할 것인가?
Step6: ... |
11,730 | <ASSISTANT_TASK:>
Python Code:
from keras.layers import Conv2D, MaxPooling2D, Input, Dense, Flatten, Activation, add
from keras.layers.core import Dropout
from keras.layers.normalization import BatchNormalization
from keras.layers.pooling import GlobalAveragePooling2D
from keras.optimizers import RMSprop
from keras.mod... | <SYSTEM_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 the MNIST data. Notice that we assume that it's 'kaggle-DigitRecognizer/data/train.csv', and we use helper function to read into a dictiona... |
11,731 | <ASSISTANT_TASK:>
Python Code:
dgm = gm.DGM.read('../networks/earthquake.bif')
dgm.draw() # you can move the cursor on a node to see it's CPD
nx.dag_longest_path(dgm)
nx.average_neighbor_degree(dgm)
list(dgm.immoralities) # list of all immoralities in graph
list(dgm.v_structures) # list of all v_structures in graph
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: DGM is a subclass of networkx.DiGraph, so you can use any networkx functions on it.
Step2: Also, some DGM-specific queries about the graph are ... |
11,732 | <ASSISTANT_TASK:>
Python Code:
fname = io.download_occultation_times(outdir='../data/')
print(fname)
tlefile = io.download_tle(outdir='../data')
print(tlefile)
times, line1, line2 = io.read_tle_file(tlefile)
tstart = '2019-01-12T00:00:00'
tend = '2019-01-12T23:00:00'
orbits = planning.sunlight_periods(fname, tstart, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download the NuSTAR TLE archive.
Step2: Here is where we define the observing window that we want to use.
Step3: We want to know how to orient... |
11,733 | <ASSISTANT_TASK:>
Python Code:
! wget -O GEM.tbz2 https://sourceforge.net/projects/gemlibrary/files/gem-library/Binary%20pre-release%202/GEM-binaries-Linux-x86_64-core_i3-20121106-022124.tbz2/download
! tar -xjvf GEM.tbz2
! sudo cp GEM-binaries-Linux-x86_64-core_i3-20121106-022124/gem-mapper /usr/local/bin/
! sudo cp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Uncompress the archive
Step2: And copy the needed binaries to somewhere in your PATH, like
Step3: In case you do not have root access, just co... |
11,734 | <ASSISTANT_TASK:>
Python Code:
import os
from PIL import Image
def get_record_and_image(index):
record = df.iloc[index]
path = os.path.join('data', record.center)
return record, Image.open(path)
def layer_info(model):
for n, layer in enumerate(model.layers, 1):
print('Layer {:2} {:16} input shap... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1
Step2: Step 2
Step3: Now I need to create the actual training data, X_train and y_train. I will just read all the images and store them... |
11,735 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
import sklearn as skl
import holcrawl.shared
dataset_dir = holcrawl.shared._get_dataset_dir_path()
dataset_path = os.path.join(dataset_dir, 'movies_dataset.csv')
df = pd.read_csv(dataset_path)
df['ROI'] = (df['gross_income'] - df['budget']) / df['budget']
df... | <SYSTEM_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 Generation
Step2: The number of null values per column
Step3: Keeping all genre dummy variables
Step4: Dropping non-feature columns
S... |
11,736 | <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: Signatures in TensorFlow Lite
Step2: Example model
Step3: In the signature wise, the above TensorFlow model can be summarized as follows
Step4... |
11,737 | <ASSISTANT_TASK:>
Python Code:
import graphlab
graphlab.product_key.set_product_key("C0C2-04B4-D94B-70F6-8771-86F9-C6E1-E122")
tmp = graphlab.SArray([1., 2., 3.])
tmp_cubed = tmp.apply(lambda x: x**3)
print tmp
print tmp_cubed
ex_sframe = graphlab.SFrame()
ex_sframe['power_1'] = tmp
print ex_sframe
def polynomial_sf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next we're going to write a polynomial function that takes an SArray and a maximal degree and returns an SFrame with columns containing the SArr... |
11,738 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
import numpy as np # note this allows us to refer to numpy as np instead
def get_numpy_data(data_sframe, features, output):
data_sframe['constant'] = 1 # this is how you add a constant column to an SFrame
# add the co... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in house sales data
Step2: If we want to do any "feature engineering" like creating new features or adjusting existing ones we should do t... |
11,739 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-2', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
11,740 | <ASSISTANT_TASK:>
Python Code:
ph_sel_name = "all-ph"
data_id = "12d"
# ph_sel_name = "all-ph"
# data_id = "7d"
from fretbursts import *
init_notebook()
from IPython.display import display
data_dir = './data/singlespot/'
import os
data_dir = os.path.abspath(data_dir) + '/'
assert os.path.exists(data_dir), "Path '%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: Load software and filenames definitions
Step2: Data folder
Step3: Check that the folder exists
Step4: List of data files in data_dir
Step5: ... |
11,741 | <ASSISTANT_TASK:>
Python Code:
ls
# the name of the file that you wish to open
specfilename = '20151111'
# the name of the x column
x = 'MCMY'
# the name of the detector (y column)
y = 'PD21'
# the name of the monitor column
monitor = 'SRcur'
# the scans that you wish to process
scans = [108, 110, 112, 114]
# the 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: Specify the kind of interpolation you want to use as a string
Step2: The boring stuff
Step4: Defining required objects and functions
Step5: ... |
11,742 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import astropy.units as u
from astropy import time
from poliastro import iod
from poliastro.plotting import plot
from poliastro.bodies import Sun, Earth
from poliastro.twobody 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: Primero
Step2: Segundo
Step3: Tercero
Step5: ...y es Python puro!
Step6: Quinto
|
11,743 | <ASSISTANT_TASK:>
Python Code:
import sympy as sp
from sympy.interactive import printing
printing.init_printing(use_latex=True)
from sympy.stats import Bernoulli, LogNormal, density, sample, P as Prob, E as Expected, variance
k1, k2 = sp.symbols('k1 k2', real=True)
p = sp.symbols('p', nonnegative=True)
Xs = sp.symbols... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Start by looking at a fair lottery random. A Bernoulli distribution can be used to represent a fair lottery
Step2: Playing around with random ... |
11,744 | <ASSISTANT_TASK:>
Python Code:
number = int(input("Enter a number: "))
if number > 0:
print("The number is positive.")
number = int(input("Enter a number: "))
if number >= 0:
print("The number is zero or positive.")
else:
print("The number is negative.")
number = int(input("Enter a number: "))
if (nu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ključna reč <i>else</i> koristi se u paru sa ključnom rečju <i>if</i> i njome definišemo <i>else</i> granu, ili granu "ne". To je blok koda koji... |
11,745 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn')
from sklearn.linear_model import LinearRegression
model = LinearRegression(normalize=True)
print(model.normalize)
print(model)
x = np.arange(10)
y = 2 * x + 1
print(x)
print(y)
plt.plot(x, 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: The Scikit-learn Estimator Object
Step2: Estimator parameters
Step3: Estimated Model parameters
Step4: The model found a line with a slope 2 ... |
11,746 | <ASSISTANT_TASK:>
Python Code:
# NBVAL_SKIP
from openeye import oechem # OpenEye Python toolkits
import oenotebook as oenb
# Check license
print("Is your OEChem licensed? ", oechem.OEChemIsLicensed())
from openeye import oeomega # Omega toolkit
from openeye import oequacpac #Charge toolkit
from openeye import oedocking... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configuration for your run
Step2: Quickly draw your guest and make sure it's what you intended
Step3: Get host file and prep it for docking
St... |
11,747 | <ASSISTANT_TASK:>
Python Code:
%sosdict
%sos a = 1
%sosdict
d = %sosdict
d.keys()
d = %sosdict a
d.keys()
%sosdict --keys
%sosdict --reset
%sosdict
%sosdict --keys --all
%sos a=10
%sos "a + 100 = ${{a+100}}"
%sos_options sigil='` `'
%sos "a + 100 = `1+100`"
%sos b=['file1.txt', 'file2.txt']
%sos "`b!r,`"
%sos_... | <SYSTEM_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 dictionary is empty because we have not assigned anything to it. Let us run a sos statement
Step2: and you can see the sos dictionary conta... |
11,748 | <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... |
11,749 | <ASSISTANT_TASK:>
Python Code:
import SimpleITK as sitk
# Utility method that either downloads data from the MIDAS repository or
# if already downloaded returns the file name for reading from disk (cached data).
from downloaddata import fetch_data as fdata
# Always write output to a separate directory, we don't want to... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Utility functions
Step2: Read images
Step3: Initial Alignment
Step4: Registration
Step5: Post registration analysis
Step6: Now visually ins... |
11,750 | <ASSISTANT_TASK:>
Python Code:
from rmgpy.data.rmg import RMGDatabase
from rmgpy import settings
from rmgpy.species import Species
from rmgpy.molecule import Molecule
from rmgpy.molecule import Group
from rmgpy.rmg.main import RMG
from rmgpy.cnn_framework.predictor import Predictor
from IPython.display import display
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: Validation Test
Step4: Create pandas dataframe for easy data validation
Step5: categorize error sources
Step6: Parity Plot
Step7: Histogram ... |
11,751 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
#!pip install --upgrade tensorflow==2.5
import tensorflow as tf
import numpy as np
import IPython.display as display
print("TensorFlow version: ",tf.version.VERSION)
# TODO 1a
# The following functions can be used to conv... | <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: Please ignore any incompatibility warnings and errors.
Step5: Note
Step6: Lab Task #1b
Step7: Creating a tf.Example message
Step9: Each of t... |
11,752 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import geopandas
from shapely.geometry import Polygon
capitals = geopandas.read_file(geopandas.datasets.get_path("naturalearth_cities"))
world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
# Create a subset of the world data tha... | <SYSTEM_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 or Create Example Data
Step2: Plot the Unclipped Data
Step3: Clip the Data
Step4: <div class="alert alert-info">
|
11,753 | <ASSISTANT_TASK:>
Python Code:
# importing packages for wrangling tasks
import pandas as pd
import numpy as np
import re
from fuzzywuzzy import process
from fuzzywuzzy import fuzz
from geopy.distance import great_circle
# create a function to quickly tabulate a dataframe column
def tab(dfcol):
t = pd.crosstab(index... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fuzzy matching player names
Step2: After loading the separate sportsreference and espn files, I add some common team identifers to each datafra... |
11,754 | <ASSISTANT_TASK:>
Python Code:
import os
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if os.getenv("IS_TESTING"):
!... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
11,755 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import os
from os.path import join
import glob
import numpy as np
from joblib import Parallel, delayed
import sys
import json
cwd = os.getcwd()
data_path = join(cwd, '..', 'Data storage')
idx = pd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: EIA facility data and EPA monthly emissions
Step3: JSON files with fuel categories
Step4: EIA total monthly gen and fuel con... |
11,756 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data')
def model_inputs(real_dim, z_dim):
inputs_real = tf.placeholde... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model Inputs
Step2: Generator network
Step3: Discriminator
Step4: Hyperparameters
Step5: Build network
Step6: Discriminator and Generator L... |
11,757 | <ASSISTANT_TASK:>
Python Code:
reset_start_time(O.just)
stream = O.just({'answer': rand()})
disposable = subs(stream)
sleep(0.5)
disposable = subs(stream) # same answer
# all stream ops work, its a real stream:
disposable = subs(stream.map(lambda x: x.get('answer', 0) * 2))
print('There is a little API difference to R... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ..that was returned from a function called at subscribe-time
Step2: ..that was returned from an Action, Callable, Runnable, or something of tha... |
11,758 | <ASSISTANT_TASK:>
Python Code:
!git clone https://github.com/tensorflow/models
from __future__ import print_function
from IPython import display
checkpoint_name = 'mobilenet_v2_1.0_224' #@param
url = 'https://storage.googleapis.com/mobilenet_v2/checkpoints/' + checkpoint_name + '.tgz'
print('Downloading from ', url)
!... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Checkpoint based inference
Step2: Frozen inference
|
11,759 | <ASSISTANT_TASK:>
Python Code:
import pymrio
mrio = pymrio.load_test()
mrio.get_sectors()
mrio.get_regions()
mrio.get_Y_categories()
mrio.get_extensions()
list(mrio.get_extensions())
mrio.rename_regions({"reg1": "REGION A", "reg2": "REGION B"})
mrio.get_regions()
mrio.rename_sectors({"mining": "dwarf business"})
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: We can use several functions to get a quick overview over the MRIO system
Step2: A list of available satellite accounts can be obtained by
Step... |
11,760 | <ASSISTANT_TASK:>
Python Code:
def in_unit_circle(x, y):
if x**2 + y**2 < 1:
return 1
else:
return 0
@numba.vectorize('int64(float64, float64)',target='cpu')
def in_unit_circle_serial(x, y):
if x**2 + y**2 < 1:
return 1
else:
return 0
@numba.vectorize('int64(float64, floa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Multi-core processing
Step2: Single core
Step3: Threads
Step4: Parallel comprehensions with joblib
Step5: Blocking and non-blocking calls
|
11,761 | <ASSISTANT_TASK:>
Python Code:
# Basemap Mosaic (v1 API)
mosaicsSeries = 'global_quarterly_2017q1_mosaic'
# Planet tile server base URL (Planet Explorer Mosaics Tiles)
mosaicsTilesURL_base = 'https://tiles0.planet.com/experimental/mosaics/planet-tiles/' + mosaicsSeries + '/gmap/{z}/{x}/{y}.png'
# Planet tile server url... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Query the API
Step2: Just like before we clean up our data and distill it down to just the scenes we want.
Step3: To make sure we are good we'... |
11,762 | <ASSISTANT_TASK:>
Python Code:
#If you haven't already, make sure you install the `dfcx-scrapi` library
!pip install dfcx-scrapi
from dfcx_scrapi.core.intents import Intents
from dfcx_scrapi.tools.dataframe_functions import DataframeFunctions
creds_path = '<YOUR_CREDS_PATH_HERE>'
agent_id = '<YOUR_AGENT_ID_HERE>'
goo... | <SYSTEM_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
Step2: User Inputs
Step3: CX to Sheets
|
11,763 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# Define your function
def softmax(x):
# This is where you write your code!
vector = "This is only psudo code.\nYou will have to write this function yourself!"
return vector # Replace this with the new array
# Test it out on an array
test=[1,3,2]
print(softm... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 5
|
11,764 | <ASSISTANT_TASK:>
Python Code:
import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
G = nx.Graph() # create an empty graph
G.add_node('Luke') # add one node
G.add_nodes_from(['Leia', 'Han']) # add multiple nodes
G.add_edge('Luke', 'Leia') # add one edge
G.add_edges_from([('Luke', 'Han'), ('Leia', '... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: There are two major components in a network - nodes (or vertices) and edges connecting nodes. They are not specified as networkx objects, leavin... |
11,765 | <ASSISTANT_TASK:>
Python Code:
import pickle
import logging
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from ptm import AuthorTopicModel
from ptm.utils import convert_cnt_to_list, get_top_words
logger = logging.getLogger('AuthorTopicModel')
logger.propagate=False
%matplotlib inline
doc_ids = p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load CORA dataset
Step2: Fit author-topic model
Step3: Print top 10 words for each topic
Step4: Plot topic distribution of random author
|
11,766 | <ASSISTANT_TASK:>
Python Code:
# show plots in this notebook
%matplotlib inline
import os
# import corpkit
from corpkit import interrogator, editor, plotter, conc
# some wordlists we'll use later
from dictionaries.process_types import processes
from dictionaries.wordlists import wordlists
from dictionaries.roles 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: Let's begin.
Step5: As in our last investigation, we can define a few helper functions to collapse distinctions betwee newspapers, years and en... |
11,767 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import HTML
css_file = 'pynoddy.css'
HTML(open(css_file, "r").read())
import sys, os
import matplotlib.pyplot as plt
# adjust some settings for matplotlib
from matplotlib import rcParams
# print rcParams
rcParams['font.size'] = 15
# determine path of repository 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: Load original model
Step2: Load sample classification results
Step3: Results of the classification do not necessarily contain the same ids as ... |
11,768 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
#print(plt.style.available)
%%latex
Entropy formula
\begin{align}
H(X) = -\sum_{x}{p(x) * log_2\,{p(x)}}
\end{align}
def entropy(p_x):
h_sum = float()
for item in p_x:
h_sum += item *... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Utils functions
Step2: Entropy vs probability
Step3: What can be seen in this graph is that we get the most bits of information when our sets ... |
11,769 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2021 Google LLC
#
# 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 applicabl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introduction
Step2: Imports
Step3: User Inputs
Step4: Extract Intents and Training Phrases
Step5: View Results Sample
|
11,770 | <ASSISTANT_TASK:>
Python Code:
import pyspark
from pyspark import SparkContext
import urllib
from pyspark.mllib.regression import LabeledPoint
from numpy import array
from pyspark.mllib.tree import RandomForest, RandomForestModel
from pyspark.sql import SQLContext
from time import time
# Custom imports
import MySQLCon... | <SYSTEM_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 training data and creating the RDD
Step2: Split training data into training set and test set
Step3: Create an RDD of LabeledPoints... |
11,771 | <ASSISTANT_TASK:>
Python Code:
import networkx as nx
from networkx.algorithms import bipartite
# Initialize the city/person bipartite graph.
B = nx.Graph()
cities = ['Beijing', "Xi'an", 'Vancouver', 'San Francisco', 'Austin', 'Boston'] # populate a list of cities
people = ['Eric', 'Nan'] # populate a list of people's 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: Explore the graph by going through the following algorithms
Step2: Think about it...
|
11,772 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from prosail_functions import *
plot_config()
def hspot ( h ):
retval = []
wv = np.arange(400, 2501)
for theta_v in np.arange ( -80,80, 5):
if theta_v < 0:
raa = -180
t = -the... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A trip to RED/NIR space
Step2: Exploring the MTCI (MERIS Terrestrial Chlorophyll Index)
|
11,773 | <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 os
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
data_root = '../data... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First reload the data we generated in 1_notmnist.ipynb.
Step2: Reformat into a shape that's more adapted to the models we're going to train
Ste... |
11,774 | <ASSISTANT_TASK:>
Python Code:
# import requirements
import pandas as pd
import nltk
import gensim
import spacy
# read subset of data from csv file into panadas dataframe
df = pd.read_csv('1_100.csv')
# for now, chosing one article to illustrate preprocessing
article = df['full_text'][939]
article[:500]
article[:500... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h2>Data</h2>
Step2: Let's take a peek at the raw text of this article to see what we are dealing with!
Step3: <h2>Preprocessing Text</h2>
Ste... |
11,775 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from quantopian.pipeline.classifiers.morningstar import Sector
from quantopian.pipeline import Pipeline
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.research import run_pipeline
from qua... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Relative Value
Step2: Before performing analysis on this data, let us look at the Sector column. This is an example of a Pipeline Classifier. W... |
11,776 | <ASSISTANT_TASK:>
Python Code:
import pickle
def separate_sentences(filename):
checks = ['. ', '; ', '? ', '! ']
for sentences in open(filename, 'r'):
sentences = sentences.strip()
sep_flag = False
sep_index = 0
check_sign = ''
for i in checks:
if i in senten... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 50. 文区切り
Step2: 51. 単語の切り出し
Step3: 52. ステミング
Step4: 53. Tokenization
Step5: 54. 品詞タグ付け
Step6: 55. 固有表現抽出
Step7: 56. 共参照解析
Step8: 57. 係り受け... |
11,777 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import h5py
import scipy
from PIL import Image
from scipy import ndimage
from lr_utils import load_dataset
%matplotlib inline
# Loading the data (cat/non-cat)
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2 - Overview of the Problem set
Step2: We added "_orig" at the end of image datasets (train and test) because we are going to preprocess them. ... |
11,778 | <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('lc', times=np.linspace(0,1,101), dataset='lc01')
print(b['exptime'])
b['exptime'] = 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: As always, let's do imports and initialize a logger and a new bundle.
Step2: Relevant Parameters
Step3: Let's set the exposure time to 1 hr to... |
11,779 | <ASSISTANT_TASK:>
Python Code:
def list_primes(n):
# TODO: Implement me
pass
# %load test_list_primes.py
from nose.tools import assert_equal
class Test_list_primes(object):
def test_list_primes(self):
assert_equal(list_primes(1), [])
assert_equal(list_primes(2), [2])
assert_equal(li... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Unit Test
|
11,780 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# Load local version of yabox
import sys
sys.path.insert(0, '../')
from yabox import DE, PDE
import numpy as np
# Imports required for 3d animations
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Main functions for plotting and generating the animations
Step2: Usage example
|
11,781 | <ASSISTANT_TASK:>
Python Code:
# importamos la libreria
import tensorflow as tf
# importamos librerías adicionales
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import pandas as pd
%matplotlib inline
# Creación de Constantes
# El valor que retorna el constructor es el valor de la consta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Constantes
Step2: Sesiones
Step3: Las Sesiones deben ser cerradas para liberar los recursos, por lo que es una buena práctica incluir la Sesió... |
11,782 | <ASSISTANT_TASK:>
Python Code:
import agate
lunches2013 = agate.Table.from_csv('frl13.csv')
cleanLunches2013 = lunches2013.where(lambda row: row['FREEREDUCED13'] is not None)
print(cleanLunches2013)
print(len(cleanLunches2013.rows))
lunches2014 = agate.Table.from_csv('frl14.csv')
cleanLunches2014 = lunches2014.where(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pull in the 2013 lunch information csv, clean out any empty values, print table columns and lengths
Step2: Pull in the 2014 lunch information c... |
11,783 | <ASSISTANT_TASK:>
Python Code:
from sklearn.linear_model import RidgeCV
from sklearn.model_selection import train_test_split
from sklearn.externals import joblib
import numpy as np
import matplotlib.pyplot as plt
import os
data = np.loadtxt(fname = 'data.txt', delimiter = ',')
X, y = data[:,:5], data[:,5]
print("Featur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ridge as Linear Regressor
|
11,784 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import statsmodels.api as sm
spector_data = sm.datasets.spector.load()
spector_data.exog = sm.add_constant(spector_data.exog, prepend=False)
print(spector_data.exog.head())
print(spector_data.endog.head())
lpm_mod = sm.OLS(spector_data.endog, spector_data.exog)
lpm_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: Data
Step2: Inspect the data
Step3: Linear Probability Model (OLS)
Step4: Logit Model
Step5: Marginal Effects
Step6: As in all the discrete... |
11,785 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'uhh', 'sandbox-1', 'landice')
# 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: 1... |
11,786 | <ASSISTANT_TASK:>
Python Code:
from threeML import *
import matplotlib.pyplot as plt
%matplotlib inline
from threeML.minimizer.tutorial_material import *
# This returns a JointLikelihood object with a simple likelihood function,
# and the corresponding Model instance. These objects are what you will have
# in a typica... | <SYSTEM_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 get a JointLikelihood object like the one we would have in a normal 3ML analysis. We use a custom function, prepared for this tutorial, wh... |
11,787 | <ASSISTANT_TASK:>
Python Code:
import os
PROJECT = 'your-project-id' # REPLACE WITH YOUR PROJECT ID
REGION = 'us-central1' # REPLACE WITH YOUR REGION e.g. us-central1
# do not change these
os.environ['PROJECT'] = PROJECT
os.environ['REGION'] = REGION
%%bash
## create GCS buckets
exists=$(gsutil ls -d | grep -w gs://${... | <SYSTEM_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 Cloud Storage buckets
Step4: Create BigQuery Destination Dataset and Table
Step5: Viewing environment information
Step6: Option 1
Step... |
11,788 | <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 *
# set the ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: One queue or two?
Step2: Test this function by creating a System object with lam=1/8 and mu=1/5.
Step3: Write an update function that takes as... |
11,789 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
import scipy.signal
from IPython.display import Image
import matplotlib.image as mpimg
# This section uses the optional slimscat package ... | <SYSTEM_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 section specific modules
Step2: 7.7 Propagation effects <a id='instrum
Step3: Figure 7.7.1
Step4: Figure 7.7.2
Step5: Figure 7.7.3
St... |
11,790 | <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: Training and evaluation with the built-in methods
Step2: Introduction
Step3: Here's what the typical end-to-end workflow looks like, consistin... |
11,791 | <ASSISTANT_TASK:>
Python Code:
from scipy.fftpack import fft, fftshift
import numpy as np
from math import gcd, ceil, floor
import sys
sys.path.append('../software/models/')
from dftModel import dftAnal, dftSynth
from scipy.signal import get_window
import matplotlib.pyplot as plt
# E3 - 1.1: Complete the function minim... | <SYSTEM_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 3
Step2: Test cases for minimize_energy_spread_dft()
Step4: Part 2 - Symmetry properties of the DFT
Step5: Test cases for test_real_... |
11,792 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
from sklearn.decomposition import PCA, KernelPCA
from sklearn.datasets import make_circles
# Create linearly inseparable data
X, _ = make_circles(n_samples=1000, random_state=1, noise=0.1, factor=0.1)
# Apply kernal PCA with radius basis function (RBF) kernel
kpca = Ker... | <SYSTEM_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 Linearly Inseparable Data
Step2: Conduct Kernel PCA
Step3: View Results
|
11,793 | <ASSISTANT_TASK:>
Python Code:
import array
import binascii
s= b'this is a array'
a = array.array('b', s)
print('As byte string', s)
print('As array ', a)
print('As hex', binascii.hexlify(a))
import array
import pprint
a = array.array('i', range(3))
print('initialize\n', a)
a.extend(range(3))
print('Extend\n',a)
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: Manuipulating Arrays
Step2: Arrays and Files
Step3: Alternative Byte Ordering
|
11,794 | <ASSISTANT_TASK:>
Python Code:
from sklearn.metrics import normalized_mutual_info_score
import matplotlib.pyplot as plt
from scipy.cluster.hierarchy import dendrogram, linkage, fcluster
from sklearn.datasets.samples_generator import make_blobs
import numpy as np
X, y = make_blobs(n_samples=90, centers=4, n_features=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: Generating Sample data
Step2: Performing Hierarchical clustering
Step3: Plotting dendrogram
Step4: Retrive the clusters
Step5: Plotting Clus... |
11,795 | <ASSISTANT_TASK:>
Python Code:
arthur = "king"
lancelot = -23
robin = 1.99
bedevere = True
arthur = "king"
type(arthur)
lancelot = -23
type(lancelot)
robin = 1.99
type(robin)
bedevere = True
type(bedevere)
galahad = 1
galahad = 57
galahad
patsy = 2
patsy = "Clip clop"
type(patsy)
zoot = float(5)
zoot = 5.0
zoot
typ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How does Python know the data type?
Step2: Reassigning Variables
Step3: Variables can also change types after initial assignment
Step4: Value... |
11,796 | <ASSISTANT_TASK:>
Python Code:
import re
import pandas as pd
import urllib.request
frequency = {}
document_text = urllib.request.urlopen \
('http://www.textfiles.com/etext/FICTION/bronte-jane-178.txt') \
.read().decode('utf-8')
text_string = document_text.lower()
match_pattern = re.findall(r'\b[a-z]{3,15}\b', 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: Word frequency list
Step2: Filtering the results
|
11,797 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy
x = numpy.linspace(0, 1)
y1 = numpy.sin(numpy.pi * x) + 0.1 * numpy.random.rand(50)
y2 = numpy.cos(3.0 * numpy.pi * x) + 0.2 * numpy.random.rand(50)
from matplotlib import pyplot
pyplot.plot(x, y1)
pyplot.show()
pyplot.plot(x, y1)
pyplot.xlabel('x')
pypl... | <SYSTEM_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 above command is only needed if you are plotting in a Jupyter notebook.
Step2: And then produce a line plot
Step3: We can add labels and t... |
11,798 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv("./2017-german-election-overall.csv")
type(df)
df
df.info()
df.describe()
df.copy()
df.shape
list(df.columns)
df.rename(columns = {'registered.voters':'registered_voters', 'area_names':'area'}, inplace = True)
df
df.drop(['invalid_second_votes', ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Leggere un file csv con Pandas
Step2: Ottenere informazioni sul data frame
Step3: Ottenere la copia di un data frame
Step4: Variabili shape e... |
11,799 | <ASSISTANT_TASK:>
Python Code:
import arcpy as ARCPY
import arcgisscripting as ARC
import SSDataObject as SSDO
import SSUtilities as UTILS
import WeightsUtilities as WU
import numpy as NUM
import scipy as SCIPY
import pysal as PYSAL
import os as OS
import pandas as PANDAS
inputFC = r'../data/CA_Polygons.shp'
fullFC = ... | <SYSTEM_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: Use the PySAL-ArcGIS Utilities to Read in Spatial Weights Files
Step3: Run the Auto Model Class and Export Your Data to an Outp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.