Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
3,600 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
import random
%matplotlib inline
import matplotlib.pyplot as plt
n_features = 2
def get_data():
data_a = np.random.rand(10, n_features) + 1
data_b = np.random.rand(10, n_features)
plt.scatter(data_a[:, 0], data_a[:, 1], c='r', 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: Let's fabricate some data. We'll call get_data() to generate two datasets
Step2: Now, let's define our ranking model. It'll take in two items (... |
3,601 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import theano
theano.config.floatX = 'float64'
import matplotlib.pyplot as plt
import numpy as np
import pymc3 as pm
import pandas as pd
data = pd.read_csv('../data/radon.csv')
county_names = data.county.unique()
county_idx = data['county_code'].values
n_counties = len... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here, 'log_radon_t' is a dependent variable, while 'floor_t' and 'county_idx_t' determine independent variable.
Step2: Random variable 'radon_l... |
3,602 | <ASSISTANT_TASK:>
Python Code:
#the seed information
df_seeds = pd.read_csv('../input/WNCAATourneySeeds_SampleTourney2018.csv')
#tour information
df_tour = pd.read_csv('../input/WRegularSeasonCompactResults_PrelimData2018.csv')
df_seeds['seed_int'] = df_seeds['Seed'].apply( lambda x : int(x[1:3]) )
df_winseeds = df_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: Now we separate the winners from the losers and organize our dataset
Step2: Now we match the detailed results to the merge dataset above
Step3:... |
3,603 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy import optimize, special
from matplotlib import pyplot as plt
from astropy.io import fits
%matplotlib inline
# open the data file and load data into a list of points
infile = open("./samplevals_PA.txt", 'r')
v_arr = [ ]
for line in iter(infile):
line =... | <SYSTEM_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> Problem 1
Step7: To estimate the values of $(\alpha,\beta)$, we maximize the posterior function $p(\alpha,\beta\mid{D})$ with respect to $... |
3,604 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bnu', 'sandbox-1', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "emai... | <SYSTEM_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... |
3,605 | <ASSISTANT_TASK:>
Python Code:
import random as rnd
import math
def approximate_pi(n):
k = 0
for _ in range(n):
x = 2 * rnd.random() - 1
y = 2 * rnd.random() - 1
r = x * x + y * y
if r <= 1:
k += 1
return 4 * k / n
def std_and_mean(L):
N = len(L)
mean... | <SYSTEM_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 unit circle $U$ is defined as the set
Step2: Given a list $L = [x_1, \cdots, x_n]$, the function $\texttt{std_and_mean}(L)$ computes the p... |
3,606 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_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 and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
3,607 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import time
%pylab inline
gtd=pd.read_excel("data/gtd_12to15_0616dist.xlsx")
headers = pd.read_excel("data/GDELT Metadata.xlsx").columns.values
gdelt = pd.read_csv("data/20150108.export.txt", delimiter="\t", names=headers, parse_dates=["Day"])
gtd = gtd.dropna(subset... | <SYSTEM_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: Cleaning
Step3: Common Years
Step4: The years in GDLET are distributed strangly
Step5: Filter for 2015
Step6: Rule-Based Matchi... |
3,608 | <ASSISTANT_TASK:>
Python Code:
import torch
import numpy
import inspect # this should raise the "we'll do gross things Python internals flag"
# Based on the the original implementation from PyTorch
# So portions copyright by the PyTorch contributors, in particular Simon Wang worked on it a lot.
# Errors probably are ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Spectral normalization and the PyTorch implementation
Step2: But how to apply this to our weight?
Step3: Unsurprisingly, as we don't subclass ... |
3,609 | <ASSISTANT_TASK:>
Python Code:
X = np.array([[-1.0, -1.0], [-1.2, -1.4], [1, -0.5], [-3.4, -2.2], [1.1, 1.2], [-2.1, -0.2]])
y = np.array([1, 1, 1, 2, 2, 2])
x_new = [0, 0]
plt.scatter(X[y==1,0], X[y==1,1], s=100, c='r')
plt.scatter(X[y==2,0], X[y==2,1], s=100, c='b')
plt.scatter(x_new[0], x_new[1], s=100, c='g')
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: 다수결 모형이 개별 모형보다 더 나은 성능을 보이는 이유는 다음 실험에서도 확인 할 수 있다.
Step2: 배깅
Step3: 랜덤 포레스트
Step4: 랜덤 포레스트의 장점 중 하나는 각 독립 변수의 중요도(feature importance)를 계산할 ... |
3,610 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
%pylab inline
import matplotlib.pylab as plt
import numpy as np
from distutils.version import StrictVersion
import sklearn
print(sklearn.__version__)
assert StrictVersion(sklearn.__version__ ) >= StrictVersion('0.18.1')
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Originalen Datensatz laden
Step2: Wir erkunden Keras' ImageDataGenerator
Step3: Hands-On
|
3,611 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import pymc3 as pm
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
warnings.filterwarnings("ignore", category=FutureWarning)
from IPython.display import Image
from matplotlib import gridspec
%matplotlib inline
plt.style.use('sea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 9.2.4 - Example
Step2: Figure 9.9
Step3: Model (Kruschke, 2015)
Step4: Figure 9.10 - Marginal posterior distributions
Step5: Shrinkage
Step6... |
3,612 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_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 and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
3,613 | <ASSISTANT_TASK:>
Python Code:
# Downloading data - you get this for free :-)
import requests
import os
def download_book(url):
Download book given a url to a book in .txt format and return it as a string.
text_request = requests.get(url)
text = text_request.text
return text
book_urls = dict(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Assignment 3b
Step2: Encoding issues with txt files
Step3: 2.b) Store the function in the Python module utils.py. Import it in analyze.py.
St... |
3,614 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
# we can import the CSV data as a numpy rec array
from matplotlib.pylab import csv2rec
trends = csv2rec('trends.csv')
plot(trends.week_start, trends.spring_break, label='spring break')
plot(trends.week_start, trends.textbooks, label='texbooks')
plot(trends.week_start, trend... | <SYSTEM_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. Use the "trends.csv" file and csv2rec() to import the data and reproduce this plot
Step2: 2. Determine in which week of each year (for all f... |
3,615 | <ASSISTANT_TASK:>
Python Code:
model simple()
S1 -> S2; k1*S1
k1 = 0.1
S1 = 10
end
simple.simulate(0, 50, 100)
simple.plot()
model advanced()
# Create two compartments
compartment compA=1, compB=0.5 # B is half the volume of A
species A in compA, B in compB
# Use the label `J0` for the reaction
J0: A -... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a id="ex2"></a>
Step2: <a id="ex3"></a>
|
3,616 | <ASSISTANT_TASK:>
Python Code:
cc1 = block.FECCyclic('1011')
# Generate 16 distinct codewords
codewords = zeros((16,7),dtype=int)
x = zeros((16,4))
for i in range(0,16):
xbin = block.binary(i,4)
xbin = array(list(xbin)).astype(int)
x[i,:] = xbin
x = reshape(x,size(x)).astype(int)
codewords = cc1.cyclic_en... | <SYSTEM_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 the cyclic code object cc1 is created, the cc1.cyclic_encoder method can be used to encode source data bits. In the following example, we ... |
3,617 | <ASSISTANT_TASK:>
Python Code:
#!conda install -y numpy pandas matplotlib seaborn statsmodels
%matplotlib inline
import seaborn as sns
import pandas as pd
sns.set(style="ticks")
df = sns.load_dataset("anscombe")
type(df)
df.head()
df[df.dataset == 'I']
groups = ['I', 'II', 'III', 'IV']
for group in groups:
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: Load the Anscombe's quartet dataset
Step2: And df is... a pandas dataframe
Step3: that we can print, plot, ...
Step4: Print just first datase... |
3,618 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Eric Larson <larson.eric.d@gmail.com>
# Denis Engemannn <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
from numpy.random import randn
import matplotlib.pyplot as... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: Read epochs for all channels, removing a bad one
Step3: Transform to source space
Step4: Transform to common cortical s... |
3,619 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
# use seaborn plotting defaults
import seaborn as sns; sns.set()
from sklearn.datasets.samples_generator import make_blobs
X, y = make_blobs(n_samples=50, centers=2,
random_sta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Motivating Support Vector Machines
Step2: A linear discriminative classifier would attempt to draw a straight line separating the two sets of d... |
3,620 | <ASSISTANT_TASK:>
Python Code:
import ROOT
treename = "Events"
filename = "root://eospublic.cern.ch//eos/opendata/cms/derived-data/AOD2NanoAODOutreachTool/Run2012BC_DoubleMuParked_Muons.root"
df = ROOT.RDataFrame(treename, filename)
# Take only the first 1M events
df_range = # do something here
# Change the first... | <SYSTEM_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 ROOT dataframe in Python
Step2: Run only on a part of the dataset
Step3: Filter relevant events for this analysis
Step4: Perform com... |
3,621 | <ASSISTANT_TASK:>
Python Code:
import urllib.request
fuel_pin_url = 'https://tinyurl.com/y3ugwz6w' # 1.2 MB
teapot_url = 'https://tinyurl.com/y4mcmc3u' # 29 MB
def download(url):
Helper function for retrieving dagmc models
u = urllib.request.urlopen(url)
if u.status != 200:
raise Runt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using CAD-Based Geometries
Step2: This notebook is intended to demonstrate how DagMC problems are run in OpenMC. For more information on how Da... |
3,622 | <ASSISTANT_TASK:>
Python Code:
# Author: Tommy Clausner <tommy.clausner@gmail.com>
#
# License: BSD (3-clause)
import os
import matplotlib.pyplot as plt
import nibabel as nib
import mne
from mne.datasets import sample
from mne.minimum_norm import apply_inverse, read_inverse_operator
from nilearn.plotting import plot_gl... | <SYSTEM_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 paths
Step2: Compute example data. For reference see
Step3: Get a SourceMorph object for VolSourceEstimate
Step4: Apply morph to VolSou... |
3,623 | <ASSISTANT_TASK:>
Python Code:
# built-in package
import os
import sys
import json
import time
import datetime as dt
# third-parth package
import dashboard as dash
import pandas as pd
import matplotlib as plt
import seaborn
import mpld3
# package configre
pd.options.display.max_columns = 100
pd.options.display.max_rows... | <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: 2. Load data
Step3: 3. Traditionaly way of plotting [ I really like ipython indeed, but ... ]
Step4: 4. Not enough even arm matplotlib with se... |
3,624 | <ASSISTANT_TASK:>
Python Code:
# Importing the libraries which we need now.
import pandas
from pandas.plotting import scatter_matrix
import matplotlib.pyplot as plt
%matplotlib inline
# Dataset from - https://archive.ics.uci.edu/ml/datasets/Nursery
df = pandas.read_table('nursery.txt', sep=',', header=None, names=['par... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Summarizing the Dataset
Step2: The above displayed result shows that the dataframe has 12960 rows and 9 colums. It means that we have 9 feature... |
3,625 | <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
Step3: Transforming Text into Numbers
Step4: Project 2
Step5: Project 3
Step6: Understanding Neural Noise
Step7: P... |
3,626 | <ASSISTANT_TASK:>
Python Code:
window = {
'since' : "2018-01-01T00:00:00",
'until' : "2018-01-10T00:00:00"
}
dt = DataTracker()
def extract_data(doc):
data = {}
## TODO: Add document UID?
data['title'] = doc.title
data['time'] = doc.time
data['group-acronym'] = dt.group(doc.group).acronym
... | <SYSTEM_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 table for the group and affiliation links in particular.
Step2: Entity resolution on the affiliations
Step3: Plot the network links b... |
3,627 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from mpl_toolkits.axes_grid1 import make_axes_locatable
from pandas import set_option
set_option("display.max_rows", 10)
pd.options.mode.ch... | <SYSTEM_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 data is from the Council Grove gas reservoir in Southwest Kansas. The Panoma Council Grove Field is predominantly a carbonate gas reservoi... |
3,628 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
from ipywidgets import interact
import matplotlib.pyplot as plt, mpld3
import seaborn as sns
mpld3.enable_notebook()
mean, cov = [0, 1], [(1, .5), (.5, 1)]
data = np.random.multivariate_normal(mean, cov, 200)
df = pd.DataFrame(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: d3.js via mpld3
|
3,629 | <ASSISTANT_TASK:>
Python Code:
#general imports
import matplotlib.pyplot as plt
import pygslib
from matplotlib.patches import Ellipse
import numpy as np
import pandas as pd
#make the plots inline
%matplotlib inline
#get the data in gslib format into a pandas Dataframe
mydata= pygslib.gslib.read_gslib_file('..... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting the data ready for work
Step2: The nscore transformation table function
Step3: Get the transformation table
Step4: Get the normal sco... |
3,630 | <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
pass
HTML('../style/code_toggle.html')
<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: Import section specific modules
|
3,631 | <ASSISTANT_TASK:>
Python Code:
# based on http://matplotlib.org/examples/api/barchart_demo.html
# Make some fake data
d = {'gender': np.hstack([np.ones(10), np.zeros(10)]), 'scores': np.hstack([np.random.rand(10), np.random.rand(10)+1])}
df = pd.DataFrame(d)
# Change this part and replace with the variables you 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: Bar graphs with standard error bars for 2 group
Step2: Scatterplots of 1 group with jittered location
Step3: Here is the fix.
Step4: Drawing ... |
3,632 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
data = pd.read_csv('data.csv')
data
data['T']
data[T]
T = 'T'
#alias v hodnota
3 = 'T'
300
x = 1 # zde vznikne místo v paměti, do které se uloží číslo 1 a proměnná x ukazuje na to místo
x = x + 1 # zde se vezme obsah proměnné x (číslo 1) a provede 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: Pokud vzpomínáte, tak ke sloupci T jsme přistupovali takto
Step2: Proč jsme nemohli jednoduše vykonat následující?
Step3: Alias v hodnota
Step... |
3,633 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-hh', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "emai... | <SYSTEM_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... |
3,634 | <ASSISTANT_TASK:>
Python Code:
data_in_shape = (3, 5, 2)
L = ZeroPadding2D(padding=(1, 1), data_format='channels_last')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(250)
data_in = 2 * np.ran... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: [convolutional.ZeroPadding2D.1] padding (1,1) on 3x5x2 input, data_format='channels_first'
Step2: [convolutional.ZeroPadding2D.2] padding (3,2)... |
3,635 | <ASSISTANT_TASK:>
Python Code:
import dask.dataframe as ddf
columns = {
'sceneID': str,
'sensor': str,
'path': int,
'row': int,
'acquisitionDate': str,
'cloudCover': float,
'cloudCoverFull': float,
'sunElevation': float,
'sunAzimuth': float,
'DATA_TYPE_L1': str,
'GEOMETRIC_RM... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question
Step2: Question
Step3: Question
Step4: Looks like there is a labeling issue due to a capitalization difference in L1GT versus L1Gt. ... |
3,636 | <ASSISTANT_TASK:>
Python Code:
import sys, platform, subprocess
ansibleVersion = subprocess.check_output(['ansible', '--version']).decode('utf-8').split()[1]
print( f" Python: {' '.join(sys.version.split()[0:4])}\n" # Not the version of Pythone used by Ansible.
f' macOS: {platform.mac_ver()[0]}\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: View of the network, private, from /etc/hosts
Step2: Review of control machine's Ansible configuration
Step3: Note use of group "aur" to provi... |
3,637 | <ASSISTANT_TASK:>
Python Code:
query_url = 'https://data.sfgov.org/resource/wbb6-uh78.json?$order=close_dttm%20DESC&$offset={}&$limit={}'
offset = 0
limit = 1000000
df = pd.read_json(query_url.format(offset, limit))
cols_to_drop = ["automatic_extinguishing_sytem_failure_reason",
"automatic_extinguishing... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: According to wikipeda, the mission district falls into two zipcodes, 94103, 94110
Step2: Initial Conclusions
Step3: Disclaimers from the Fire ... |
3,638 | <ASSISTANT_TASK:>
Python Code:
from functools import partial
def convert(s):
converters = (int, float)
for converter in converters:
try:
value = converter(s)
except ValueError:
pass
else:
return value
return s
def process_input(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: Below is a typical loop for
Step2: It works as shown below.
Step3: Below is a different way of writing that loop.
Step4: It can be reduced to... |
3,639 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import sympy as sp
# comment out if you don't want plots rendered in notebook
%matplotlib inline
from quantecon import ivp
ivp.IVP?
def lotka_volterra_system(t, y, a, b, c, d):
Return the Lotka-Voltera system.
Parameters
... | <SYSTEM_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. Introduction
Step2: 2.1 Lotka-Volterra "Predator-Prey" model
Step5: From the docstring we see that we are required to define a function des... |
3,640 | <ASSISTANT_TASK:>
Python Code:
%run make_topo.py
%run make_data.py
!slosh
#!mpirun -n 4 slosh
%run make_plots.py
%pylab inline
import glob
from matplotlib import image
from clawpack.visclaw.JSAnimation import IPython_display
from matplotlib import animation
def init():
im.set_data(image.imread(filenames[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: Run code in serial mode (will work, even if code is compiled with MPI)
Step2: Or, run code in parallel mode (command may need to be customized,... |
3,641 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import time
from tqdm import tqdm
import gc
print('loading prior')
priors = pd.read_csv('./data/order_products__prior.csv')
print('loading train')
train_all = pd.read_csv('./data/order_products__train.csv')
## Have split the trian data into two set... | <SYSTEM_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 Products
Step2: 2. Prepare data
Step3: Join with orders table to get the user id
Step4: Make a data frame of user and previous product l... |
3,642 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
# If you have a GPU, execute the following lines to restrict the amount of VRAM used:
gpus = tf.config.experimental.list_physical_devices('GPU')
if len(gpus) > 1:
print("Using GPU {}".format(gpus[0]))
tf.config.experimental.set_visible_devices(gpus[0], 'GPU... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Processing the dataset
Step2: In each directory, there is one or more images corresponding to the identity. We map each image path with an inte... |
3,643 | <ASSISTANT_TASK:>
Python Code:
import pandas
import igraph
edge_list = pandas.read_csv('hsmetnet.txt', sep='\t', header=None).values.tolist()
graph = igraph.Graph.TupleList(edge_list, directed=True)
igraph.summary(graph)
flatten = lambda l: sum(l, [])
vertex_set = set(flatten(edge_list))
isreaction = lambda vertex: ve... | <SYSTEM_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 many distinct metabolites are there in the graph?
Step2: How many reactions?
Step3: How many edges are there?
Step4: Calculate the degree... |
3,644 | <ASSISTANT_TASK:>
Python Code:
km.random_init(data2, 3)
init_centroids = km.random_init(data2, 3)
init_centroids
x = np.array([1, 1])
fig, ax = plt.subplots(figsize=(6,4))
ax.scatter(x=init_centroids[:, 0], y=init_centroids[:, 1])
for i, node in enumerate(init_centroids):
ax.annotate('{}: ({},{})'.format(i, node[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: 1. cluster assignment
Step2: 1 epoch cluster assigning
Step3: See the first round clustering result
Step4: 2. calculate new centroid
Step5: ... |
3,645 | <ASSISTANT_TASK:>
Python Code:
# imports
from desispec.qa import qa_exposure as qa_exp
from desispec.io import qa as desio_qa
reload(qa_exp)
qaframe = qa_exp.QA_Frame(flavor='arc')
print(qaframe)
reload(qa_exp)
qaframe = qa_exp.QA_Frame(flavor='science')
qaframe.init_skysub()
print(qaframe.data)
from desispec.io 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: Instantiate
Step2: Init SkySub
Step3: I/O
Step4: Test FiberFlat QA
|
3,646 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
from __future__ import absolute_import, division, print_function
import time
import numpy as np
import matplotlib.pyplot as plt
from cs231n.classifiers.fc_net import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check import eval_numerica... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dropout
Step2: Dropout forward pass
Step3: Dropout backward pass
Step4: Fully-connected nets with Dropout
Step5: Regularization experiment
|
3,647 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import pandas as pd
import sys
sys.path.insert(0, '../')
from paleopy import proxy
from paleopy import analogs
from paleopy import ensemble
djsons = '../jsons/'
pjsons = '../jsons/proxies'
p = proxy(sitename='Rarotonga', \
... | <SYSTEM_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 the development version of paleopy
Step2: instantiates a proxy with the required parameters
Step3: find the analogs
Step4: print the u... |
3,648 | <ASSISTANT_TASK:>
Python Code:
#Begin spark session
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
#Create pysplice context. Allows you to create a Spark dataframe using our Native Spark DataSource
from splicemachine.spark import PySpliceContext
splice = PySpliceContext(spark)
#Initia... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Deploy Machine Learning model as a table in the database
Step2: Create the deployment table
Step3: Insert data into this empty table using the... |
3,649 | <ASSISTANT_TASK:>
Python Code:
import DSGRN
br=DSGRN.Network("br.txt")
print(br)
import graphviz
print(br.graphviz())
graph=graphviz.Source(br.graphviz())
graph
br_pg=DSGRN.ParameterGraph(br)
print(br_pg.size())
br_64 = br_pg.parameter(64)
print(br_64.inequalities())
br_dg_64=DSGRN.DomainGraph(br_64)
graphviz... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Network
Step2: We would like to see the network in the way that it is specified in the file br.txt
Step3: Graphviz
Step4: DSGRN created an ob... |
3,650 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import math
import openmc
fuel = openmc.Material(name="uo2")
fuel.add_element("U", 1, percent_type="ao", enrichment=4.25)
fuel.add_element("O", 2)
fuel.set_density("g/cc", 10.4)
clad = openmc.Material(name="clad")
clad.add_element("Zr", 1)
clad.set_density("g/cc", 6)
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: Build the Geometry
Step2: Here, we are going to use the openmc.model.pin function to build our pin cell. The pin function anticipates concentri... |
3,651 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
!head -n 30 open_exoplanet_catalogue.txt
data = np.genfromtxt('open_exoplanet_catalogue.txt' , delimiter = ",")
assert data.shape==(1993,24)
mass = data[:2]
assert True # leave for grading
# YOUR CODE HERE
raise Not... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exoplanet properties
Step2: Use np.genfromtxt with a delimiter of ',' to read the data into a NumPy array called data
Step3: Make a histogram ... |
3,652 | <ASSISTANT_TASK:>
Python Code:
import sys
try:
import docplex.mp
except:
raise Exception('Please install docplex. See https://pypi.org/project/docplex/')
products = [("kluski", 100, 0.6, 0.8),
("capellini", 200, 0.8, 0.9),
("fettucine", 300, 0.3, 0.4)]
# resources are a list of simple 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: Step 2
Step2: Step 3
Step3: Define the decision variables
Step4: Express the business constraints
Step5: Express the objective
Step6: Solve... |
3,653 | <ASSISTANT_TASK:>
Python Code:
!type Examples\c-grammar.g
!cat Examples/arith.g
!cat Pure.g4
!cat -n Grammar.g4
!antlr4 -Dlanguage=Python3 Grammar.g4
from GrammarLexer import GrammarLexer
from GrammarParser import GrammarParser
import antlr4
class GrammarRule:
def __init__(self, variable, body):
self.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 use <span style="font-variant
Step2: The annotated grammar is stored in the file Grammar.g4.
Step3: We start by generating both scanner and... |
3,654 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
N = 50
sig_x = 0.5
sig_y = 0.5
a_true = 5.0
b_true = 2.0
x_true = np.random.uniform(0,10,size=N)
y_true = a_true + x_true*b_true
x_obs = x_true + np.random.normal(0, sig_x, size=N)
y_obs = y_true + np.random.normal(0, sig_y, size=N)
fig,a... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Looks reasonable, I hope. We want to find the best-fit line to the data. It should be close to the orange line (the truth), but not equal, since... |
3,655 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from statsmodels.compat import lzip
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
from statsmodels.formula.api import ols
plt.rc("figure", figsize=(16,8))
plt.rc("font", size=14)
prestige = sm.datasets.get_rdataset("Duncan", "carData",... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Duncan's Prestige Dataset
Step2: Influence plots
Step3: As you can see there are a few worrisome observations. Both contractor and reporter ha... |
3,656 | <ASSISTANT_TASK:>
Python Code:
text = "yeah, but no, but yeah, but no, but yeah"
# Exact match
text == "yeah"
# Match at start or end
text.startswith("yeah")
text.endswith("yeah")
text.endswith("no")
text.find("no")
text1 = "11/27/2012"
text2 = "Nov 27, 2012"
import re
# Simple matching: \d+ means match one or more di... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 对于复杂的匹配需要使用正则表达式和 re 模块。 为了解释正则表达式的基本原理,假设你想匹配数字格式的日期字符串比如 11/27/2012 ,你可以这样做:
Step2: 如果你想使用同一个模式去做多次匹配,你应该先将模式字符串预编译为模式对象。比如:
Step3: match() ... |
3,657 | <ASSISTANT_TASK:>
Python Code:
import os
resFile = os.path.join(
os.environ["SERPENT_TOOLS_DATA"],
"InnerAssembly_res.m")
import numpy as np
import serpentTools
from serpentTools.settings import rc
rc['serpentVersion'] = '2.1.30'
res = serpentTools.read(resFile)
print(res.metadata['version']) # Serpent versi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Results Reader
Step2: Metadata
Step3: Results Data
Step4: Values are presented in similar fashion as if they were read in to Matlab, with one... |
3,658 | <ASSISTANT_TASK:>
Python Code:
from imitation.algorithms import preference_comparisons
from imitation.rewards.reward_nets import BasicRewardNet
from imitation.util.networks import RunningNorm
from imitation.policies.base import FeedForward32Policy, NormalizeFeaturesExtractor
import seals
import gym
from stable_baseline... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then we can start training the reward model. Note that we need to specify the total timesteps that the agent should be trained and how many frag... |
3,659 | <ASSISTANT_TASK:>
Python Code:
%%bash
curl -v -s --head https://demo.loris.ca/main.php 2>&1 |grep '[<>]'
%%bash
curl -k -i -s \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=demo&password=demo&login=Click+to+enter' \
https://demo.loris.ca/main.php
%%bash
curl -s https://demo.loris.ca/api/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: With a html parser user agent (browser)
Step2: LORIS API ressources (endpoints)
Step3: Great, we have a token... now what?
|
3,660 | <ASSISTANT_TASK:>
Python Code:
### Your code implementation goes here.
### Feel free to use as many code cells as needed.
### Your code implementation goes here.
### Feel free to use as many code cells as needed.
### Your code implementation goes here.
### Feel free to use as many code cells as needed.
### Your code... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question 1
Step2: Question 4
Step3: Question 7
Step4: Question 10
|
3,661 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image('diagrams/skip-gram.png')
from keras.preprocessing.sequence import skipgrams
from keras.preprocessing.text import Tokenizer, text_to_word_sequence
text1 = "I love deep learning."
text2 = "Read Douglas Adams as much as possible."
tokenizer = Tok... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: skip-gram
Step2: ```python
Step3: Note word id's are numbered from 1, not zero
Step4: Model parameters
Step5: Model build
Step6: Create a d... |
3,662 | <ASSISTANT_TASK:>
Python Code:
from astropy.io import ascii
data = ascii.read('./XTE_J1550_564_30191011500A_2_13kev_001s_0_2505s.txt')
time = data['col1']
rate = data['col2']
dt = time[1] - time[0]
from hhtpywrapper.eemd import EEMD
eemd_post_processing = EEMD(rate, 6.0, 100, num_imf=10, seed_no=4, post_processing=Tru... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Running EEMD of the QPO signal and checking the orthogonality of the IMF components
Step2: Reproducing Figure 2 in Su et al. 2015
Step3: Hilbe... |
3,663 | <ASSISTANT_TASK:>
Python Code:
!polyglot --help
!polyglot --lang en tokenize --input testdata/cricket.txt | head -n 3
!polyglot tokenize --input testdata/cricket.txt | head -n 3
!polyglot count --help
!polyglot count --input testdata/cricket.txt --min-count 2
!polyglot --log debug --workers 5 count --input testdat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Notice that most of the operations are language specific.
Step2: In case the user did not supply the the language code, polyglot will peek ahea... |
3,664 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
from sympy import init_printing
from sympy import S
from sympy import sin, cos, tanh, exp, pi, sqrt
from boutdata.mms import x, y, z, t
from boutdata.mms import Delp2, DDX, DDY, DDZ
import os, sys
# If we add to sys.path, then it must be an absolute path
common_dir = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initialize
Step2: Define the variables
Step3: Define manifactured solutions
Step4: Calculate the solution
Step5: Plot
Step6: Print the vari... |
3,665 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import scipy as scipy
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import rc
# set to use tex, but make sure it is sans-serif fonts only
rc('text', usetex=True)
rc('text.latex', preamble=r'\usepackage... | <SYSTEM_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 Synthetic Data
Step3: From these results, we can already draw a number of tentative observations. Namely, the mutant data has a diff... |
3,666 | <ASSISTANT_TASK:>
Python Code:
#!pip install -qq blackjax
!pip install -qq git+https://github.com/blackjax-devs/blackjax
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
from jax.scipy.stats import multivariate_normal
jax.config.update("jax_platform_name", "cpu")
try:
from blackjax.hmc import kern... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Target distribution
Step2: Tempered distribution
Step3: HMC
Step4: NUTS
Step6: SMC
Step7: SMC modified
Step8: If necessary, we can grow th... |
3,667 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-2', 'ocnbgchem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contribut... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
3,668 | <ASSISTANT_TASK:>
Python Code:
print("Calculation: %.3e"%(k_b * m_star/ (pi * hbar**2)))
print("Hard-Coded: %.3e"%nu0)
n_e = 3e15
E_f = E_fermi(n_e)
print('Fermi energy is: %.3f'%E_f)
eps = np.linspace(0, 500, 10000)
dens = np.ones(len(eps))
plt.plot (eps, dens)
plt.xlabel (r'$\epsilon$ (K)')
plt.ylabel (r'Reduced De... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Zero field calculations
Step2: For now, let's choose $\epsilon \,$ to span from 0 to 500, with 10000 points. Later, we can be more clever in or... |
3,669 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%pdb off
# set DISPLAY = True when running tutorial
DISPLAY = False
# set PARALLELIZE to true if you want to use ipyparallel
PARALLELIZE = False
import warnings
warnings.filterwarnings('ignore')
import deepchem as dc
from deepchem.utils import download_u... | <SYSTEM_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 see what dataset looks like
Step2: One of the missions of deepchem is to form a synapse between the chemical and the algorithmic worlds
S... |
3,670 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
distance=np.array([4,7.75,7.75,14,14,19])
fake_reddening=np.array([0,0,2,2,5,5])
plt.plot(distance, fake_reddening,lw=5)
plt.xlabel(r'Distance Modulus')
plt.ylabel('Reddening')
plt.xlim(4,19)
plt.ylim(0,7)
plt.title("Ou... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From the reddening profile, we can tell that this is a two cloud model towards a specific line of sight. We see that there are no clouds (and th... |
3,671 | <ASSISTANT_TASK:>
Python Code:
2+3
2*3
2/3
2**3
# Importar una libreria en Python
import numpy as np # el comando "as np" sirve para asignarle un codigo mas corto a la libreria y ser mas rapido.
np.sin(3)
(np.sin(3))*(np.sin(2))
np.log(3)
np.exp(3)
# Ejemplo
a = 5
print (a) # Imprimir mi variable
b = -15
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: Multiplicación
Step2: División
Step3: Potencia
Step4: Funciones Trigonometricas
Step5: Logaritmo y Exponencial
Step6: Reto de Programación
... |
3,672 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import seaborn as sns
from google.cloud import bigquery
import matplotlib as plt
%matplotlib inline
bq = bigquery.Client()
query =
SELECT
weight_pounds,
is_male,
gestation_weeks,
mother_age,
plurality,
mother_race
FROM
`bigquery-public-data.samples.natali... | <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: Reframing Design Pattern
Step3: Comparing categorical label and regression
Step4: We'll use the same features for both models. But we need to ... |
3,673 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset if ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
3,674 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras.datasets import imdb
from keras.models import Sequential
from keras.layers import Dense, LSTM, GRU, Dropout
from keras.layers.embeddings import Embedding
from keras.preprocessing import sequence
from keras.callbacks import TensorBoard
from keras import backen... | <SYSTEM_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 IMDB Dataset
Step2: Pad sequences so they are all the same length (required by keras/tensorflow).
Step3: Setup Vocabulary Dictionary
Step... |
3,675 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
# This is needed to display the images.
%... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Env setup
Step2: Object detection imports
Step3: Model preparation
Step4: Download Model
Step5: Load a (frozen) Tensorflow model into memory... |
3,676 | <ASSISTANT_TASK:>
Python Code:
data = 79,05 102,40 115,40 126,10 217,50 240,70
82,4 101,5 114,1 123,1 215,8 239
81,90 104,80 113,20 121,50 214,20 237,50
data = data.replace(',', '.')
lines = data.split('\n')
values = [line.split('\t') for line in lines]
values
import numpy as np
import pandas as pd
s = pd.DataFrame(val... | <SYSTEM_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ère partie
Step2: Il nous faut construire le vecteur des $\Delta T _ i$ à partir des mesures de fréquences. On construit d'abord le vecteur d... |
3,677 | <ASSISTANT_TASK:>
Python Code:
import IPython as IP
IP.display.Image("example_of_name_matching_problems_mod.png",width=400,height=200,embed=True)
IP.display.Image("../aux/bad_csv_data_mod.png",width=500,height=500,embed=True)
# name of database
db_name = "tennis"
# name of db user
username = "testuser"
# db password ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bad match dates
Step2: Setup MySQL connection
Step3: All import statements here.
Step4: Try to connect to the tennis database on the local my... |
3,678 | <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... |
3,679 | <ASSISTANT_TASK:>
Python Code:
# not so functional function
a = 0
def global_sum(x):
global a
x += a
return x
print(global_sum(1))
print(a)
a = 11
print(global_sum(1))
print(a)
# not so functional function
a = 0
def global_sum(x):
global a
return x + a
print(global_sum(x=1))
print(a)
a = 11
print(gl... | <SYSTEM_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 above example, the output of the function global_sum changed due to the value of a, thus it is unfunctional function.
|
3,680 | <ASSISTANT_TASK:>
Python Code:
employee_names = ['A','B','C','D','E','F','G','H']
n_days = 14 # number of days
days = list(range(n_days))
max_seq = 5 # max number of consecutive shifts
min_seq = 2 # min sequence without gaps
max_work = 10 # max total number of shifts
min_work = 7 # min total number of shifts
max_weeken... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Solving without shift requests
Step2: Solving with shift requests
|
3,681 | <ASSISTANT_TASK:>
Python Code:
import rebound
sim = rebound.Simulation()
sim.integrator = "whfast"
sim.dt = 2.*3.1415/365.*6 # 6 days in units where G=1
sim.add(m=1.)
sim.add(m=1e-3,a=1.)
sim.add(m=5e-3,a=2.25)
sim.move_to_com()
sim.automateSimulationArchive("simulationarchive.bin", walltime=1.,deletefile=True)
sim.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: We then initialize the SA and specify the output filename and output cadence. We can choose the output interval to either correspond to constant... |
3,682 | <ASSISTANT_TASK:>
Python Code:
def strange_sort_list(lst):
'''
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 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:
|
3,683 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
fig = plt.figure()
plt.show()
ax = plt.axes()
plt.show()
ax = plt.axes()
line1, = ax.plot([0, 1, 2, 1.5], [3, 1, 2, 4])
plt.show()
plt.plot([0, 1, 2, 1.5], [3, 1, 2, 4])
plt.show()
ax_left = plt.subplot(1, 2, 1)
plt.plot([2,1,3,4])
plt.title('left = #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: The matplotlib Figure
Step2: On its own, drawing the Figure is uninteresting and will result in an empty piece of paper (that's why we didn't s... |
3,684 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import statsmodels.api as sm
import dismalpy as dp
import matplotlib.pyplot as plt
dta = pd.read_stata('data/lutkepohl2.dta')
dta.index = dta.qtr
endog = dta.ix['1960-04-01':'1978-10-01', ['dln_inv', 'dln_inc', 'dln_consump']]
exo... | <SYSTEM_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 specification
Step2: Example 2
Step3: Caution
|
3,685 | <ASSISTANT_TASK:>
Python Code:
# If we're running on Colab, install empiricaldist
# https://pypi.org/project/empiricaldist/
import sys
IN_COLAB = 'google.colab' in sys.modules
if IN_COLAB:
!pip install empiricaldist
# Get utils.py and create directories
import os
if not os.path.exists('utils.py'):
!wget https:/... | <SYSTEM_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: So that's the distribution of k given N, K, and n.
Step3: So that's our prior.
Step4: We can compute the posterior in the... |
3,686 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis Engemann <denis.engemann@gmail.com>
# Eric Larson <larson.eric.d@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.time_frequency i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: We have to make sure all conditions have the same counts, as the ANOVA
Step3: Create TFR representations for all conditi... |
3,687 | <ASSISTANT_TASK:>
Python Code:
import ckanapi
from datetime import datetime
import json
import os
import requests
from slugify import slugify
from harvest_helpers import *
from secret import CKAN, ARCGIS
print("The ARCGIS REST service endpoint QC lives at {0}".format(ARCGIS["SLIPFUTURE"]["url"]))
print("The catalogue ... | <SYSTEM_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: Harvest
|
3,688 | <ASSISTANT_TASK:>
Python Code:
import os
import requests
from datetime import datetime
from clint.textui import progress
import pandas
pandas.set_option('display.float_format', lambda x: '%.2f' % x)
pandas.set_option('display.max_columns', None)
import matplotlib.pyplot as plt
import matplotlib.dates as dates
%matplotl... | <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: Independent expenditures experiments
Step3: Download quarterly filings
Step4: Basic information about the file
Step5: Frequency counts on the... |
3,689 | <ASSISTANT_TASK:>
Python Code:
from keras.datasets import mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
train_images.shape
len(train_labels)
train_labels
test_images.shape
len(test_labels)
test_labels
from keras import models
from keras import layers
network = models.Sequential()... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: train_images and train_labels form the "training set", the data that the model will learn from. The model will then be tested on the
Step2: Le... |
3,690 | <ASSISTANT_TASK:>
Python Code:
import berrl as bl
import numpy as np
import pandas as pd
apikey='pk.eyJ1IjoibXVycGh5MjE0IiwiYSI6ImNpam5kb3puZzAwZ2l0aG01ZW1uMTRjbnoifQ.5Znb4MArp7v3Wwrn6WFE6A'
data=pd.read_csv('wv_traffic_fatals.csv')
#data=data[data.CNTYNAME=='Clay County']
a=bl.make_points(data,list=True)
bl.parselist(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mapping all fatalities and getting unique hashs for each
Step2: Showing the new url made with fatalities along certain routes
|
3,691 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# 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 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: Chapter 2 - Small Worlds and Large Worlds
Step2: 2.1.3. From counts to probability
Step3: 2.3.2.1. Observed variables
Step4: 2.4.3.Grid Appro... |
3,692 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'mpiesm-1-2-ham', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contrib... | <SYSTEM_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... |
3,693 | <ASSISTANT_TASK:>
Python Code:
!wget -qN ftp://sidads.colorado.edu/pub/DATASETS/nsidc0611_seaice_age/data/2012/iceage-2012w19.bin
import numpy as np
filename = 'iceage-2012w19.bin'
data = np.fromfile(filename, dtype=np.uint8) # read the data as unsigned bytes
print (data.shape)
print 722 * 722
data = data.reshape(7... | <SYSTEM_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 file into a numpy array
Step2: see that we loaded all of the data and it matches the size of the expected dataset
Step3: reshape the data... |
3,694 | <ASSISTANT_TASK:>
Python Code:
from datetime import datetime
import os
REGION = 'us-central1'
PROJECT = !(gcloud config get-value core/project)
PROJECT = PROJECT[0]
BUCKET = PROJECT
MODEL_TYPE = "cnn" # "linear", "dnn", "dnn_dropout", or "cnn"
# Do not change these
os.environ["PROJECT"] = PROJECT
os.environ["BUCKET"]... | <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: Building a dynamic model
Step6: Next, group non-model functions into a util file to keep the model file simple. Use the scale and load_dataset ... |
3,695 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data_small.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 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 in house sales data
Step2: Import useful functions from previous notebooks
Step3: We will also need the normalize_features() function fro... |
3,696 | <ASSISTANT_TASK:>
Python Code:
ratings = pd.read_csv(path+'ratings.csv')
ratings.head()
len(ratings)
movie_names = pd.read_csv(path+'movies.csv').set_index('movieId')['title'].to_dict()
users = ratings.userId.unique()
movies = ratings.movieId.unique()
userid2idx = {o:i for i,o in enumerate(users)}
movieid2idx = {o:i 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: Just for display purposes, let's read in the movie names too.
Step2: We update the movie and user ids so that they are contiguous integers, whi... |
3,697 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.time_frequency import tfr_morlet, psd_multitaper
from mne.datasets import somato
data_path = somato.data_path()
raw_fname = data_path + '/MEG/somato/sef_raw_sss.fif'
# Setup for reading the raw data
raw = mne.io.read_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: Frequency analysis
Step3: Now let's take a look at the spatial distributions of the PSD.
Step4: Alternatively, you can ... |
3,698 | <ASSISTANT_TASK:>
Python Code:
# Run this once before starting your tasks
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
import thread
mc = minecraft.Minecraft.create()
# Task 1 code
# add a variable with an initial value
# toggle the variable
# print the value of the variable
# Task 2 cod... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Task 1
Step2: Task 2
Step3: We need to run the function you defined in Task 2 using the following statement.
|
3,699 | <ASSISTANT_TASK:>
Python Code:
from mpl_toolkits.basemap import Basemap
import opsimsummary as oss
oss.__VERSION__
from opsimsummary import HealpixTree, pixelsForAng, HealpixTiles
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import healpy as hp
htree = HealpixTree(nside=1, nest=True)
# By def... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Instantiate the object
Step2: Find all the healpixels at the resolution one level higher
Step3: Find all the pixels at NSIDE=256, which are ow... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.