Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
6,600 | <ASSISTANT_TASK:>
Python Code:
print(
This is some printed text,
with a nicely formatted output.
)
Image('example.jpg',height=400)
plt.scatter(np.random.rand(10), np.random.rand(10),
label='data label')
plt.ylabel(r'a y label with latex $\alpha$')
plt.legend();
df = pd.DataFrame(np.random.rand(3,4),colu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Markdown
Step2: Images and Figures
Step3: Displaying a plot with its code
Step4: Tables (with pandas)
Step5: Equations (with ipython or symp... |
6,601 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import os, sys
import re, json
from urllib.parse import urlparse
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.preprocessing import Imputer, FunctionTransformer
from sklearn.pipeline import Pipeline, FeatureUnion
from sklearn.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Text Features based on the boiler plate
Step2: Split into training and test sets.
Step3: Load Textual Features Prepared from raw content
Step5... |
6,602 | <ASSISTANT_TASK:>
Python Code:
# you would normaly install eppy by doing
# python setup.py install
# or
# pip install eppy
# or
# easy_install eppy
# if you have not done so, uncomment the following three lines
import sys
# pathnameto_eppy = 'c:/eppy'
pathnameto_eppy = '../'
sys.path.append(pathnameto_eppy)
from eppy... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: When things go wrong in your eppy script, you get "Errors and Exceptions".
Step2: Now let us open file fname1 without setting the idd file
Ste... |
6,603 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd, numpy as np, scipy.sparse as sp
import os, gc, regex as re, time as tm
import matplotlib.pyplot as plt
%matplotlib inline
DATADIR = os.path.realpath( os.path.join( ".", "data", "proj02" ) )
raw_dblp_file = os.path.join( DATADIR, "dblp_2000.csv.gz" )
cached_dblp_file =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Define some helper functions
Step2: A handy procedure for converting an $(v_{ij})$ list into a sparse matrix.
Step3: Load the DBLP dataset, ma... |
6,604 | <ASSISTANT_TASK:>
Python Code:
print "print out some values of the observation 'TOTAL'"
for name, person in data_dict.iteritems():
if name == 'TOTAL':
print person
salary = []
for name, person in data_dict.iteritems():
if float(person['salary']) > 0:
salary.append(float(person['salary']))
print "the sum... | <SYSTEM_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 see that the total salary matches to the salary against the "TOTAL" record in the dataset.
|
6,605 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
6,606 | <ASSISTANT_TASK:>
Python Code:
api_key = 'PASTE_ALCHEMY_API_KEY_HERE'
import requests
import os
import pandas as pd
from datetime import datetime
hacker_news_api_base_url = 'https://hacker-news.firebaseio.com/v0/'
hacker_news_feature_url_item = 'item/'
hacker_news_feature_url_topstories = 'topstories'
hacker_news_api... | <SYSTEM_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 required Python libraries
Step2: Query the current 500 most popular Hacker News stories
Step3: Define Hacker News API helper functions
... |
6,607 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
print(tf.__version__)
a = 1.
b = 2.
c = a + b
print(c)
a = tf.constant(1.)
b = tf.constant(2.)
c = tf.add(a, b)
print(c)
with tf.Session() as sess:
result = sess.run(c)
print(result)
a = np.array([5, 3, 8])
b = np.array([3, -1, 2])
c = 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: Hello TensorFlow
Step2: 当然ですが 3.0 と答えが表示されます。
Step3: Tensor というオブジェクトが表示されますね。
Step4: 行列演算
Step5: TensorFlow
Step6: TensorFlow + placeholde... |
6,608 | <ASSISTANT_TASK:>
Python Code:
G = cf.load_seventh_grader_network()
len(G.nodes())
# Who are represented in the network?
list(G.nodes())[0:5]
len(G.nodes())
# len(G)
# Who is connected to who in the network?
# list(G.edges())[0:5]
list(G.edges())[0:5]
len(G.edges())
# Let's get a list of nodes with their attribut... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic Network Statistics
Step2: Exercise
Step3: Let's now figure out who is connected to who in the network
Step4: Exercise
Step5: Concept
S... |
6,609 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
DON'T MODIFY AN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
6,610 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
x = tf.placeholder(tf.float32, shape=[None, 784])
y_ = tf.placeholder(tf.float32, shape=[None, 10])
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
y = tf.matmul(x,W) + b
cross_entropy = tf.reduce_mean(
tf.nn.softmax_cross_entropy_with_logit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Additionally, we declare pred value, which is the actual prediction.
Step2: We download training examples and train the model.
Step3: Let's ma... |
6,611 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'sandbox-3', 'land')
# 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... |
6,612 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
from __future__ import print_function
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: Extract Features
Step3: Train SVM on features
Step4: Inline question 1
|
6,613 | <ASSISTANT_TASK:>
Python Code:
class Ball:
def __init__(self, start_position, start_velocity, radius):
self.position = start_position
self.velocity = start_velocity
self.radius = radius
def move(self, time_step):
self.position[0] += self.velocity[0] * time_step
self.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Analytical solution
Step2: As you can see there is a difference between the numerical and analytical solution.
|
6,614 | <ASSISTANT_TASK:>
Python Code:
import os
import glob
import itertools
import nestly
%load_ext rpy2.ipython
%load_ext pushnote
%%R
library(ggplot2)
library(dplyr)
library(tidyr)
library(gridExtra)
## min G+C cutoff
min_GC = 13.5
## max G+C cutoff
max_GC = 80
## max G+C shift
max_13C_shift_in_BD = 0.036
min_BD = min_GC/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: BD min/max
Step2: Nestly
Step3: Nestly params
Step4: Copying input files
Step5: Multi-window HR-SIP
Step6: Making confusion matrices
Step7:... |
6,615 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib.image as mpimg
import cv2
%%bash
ls -l | grep .tiff
img = mpimg.imread('Lab_3_DIP.tiff')
plt.figure(figsize=(15,10))
plt.imshow(img)
plt.figure(figsize=(20,20))
kernel = np.ones((5,5),np.uint8)
erosio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Erosion / dilation steps
|
6,616 | <ASSISTANT_TASK:>
Python Code:
import argparse
import os
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
import scipy.io
import scipy.misc
import numpy as np
import pandas as pd
import PIL
import tensorflow as tf
from keras import backend as K
from keras.layers import Input, Lambda, Conv2D
from ker... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Important Note
Step4: Expected Output
Step6: Expected Output
Step8: Expected Output
Step9: Expected Output
Step10: 3.1 - Defining classes, ... |
6,617 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv('atlas-taggings.csv')
df.head(10)
articles = df[df.tagged_type == 'Article']
articles.head()
def get_tag(x):
return x.split('/')[2]
#changing this function to get_tag_name() 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: First, import the table of tag-article mappings from our SQL db
Step2: We only care about the articles for this analysis. Place entries are out... |
6,618 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import Aer, execute
from qiskit.quantum_info import Pauli, state_fidelity, basis_state, process_fidelity
q0 = QuantumRegister(2, 'q0')
c0 = ClassicalRegister(2, 'c0')
q1 = QuantumRegiste... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Quantum and Classical Registers
Step2: The name is optional. If not given Qiskit will name it $qi$ where $i$ is an interger which will count fr... |
6,619 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('lc', compute_times=phoebe.linspace(0,1,101), dataset='lc01')
b.add_dataset('mesh', comput... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new bundle.
Step2: Adding Datasets
Step3: Distortion Method
Step4: IMPORTANT NOTE
S... |
6,620 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mohc', 'ukesm1-0-mmh', 'atmos')
# 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... |
6,621 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
email_list_lst=[('Omar','Bayramov','omarbayramov@hotmail.com',1),
('Ali','Aliyev','alialiyev@example.com',0),
('Dmitry','Vladimirov','v.dmitry@koala.kl',1),
('Donald','Trump','grabthat@pussycatdolls.com',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: Datafreymin əsasına yerləşəcək verilənlər mənbə üzrə üzrə daxili və xarici formalara bölünür
Step2: Növbəti email_list_lst_cln dəyşəninə isə sü... |
6,622 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from __future__ import print_function
print(plt.style.available)
# Let's choose one style. And while we are at it, define thicker lines and big graphic sizes
plt.style.use('bmh')
plt.rcParams['lines.linewidth'] = 1.5
plt.rcParams['figur... | <SYSTEM_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 need to import the library in our notebook. There are a number of different ways to do it, depending on what part of matplotlib we want t... |
6,623 | <ASSISTANT_TASK:>
Python Code:
the_number_four = 4
print(the_number_four)
x = 4
x = 5
print(x)
the_number_four = 4
print("theNumberFour")
print(the_number_five)
the_number_five = 5
the_number_five = 5
print(the_number_five)
a = 4
a = b # throws a NameError, b is not defined!
# So what should we do if we want b to ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: QUESTION
Step2: So what is going on here? Well, Python first defines ‘x’ as equal to 4. In the very next line Python says "oh, x is equal to 5 ... |
6,624 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
%%time
Empoyees = pd.read_excel('/home/data/AdventureWorks/Employees.xls')
%%time
Territory = pd.read_excel('/home/data/AdventureWorks/SalesTerritory.xls')
%%time
Customers = pd.read_excel('/home/data/AdventureWorks/Customers.xls')
%%time
Orders = pd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Filtering (with)
|
6,625 | <ASSISTANT_TASK:>
Python Code:
from pymldb import Connection
mldb = Connection("http://localhost/")
mldb.put('/v1/procedures/import_bench_train_1m', {
"type": "import.text",
"params": {
"dataFileUrl": "https://s3.amazonaws.com/benchm-ml--main/train-1m.csv",
"outputDataset":"bench_train_1m",
... | <SYSTEM_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 create the datasets directly from the remote files.
Step4: Now we create the experimental setup.
Step5: Finally, we run the experiment... |
6,626 | <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: Weight clustering in Keras example
Step2: Train a tf.keras model for MNIST without clustering
Step3: Evaluate the baseline model and save it f... |
6,627 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_digits
digits = load_digits()
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(digits.data,
digits.target)
X_train.shape
from sklearn.svm 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: Really Simple API
Step2: 1) Instantiate an object and set the parameters
Step3: 2) Fit the model
Step4: 3) Apply / evaluate
Step5: And again... |
6,628 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
GMAT_PATH = '/home/daniel/GMAT/R2018a/bin/GMAT-R2018a'
import numpy as np
import matplotlib.pyplot as plt
from astropy.time import Time
import subprocess
# Larger figure size
fig_size = [10, 6]
plt.rcParams['figure.figsize'] = fig_size
gmat_script_template =
%-------... | <SYSTEM_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 this to the path of your GMAT executable
Step3: The GMAT script template contains fields ready to be filled in using Python's format() func... |
6,629 | <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: モデルを定義する
Step3: 一部のレイヤーをプルーニングする(Sequential と Functional)
Step4: この例ではプルーニングするものを決定するためにレイヤーの種類が使用されていますが、特定のレイヤーをプルーニングす... |
6,630 | <ASSISTANT_TASK:>
Python Code:
import theano
import theano.tensor as T
# cf. https://github.com/lisa-lab/DeepLearningTutorials/blob/c4db2098e6620a0ac393f291ec4dc524375e96fd/code/logistic_sgd.py
import cPickle, gzip, numpy
import os
os.getcwd()
os.listdir( os.getcwd() )
f = gzip.open('./Data/mnist.pkl.gz')
train_set, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: cf. 3.2 Datasets, 3.2.1 MNIST Dataset
Step3: GPU note
|
6,631 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import graphviz
import lingam
from lingam.utils import print_causal_directions, print_dagc, make_dot
print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])
np.set_printoptions(precision=3, suppress=True)
np.random.seed(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: Test data
Step2: We create a list variable that contains two datasets.
Step3: Causal Discovery
Step4: Using the causal_order_ properties, we ... |
6,632 | <ASSISTANT_TASK:>
Python Code:
# Ensure the right version of Tensorflow is installed.
!pip install tensorflow==2.6 --user
!pip install gym==0.12.5 --user
import gym
import numpy as np
import random
env = gym.make('FrozenLake-v0', is_slippery=False)
state = env.reset()
env.render()
print(state)
def print_state(state... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NOTE
Step2: There are four methods from Gym that are going to be useful to us in order to save the gumdrop.
Step3: If we print the state we'll... |
6,633 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from ttim import *
drawdown = np.loadtxt('data/oudekorendijk_h30.dat')
tobs = drawdown[:,0] / 60 / 24
robs = 30
Q = 788
ml = ModelMaq(kaq=60, z=(-18, -25), Saq=1e-4, tmin=1e-5, tmax=1)
w = Well(ml, xw=0, yw=0, rw=0.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: Use observation times from Oude Korendijk
Step2: Generate data
Step3: See if TTim can find aquifer parameters back
Step4: Fit with scipy.leas... |
6,634 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import graphviz
import lingam
from lingam.utils import print_causal_directions, print_dagc, make_dot
import warnings
warnings.filterwarnings('ignore')
print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])
np.set_printoptio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test data
Step2: Causal Discovery
Step3: Using the causal_order_ properties, we can see the causal ordering as a result of the causal discover... |
6,635 | <ASSISTANT_TASK:>
Python Code:
import os
import matplotlib.pyplot as plt
import numpy as np
import openmc
%matplotlib inline
# Instantiate some elements
elements = {}
for elem in ['H', 'O', 'U', 'Zr', 'Gd', 'B', 'C', 'Fe']:
elements[elem] = openmc.Element(elem)
materials = {}
# Fuel
materials['Fuel'] = openmc.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: We will be running a rodded 8x8 assembly with Gadolinia fuel pins. Let's create all the elemental data we would need for this case.
Step2: With... |
6,636 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import networkx as nx
K_5=nx.complete_graph(5)
nx.draw(K_5)
def complete_deg(n):
Return the integer valued degree matrix D for the complete graph K_n.
a = np.identity(n, dtype=np.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: Complete graph Laplacian
Step3: The Laplacian Matrix is a matrix that is extremely important in graph theory and numerical analysis. It is defi... |
6,637 | <ASSISTANT_TASK:>
Python Code:
combined["g_minus_r"] = combined.gcmodel_mag - combined.rcmodel_mag
combined["r_minus_i"] = combined.rcmodel_mag - combined.icmodel_mag
combined["i_minus_z"] = combined.icmodel_mag - combined.zcmodel_mag
combined["z_minus_y"] = combined.zcmodel_mag - combined.ycmodel_mag
mask = np.isf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Filter out bad data
Step2: Create classification labels
Step3: Load the IDs of the narrowband population
Step4: Setup locations of images
Ste... |
6,638 | <ASSISTANT_TASK:>
Python Code:
from SeisCL import SeisCL
seis = SeisCL()
import numpy as np
import matplotlib.pyplot as plt
seis.csts['ND'] = 3 # Number of dimension
seis.csts['N'] = np.array([300, 300, 300]) # Grid size [NZ, NX, NY]
seis.csts['dt'] = dt = 0.25e-03 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <!-- ## Simulation constants -->
Step2: Boundary layers
Step3: Model parameters
Step4: Sources
Step5: Simulation
Step6: The result of SeisC... |
6,639 | <ASSISTANT_TASK:>
Python Code:
# !gcloud compute tpus list --zone=YOUR_ZONE_HERE_SUCH_AS_us-central1-b
# tpu_ip_address='10.1.2.3'
# tpu_cores=8
# # TPU configuration
# %env XRT_TPU_CONFIG=tpu_worker;0;$tpu_ip_address:8470
# # Use bfloat16
# %env XLA_USE_BF16=1
!pip install -U pytorch-lightning --quiet
from pytorch_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Update TPU configuration
Step2: Set TPU environment variables
Step3: Install and import packages
Step4: Environment configuration
Step5: Dow... |
6,640 | <ASSISTANT_TASK:>
Python Code:
!mkdir followers
!mkdir following
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
#make sure the path is correct for your chromedriver. can place next to it
# driver = webdriver.Chrome('./chro... | <SYSTEM_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 new, throwaway Twitter account with throwaway email address from here and throwaway phone number here (UK numbers work typically)
|
6,641 | <ASSISTANT_TASK:>
Python Code:
x = 2
y = 2.0
x = 2
y = 3
z = x / y
type(z)
x = 2
y = 3
z = x * y
type(z)
x = 2.5
y = 3.5
z = x * y
type(z)
x = 2.5
y = 3.5
z = x * y
print("Float z:\t{}\nInteger z:\t{}".format(z, int(z)))
x = "this is a string"
type(x)
x = "some string"
y = "another string"
z = x + " " + y
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: It's easy to determine the name of the variable; in this case, the name is $x$. It can be a bit more complicated to determine the type of the va... |
6,642 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'dwd', 'sandbox-3', 'ocnbgchem')
# 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... |
6,643 | <ASSISTANT_TASK:>
Python Code:
import pandas
import graphistry
try:
from urllib.parse import unquote # Python 3
except ImportError:
from urllib import unquote # Python 2
# To specify Graphistry account & server, use:
# graphistry.register(api=3, username='...', password='...', protocol='https', server='hu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download+Parse Apache Logs to Create a Pandas Dataframe
Step2: Graph connecting Hosts to URLs
Step3: Graph connecting Hosts to URLs
Step4: Pl... |
6,644 | <ASSISTANT_TASK:>
Python Code:
!pip install matplotlib==3.2.2
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow_datasets as tfds
import tensorflow_hub as hub
#@title Helper function for displaying examples
def plot(examples, predictions=None):
# Get the images, labels, and o... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: データセット
Step2: データセットの情報を見て、説明や引用、例の数などの詳細情報を確認しましょう。
Step3: キャッサバデータセットには、健康なキャッサバの葉とそれぞれ異なる病気を持つ 4 枚のキャッサバの葉の画像があります。モデルはこれらの全てのクラスの予測ができ、予測に... |
6,645 | <ASSISTANT_TASK:>
Python Code:
class Module(object):
def __init__ (self):
self.output = None
self.gradInput = None
self.training = True
Basically, you can think of a module as of a something (black box)
which can process `input` data and produce `ouput` data.
This is like 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:
Step12: Module is an abstract class which defines fundamental methods necessary for a training a neural network. You do not need to change anything her... |
6,646 | <ASSISTANT_TASK:>
Python Code:
PROJECT_ID = "[your-project-id]"
if PROJECT_ID == "" or PROJECT_ID is None or PROJECT_ID == "[your-project-id]":
# Get your GCP project id from gcloud
shell_output = !gcloud config list --format 'value(core.project)' 2>/dev/null
PROJECT_ID = shell_output[0]
print("Project ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Region
Step2: Timestamp
Step3: Create a Cloud Storage bucket
Step4: Only if your bucket doesn't already exist
Step5: Import libraries
Step6:... |
6,647 | <ASSISTANT_TASK:>
Python Code:
print 10*100/10+5.75-5.5
2.0/3
print 4*(6+5)
print 4*6+5
print 4+6*5
print 3+1.5+4
print 2**(0.5)
s = 'hello'
# Print out 'e' using indexing
print s[1]
# Code here
s ='hello'
# Reverse the string using indexing
print s[::-1]
print s[:3:-1]
# Code here
s ='hello'
# Print out the
prin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Explain what the cell below will produce and why. Can you change it so the answer is correct?
Step2: Answer these 3 questions without typing co... |
6,648 | <ASSISTANT_TASK:>
Python Code:
import requests
import json
import random
import getpass
#import couchdb
import pickle
import getpass
#!flask/bin/python
#from flask import Flask, jsonify
myusr = getpass.getuser()
print(myusr)
#couch = couchdb.Server()
with open('/home/{}/prn.pickle'.format(myusr), 'rb') as handle:
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: Requests and json are the two main modules used for this. Random can also be handy
Step2: Convert it into readable text that you can work with
|
6,649 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
import os
import time
path_to_file = tf.keras.utils.get_file('shakespeare.txt', 'https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt')
# TODO 1
# Read, then decode for py2 compat.
text = # TODO 1: Your code goes here
# 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: Download the Shakespeare dataset
Step2: Read the data
Step3: Process the text
Step4: Now create the tf.keras.layers.StringLookup layer
Step5:... |
6,650 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
class Circle(object):
def __init__(self,radius=3,color='blue'):
self.radius=radius
self.color=color
def add_radius(self,r):
self.radius=self.radius+r
return(self.radi... | <SYSTEM_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 first step in creating your own class is to use the class keyword, then the name of the class as shown in Figure 4. In this course the class... |
6,651 | <ASSISTANT_TASK:>
Python Code:
# Evaluate this cell to identifiy your form
from dkrz_forms import form_widgets, form_handler, checks
form_infos = form_widgets.show_selection()
# Evaluate this cell to generate your personal form instance
form_info = form_infos[form_widgets.FORMS.value]
sf = form_handler.init_form(form_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Edit form information
Step2: Save your form
Step3: Send an email to me to complete the form later on
Step4: officially submit your form
|
6,652 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from IPython.display import display, HTML
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (14.0, 8.0)
import numpy as np
from dtocean_core import start_logging
from dtocean_core.core import Core
from dtocean_core.menu import ModuleMenu, ProjectMenu, The... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create the core, menus and pipeline tree
Step2: Create a new project
Step3: Set the device type
Step4: Initiate the pipeline
Step5: Discover... |
6,653 | <ASSISTANT_TASK:>
Python Code:
df = load_rossi()
df['age_strata'] = pd.cut(df['age'], np.arange(0, 80, 5))
df = df.drop('age', axis=1)
cph = CoxPHFitter()
cph.fit(df, 'week', 'arrest', strata=['age_strata', 'wexp'])
cph.print_summary()
cph.plot();
r = cph.compute_residuals(df, 'martingale')
r.head()
r.plot.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: Martingale residuals
Step2: Deviance residuals
|
6,654 | <ASSISTANT_TASK:>
Python Code:
%install_ext http://raw.github.com/jrjohansson/ipython-circuitikz/master/circuitikz.py
%reload_ext circuitikz
%%circuitikz filename=squid dpi=125
\begin{circuitikz}[scale=1]
\draw ( 0, 0) [short, *-] node[anchor=south] {$\Phi_J$} to (0, -1);
% right
\draw ( 0, -1) to (2, -1) to node[anc... | <SYSTEM_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 extension
Step2: Example
Step3: Example
|
6,655 | <ASSISTANT_TASK:>
Python Code:
import krisk.plot as kk
import pandas as pd
# Use this when you want to nbconvert the notebook (used by nbviewer)
from krisk import init_notebook; init_notebook()
df = pd.read_csv('../krisk/tests/data/gapminderDataFiveYear.txt', sep='\t').sample(50)
p = kk.bar(df,'year',c='continent',sta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Themes
Step2: Vintage
Step3: Dark
Step4: Macarons
Step5: Infographic
Step6: Roma
Step7: Shine
Step8: Colors (Palette and Background)
Step... |
6,656 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
% matplotlib inline
import warnings
warnings.filterwarnings('ignore')
import math
import numpy as np
from thinkbayes2 import Pmf, Cdf, Suite, Joint
import thinkplot
# Solution
from scipy.stats import poisson
poisson.pmf(3, 2.9)
# Solution
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: Warm-up exercises
Step2: Exercise
Step3: Exercise
Step4: Exercise
Step8: The Boston Bruins problem
Step9: Now we can initialize a suite for... |
6,657 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import time
import pandas
import random
import numpy
import matplotlib.pyplot as plt
import seaborn; seaborn.set_style('whitegrid')
import itertools
from pomegranate import *
random.seed(0)
numpy.random.seed(0)
numpy.set_printoptions(suppress=True)
%load_ext watermark
%... | <SYSTEM_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. Training a Probability Distribution
Step2: Then we can make a blank distribution with 2 dimensions. This is equivalent to filling in the mea... |
6,658 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/orlando_furioso.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
#text = text[81:]
# Need to clean by all numbers and subtitute italian tokens not present in english
vi... | <SYSTEM_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... |
6,659 | <ASSISTANT_TASK:>
Python Code:
import MySQLdb
#Enter the values for you database connection
dsn_database = "verein" # e.g. "MySQLdbtest"
dsn_hostname = "localhost" # e.g.: "mydbinstance.xyz.us-east-1.rds.amazonaws.com"
dsn_port = 3306 # e.g. 3306
dsn_uid = "steinam" # e.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: Database Connection Properties and Connect to the database
Step12: Let's create a sample table and insert some data into it.
Step14: conn.curs... |
6,660 | <ASSISTANT_TASK:>
Python Code:
# from terminal or command window
pip install virtualenv
# from terminal or command window
cd my_project_folder
virtualenv my_project
# from terminal or command window
virtualenv -p /usr/bin/python2.7 my_project
# from terminal or command window
export VIRTUALENVWRAPPER_PYTHON=/usr/bin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic Usage
Step2: virtualenv my_project will create a folder in the current directory which will contain the Python executable files, and a co... |
6,661 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
import math
import numpy as np
import tensorflow as tf
import time
from datasets import dataset_utils
# Main slim library
slim = tf.contrib.slim
def regression_model(inputs, is_training=True, scope="deep_regression"):
... | <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: Creating your first neural network with TF-Slim
Step3: Let's create the model and examine its structure.
Step4: Let's create some 1d regressio... |
6,662 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('..')
import os
import numpy as np
import pypmj as jpy
jpy.import_jcmwave('/path/to/your/JCMsuite/installation/directory')
project = jpy.JCMProject('../projects/scattering/mie/mie2D')
mie_keys = {'constants' :{}, # <-- can be anything, but is not looped over ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Specify the path to your JCMsuite installation directory here. You can skip this later if you have a configuration file.
Step2: Prepare
Step3: ... |
6,663 | <ASSISTANT_TASK:>
Python Code:
a = 140e-3 /2 # inner conductor radius
b = 230e-3 /2 # inner conductor radius
def coax_electric_field(rho, V, a, b):
Returns the electric field in a coaxial line.
return 1/rho*V/log(b/a)
rho = linspace(a, b, 101)
V = 1 # V
plot(rho/a, coax_electric_field(rho, V, a, b)/V)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Power Handling
Step2: This is maximum for $\rho=a$. Let us suppose that the peak voltage $V_p$ (or equivalently the maximum RF power $P_p$ the ... |
6,664 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'emac-2-53-vol', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contri... | <SYSTEM_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... |
6,665 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
pdf = pd.DataFrame({
'x1': ['a','a','b','b', 'b', 'c'],
'x2': ['apple', 'orange', 'orange','orange', 'peach', 'peach'],
'x3': [1, 1, 2, 2, 2, 4],
'x4': [2.4, 2.5, 3.5, 1.4, 2.1,1.5],
'y1': [1, 0, 1, 0, 0, 1],
'y2': ['yes'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: StringIndexer
Step2: From the result above, we can see that (a, b, c) in column x1 are converted to (1.0, 0.0, 2.0). They are ordered by their ... |
6,666 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import statsmodels.api as sm
p = 5
groups_var = 1
level1_var = 2
level2_var = 3
resid_var = 4
n_groups = 100
group_size = 20
level1_size = 10
level2_size = 5
n = n_groups * group_size * level1_size * level2_size
xmat = np.random.normal(size=(n,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set the number of covariates.
Step2: These parameters define the population variance for each level of grouping.
Step3: Set the number of grou... |
6,667 | <ASSISTANT_TASK:>
Python Code:
import ipyrad.analysis as ipa
import ipyparallel as ipp
import toytree
ipyclient = ipp.Client()
len(ipyclient)
locifile = "./analysis-ipyrad/pedic_outfiles/pedic.loci"
newick = "./analysis-raxml/RAxML_bestTree.pedic"
## parse the newick tree, re-root it, and plot it.
tre = toytree.tree(... | <SYSTEM_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 cluster
Step2: Load in your .loci data file and a tree hypothesis
Step3: Short tutorial
Step4: Look at the results
Step5: Plottin... |
6,668 | <ASSISTANT_TASK:>
Python Code:
import math as mt
def findPermutation(string , k ) :
has =[False for i in range(26 ) ]
cnt = 0
for i in range(len(string ) ) :
if(has[ord(string[i ] ) - ord(' a ' ) ] == False ) :
cnt += 1
has[ord(string[i ] ) - ord(' a ' ) ] = True
ans = 1
for i in range(2 , cnt ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
6,669 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat
import tensorflow as tf
!mkdir data
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
data_dir = 'data/'
if not isdir(data_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting the data
Step2: These SVHN files are .mat files typically used with Matlab. However, we can load them in with scipy.io.loadmat which we... |
6,670 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from pymt import models
cem, waves = models.Cem(), models.Waves()
waves.get_output_var_names()
cem.get_input_var_names()
args = cem.setup(number_of_rows=100, number_of_cols=200, grid_spacing=200.)
cem.initialize(*args)
args = waves.setup()
waves.in... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import the Cem class, and instantiate it. In Python, a model with a BMI will have no arguments for its constructor. Note that although the class... |
6,671 | <ASSISTANT_TASK:>
Python Code:
from Frame2D import Frame2D
from Tables import Table, DataSource
import numpy as np
import pandas as pd
## NOTE: all units are kN and m
FD = {'storey_heights': [6.5] + [5.5]*20 + [7.0], # m
'bay_widths': [10.5,10,10,10,10,10.5], # m
'frame_spacing':8, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: On Flex 5
Step2: On Flex 5
|
6,672 | <ASSISTANT_TASK:>
Python Code:
# exerices for section 8.1
# exerices for section 8.2
plt.figure(figsize=(5,8))
plt.imshow(plt.imread('./res/fig8_1.png'))
plt.figure(figsize=(8,8))
plt.imshow(plt.imread('./res/fig8_2.png'))
bipartite_graph = [('1', 'a'), ('1', 'c'), ('2', 'b'), ('3', 'b'), ('3', 'd'), ('4', 'a')]
bi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 8.2 On-Line Algorithms
Step2: 8.3 The Matching Problem
Step3: 8.3.1 Matches and Perfect Matches
Step4: 8.3.2 The Greedy Algorithm for Maximal... |
6,673 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time
import numpy as np
import matplotlib.pyplot as plt
from cs231n.classifiers.fc_net import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array
from cs231n.solver 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: Batch Normalization
Step2: Batch normalization
Step3: Batch Normalization
Step4: Batch Normalization
Step5: Fully Connected Nets with Batch ... |
6,674 | <ASSISTANT_TASK:>
Python Code:
import os, sys
import shutil, time, warnings
from contextlib import redirect_stdout
import numpy as np
import numpy.ma as ma
import matplotlib.pyplot as plt
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table, Column, vstack
from astropy.io 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: Preliminaries
Step2: Read the Open NGC catalog created by Mattia Verga
Step3: Select the desired object types.
Step4: Require "big" objects, ... |
6,675 | <ASSISTANT_TASK:>
Python Code:
import graphlab as gl
sales = gl.SFrame('data/kc_house_data.gl/')
def calcRSS(model, features, output):
predict = model.predict(features)
error = output - predict
rss = np.sum(np.square(error))
return rss
import numpy as np # note this allows us to refer to numpy as 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: Load in house sales data
Step2: If we want to do any "feature engineering" like creating new features or adjusting existing ones we should do t... |
6,676 | <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 = (150, 170)
DON'T MODIFY ANYTHING IN THIS CELL
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: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
6,677 | <ASSISTANT_TASK:>
Python Code:
import numpy, scipy
import scipy.linalg
import scipy.sparse
import scipy.sparse.linalg
%matplotlib inline
import matplotlib.pyplot
from sklearn import datasets
iris = datasets.load_iris()
print('Target names:', iris.target_names)
print('Features:', iris.feature_names)
print(iris.data)
fi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Iris
Step2: A = 0.5*(numpy.diag(numpy.ones(7), k=1) - numpy.diag(numpy.ones(7), k=-1))
Step3: Document-term matrix decomposition
Step4: Task ... |
6,678 | <ASSISTANT_TASK:>
Python Code:
%run db2.ipynb
%sql -sampledata
%%sql
SELECT DEPTNAME, LASTNAME FROM
DEPARTMENT D LEFT OUTER JOIN EMPLOYEE E
ON D.DEPTNO = E.WORKDEPT
%%sql
SELECT DEPTNAME, LASTNAME FROM
DEPARTMENT D, EMPLOYEE E
WHERE D.DEPTNO = E.WORKDEPT (+)
%%sql -q
DROP TABLE LONGER_CHAR;
CREATE TABLE LO... | <SYSTEM_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 populate the database with the EMPLOYEE and DEPARTMENT tables so that we can run the various examples.
Step2: Table of Contents
Step3: This... |
6,679 | <ASSISTANT_TASK:>
Python Code:
import graphlab
import matplotlib.pyplot as plt
import numpy as np
import sys
import os
import time
from scipy.sparse import csr_matrix
from sklearn.cluster import KMeans
from sklearn.metrics import pairwise_distances
%matplotlib inline
'''Check GraphLab Create version'''
from distutils.v... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the Wikipedia dataset
Step2: As we did in previous assignments, let's extract the TF-IDF features
Step3: To run k-means on this dataset, ... |
6,680 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
dfA = pd.DataFrame({'A':[1,1,1,1,1,1,1,1],
'B':[2,2,2,2,2,2,2,2]})
dfA
dfB = pd.DataFrame({'C':[3,3,3,3,3,3,3,3],
'D':[4,4,4,4,4,4,4,4]})
pd.merge(dfA, dfB, left_index=True, right_index=True)
import string
dfA... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You get to choose which columns, left and right, serve as "gear teeth" for synchronizing rows (sewing them together). Or choose the index, not ... |
6,681 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
rcParams['figure.figsize'] = (10,7)
!sequana_coverage --download-reference FN433596
import subprocess
for DP in [200, 100, 80, 60, 40, 20, 10]:
print(DP)
# Creating the simulated data with expected depth of coverage
cmd = "art_illumina -sam -i FN433596.fa -p -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: Get the reference
Step2: Simulated FastQ data
Step3: Impact of the window parameter on the normalised coverage distribution (100X case)
Step4:... |
6,682 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import calin.math.hex_array
import calin.provenance.system_info
import calin.simulation.vs_optics
import calin.simulation.geant4_shower_generator
import calin.simulation.ray_processor
import calin.simulation.tracker
import calin.simulation.detector_efficiency
import calin.si... | <SYSTEM_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. Define telescope properties for ray tracer and construct array
Step2: 3. Construct detection efficiency curve, cone efficiency and atmospher... |
6,683 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'A': [1, 0, 0, 0, 1, 0],
'B': [0, 1, 0, 0, 0, 1],
'C': [0, 0, 1, 0, 0, 0],
'D': [0, 0, 0, 1, 0, 0]})
df["category"] = df.idxmax(axis=1)
<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:
|
6,684 | <ASSISTANT_TASK:>
Python Code:
import os
import glob
import re
import nestly
%load_ext rpy2.ipython
%load_ext pushnote
%%R
library(ggplot2)
library(dplyr)
library(tidyr)
library(gridExtra)
library(phyloseq)
## BD for G+C of 0 or 100
BD.GCp0 = 0 * 0.098 + 1.66
BD.GCp100 = 1 * 0.098 + 1.66
workDir = '/home/nick/notebook... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Nestly
Step2: BD min/max
Step3: Loading data
Step4: bulk soil samples
Step5: Simulated
Step6: 'bulk soil' community files
Step7: BD span o... |
6,685 | <ASSISTANT_TASK:>
Python Code:
def Solar_Power_Calculator(Day_Of_Year,Lattitude,Hour_of_Day):
'''This function will tell you how much power the sun is '''
# Calculating Theta D
ThetaD = (2*np.pi*Day_Of_Year)/365
# Calculating distance
# Constants for calculating distance
Dis_n = [0,1,2]
Dis_... | <SYSTEM_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 I'm going to take the above function and do the same thing except make it print the number of Wh in one square meter for a year.
Step2: Loa... |
6,686 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import display
from IPython.display import (
display_pretty, display_html, display_jpeg,
display_png, display_json, display_latex, display_svg
)
from IPython.display import Image
assert 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: Basic rich display
Step2: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi... |
6,687 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bnu', 'sandbox-2', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
6,688 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
%matplotlib inline
known_behaviors = pd.read_csv("https://raw.githubusercontent.com/vberaudi/utwt/master/known_behaviors2.csv")
known_behaviors.head()
a = known_behaviors[known_behaviors.Mor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Understand the historical data
Step2: Check the 2016 customers
Step3: Do some visual analysis of the historical data
Step4: In the following ... |
6,689 | <ASSISTANT_TASK:>
Python Code:
edge_list =
krogan_graph =
krogan_graph.summary()
res =
<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: Make an igraph graph and print its summary
Step2: Run mcode on your graph with vwp=0.1
|
6,690 | <ASSISTANT_TASK:>
Python Code:
import graphlab as gl
import numpy as np
def polynomial_sframe(feature, degree):
# assume that degree >= 1
# initialize the SFrame:
poly_sframe = gl.SFrame()
# and set poly_sframe['power_1'] equal to the passed feature
poly_sframe['power_1'] = feature
# first... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Polynomial regression, revisited
Step2: Let's use matplotlib to visualize what a polynomial regression looks like on the house data.
Step3: As... |
6,691 | <ASSISTANT_TASK:>
Python Code:
def task1():
cursor = db.cursor()
cursor.execute('''
select distinct ar.Name
from tracks t
inner join albums al
on t.albumid = al.albumid
inner join artists ar
on al.artistid = ar.artistid
inner join genres g
on t.genreid = g.genreid
where g.name = 'Rock'
... | <SYSTEM_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
Step2: Проверим, что таблица создана
Step3: Задание 3
Step4: Задание 4
Step5: Задание 5
Step6: Задание 6
|
6,692 | <ASSISTANT_TASK:>
Python Code:
# import the maps
from marvin.tools.maps import Maps
# Load a MPL-5 map
mapfile = '/Users/Brian/Work/Manga/analysis/v2_0_1/2.0.2/SPX-GAU-MILESHC/8485/1901/manga-8485-1901-MAPS-SPX-GAU-MILESHC.fits.gz'
# Let's get a default map of
maps = Maps(filename=mapfile)
print(maps)
# Let's grab the... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Once you have a maps object, you can access the raw maps file and header and extensions via maps.header and maps.data. Alternatively, you can a... |
6,693 | <ASSISTANT_TASK:>
Python Code:
!wget -q https://raw.githubusercontent.com/sayantanauddy/vae_lightning/main/data.py
!wget -q https://raw.githubusercontent.com/probml/pyprobml/master/scripts/mfa_celeba_helpers.py
!pip install kaggle
from google.colab import files
uploaded = files.upload()
!mkdir /root/.kaggle
!cp kaggl... | <SYSTEM_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 helper functions
Step2: Get the Kaggle api token and upload it to colab. Follow the instructions here.
Step4: Train and saving the che... |
6,694 | <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: Keras 回调函数概述
Step3: 然后,从 Keras 数据集 API 加载 MNIST 数据进行训练和测试:
Step4: 接下来,定义一个简单的自定义回调函数来记录以下内容:
Step5: 我们来试一下:
Step6: logs 字典... |
6,695 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def sobel(f):
from pconv import pconv
Sx = np.array([[1.,2.,1.],
[0.,0.,0.],
[-1.,-2.,-1.]])
Sy = np.array([[1.,0.,-1.],
[2.,0.,-2.],
[1.,0.,-1.]])
fx = pconv(f, Sx)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Description
Step2: Numerical Example
Step3: Image examples
Step4: Example 2.
|
6,696 | <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... |
6,697 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo("ud_frfkt1t0")
# Import libraries
from __future__ import division
from scipy.stats import binom
import numpy as np
import matplotlib.pyplot as plt
%pylab inline
# Initialize random seed
np.random.seed(1)
def genABK(nTrials,int_min,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: Simulation 1
Step2: Simulation 2
Step3: Simulation 3
Step4: Simulation 4
|
6,698 | <ASSISTANT_TASK:>
Python Code:
import os, glob
import pandas as pd
import numpy as np
from support import data_dir
fileimport = glob.glob(os.path.join(data_dir, 'BN','*.txt'))
data = {}
names = [(f.rpartition('/')[2]).partition('.')[0] for f in fileimport]
for n, f in zip(names, fileimport):
print(n)
data[n] = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Customer class marginal probability distribution
Step2: P ( class | electrified household )
Step3: Derivation of monthly income by customer cl... |
6,699 | <ASSISTANT_TASK:>
Python Code:
# YOUR CODE HERE
from IPython.display import display
from IPython.display import Image
assert True # leave this to grade the import statements
# YOUR CODE HERE
Image(url="http://hyperphysics.phy-astr.gsu.edu/hbase/quantum/imgqua/h21.gif", width=600, height=600)
assert True # leave this 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: Basic rich display
Step2: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.