Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
9,700 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sympy as sp
sp.init_printing()
fh, d = sp.symbols("fh, d")
Mqf = sp.Matrix([[1, 0],[-1/fh, 1]])
Md = sp.Matrix([[1, d],[0, 1]])
Mqd = sp.Matrix([[1, 0],[1/fh, 1]])
M1 = Mqf*Md*Mqd
sp.simplify(M1)
M2 = sp.Matrix([
[(d - fh)/-fh, d],
[ -d/fh**2, (-d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a id='half_cell'></a>
Step2: For second half cell $f_h \to -f_h$
Step3: Phase advance and stability of the FODO cell
Step4: Phase advance
St... |
9,701 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import os
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.multiclass import OneVsRestClassifier
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
... | <SYSTEM_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 count vectorizer
Step2: Create y
Step3: Train multi-class multi-label model
Step4: Predict the testing dataset
|
9,702 | <ASSISTANT_TASK:>
Python Code:
# set up plotting
%matplotlib inline
from matplotlib import pyplot as plt
plt.rcParams['figure.figsize'] = (8.0, 5.0)
plt.rcParams['font.family'] = 'serif'
plt.rcParams['mathtext.fontset'] = 'dejavuserif'
plt.rcParams['font.size'] = 16
def npf(i, a, b, c, d):
return a * b**c / (b**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: The following figure shows the behaviour of the chosen function and demonstrates how the $npf$ schedule changes depending on the supplied parame... |
9,703 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd # importing pandas
import numpy as np # importing numpy
from pandas import DataFrame, Series # importing DataFrame and Series objects from pandas
import matplotlib.pyplot as plt # importing matplotlib for plotting.
from sklearn.ensemble import RandomForestRegressor # 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: To manipulate the data we will use the DataFrame object from pandas library. A DataFrame represents a tabular, spreadsheet-like data structure c... |
9,704 | <ASSISTANT_TASK:>
Python Code:
bigsourcefile = 'TextProcessing_2017/W0013.orig.txt' # This is the path to our file
input = open(bigsourcefile, encoding='utf-8').readlines() # We use a variable 'input' for
# keeping its contents.
input[:10] ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Segment source text<a name="SegmentSourceText"></a>
Step2: Read segments into a variable <a name="ReadSegmentsIntoVariable"></a>
Step3: Now we... |
9,705 | <ASSISTANT_TASK:>
Python Code:
# Import the function to create an spm fmri preprocessing workflow
from niflow.nipype1.workflows.fmri.spm import create_spm_preproc
# Create the workflow object
spmflow = create_spm_preproc()
# Import relevant modules
from nipype import IdentityInterface, Node, Workflow
# Create an itern... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For a reason that will become clearer under the exec visualization, let's add an iternode at the beginning of the spmflow and connect them toget... |
9,706 | <ASSISTANT_TASK:>
Python Code:
#@title
# Copyright 2018 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 applicable... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Tensor2Tensor Reinforcement Learning
Step2: Play using a pre-trained policy
Step3: To evaluate and generate videos for a pretrained policy on ... |
9,707 | <ASSISTANT_TASK:>
Python Code:
def greeter(func):
print("Hello")
func()
def say_something():
print("Let's learn some Python.")
greeter(say_something)
# greeter(12)
def count_predicate(predicate, iterable):
true_count = 0
for element in iterable:
if predicate(element) is True:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Functions are first class objects
Step2: Q. Can you write this function in fewer lines?
Step3: The predicate parameter
Step4: 2. instance of ... |
9,708 | <ASSISTANT_TASK:>
Python Code:
import os
import shutil
import nansat
idir = os.path.join(os.path.dirname(nansat.__file__), 'tests', 'data/')
import matplotlib.pyplot as plt
%matplotlib inline
from nansat import Nansat
n = Nansat(idir+'gcps.tif')
print (n)
b1 = n[1]
%whos
plt.imshow(b1);plt.colorbar()
plt.show()
<E... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Open file with Nansat
Step2: Read information ABOUT the data (METADATA)
Step3: Read the actual DATA
Step4: Check what kind of data we have
|
9,709 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from sklearn.linear_model import RidgeClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
X, y = load_data()
assert type(X) == np.ndarray
assert type(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:
|
9,710 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import clear_output, Image
!pip install evojax
clear_output()
import os
import numpy as np
import jax
import jax.numpy as jnp
from evojax.task.cartpole import CartPoleSwingUp
from evojax.policy.mlp import MLPPolicy
from evojax.algo import PGPE
from evojax import Train... | <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: Introduction
Step4: This tutorial walks you through the process of creating a new neuroevolution algoritm.
Step8: Notice that our implementa... |
9,711 | <ASSISTANT_TASK:>
Python Code:
# we are dependent on numpy, sympy and cvxopt.
import numpy as np
import cvxopt
import mompy as mp
# just some basic settings and setup
mp.cvxsolvers.options['show_progress'] = False
from IPython.display import display, Markdown, Math, display_markdown
sp.init_printing()
def print_problem... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Noiseless mixture of 2 Gaussians in 1D
Step2: Noisy mixture of Gaussian
Step3: PSD max-cut
|
9,712 | <ASSISTANT_TASK:>
Python Code:
from openpathsampling.tests.test_helpers import make_1d_traj
left_state_edge = 0.0
right_state_edge = 10.0
def make_traj(suffix, stride=1):
frame = left_state_edge -1.0 + suffix
coords = [frame]
while frame < right_state_edge:
frame += 1.0*stride
coords.append(... | <SYSTEM_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 join the two trajectories together. The approach we use is a little complicated, but the basic idea is this
Step2: Note, importantly, th... |
9,713 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import num... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
9,714 | <ASSISTANT_TASK:>
Python Code:
from itertools import combinations
import sympy
from sympy import Function, integrate, Product, Sum, Symbol, symbols
from sympy.abc import a,b,h,i,k,m,n,x
from sympy import Rational as Rat
def lagrange_basis_polys(N,x,xpts=None):
lagrange_basis_polynomials(N,x,xpts)
returns 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:
Step2: Numerical Integration
Step3: Below is, mathematically, $f_{-h}
Step4: Then, we can use sympy to calculate, symbolically, $f_{h}
Step5: Succ... |
9,715 | <ASSISTANT_TASK:>
Python Code:
ABIG = 1.0
big_sil = SingleGrainPop('Grain', 'Silicate', 'Mie', amax=ABIG, md=MD)
big_gra = SingleGrainPop('Grain', 'Graphite', 'Mie', amax=ABIG, md=MD)
%%time
big_sil.calculate_ext(EVALS, unit='kev', theta=THVALS)
%%time
big_gra.calculate_ext(EVALS, unit='kev', theta=THVALS)
ax = plt.su... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Make a giant comparison plot
|
9,716 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os, sys, numpy as np, matplotlib.pyplot as plt
sys.path.insert(1,os.path.abspath('../..'))
import burnman
from burnman import minerals
seismic_model = burnman.seismic.PREM()
depths = np.linspace(750e3, 2800e3, 20)
pressure, seis_rho, seis_vp, seis_vs, seis_vp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here we import the relevant modules from BurnMan. The burnman
Step2: 2. Import seismic model
Step3: We create an array of 20 depths at which ... |
9,717 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import time
from os.path import join
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix
import utils
from data import Dataset
tf.set_random_seed(31415)
tf.logging.set_verbosity(tf.logging.ERROR)
plt.rc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dataset
Step2: Inputs
Step3: Model
Step4: Loss
Step5: Putting it all together
Step6: 3. Training the model
Step7: Validation
Step8: Tenso... |
9,718 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import statsmodels.api as sm
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
np.random.seed(123)
n = 100
x = np.linspace(0.01, 2, n)
y = 2 * np.log(x)
y_noise = y + np.random.normal(size=(n))
plt.figure(figsize=(12, 8))
plt.scatter... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: And here is how our random sample looks like. Without knowing the true relation between feature and response one could easily argue the dependen... |
9,719 | <ASSISTANT_TASK:>
Python Code:
s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
s
s[10]
s[20:] # start from 10 to end of string
s[:20] # start from 0 to index 19
s[10:30:2] # start from 10, end at 29 with steps of 2
s[30:10:-2] # in reverse... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Operators on Strings
Step2: Operations on Strings
|
9,720 | <ASSISTANT_TASK:>
Python Code:
import graphviz as gv
def toDot(A, f, g, u=None):
n = len(A)
dot = gv.Digraph(node_attr={'shape': 'record'})
for k, p in enumerate(A):
if k == u:
dot.node(str(k), label='{' + str(p) + '|' + str(k) + '}', style='filled', fillcolor='orange')
elif k... | <SYSTEM_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 function toDot takes four arguments
Step2: HeapSort
Step3: The function ascend takes two arguments
Step4: The function sink takes three a... |
9,721 | <ASSISTANT_TASK:>
Python Code:
import os
import csv
import codecs
import numpy as np
import pandas as pd
np.random.seed(1337)
from keras.preprocessing.text import Tokenizer
from keras.preprocessing.sequence import pad_sequences
from keras.utils.np_utils import to_categorical
from keras.layers import Dense, Input, Flatt... | <SYSTEM_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 read the train and test questions into list of questions.
Step2: Using keras tokenizer to tokenize the text and then do padding the sentenc... |
9,722 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import copy
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from keras.datasets import mnist, cifar10
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.optimizers import SGD, RMSprop
from k... | <SYSTEM_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 MNIST dataset, flatten the images, convert the class labels, and scale the data.
Step2: I. Basic CNN Example
Step3: Fit the model ove... |
9,723 | <ASSISTANT_TASK:>
Python Code:
def equilibrium(arr ) :
left_sum =[]
right_sum =[]
for i in range(len(arr ) ) :
if(i ) :
left_sum . append(left_sum[i - 1 ] + arr[i ] )
right_sum . append(right_sum[i - 1 ] + arr[len(arr ) - 1 - i ] )
else :
left_sum . append(arr[i ] )
right_sum . append(arr[len(ar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
9,724 | <ASSISTANT_TASK:>
Python Code:
# This tells matplotlib not to try opening a new window for each plot.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import load_iris
from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
# For producing decision tree diagra... | <SYSTEM_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 do not have pydot library installed, open your terminal and type either conda install pydot or pip install pydot
Step2: The plan
Step3: ... |
9,725 | <ASSISTANT_TASK:>
Python Code:
import pickle
path = '../../rsc/obj/'
X_train_path = path + 'X_train.sav'
y_train_path = path + 'y_train.sav'
X_train = pickle.load(open(X_train_path, 'rb'))
y_train = pickle.load(open(y_train_path, 'rb'))
print(X_train.shape)
from sklearn.svm import LinearSVC
from sklearn.model_selectio... | <SYSTEM_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. Entrenamos múltiples clasificadores
Step2: 2.2. Gradient tree boosting
Step3: 2.3. Random forests
Step4: 2.4. SVM con probabilidades
Step5... |
9,726 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import pandas as pd
import numpy
from po_data_process import get_data_from_point_API, make_histogram, make_plot
import warnings
import matplotlib.cbook
warnings.filterwarnings("ignore",category=matplotlib.cbook.mplDeprecation)
API_key = open('APIKEY').read().strip()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font color='red'>Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly ... |
9,727 | <ASSISTANT_TASK:>
Python Code:
import datetime
import json
import os
from pathlib import Path
from pprint import pprint
import time
from zipfile import ZipFile
import numpy as np
from planet import api
from planet.api import filters
import rasterio
from rasterio import plot
from shapely.geometry import MultiPolygon, sh... | <SYSTEM_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: As we can see, the footprints (rectangles) do not exactly match the AOI. Indeed, none of them cover the AOI. We do... |
9,728 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
import os
PROJECT = 'cloud-training-demos' # REPLACE WITH YOUR PROJECT ID
BUCKET = 'cloud-training-demos-ml' # REPLACE WITH YOUR BUCKET NAME
REGION = 'us-central1' # REPLACE WITH YOUR BUCKET REGION e.g. us-central1
# For 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: Packaging up the code
Step2: Find absolute paths to your data
Step3: Running the Python module from the command-line
Step4: Clean model train... |
9,729 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import numpy, pandas
from rep.utils import train_test_split
from sklearn.metrics import roc_auc_score
sig_data = pandas.read_csv('toy_datasets/toyMC_sig_mass.csv', sep='\t')
bck_data = pandas.read_csv('toy_datasets/toyMC_bck_mass.csv', sep='\t')
labels = numpy.array([1] * 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: Loading data
Step2: Training variables
Step3: Folding strategy - stacking algorithm
Step4: Define folding model
Step5: Default prediction (p... |
9,730 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import seaborn as sns
import numpy as np
from IPython.display import display
%matplotlib inline
import plotly.plotly as py
from plotly.graph_objs import *
# @YOUSE: Fill in your credentials (user ID, API key) for Plotly here
py.sign_in ('USERNAME', 'APIKEY')
%reload_ex... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Notation
Step2: Definition 3. The heaviside function maps strictly positive values to the value 1 and non-positive values to 0
Step3: Definiti... |
9,731 | <ASSISTANT_TASK:>
Python Code:
from symbulate import *
%matplotlib inline
n = 6
die = list(range(1, n+1))
P = BoxModel(die)
RV(P).sim(10000).plot()
P = BoxModel(['H', 'T'], size=2, order_matters=True)
P.sim(10000).tabulate(normalize=True)
P = BoxModel(['orange', 'brown', 'yellow'], probs=[0.5, 0.25, 0.25])
P.sim(100... | <SYSTEM_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. Rolling a fair n-sided die (with n=6).
Step2: Example. Flipping a fair coin twice and recording the results in sequence.
Step3: Exam... |
9,732 | <ASSISTANT_TASK:>
Python Code:
# Import the packages that will be usefull for this part of the lesson
from collections import OrderedDict, Counter
import pandas as pd
from pprint import pprint
# Small trick to get a larger display
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reminder on file parsing strategy
Step2: The file indicated bellow contain a representative sample of popular votes for the last US presidentia... |
9,733 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'dwd', 'sandbox-3', '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... |
9,734 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# The line above is needed to include the figures in this notebook, you can remove it if you work with a normal script
import numpy as np
import csv
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsRegressor
from sklearn.preprocessing impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. NUMPY
Step2: Define a new 3x2 array named my_array2 with [1, 2, 3] in the first row and [4,5,6] in the second.
Step3: Until now, we have c... |
9,735 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import datetime
np.random.seed(1337) # for reproducibility
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
from keras.utils import np_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Settings
Step2: Dataset Preparation
Step3: Your Turn
|
9,736 | <ASSISTANT_TASK:>
Python Code:
import rebound
import numpy as np
def setupSimulation():
rebound.reset()
rebound.integrator = "ias15" # IAS15 is the default integrator, so we don't need this line
rebound.add(m=1.)
rebound.add(m=1e-3,a=1.)
rebound.add(m=1e-3,a=1.25)
rebound.move_to_com()
setupSim... | <SYSTEM_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 integrate this system for 100 orbital periods.
Step2: Rebound exits the integration routine normally. We can now explore the final partic... |
9,737 | <ASSISTANT_TASK:>
Python Code:
import math
import shutil
import numpy as np
import pandas as pd
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.INFO)
pd.options.display.max_rows = 10
pd.options.display.float_format = '{:.1f}'.format
df = pd.read_csv("https://storage.googleapis.com/ml_universities/californi... | <SYSTEM_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'll load our data set.
Step2: Examine the data
Step3: This data is at the city block level, so these features reflect the total number... |
9,738 | <ASSISTANT_TASK:>
Python Code:
import sys
print('Python version:', sys.version)
import IPython
print('IPython:', IPython.__version__)
import numpy
print('numpy:', numpy.__version__)
import scipy
print('scipy:', scipy.__version__)
import matplotlib
print('matplotlib:', matplotlib.__version__)
import pandas
print('pandas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I. Python Overview
Step2: (If you're typing this into an IPython notebook, or otherwise using notebook file, you hit shift-Enter to evaluate a ... |
9,739 | <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: TensorBoard を使う
Step2: MNIST データセットを例として使用しながら、データを正規化し、画像を 10 個のクラスに分類する単純な Keras モデルを作成する関数を記述します。
Step3: Keras Model.fit() で TensorBoard を使... |
9,740 | <ASSISTANT_TASK:>
Python Code:
import pysal.lib as ps
import numpy as np
from pysal.explore.pointpats import PointPattern
f = ps.examples.get_path('vautm17n_points.shp')
fo = ps.io.open(f)
pp_va = PointPattern(np.asarray([pnt for pnt in fo]))
fo.close()
pp_va.summary()
pp_va.window.area
pp_va.window.bbox
pp_va.window... | <SYSTEM_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 summary method we see that the Bounding Rectangle is reported along with the Area of the window for the point pattern. Two things to no... |
9,741 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
from collections import defaultdict
import json
import os
import time
import requests
def save_output(data, output_file):
with open(output_file, "w") as f:
json.dump(data, f)
# Set some global variables
MEETUP_API_KEY = "yeah right"
MEETU... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Part 1
Step2: The Meetup API limits requests, however their documentation isn't exactly helpful. Using their headers, I saw that I was limited... |
9,742 | <ASSISTANT_TASK:>
Python Code:
Image('./res/first_visit_mc.png')
Image('./res/gpi.png')
Image('./res/monte_carlo_es.png')
Image('./res/on_epsilon_soft.png')
Image('./res/off_policy_predict.png')
Image('./res/off_policy_control.png')
<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: Monte Carlo methods do not bootstrap
Step2: 5.4 Monte Carlo Control without Exploring Starts
Step3: 5.5 Off-policy Prediction via Importances ... |
9,743 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 策略
Step2: Python 策略
Step3: 最重要的方法为 action(time_step),该方法可将包含环境观测值的 time_step 映射到包含以下特性的 PolicyStep 命名元组:
Step4: 示例 2:脚本化 Python 策略
Step5: Te... |
9,744 | <ASSISTANT_TASK:>
Python Code:
from abydos.phonetic import *
from abydos.distance import *
import pandas as pd
names = pd.read_csv('../tests/corpora/uscensus2000.csv',
comment='#', index_col=1, usecols=(0,1), keep_default_na=False)
names.head()
soundex('WILLIAMSON')
sdx = Soundex()
reverse_sounde... | <SYSTEM_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 we load some data into a DataFrame. In this case, we'll load the US Census surnames data ranked by frequency.
Step2: We can create a dictio... |
9,745 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install -U google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if not 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:... |
9,746 | <ASSISTANT_TASK:>
Python Code:
random_state = 1234
dataset = pd.read_csv("../data/titanic/titanic.csv")
# Fill missing values for Age
dataset.fillna({"Age":dataset.Age.mean()}, inplace=True)
# Encode categorical variables
dataset["Sex_label"] = dataset.Sex.astype("category").cat.codes
dataset["Cabin_label"] = dataset.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: Set up the pipeline
Step2: Extract relevant parameters for dtreeviz from the pipeline
Step3: Initialize shadow tree
Step4: Visualizations
Ste... |
9,747 | <ASSISTANT_TASK:>
Python Code:
d1 = {}
d2 = {'Hola': ['Hi','Hello'], 'Adios': ['Bye'] }
d2["Hola"]
# Sol:
# Sol:
def fusion():
dic1 = {1: 'A', 2:'B', 3:'C'}
dic2 = {4: 'Aa', 5:'Ba', 6:'Ca'}
dic1.update(dic2)
return dic1
fusion()
# Sol:
it = [ 'Roma', 'Milán', 'Nápoles', 'Turín', 'Palermo' , 'Génova'... | <SYSTEM_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 Ejercicio
Step2: Dada la lista de las ciudades más pobladas de Italia it
|
9,748 | <ASSISTANT_TASK:>
Python Code:
# import packages
import numpy as np
import matplotlib.pyplot as plt
from reg_utils import sigmoid, relu, plot_decision_boundary, initialize_parameters, load_2D_dataset, predict_dec
from reg_utils import compute_cost, predict, forward_propagation, backward_propagation, update_parameters
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: Problem Statement
Step3: Each dot corresponds to a position on the football field where a football player has hit the ball with his/her head af... |
9,749 | <ASSISTANT_TASK:>
Python Code:
# Required imports
import pandas as pd
from bqplot import (LogScale, LinearScale, OrdinalColorScale, ColorAxis,
Axis, Scatter, CATEGORY10, Label, Figure)
from bqplot.default_tooltip import Tooltip
from ipywidgets import VBox, IntSlider, Button
from IPython.display impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Cleaning and Formatting JSON Data
Step2: Creating the Tooltip to display the required fields
Step3: Creating the Label to display the year
Ste... |
9,750 | <ASSISTANT_TASK:>
Python Code:
import time
from collections import namedtuple
import numpy as np
import tensorflow as tf
with open('anna.txt', 'r') as f:
text=f.read()
vocab = sorted(set(text))
vocab_to_int = {c: i for i, c in enumerate(vocab)}
int_to_vocab = dict(enumerate(vocab))
encoded = np.array([vocab_to_int... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First we'll load the text file and convert it into integers for our network to use. Here I'm creating a couple dictionaries to convert the chara... |
9,751 | <ASSISTANT_TASK:>
Python Code:
age = float(input())
sex = input()
if sex == "m":
if age >= 16:
print("Mr.")
else:
print("Master")
else:
if age >= 16:
print("Ms.")
else:
print("Miss")
product = input()
city = input()
quantity = float(input())
price = 0
if city == "Sofia":... | <SYSTEM_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>02.Small Shop</h2>
Step2: <h2>03.Point in Rectangle</h2>
Step3: <h2>04.Fruit or Vegetable</h2>
Step4: <h2>05.Invalid Number</h2>
Step5: ... |
9,752 | <ASSISTANT_TASK:>
Python Code:
# Install the TimeSketch API client if you don't have it
!pip install timesketch-api-client
# Import some things we'll need
from timesketch_api_client import config
from timesketch_api_client import search
import pandas as pd
pd.options.display.max_colwidth = 60
#@title Client Informatio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Connect to Timesketch
Step2: Now that we've connected to the Timesketch server, we need to select the Sketch that has the CTF timeline.
Step3:... |
9,753 | <ASSISTANT_TASK:>
Python Code:
import pickle
import gpflow
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from BranchedGP import BranchingTree as bt
from BranchedGP import VBHelperFunctions as bplot
from BranchedGP import branch_kernParamGPflow as bk
plt.style.use("ggplot")
%matplotlib inli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create the tree
Step2: Specify where to evaluate the kernel
Step3: Specify the kernel and its hyperparameters
Step4: Sample the kernel
Step5:... |
9,754 | <ASSISTANT_TASK:>
Python Code:
import os, sys, math
import numpy as np
from matplotlib import pyplot as plt
import tensorflow as tf
print("Tensorflow version " + tf.__version__)
#@title "display utilities [RUN ME]"
def display_9_images_from_dataset(dataset):
plt.figure(figsize=(13,13))
subplot=331
for i, (image, ... | <SYSTEM_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
Step2: Read images and labels [WORK REQUIRED]
Step3: Useful code snippets
Step4: Decode a JPEG and extract folder name in TF
|
9,755 | <ASSISTANT_TASK:>
Python Code:
# Implement function in the ```pset2.py``` file
from pset2 import band_lu
import scipy.sparse
import scipy as sp # can be used with broadcasting of scalars if desired dimensions are large
import numpy as np
import scipy.linalg as lg
import time
import matplotlib.pyplot as plt
%matplotlib ... | <SYSTEM_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 out algorithm we know that the matrix is banded and apply much faster algorithm which is linear of size of matrix and quadratic of band size.... |
9,756 | <ASSISTANT_TASK:>
Python Code:
from bass import *
#initialize new file
Data = {}
Settings = {}
Results ={}
############################################################################################
#manual Setting block
Settings['folder']= r"/Users/abigaildobyns/Desktop"
Settings['Label'] = r'rat34_ECG.txt'
Settings... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Begin User Input
Step2: Load Settings from previous analysis
Step3: Display Event Detection Tables
Step4: Display Summary Results for Peaks
S... |
9,757 | <ASSISTANT_TASK:>
Python Code:
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
import pandas as pd
data = dict(type = 'choropleth',
locations = ['AZ','CA','NY'],
locati... | <SYSTEM_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 set up everything so that the figures show up in the notebook
Step2: More info on other options for Offline Plotly usage can be found here.... |
9,758 | <ASSISTANT_TASK:>
Python Code:
import requests
import json
import numpy as np
from passlib.apps import custom_app_context as pwd_context
API_ENDPOINT = 'https://embeddings.gh-issue-labeler.com/text'
API_KEY = 'YOUR_API_KEY' # Contact maintainers for your api key
data = {'title': 'Fix the issue',
'body': 'I am... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: API Endpoints
Step2: Convert byte stream sent over REST back to a numpy array. The numpy array is a 2,400 dimensional embedding which are late... |
9,759 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import holoviews as hv
hv.extension('bokeh')
%opts Curve Area [width=600]
def fm_modulation(f_carrier=110, f_mod=110, mod_index=1, length=0.1, sampleRate=3000):
x = np.arange(0, length, 1.0/sampleRate)
y = np.sin(2*np.pi*f_carrier*x + mod_index*np.sin(2*np.pi*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: Declaring elements in a function
Step2: The function defines a number of parameters that will change the signal, but using the default paramete... |
9,760 | <ASSISTANT_TASK:>
Python Code:
import mdtraj as md
from contact_map import ContactFrequency
full = md.load("data/gsk3b_example.h5") # Start with the full trajectory from another example
# Slice another trajectory down to 150 residues
truncated = full.atom_slice(full.topology.select("resid 0 to 150"))
map_full = Conta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Comparing mutated proteins.
Step2: If we now try to subtract the two, this will fail because we can't overlap the atom contact maps
Step3: But... |
9,761 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import seaborn as sns
sns.set_context("notebook", font_scale=1.5)
import warnings
warnings.filterwarnings("ignore")
from astropy.io import ascii
tbl4 = ascii.read("http://iopscience.iop.org/0004-637X/794/1/36/suppdata/apj500669t4_mrt.txt")
tbl4[0:4]
Na_mask = ((tbl4["f_EWNa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Table 4 - Low Resolution Analysis
|
9,762 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
init_printing()
from IPython.display import display
x = Symbol("x")
y = Function("y")
f = Function("f")
eqn = Eq(Derivative(y(x), x, x) + 2*Derivative(y(x), x) + y(x), 0)
display(eqn)
dsolve(eqn)
eqn = Eq(Derivative(y(x), x, x) + 2*Derivative(y(x), x) + y(x), f(x))
d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We first solve the homogeneous equation
Step2: Now solve the non-homogeneous case for some $f(x)$
|
9,763 | <ASSISTANT_TASK:>
Python Code:
from jupyterthemes import get_themes
from jupyterthemes.stylefx import set_nb_theme
themes = get_themes()
set_nb_theme(themes[1])
%load_ext watermark
%watermark -a 'Ethen' -d -t -v -p jupyterthemes
def to_str(n, base):
convert_str = '0123456789ABCDEF'
if n < base:
# look ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Recursion, Greedy Algorithm, Dynamic Programming
Step3: Greedy Algorithm
Step5: The greedy method works fine when we are using U.S. coins, but... |
9,764 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import copy
import numpy as np
import pandas as pd
import sys
import os
import re
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD, RMSprop
from keras.layers.normalization import BatchNormalization
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I. Problem Set 8, Part 1
Step2: And construct a flattened version of it, for the linear model case
Step3: (1) neural network
Step4: (2) suppo... |
9,765 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from collections import Counter
from math import sqrt
import random
import warnings
df = pd.read_table('train.csv', sep=',', header=None, names=['Type', 'LifeStyle', 'Vacation', 'eCredit', 'Salary', 'Property', 'Label'])
df.head()
dft = pd.read_tab... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: reading the training data into a data frame and assigning headings
Step2: reading the testing data into a data frame and assigning headings
Ste... |
9,766 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import networkx as nx
from matplotlib import pyplot as plt
%matplotlib inline
import warnings
warnings.filterwarnings( 'ignore' )
def fw( A, pi = None ) :
if pi is None :
pi = A.copy( )
pi[ A == 0 ] = np.inf
np.fill_diagonal( pi, 0 )
for ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <hr/>
Step2: The mixing coefficient for a numerical node attribute $X = \big(x_i\big)$ in an undirected graph $G$, with the adjacency matrix $A... |
9,767 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import numpy as np
from fermipy.gtanalysis import GTAnalysis
from fermipy.plotting import ROIPlotter, SEDPlotter
import matplotlib.pyplot as plt
import matplotlib
from IPython.display import Image
if os.path.isfile('../data/SMC_data.tar.gz'):
!tar xzf ../... | <SYSTEM_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 untar the file ../data/SMC_data.tar.gz. This will copy the config.yaml and ft1 file in the notebook directory.
Step2: The setup() metho... |
9,768 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import urllib
import datetime
import matplotlib.pyplot as plt
%matplotlib inline
%load_ext autoreload
%autoreload 2
import beapy
apiKey = '3EDEAA66-4B2B-4926-83C9-FD2089747A5B'
bea = beapy.initialize(apiKey =apiKey)
# Get a list of the the data sets... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Methods for searching for data
Step2: Datasets
Step3: Example
|
9,769 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.plots import add_metpy_logo, Hodograph, SkewT
from metpy.units import units
col_names = ['pressure', ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Upper air data can be obtained using the siphon package, but for this example we will use
Step2: We will pull the data out of the example datas... |
9,770 | <ASSISTANT_TASK:>
Python Code:
from kubeflow import fairing
# Setting up google container repositories (GCR) for storing output containers
# You can use any docker container registry istead of GCR
GCP_PROJECT = fairing.cloud.gcp.guess_project_name()
DOCKER_REGISTRY = 'gcr.io/{}/fairing-job'.format(GCP_PROJECT)
BASE_IMA... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Build a base image for LightGBM
Step2: Launch a LightGBM train task
Step3: Let's look at the trained model
|
9,771 | <ASSISTANT_TASK:>
Python Code:
! wget --no-check-certificate http://www.hobieco.com/linked_images/H18-Magnum.jpg
%matplotlib inline
import cv2
from matplotlib import pyplot as plt
import numpy as np
import time as t
print "OpenCV Version : %s " % cv2.__version__
image = cv2.imread("H18-Magnum.jpg")
fig, ax = plt.subplo... | <SYSTEM_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 image has been correctly loaded by openCV as a numpy array, but the color of each pixel has been sorted as BGR. Matplotlib's plot expects an... |
9,772 | <ASSISTANT_TASK:>
Python Code:
'hello ' + 'world!'
name = 'Alice'
place = 'Main Street'
time = '6 pm'
food = 'turnips'
print('Hello ' + name + ', you are invited to a party at ' + place + ' at ' + time + '. Please bring ' + food + '.')
print(' Hello %s, you are invited to a party at %s at %s. Please bring %s.' % (nam... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This gets harder with more variables.
Step2: Python has string interpolation, which uses %s to insert other strings into placeholders.
|
9,773 | <ASSISTANT_TASK:>
Python Code:
#import Opencv library
import os
SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data')
try:
import cv2
except ImportError:
print "You must have OpenCV installed"
exit(1)
#check the OpenCV version
try:
v=cv2.__version__
assert (tuple(map(int,v.split(".")))>(2,4,... | <SYSTEM_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 try to construct the vocabulary from a set of template images. It is a set of three general images belonging to the category of car, plane an... |
9,774 | <ASSISTANT_TASK:>
Python Code:
from PIL import Image
import pytesseract
import googlemaps
import gmaps as jupmap
import sys
from datetime import datetime
# get my private keys for google maps and gmaps
f = open('private.key', 'r')
for line in f:
temp = line.rstrip('').replace(',','').replace('\n','').split(" ")... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Part 2 - Use OCR to read the address
Step2: Testing location
Step3: Google Maps
|
9,775 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
#%matplotlib notebook
from IPython.display import display
import matplotlib
matplotlib.rcParams['figure.figsize'] = (9, 9)
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime
import pandas as pd
import numpy as np
pd.__version__
data_list ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Make data
Step2: With defined indices
Step3: Get information about a series
Step4: Date ranges
Step5: Frames (2D data)
Step6: With defined ... |
9,776 | <ASSISTANT_TASK:>
Python Code:
import random, pandas
text = [ "one","two","three","four","five","six","seven","eight","nine","ten" ]
data = [ { "name": text[random.randint(0,9)], "number": random.randint(0,99)} \
for i in range(0,10000) ]
df = pandas.DataFrame(data)
df.head(n=3)
df.to_csv("flatf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Le's assume now we introduce extra tabulations.
Step2: It works well because we use pandas to save the dataframe, and we use pandas to restore ... |
9,777 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
%matplotlib inline
import numpy as np
import pandas as pd
import re
import six
from IPython.display import display
import sys
sys.path.append('..')
from pummeler.data import geocode_data
county_to_region = geocode_data('county_region_10').re... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Map electoral results to regions
Step2: First, handle Alaska specially
Step3: Normalize candidate names
Step4: Slightly disagrees with https
... |
9,778 | <ASSISTANT_TASK:>
Python Code:
# Setup plotting
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
# Set Matplotlib defaults
plt.rc('figure', autolayout=True)
plt.rc('axes', labelweight='bold', labelsize='large',
titleweight='bold', titlesize=18, titlepad=10)
plt.rc('animation', html='html5')
# 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: First load the Spotify dataset.
Step2: 1) Add Dropout to Spotify Model
Step3: Now run this next cell to train the model see the effect of addi... |
9,779 | <ASSISTANT_TASK:>
Python Code:
# define a dipole
dipoleloc = (0.,0.,-50.)
dipoleL = 100.
dipoledec, dipoleinc = 0., 90.
dipolemoment = 1e13
# geomagnetic field
B0, Binc, Bdec = 53600e-9, 90., 0. # in Tesla, degree, degree
B0x = B0*np.cos(np.radians(Binc))*np.sin(np.radians(Bdec))
B0y = B0*np.cos(np.radians(Binc))*np.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: Define the Earth's magnetic field $B_0$
Step2: Define the observations
Step3: Calculate data for plotting
Step4: 3D plot of field lines and d... |
9,780 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
# give access to importing dwarfz
import os, sys
dwarfz_package_dir = os.getcwd().split("dwarfz")[0]
if dwarfz_package_dir not in sys.path:
sys.path.insert(0, dwarfz_package_dir)
import dwarfz
from dwarfz.hsc_credentials import credentia... | <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: Get HSC Fluxes
Step3: Make the query
Step4: Check if it worked
Step5: Combine databases
Step6: Match HSC objects to COSMOS objects
Step7: C... |
9,781 | <ASSISTANT_TASK:>
Python Code:
!pip install -q numpyro@git+https://github.com/pyro-ppl/numpyro
import time
import numpy as np
import jax.numpy as jnp
from jax import random
import numpyro
import numpyro.distributions as dist
from numpyro.examples.datasets import COVTYPE, load_dataset
from numpyro.infer import HMC, MCMC... | <SYSTEM_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 do preprocessing steps as in source code of reference [1]
Step2: Now, we construct the model
Step3: Benchmark HMC
Step4: In CPU, we get av... |
9,782 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
ncep_url = "https://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis.derived/"
ncep_air = xr.open_dataset( ncep_url + "pressure/air.mon.1981-2010.ltm.nc", decode_times=False)
level = ncep_air.leve... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Take global averages and time averages.
Step2: Here is code to make a nicely labeled sounding plot.
Step3: Now compute the Radiative Equilibri... |
9,783 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Martin Luessi <mluessi@nmr.mgh.harvard.edu>
# Eric Larson <larson.eric.d@gmail.com>
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import 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
|
9,784 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
cd ~/Dropbox/dev/rainbow/notebooks
from PIL import Image
# img = Image.open('data/cbar/boxer.png')
# img = Image.open('data/cbar/fluid.png')
# img = Image.open('data/cbar/lisa.png')
# img = Image.open('data/cbar/redblu... | <SYSTEM_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 an image
Step2: Quantize with scikit
Step6: Colinearity adjustment
Step7: Travelling salesman problem
Step8: The zero-point trick is le... |
9,785 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# Create an array with the statement np.array
a = np.array([1,2,3,4])
print('a is of type:', type(a))
print('dimension of a:', a.ndim) # To find the dimension of 'a'
arr1 = np.array([1,2,3,4])
arr1.ndim
arr2 = np.array([[1,2],[2,3],[3,4],[4,5]])
arr2.ndim
# Doesn't make... | <SYSTEM_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 easy to tell the number of dimensions - look at the number of square brackets at the beginning. [[ = 2 dimensions. [[[ = 3 dimensions. <br>
... |
9,786 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'ukesm1-0-ll', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,787 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-3', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,788 | <ASSISTANT_TASK:>
Python Code:
import cv2
import numpy as np
import matplotlib.pyplot as plt
import scipy.ndimage as scp
img = cv2.imread('paint.jpg', cv2.IMREAD_GRAYSCALE)
kernal = np.zeros((51,51))
kernal[25,25] = 1
Constant_filter = scp.correlate(img,kernal,mode='constant')
Wrap_filter = scp.correlate(img,kernal,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: Read Image
Step2: Boundary filters
|
9,789 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
# RMS Titanic data visualization code
from titanic_visualizations import survival_stats
from IPython.display import display
%matplotlib inline
# Load the dataset
in_file = 'titanic_data.csv'
full_data = pd.read_csv(in_file)
# Print the first few ent... | <SYSTEM_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 a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship
Step3: The very same sample of th... |
9,790 | <ASSISTANT_TASK:>
Python Code:
import sympy
from sympy import Eq,solve
from sympy.abc import x,y
sympy.init_printing()
f = lambda x: (2*x+2)/(x-1)
enacba = Eq(f(y),x)
enacba
resitve = solve(enacba,y) # izrazimo y
resitve
invf = sympy.lambdify(x,resitve[0])
Eq(y,invf(x))
import numpy as np
import matplotlib.pyplot as p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Narišimo še grafe funkcij. Uporabimo lahko funkcijo plot iz knjižnice matplotlib.
Step2: Primer
Step3: Vrednost $\log_2(3)$ je rešitev enačbe ... |
9,791 | <ASSISTANT_TASK:>
Python Code:
scopes = {
"local": {"locals": None,
"non-local": {"locals": None,
"global": {"locals": None,
"built-in": ["built-ins"]}}},
}
x = 100
def main():
x += 1
print(x)
main()
x = 100
def main():
global ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 除了默认的局部变量声明方式,Python 还有global和nonlocal两种类型的声明(nonlocal是Python 3.x之后才有,2.7没有),其中 global 指定的变量直接指向(3)当前模块的全局变量,而nonlocal则指向(2)最内层之外,global以内的变量。这里... |
9,792 | <ASSISTANT_TASK:>
Python Code:
import os, subprocess
if not os.path.isfile('data/hg19.ml.fa'):
subprocess.call('curl -o data/hg19.ml.fa https://storage.googleapis.com/basenji_tutorial_data/hg19.ml.fa', shell=True)
subprocess.call('curl -o data/hg19.ml.fa.fai https://storage.googleapis.com/basenji_tutorial_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: Next, let's grab a few CAGE datasets from FANTOM5 related to heart biology.
Step2: Then we'll write out these BigWig files and labels to a samp... |
9,793 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
import tarfile
from IPython.display import display, Image
from scipy i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: First, we'll download the dataset to our local machine. The data consists of characters rendered in a variety of fonts on a 28x28 image. The lab... |
9,794 | <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:
Step3: Shor's algorithm
Step6: Order finding
Step8: For example, the multiplicative group modulo $n = 15$ is shown below.
Step11: One can check that... |
9,795 | <ASSISTANT_TASK:>
Python Code:
pip freeze | grep google-cloud-automl==1.0.1 || pip install google-cloud-automl==1.0.1
pip freeze | grep google-cloud-storage==1.27.0 || pip install google-cloud-storage==1.27.0
import os
from google.cloud import automl
import tensorflow as tf
PROJECT_ID = "YOUR_PROJECT_ID" # Replace wit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <br>
Step2: <br>
Step3: <br>
Step4: <br>
Step5: <br>
Step6: <br>
Step7: <br>
Step8: <br>
Step9: <br>
Step10: <br>
Step11: <br>
Step12:... |
9,796 | <ASSISTANT_TASK:>
Python Code:
import keras
import numpy as np
from keras.datasets import mnist
from keras.optimizers import Adam
from keras.models import Sequential
from keras.preprocessing import image
from keras.layers.core import Dense
from keras.layers.core import Lambda
from keras.layers.core import Flatten
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: I want to import Vgg16 as well because I'll want it's low-level features
Step2: Actually, looks like Vgg's ImageNet weights won't be needed.
St... |
9,797 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from random import randint
from pandas import Series,DataFrame
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib
import math
import time
%matplotlib inline
plt.rcParams['figure.figsize'] = (8, 6)
plt.rcParams['font.size'] = 14
d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Libraries available in python
Step2: Theano
Step3: Tensorflow
|
9,798 | <ASSISTANT_TASK:>
Python Code:
# This is for graph visualization.
from IPython.display import clear_output, Image, display, HTML
def strip_consts(graph_def, max_const_size=32):
Strip large constant values from graph_def.
strip_def = tf.GraphDef()
for n0 in graph_def.node:
n = strip_def.node.add()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step4: Boilerplate for graph visualization
Step5: Load the data
Step6: Create a simple classifier with low-level TF Ops
Step7: We can run this graph... |
9,799 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
plt.rcParams['figure.figsize'] = (20.0, 10.0)
plt.rcParams['font.family'] = "serif"
df = pd.pivot_table(data=sns.load_dataset("flights"),
index='month',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Default plot
Step2: cmap adjusts the colormap used. I like diverging colormaps for heatmaps because they provide good contrast.
Step3: center ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.