Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
9,900 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'sandbox-2', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,901 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn import datasets
from sklearn.cross_validation import train_test_split
from sklearn import tree
iris = datasets.load_iris()
x = iris.data[:,2:] #attributes
y = iris.target #target variable
dt = tree.Decis... | <SYSTEM_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. Load the iris dataset and create a holdout set that is 50% of the data (50% in training and 50% in test). Output the results (don't worry abo... |
9,902 | <ASSISTANT_TASK:>
Python Code:
def quicksort(arr, depth=0, pos="middle", verbose=False):
if len(arr) <= 1:
if verbose:
print("pos:", pos)
print("depth:", depth)
print("###")
return arr
pivot = arr[int(len(arr) / 2)]
left = [x for x in arr if x < pivot]
... | <SYSTEM_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 versions
Step2: Note that unlike many languages, Python does not have unary increment (x++) or decrement (x--) operators.
Step3: String... |
9,903 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'awi-cm-1-0-hr', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
9,904 | <ASSISTANT_TASK:>
Python Code:
# Python Standard Library
import getopt
import os
import sys
import math
import time
import collections
import random
# IPython
from IPython.display import display
# pandas
import pandas as pd
pd.set_option("display.max_rows", 10000)
pd.set_option("display.max_columns", 10000)
# Matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Helper Functions
Step2: Load the model classes
Step3: A class that takes a set of Python dictionaries containing Wi-Fi logging data loaded fro... |
9,905 | <ASSISTANT_TASK:>
Python Code:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, sof... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: # Creación y manipulación de tensores
Step2: ## Suma de vectores
Step3: ### Formas de tensores
Step4: ### Emisión
Step5: ## Producto de arre... |
9,906 | <ASSISTANT_TASK:>
Python Code:
import calendar
import datetime
import numpy
import os.path
import pickle
from random import randrange, random, shuffle
import sys
import time
import math
import nupic
from nupic.encoders import ScalarEncoder, MultiEncoder
from nupic.bindings.algorithms import SpatialPooler as SP
from nup... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <img src="http
Step2: <img src="http
Step3: <img src="http
|
9,907 | <ASSISTANT_TASK:>
Python Code:
# Series
import numpy as np
import pandas as pd
myArray = np.array([2,3,4])
row_names = ['p','q','r']
mySeries = pd.Series(myArray,index=row_names)
print (mySeries)
print (mySeries[0])
print (mySeries['p'])
# Dataframes
myArray = np.array([[2,3,4],[5,6,7]])
row_names = ['p','q']
col_names... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Working with Data
Step2: Normalizing data
Step3: We can use standard deviation to normalize data.
Step4: We are now going to normalize the da... |
9,908 | <ASSISTANT_TASK:>
Python Code:
# create the Client class below
class Client(object):
def __init__(self, name, balance):
self.name = name
self.balance = balance + 100
#define account level
if self.balance < 5000:
self.level = "Basic"
elif self.balance < 15... | <SYSTEM_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 attributes in Client are name, balance and level.
Step2: We can see the attributes of John_Doe, or Jane_Defoe by calling them
Step3: We c... |
9,909 | <ASSISTANT_TASK:>
Python Code:
example_belief = {'a', 'b'}
'a' in example_belief
'c' in example_belief
example_belief.add('c')
example_belief
example_belief = {'a', 'b'}
example_rules = [('a', 'b'), ('c', 'd')]
def print_rules(rules):
for rule in rules:
print(str(rule[0]) + " --> " + str(rule[1]))
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: As a quick refresher, Python sets are unique, unordered collections of objects. You can check if an item is in a set with the in keyword
Step2: ... |
9,910 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
df = pd.read_csv('data/driving_log.csv')
print(df.describe())
df['steering'].hist(bins=100)
plt.title('Histogram of steering angle (100 bins)')
df[df['steering'] < -0.5].index
import os
from PIL ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Seems that we are mostly steering straight here.
Step 2
Step2: By trial and error, I ended up picking index 4341 where the image matches the le... |
9,911 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
np.random.seed(0)
%matplotlib inline
X = np.arange(1, 1001, 1)
Y = 10*X + 4 + 400* np.random.randn(1000, )
plt.scatter(X, Y, s=0.1)
plt.xlabel("X")
plt.ylabel("Y")
from sklearn.linear_model import LinearRegression
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: Creating dataset
Step2: Learning a linear regression model on the entire data
Step3: Visualising the fit
Step4: Creating the initial train se... |
9,912 | <ASSISTANT_TASK:>
Python Code:
# Generator function for the cube of numbers (power of 3)
def gencubes(n):
for num in range(n):
yield num**3
for x in gencubes(10):
print x
def genfibon(n):
'''
Generate a fibonnaci sequence up to n
'''
a = 1
b = 1
for i in range(n):
yield ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Great! Now since we have a generator function we don't have to keep track of every single cube we created.
Step2: What is this was a normal fun... |
9,913 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'Date': ['2020-02-15 15:30:00', '2020-02-16 15:31:00', '2020-02-17 15:32:00', '2020-02-18 15:33:00', '2020-02-19 15:34:00'],
'Open': [2898.75, 2899.25, 2898.5, 2898.25, 2898.5],
'High': [2899.25, 2899.75, 2899, 2... | <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,914 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cccma', 'canesm5', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,915 | <ASSISTANT_TASK:>
Python Code:
### BEGIN SOLUTION
import sympy as sym
a, b, c = sym.Symbol("a"), sym.Symbol("b"), sym.Symbol("c")
sym.expand((9 * a ** 2 * b * c ** 4) ** (sym.S(1) / 2) / (6 * a * b ** (sym.S(3) / 2) * c))
### END SOLUTION
q1_a_answer = _
feedback_text = Your output is not a symbolic expression.
You 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:
Step2: Computing for Mathematics - Mock individual coursework
Step5: b. \((2 ^ {\frac{1}{2}} + 2) ^ 2 - 2 ^ {\frac{5}{2}}\)
Step8: \((\frac{1}{8}) ^ ... |
9,916 | <ASSISTANT_TASK:>
Python Code:
def expensive_deriver(num):
# 10 minutes pass...
return num * 100
# Our fake durable storage holding the first 8 derived elements
storage = {num: expensive_deriver(num) for num in range(8)}
# The ExtantArtifact accessing that data
class ExampleExtantArtifact(ExtantArtifact):
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: Now the ChannelManager code
Step2: Note that this class is not actually a subclass of ChannelManager, but it makes use of it in two ways
Step3:... |
9,917 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import os
import re
import seaborn as sns
from datetime import datetime as dt
from support_funs_incubation import stopifnot, uwords, idx_find, find_beside, ljoin, sentence_find, record_vals
!pip install ansicolors
# Takes a tuple (list(idx), sentence... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Section 1
Step2: Section 2
Step3: Section 4
Step4: Section 5
Step5: The figure above shows thats the point estimates, especially for the mea... |
9,918 | <ASSISTANT_TASK:>
Python Code:
# Select test_size and random_state for splitting a subset
test_size=0.1
random_state=0
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import time
import gzip
import shutil
import seaborn as sns
from collections import ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step 1 (sensitivity check, run 1)
Step1: Do some preprocessing to group the data by 'Anon Stud Id' and extract features for further analysis
Step2: No... |
9,919 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%pylab inline
import fwdpy as fp
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import copy
nregions = [fp.Region(0,1,1),fp.Region(2,3,1)]
sregions = [fp.ExpS(1,2,1,-0.1),fp.ExpS(1,2,0.01,0.001)]
rregions = [fp.Region(0,3,1)]
rng = fp.GSLrng(101)... | <SYSTEM_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 a simulation
Step2: Group mutation trajectories by position and effect size
Step3: The only fixation has an 'esize' $> 0$, which means tha... |
9,920 | <ASSISTANT_TASK:>
Python Code:
import kwant
import tbmodels
import numpy as np
import scipy.linalg as la
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
model = tbmodels.Model.from_wannier_files(hr_file='data/wannier90_hr.dat')
lattice = model.to_kwant_lattice()
sym =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bulk Hamiltonian with wraparound
Step2: First we need to create the lattice from the tight-binding model and define the translation symmetries.... |
9,921 | <ASSISTANT_TASK:>
Python Code:
import os
import re
import json
import string
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tokenizers import BertWordPieceTokenizer
from transformers import BertTokenizer, TFBertModel, BertConfig
max_len = 384
configurati... | <SYSTEM_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 BERT tokenizer
Step2: Load the data
Step3: Preprocess the data
Step4: Create the Question-Answering Model using BERT and Functional AP... |
9,922 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib
%matplotlib inline
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import confusion_matrix
from sklearn.cross_validation import train_test_split
import pickle
import time
time1=time.strftime('%Y-%m-%d_%H-%M-%S')
<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: Carregando um arquivo csv em um DataFrame do Pandas
|
9,923 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image('images/02_network_flowchart.png')
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from sklearn.metrics import confusion_matrix
import time
from datetime import timedelta
import math
import os
# Use Pre... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Imports
Step2: This was developed using Python 3.5.2 (Anaconda) and TensorFlow version
Step3: PrettyTensor version
Step4: Load Data
Step5: T... |
9,924 | <ASSISTANT_TASK:>
Python Code:
import keras
from keras.datasets import imdb
from keras.preprocessing.sequence import pad_sequences
from keras.models import Sequential
from keras.layers import Dense, Flatten, Dropout
from keras.layers import Embedding # new!
from keras.callbacks import ModelCheckpoint # new!
import os ... | <SYSTEM_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 hyperparameters
Step2: Load data
Step3: Restoring words from index
Step4: Preprocess data
Step5: Design neural network architecture
Step... |
9,925 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data
y = iris.target
from sklearn.neighbors import KNeighborsClassifier
model = KNeighborsClassifier(n_neighbors=1)
model.fit(X, y)
y_model = model.predict(X)
from sklearn.metrics import accuracy_score
accuracy_score(y,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next we choose a model and hyperparameters
Step2: Then we train the model, and use it to predict labels for data we already know
Step3: Finall... |
9,926 | <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,927 | <ASSISTANT_TASK:>
Python Code:
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.interpolate import cross_section
data = xr.open_dataset(get_test_data('narr_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: Getting the data
Step2: Define start and end points
Step3: Get the cross section, and convert lat/lon to supplementary coordinates
Step4: For... |
9,928 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'gfdl-am4', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,929 | <ASSISTANT_TASK:>
Python Code:
import geosoft.gxpy.gx as gx
import geosoft.gxpy.grid as gxgrid
import geosoft.gxpy.utility as gxu
from IPython.display import Image
gxc = gx.GXpy()
url = 'https://github.com/GeosoftInc/gxpy/raw/9.3/examples/tutorial/Grids%20and%20Images/'
gxu.url_retrieve(url + 'elevation_surfer.GRD')
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convert a grid from one format to another
Step2: Working with Grid instances
Step3: Displaying a grid
Step4: A nicer image might include a ne... |
9,930 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'sandbox-3', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
9,931 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%load_ext autoreload
%autoreload 2
import numpy as np
import matplotlib.pyplot as plt
import pymks
from pymks.datasets import make_cahn_hilliard
n = 41
n_samples = 400
dt = 1e-2
np.random.seed(99)
X, y = make_cahn_hilliard(n_samples=n_samples, size=(n, n), dt=dt)
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: Modeling with MKS
Step2: The function make_cahnHilliard generates n_samples number of random microstructures, X, and the associated updated mic... |
9,932 | <ASSISTANT_TASK:>
Python Code:
x = 10 # x é um inteiro
print type(x)
x = 1.3 # x é um ponto flutuante
print type(x)
x = "Ola" # x é uma string
print type(x)
x = [1, 5, 10] # x é uma lista
print type(x)
x = 10
for i in range(20):
# Início da repetição For
x = x + 1
if x%2 == 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: (1b) Indentações
Step2: (1c) Funções
Step3: (1d) Tipos Especiais
Step4: (1e) Iteradores
Step5: (1f) Geradores e List Comprehension
Step... |
9,933 | <ASSISTANT_TASK:>
Python Code:
from dx import *
import seaborn as sns; sns.set()
import time
t0 = time.time()
r = constant_short_rate('r', 0.06)
me1 = market_environment('me1', dt.datetime(2015, 1, 1))
me2 = market_environment('me2', dt.datetime(2015, 1, 1))
me1.add_constant('initial_value', 36.)
me1.add_constant('vol... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: There are the following multiple risk factor valuation classes available
Step2: We assum a positive correlation between the two risk factors.
S... |
9,934 | <ASSISTANT_TASK:>
Python Code:
%env THEANO_FLAGS=device=cuda0
import matplotlib.pyplot as plt
%matplotlib inline
import gelato
import theano
import theano.tensor as tt
theano.config.warn_float64 = 'warn'
import numpy as np
import lasagne
import pymc3 as pm
from sklearn.datasets import fetch_mldata
from sklearn.model_s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Data
Step2: Create priors for weights (Spec classes)
Step3: Spec behaves like a tensor and has the same methods
Step4: Methods are used ... |
9,935 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
variables = (x, y, z, w) = symbols('x y z w', real=True)
print(variables)
metric=[ 1
,1
,1
,1]
myBasis='e_1 e_2 e_3 e_4'
sp4d = Ga(myBasis, g=metric, coords=variables,norm=True)
(e_1, e_2, e_3, e_4) = sp4d.mv()
sigma_1w=e_2*e_3
sigma_2w=e_3*e_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: Quaternions - Pauli matrices
Step2: PHYSICS
|
9,936 | <ASSISTANT_TASK:>
Python Code:
from dx import *
import seaborn as sns; sns.set()
ma = market_environment('ma', dt.date(2010, 1, 1))
ma.add_list('symbols', ['AAPL', 'GOOG', 'MSFT', 'FB'])
ma.add_constant('source', 'google')
ma.add_constant('final date', dt.date(2014, 3, 1))
%%time
port = mean_variance_portfolio('am_te... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Market Environment and Portfolio Object
Step2: Using pandas under the hood, the class retrieves historial stock price data from either Yahoo! F... |
9,937 | <ASSISTANT_TASK:>
Python Code:
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
mnist = input_data.read_data_sets('MNIST_data', one_hot = True)
################## build a softmax regression model
# input data
x = tf.placeholder(tf.float32, shape = [None, 784])
# real labels
y_ = tf.pla... | <SYSTEM_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 Multilayer Convolutional Network
Step2: Convolution and Pooling
Step3: First Convolutional Layer
Step4: To apply the layer, we first ... |
9,938 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from numpy import *
from scipy.integrate import odeint
from matplotlib.pyplot import *
ion()
def RM(y, t, r, K, a, h, e, d):
return array([ y[0] * ( r*(1-y[0]/K) - a*y[1]/(1+a*h*y[0]) ),
y[1] * (e*a*y[0]/(1+a*h*y[0]) - d) ])
t = arange(0, 1000, .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: For the parameters chosen above, the long-term (asymptotic) solution is a fixed point. Let's see this in the phase space, that is, the space of ... |
9,939 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
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 Conv2D, MaxPooling2D
from keras.utils import np_utils
from keras.wrappe... | <SYSTEM_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 Preparation
Step2: Build Model
Step3: GridSearch HyperParameters
|
9,940 | <ASSISTANT_TASK:>
Python Code:
import ticdat.testing.testutils as tdu
from ticdat import TicDatFactory
tdf = TicDatFactory(**tdu.netflowSchema())
dat = tdf.copy_tic_dat(tdu.netflowData())
dat.cost
df_cost = tdf.copy_to_pandas(dat).cost
df_cost
df_cost.index
('Pens', 'Denver', 'Seattle') in df_cost
('Pens', 'Denver',... | <SYSTEM_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 let's look at a couple of different types of tables, and see what how copy_to_pandas handles different types of data. Here is the "cost" tab... |
9,941 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
from tensorflow import keras
layer = keras.layers.Dense(3)
layer.build((None, 4)) # Create the weights
print("weights:", len(layer.weights), layer.weights)
print("trainable_weights:", len(layer.trainable_weights),layer.trainable_weights)
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: 介绍,Introduction
Step2: 通常,所有的权重都是可以训练的权重。keras自带的layer中只有BatchNormalization有不可训练的权重。BatchNormalization使用不可训练的权重来跟踪训练过程中输入的mean和variance。
Step3:... |
9,942 | <ASSISTANT_TASK:>
Python Code:
g = grid.make_cube_grid__2d_simplex_aluconform(lower_left=[0, 0], upper_right=[1, 1], num_elements=[4, 4], num_refinements=2, overlap_size=[0, 0])
#g.visualize('grid')
#bump = functions.make_expression_function_1x1(g, 'x', 'cos(0.5*pi*x[0])*cos(0.5*pi*x[1])', order=3, name='bump')
#one =... | <SYSTEM_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{align}\kappa(x; \mu) &
|
9,943 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
import matplotlib.pyplot as pyp
%matplotlib inline
# S -> P*S - B*S*Z - d*S
S = 500
# Z -> B*S*Z + G*R - A*S*Z
Z = 0
# R -> d*S - G*R
R = 0
P = 0.0001 # birth rate
d = 0.01 # 'natural' death percent (per day)
B = 0.0095 # transmission percent (per day)
G... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Deterministic, continuous solution
Step2: Stochastic, discrete solution
|
9,944 | <ASSISTANT_TASK:>
Python Code:
import os
assert os.environ["COLAB_TPU_ADDR"], "Make sure to select TPU from Edit > Notebook settings > Hardware accelerator"
import os
if "google.colab" in str(get_ipython()) and "COLAB_TPU_ADDR" in os.environ:
import jax
import jax.tools.colab_tpu
jax.tools.colab_tpu.setup_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: Cloning Clip_jax
Step2: pmapping the encoding function and replicating the params.
Step3: Dataset
Step4: Loading tfds
Step5: Model
Step7: D... |
9,945 | <ASSISTANT_TASK:>
Python Code:
plt.scatter?
##Some code to run at the beginning of the file, to be able to show images in the notebook
##Don't worry about this cell but run it
#Print the plots in this screen
%matplotlib inline
#Be able to plot images saved in the hard drive
from IPython.display import Image,display
#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: Assignment 1 (ungraded but important). Read some tutorials
Step2: Assignment 2
Step3: Assignment 3
Step4: Assignment 4
Step5:
Step6: What ... |
9,946 | <ASSISTANT_TASK:>
Python Code:
!pip install nltk
import nltk
nltk.download('wordnet')
from nltk.corpus import wordnet as wn
club_synsets = wn.synsets('club')
print(club_synsets)
for synset in club_synsets:
print("{0}\t{1}".format(synset.name(), synset.definition()))
dog = wn.synsets('dog')[0]
dog.definition()
... | <SYSTEM_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 nltk and use its internal download tool to get WordNet
Step2: Import the wordnet module
Step3: Access synsets of a word using the synse... |
9,947 | <ASSISTANT_TASK:>
Python Code:
Factors-and-primes functions.
Find factors or primes of integers, int ranges and int lists
and sets of integers with most factors in a given integer interval
def factorize(n):
Calculate all factors of integer n.
factors = []
if isinstance(n, int) and n > 0:
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:
Step7: Python Environment
Step8: Next we will call the factorize() function to calculate the factors of an integer.
Step9: The primes_between() funct... |
9,948 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
#config InlineBackend.figure_format = 'pdf'
from IPython.core.display import HTML
import gensim as gen
import gensim.models.word2vec as w2v
import matplotlib.pyplot as plt
from nltk.tokenize... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Gensim word2vec
Step2: Train a word2vec model
Step3: Create a representation of each paper
Step4: Load the saved pickle and check
Step5: fil... |
9,949 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
# Import the dataset
dataset_path = "spam_dataset.csv"
dataset = pd.read_csv(dataset_path, sep=",")
# Take a peak at the data
dataset.head()
# Reorder the data columns and drop email_id
cols = dataset.columns.tolist()
cols = cols[2:] + [cols[1]]
dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Cleaning up and summarizing the data
Step2: 3) Splitting data into training and testing sets
Step3: 4. Running algorithms on the data
Step4... |
9,950 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('home_data.gl/')
sales
graphlab.canvas.set_target('ipynb')
sales.show(view="Scatter Plot", x="sqft_living", y="price")
train_data,test_data = sales.random_split(.8,seed=0)
sqft_model = graphlab.linear_regression.create(train_data, target='price'... | <SYSTEM_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 some house sales data
Step2: Exploring the data for housing sales
Step3: Create a simple regression model of sqft_living to price
Step4: ... |
9,951 | <ASSISTANT_TASK:>
Python Code:
data_dir = './data'
# FloydHub - Use with data ID "R5KrjnANiKVhLWAkpXhNBe"
#data_dir = '/input'
DON'T MODIFY ANYTHING IN THIS CELL
import helper
helper.download_extract('mnist', data_dir)
helper.download_extract('celeba', data_dir)
show_n_images = 25
DON'T MODIFY ANYTHING IN THIS CELL
%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: Face Generation
Step3: Explore the Data
Step5: CelebA
Step7: Preprocess the Data
Step10: Input
Step13: Discriminator
Step16: Generator
Ste... |
9,952 | <ASSISTANT_TASK:>
Python Code:
import networkx as nx
G = nx.read_gpickle('datasets/divvy_2013/divvy_graph.pkl')
total_trips = sum([d['count'] for _,_,d in G.edges(data=True)])
print(total_trips)
float(total_trips) / len(G.nodes()) ** 2
from collections import Counter
import matplotlib.pyplot as plt
%matplotlib inline... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercise
Step2: Exercise
Step3: Exercise
Step4: Computing the interval between the 2.5th to the 97.5th percentile effectively gives you a cen... |
9,953 | <ASSISTANT_TASK:>
Python Code:
import sys
import numpy as np
from scipy.stats import linregress
import matplotlib.pyplot as plt
%matplotlib inline
#Input spectrum files
seisfile="F2_01_seismic_amplitude_spectrum.dat"
wellfile="F2_01_well_AI_amplitude_spectrum.dat"
#Shape parameter for Kaiser window
beta=150
#Normalize... | <SYSTEM_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 input and output files and input parameters for operator estimation
Step2: Load spectrums from input files, and calculate linear reg... |
9,954 | <ASSISTANT_TASK:>
Python Code:
# EIA NERC region shapefile, which has an "Indeterminate" region
# path = os.path.join(data_path, 'NERC_Regions_EIA', 'NercRegions_201610.shp')
# regions = gpd.read_file(path)
# regions.crs
path = os.path.join(data_path, 'nercregions', 'NERCregions.shp')
regions_nerc = gpd.read_file(path)... | <SYSTEM_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 using NERC region shapefiles created by DHS
Step2: Maps of 2001 and 2017 annual values
Step3: Maps of difference from national average
Ste... |
9,955 | <ASSISTANT_TASK:>
Python Code:
# import statements to make numeric and plotting functions available
%matplotlib inline
from numpy import *
from matplotlib.pyplot import *
## We'll specify the behavior of X as a series of pulse of different length
## so we'll define a function to generate pulses
def pulse(ontime, offtim... | <SYSTEM_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 Python functions for dY/dt and dZ/dt
Step2: <h3> <font color='firebrick'>Questions</font> </h3>
Step3: To Explore
Step4: Type 1 Cohere... |
9,956 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
train_data,test_data = sales.random_split(.8,seed=0)
# Let's compute the mean of the House Prices in King County in 2 different ways.
prices = sales['price'] # extract the price column of the sales SFrame -- this is now an SA... | <SYSTEM_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 house sales data
Step2: Split data into training and testing
Step3: Useful SFrame summary functions
Step4: As we see we get the same ans... |
9,957 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import re
import numpy as np
import dbpedia_config
from scipy.stats import chisquare
target_folder = dbpedia_config.TARGET_FOLDER
apost = re.compile('_s$')
female_pmi = pd.read_csv('{0}/top-200-pmi-female.csv'.format(target_folder), encoding='utf-8')
female_pmi.word ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Data
Step2: Here we load the DataFrame from the previous notebook. Note that there is an additional column cat.
Step3: Test Proportions a... |
9,958 | <ASSISTANT_TASK:>
Python Code:
# encoding: utf-8
%matplotlib inline
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
focos = gpd.read_file(r"C:\Users\dougl\Desktop\programacao\focos_2016\focos_2016.shp")
focos["timestamp"] = pd.to_datetime(focos["DataHora"])
focos_tocantins = focos[focos.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: Para que o notebook IPython coloque as figuras geradas pela matplotlib inline
Step2: Bibliotecas
Step3: <font size="3" face="Times"><h1 style=... |
9,959 | <ASSISTANT_TASK:>
Python Code:
import sys ;
CHAR_BIT = 8 ;
INT_BIT = sys . getsizeof(int() ) ;
def Min(x , y ) :
return y +(( x - y ) &(( x - y ) >>(INT_BIT * CHAR_BIT - 1 ) ) ) ;
def Max(x , y ) :
return x -(( x - y ) &(( x - y ) >>(INT_BIT * CHAR_BIT - 1 ) ) ) ;
x = 15 ;
y = 6 ;
print("Minimum... | <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,960 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
tf.set_random_seed(1337)
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
import matplotlib.pyplot as plt
def show_sample(index):
image = mnist.train.images[index].reshape(28, 28) # 784 ... | <SYSTEM_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 MNIST dataset
Step2: Every MNIST sample has two parts
Step3: Inputs
Step4: Our first classification model
Step5: Learning the model para... |
9,961 | <ASSISTANT_TASK:>
Python Code:
def query_TAP(tap_endpoint, adql_query, table_to_upload=None):
Query a TAP service (designated by its tap_endpoint)
with a given ADQL query
Query is performed synchronously
Return an AstroPy Table object
import requests
from astropy.table import... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Defining some utilitary functions and importing some modules
Step2: Query Gaia tables in VizieR
Step3: By default, output is limited to 50 row... |
9,962 | <ASSISTANT_TASK:>
Python Code:
# Load function
import emukit.test_functions.forrester
# The multi-fidelity Forrester function is already wrapped as an Emukit UserFunction object in
# the test_functions package
forrester_fcn, _ = emukit.test_functions.forrester.multi_fidelity_forrester_function()
forrester_fcn_low = fo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plot Functions
Step2: Bayesian optimization
Step3: Generate Initial Data
Step4: Define Model
Step5: Define Acquisition Function
Step6: Crea... |
9,963 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
a = 20.
b = 13.
x = 21.
y = 23.
z = 30.
p2 = 1.
p1 = a**2 + b**2 - (x**2) - (y**2) - (z**2)
p0 = (a*b)**2 - (b*x)**2 - (a*y)**2 - (a*z)**2
rho_min = -a**2 - 100.
rho_max = -b**2 + 2000.
rho = np.linspace(rho_min, rho... | <SYSTEM_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 follow the reasoning presented by Webster (1904) for analyzing the ellipsoidal coordinate $\lambda$ describing a prolate ellipsoid.
St... |
9,964 | <ASSISTANT_TASK:>
Python Code:
# Uses pip3 to install necessary package (lightgbm)
!pip3 install lightgbm
# Resets the IPython kernel to import the installed package.
import IPython
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
import os
from git import Repo
# Current working directory
repo_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: Necessary packages and functions call
Step2: Data loading & Select source, target, validation datasets
Step3: Data preprocessing
Step4: Run D... |
9,965 | <ASSISTANT_TASK:>
Python Code:
t=0
if t > 60:
print('its very hot')
elif t > 50:
print('its hot')
elif t > 40:
print('its warm')
else:
print('its cool')
t=55
if t > 40:
print('its very hot')
elif t > 50:
print('its hot')
elif t > 60:
print('its warm')
else:
print('its cool')
i=0
while 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: S be carefull!
Step2: Queez
Step3: Control Statments
Step4: tuple
Step5: Dictionaries
Step6: set
Step7: List comprehention
Step8: Generat... |
9,966 | <ASSISTANT_TASK:>
Python Code:
# re-load the saved data if needed
A = np.load('/home/nick/Documents/LewisUniversity/MachineLearning/Project/visionmatrix.npy')
#Let's start with the model parameters defined in the Week6 notebook for this data, changing the input shape as appropriate.
from keras.models import 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: This model is by no means great, but it does predict with .63 recall and .54 precision.
Step2: This is a much worse model, and it is always pre... |
9,967 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Barachant <alexandre.barachant@gmail.com>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cross_validation import StratifiedKFold
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LogisticRegression... | <SYSTEM_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 and read data
|
9,968 | <ASSISTANT_TASK:>
Python Code:
!./rungeogebra
show_dct_fig()
img = mpimg.imread('img/abel.jpg'); plt.imshow(img, cmap=mpl.cm.gray);
show_image(img)
tiny = img[40:48, 64:72];show_image(tiny)
tinyDCT = doDCT(tiny);show_image(tinyDCT)
figure(figsize=(12,36))
for u in range(12):
subplot(6, 2, u+1)
title(str(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: 你的數學書在吶喊著:
Step2: <img src="img/Dctjpeg.png" width="600"/>
Step3: $$ G = {DCT} \cdot f \cdot {DCT}^{T} $$
Step4: Hybrid Image
Step5: 更多更多
|
9,969 | <ASSISTANT_TASK:>
Python Code:
def predict(x_i, beta):
return dot(x_i, beta)
def error(x_i, y_i, beta):
return y_i - predict(x_i, beta)
def squared_error(x_i, y_i, beta):
return error(x_i, y_i, beta)**2
def squared_error_gradient(x_i, y_i, beta):
return [-2 * x_ij * error(x_i, y_i, beta) for x_ij in x_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Further Assumptions Of The Least Squares Model
Step2: Above does not match the book, could not get code to work as shown.
|
9,970 | <ASSISTANT_TASK:>
Python Code:
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import netCDF4 as nc
from mpl_toolkits.basemap import Basemap
%%time
heights = [] # empty array to append opened netCDF's to
temps = []
date_range = np.arange... | <SYSTEM_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 Import Some Data through NOAA
Step2: Take a peak to ensure everything was read successfully and understand the dataset that you have
Step... |
9,971 | <ASSISTANT_TASK:>
Python Code:
module use /global/common/$NERSC_HOST/contrib/desi/modulefiles
module load desiconda/20170719-1.1.9-imaging
conda create --prefix $CSCRATCH/conda-envs/20170719-1.1.9-imaging --file $DESICONDA/pkg_list.txt
source activate $CSCRATCH/conda-envs/20170719-1.1.9-imaging
# SF98 dust maps
export... | <SYSTEM_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 sure it all works by running a test case
Step2: Setup that went into test/test_decam_rex.py
Step7: "brick 1102p240" is in the survey-bric... |
9,972 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib
matplotlib.rcParams['figure.figsize'] = (6, 6)
import math
import cmath # math functions for complex numbers
import numpy as np
import matplotlib.pyplot as plt
import ipywidgets
from ipywidgets import interact
import sympy as sp
# See: http://... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TODO
Step2: \begin{eqnarray}
Step3: \begin{eqnarray}
Step4: \begin{eqnarray}
Step5: \begin{eqnarray}
Step6: \begin{eqnarray}
Step7: \begin... |
9,973 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import holoviews as hv
%reload_ext holoviews.ipython
np.random.seed(10)
def sine_curve(phase, freq, amp, power, samples=102):
xvals = [0.1* i for i in range(samples)]
return [(x, amp*np.sin(phase+freq*x)**power) for x in xvals]
phases = [0, np.pi/2, np.pi, ... | <SYSTEM_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 code produces what looks like a relatively simple animation of two side-by-side figures, but is actually a deeply nested data structure
Ste... |
9,974 | <ASSISTANT_TASK:>
Python Code:
import os
os.chdir('..')
# Import all the packages we need to generate recommendations
import numpy as np
import pandas as pd
import src.utils as utils
import src.recommenders as recommenders
import src.similarity as similarity
# imports necesary for plotting
import matplotlib
import matp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Understanding Movie Similarity
Step2: Creating recommendations for your personal ratings
|
9,975 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
from scipy.misc import imread, imresize
import numpy as np
from scipy.misc import imread
import matplotlib.pyplot as plt
# Helper functions to deal with image preprocessing
from cs231n.image_utils import load_image, preprocess_image, deprocess_image
%mat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Style Transfer
Step2: Load the pretrained SqueezeNet model. This model has been ported from PyTorch, see cs231n/classifiers/squeezenet.py for t... |
9,976 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from landlab import RasterModelGrid, FieldError
from landlab.components import LinearDiffuser
mg = RasterModelGrid((3, 4))
# demonstrate that arrays of properties are n-elements long
(
mg.x_of_node.shape == (mg.number_of_nodes,)
and mg.length_of_link.shape == (... | <SYSTEM_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 discussed in the grid tutorial, all data stored on the grid exists as "flat" one-dimensional arrays. This means that information can be retrie... |
9,977 | <ASSISTANT_TASK:>
Python Code:
from datetime import datetime
# Pandas and NumPy
import pandas as pd
import numpy as np
# Matplotlib for additional customization
from matplotlib import pyplot as plt
%matplotlib inline
# Seaborn for plotting and styling
import seaborn as sns
# 1. Flight delay: any flight with (real_depar... | <SYSTEM_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 - Dataset
Step2: Some EDA's tasks
Step3: 2 - Local airports (list with all the ~600 brazilian public airports)
Step4: 3 - List of codes (tw... |
9,978 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn
import porekit
import re
import pysam
import random
import feather
%matplotlib inline
directories = ["AmpliconOddEvenControl", "AmpliconOddReadUntil", "AmpliconEvenRea... | <SYSTEM_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 metadata for 4 datasets
Step2: The individual filenames will look like this
Step3: Merging alignment data
Step4: Unfortunately filenames... |
9,979 | <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... |
9,980 | <ASSISTANT_TASK:>
Python Code:
%bash
apt-get update
apt-get -y install python-mpltoolkits.basemap
from mpl_toolkits.basemap import Basemap
import google.datalab.bigquery as bq
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
query=
#standardSQL
SELECT
name,
latitude,
longitude,
iso_time... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2017 Hurricane Tracks
Step2: Plot one of the hurricanes
Step3: Plot all the hurricanes
|
9,981 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import neurodsp
%matplotlib inline
import matplotlib.pyplot as plt
np.random.seed(0)
freq = 10
T = 100
Fs = 1000
cycle_features_use = {'amp_mean': 1, 'amp_burst_std': 0, 'amp_std': 0,
'period_mean': 100,
'period_burst_std': 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. Effect of bursting changes on PSD
Step2: 2. Effect of period changes on PSD
Step3: 3. Effect of symmetry changes on PSD
|
9,982 | <ASSISTANT_TASK:>
Python Code:
import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False)
raw.crop(tmax=60).... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Background
Step2: If a scalp electrode was used as reference but was not saved alongside the
Step3: By default,
Step4: .. KEEP THESE BLOCKS ... |
9,983 | <ASSISTANT_TASK:>
Python Code:
import logging
import os
from gensim import corpora, utils
from gensim.models.wrappers.dtmmodel import DtmModel
import numpy as np
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logging.debug("test")
documents = [[u'senior', u'studios', u'studios', u'studios', u'creators', ... | <SYSTEM_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 wil setup logging
Step2: Now lets load a set of documents
Step3: This corpus contains 10 documents. Now lets say we would like to mod... |
9,984 | <ASSISTANT_TASK:>
Python Code:
from nltk.tokenize.punkt import PunktSentenceTokenizer
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
import networkx as nx
import re
import urllib2
from bs4 import BeautifulSoup
import pandas as pd
# -*- coding: ut... | <SYSTEM_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: Step 4
Step4: Step 5
Step5: Step 6
Step6: Step 7
Step7: Step 8
Step8: Step 9
|
9,985 | <ASSISTANT_TASK:>
Python Code:
import os
# The Google Cloud Notebook product has specific requirements
IS_GOOGLE_CLOUD_NOTEBOOK = os.path.exists("/opt/deeplearning/metadata/env_version")
# Google Cloud Notebook requires dependencies to be installed with '--user'
USER_FLAG = ""
if IS_GOOGLE_CLOUD_NOTEBOOK:
USER_FLAG... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Restart the kernel
Step2: Set up your Google Cloud project
Step3: Otherwise, set your project ID here.
Step4: Authenticate your Google Cloud ... |
9,986 | <ASSISTANT_TASK:>
Python Code:
import lasagne
from lasagne.layers import InputLayer
from lasagne.layers import Conv2DLayer, Pool2DLayer
from lasagne.layers import DenseLayer
from lasagne.layers import GlobalPoolLayer
from lasagne.layers import ConcatLayer
from lasagne.layers.normalization import batch_norm
import numpy... | <SYSTEM_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 model parameters and metadata¶
Step2: Trying it out
Step3: On some test images from the web
Step4: Process test images and print top... |
9,987 | <ASSISTANT_TASK:>
Python Code:
e = np.random.randn(50)
w = 3
x = np.random.rand(50)*np.random.randint(0,10,50)
y = w*x + 2*e
x
x[41], y[41]
sns.regplot(x, y, ci=False)
plt.plot((x[25], x[25]), (13, y[25]-0.3), 'r:');
plt.plot((x[41], x[41]), (y[41]+0.3, 14.5), 'r:');
import pandas as pd
from pandas import DataFrame 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: Read data files to dict
Step2: EDA
Step3: Batting
Step4: Pair Plots
|
9,988 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as sig
import control
import plot_learning_curve as plc
num_failures, time_steps_to_failure = control.simulate()
print(num_failures)
plot = plc.plot_learning_curve(time_steps_to_failure[:num_failures])
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: Part 6.a
Step2: Part 6.b.
|
9,989 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from astropy.table import Table
import matplotlib.pyplot as plt
%matplotlib inline
# execute this cell
from astroquery.sdss import SDSS # enables direct queries to the SDSS database
TSquery = SELECT TOP 10000
p.psfMag_r, p.fiberMag_r, p.fiber2Mag_r, p.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: Problem 1) Obtain and Examine Training Data
Step3: While it is possible to look up each of the names of the $r$-band magnitudes in the SDSS Pho... |
9,990 | <ASSISTANT_TASK:>
Python Code:
import pprint
def get_client():
from pymongo import MongoClient
return MongoClient('mongodb://localhost:27017/')
def get_db():
# 'examples' here is the database name. It will be created if it does not exist.
db = get_client().examples
return db
def add_city(db... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Flexible Schema
Step2: projections
Step3: Getting Data into MongoDB
Step4: Using mongoimport
Step5: These operators can also be used with da... |
9,991 | <ASSISTANT_TASK:>
Python Code:
# ceci est un commentaire, l'interpréteur ne le lit même pas
# les commentaires sont destinés au lecteur humain du code source
code = 'sesame' #affectation de variable
rep = input('Entrez le code : ') #affectation et instruction d'entrée
if rep == 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: Exercice 0
Step2: Les opérateurs arithmétiques suivent des règles de précédence (priorité de l'exponentiation sur la multiplication et de la mu... |
9,992 | <ASSISTANT_TASK:>
Python Code::
import tensorflow as tf
model = tf.keras.Model()
model.add(tf.keras.layers.Input((width, height, channels)))
model.add(tf.keras.layers.Lambda(lambda x: x / 255))
model.add(tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same'))
model.add(tf.... | <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,993 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
from load_utils import *
from analysis_utils import compare_groups,get_genders
d = load_diff... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Attacker Specific Analysis
Step2: Attack
Step3: Q
Step4: Victim Specific Analysis
Step5: Shared Analysis
Step6: Q
Step7: Q
Step8: Q
Step9... |
9,994 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
num_shares = np.asarray([30000, 60000, 10000])
prices = np.asarray([30, 31, 33])
np.dot(num_shares, prices)
# Get the average trade price
print "Average trade price: %s" % (np.mean(prices))
# Get the volume weighted 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: So total dollar volume is $3.09$ million USD. Notice that this is equivalent to taking the dollar volume averaged price and multiplying by the n... |
9,995 | <ASSISTANT_TASK:>
Python Code:
PROJECT_ID = "[your-project-id]" #@param {type:"string"}
! gcloud config set project $PROJECT_ID
import sys
# If you are running this notebook in Colab, run this cell and follow the
# instructions to authenticate your GCP account. This provides access to your
# Cloud Storage bucket and 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: Authenticate your GCP account
Step2: Create a Cloud Storage bucket
Step3: Only if your bucket doesn't already exist
Step4: Finally, validate ... |
9,996 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
mat = [[1.0, 0.0],[0.0,1.0] ] # matrice de type liste de listes
with open ("mat.txt", "w") as f : # création d'un fichier en mode écriture
for i in range (0,len (mat)) : # ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fichiers
Step2: Le même programme mais écrit avec une écriture condensée
Step3: On regare les premières lignes du fichier mat2.txt
Step4: L... |
9,997 | <ASSISTANT_TASK:>
Python Code:
# Figure 1
Image(url="https://cntk.ai/jup/201/cifar-10.png", width=500, height=500)
# Figure 2
Image(url="https://cntk.ai/jup/201/Conv2D.png")
# Figure 3
Image(url="https://cntk.ai/jup/201/Conv2DFeatures.png")
# Figure 4
Image(url="https://cntk.ai/jup/201/MaxPooling.png", width=400, he... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The above image is from
Step2: The stack of feature maps output are the input to the next layer.
Step3: Gradient-Based Learning Applied to Doc... |
9,998 | <ASSISTANT_TASK:>
Python Code:
from sklearn import tree
X = [[0, 0], [1, 1]]
Y = [0, 1]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, Y)
clf.predict([[2., 2.]])
clf.predict_proba([[2., 2.]])
X = [[0, 0], [2, 2]]
y = [0.5, 2.5]
clf = tree.DecisionTreeRegressor()
clf = clf.fit(X, y)
clf.predict([[1, 1]])
<END_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: Classification
Step2: http
|
9,999 | <ASSISTANT_TASK:>
Python Code:
# create one numpy_map array for positives and 12 for negatives
idx = positives_train
p = get_aa_frequencies(positives[idx,0])
p_train, p_filename = store_data_numpy(np.hstack(p).T, float)
# set the positive validation array
idx = positives_validation
p_valid = get_aa_frequencies(positive... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linear modeling, subsampling the negative set ~20 times
Step2: Charge can predict TAD with AUC=0.88 <br> aminoacid composition with AUC=0.93 (w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.