Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
9,500 | <ASSISTANT_TASK:>
Python Code:
# import statements to make numeric and plotting functions available
%matplotlib inline
from numpy import *
from matplotlib.pyplot import *
## define your function in this cell
def hill_activating(X, B, K, n):
Xn = X**n
return (B * Xn)/(K**n + Xn)
## generate a plot using your hil... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h2> <font color="firebrick">In class exercise</font> </h2>
Step2: Transcriptional repression
Step3: <h2> <font color='firebrick'> Interactive... |
9,501 | <ASSISTANT_TASK:>
Python Code:
A = np.array([[2, -2], [1, 0]])
B = np.array([[1],[0]])
C = np.array([[0,1]])
D = np.array([[0]])
As = sy.Matrix(A)
Bs = sy.Matrix(B)
Cs = sy.Matrix(C)
l1,l2 = sy.symbols("l1 l2")
L = sy.Matrix([[l1, l2]])
Ac = A+B*L
pc = Ac.eigenvals()
pc
l1l2 = sy.solve([l1/2+1+2, l1**2+4*l1+4*l2-4 + 4]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preparations exercise 2
Step2: Preparation exercise 3
Step3: Find the control law $L$ for the discrete time case using Ackermans formula
Step4... |
9,502 | <ASSISTANT_TASK:>
Python Code:
import json
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
def requests_retry_session(
retries=3,
backoff_factor=0.3,
status_forcelist=(500, 502, 504),
session=None,
):
session = session or requests.Sess... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: MMW production API endpoint base url.
Step2: The job is not completed instantly and the results are not returned directly by the API request th... |
9,503 | <ASSISTANT_TASK:>
Python Code:
import ROOT
%jsroot on
def writeHisto(outputFileName):
outputFile = ROOT.TFile(outputFileName, "RECREATE")
h = ROOT.TH1F("theHisto","My Test Histogram;X Title; Y Title",64, -4, 4)
h.FillRandom("gaus")
# now we write to the file
h.Write()
writeHisto("output.root")
%%... | <SYSTEM_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 now define a function that will create a histogram, fill it and write it to a file. Later, we will read back the histogram from disk.
Step2: ... |
9,504 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
# import barnaba
import barnaba.enm as enm
# define the input file
fname = "../test/data/sample1.pdb"
%time enm_obj=enm.Enm(fname,sparse=False)
%time enm_AA=enm.Enm(fname,sele_atoms="AA",cutoff=0.7)
e_val=enm_obj.get... | <SYSTEM_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
Step2: The input parameter
Step3: We can see that this takes considerably more time compared to the 3-beads choice.
Step4: We are usually ... |
9,505 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
softmax_output = load_data()
y = torch.argmin(softmax_output, dim=1).view(-1, 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:
|
9,506 | <ASSISTANT_TASK:>
Python Code:
import math
import time
import torch
import torch.utils.cpp_extension
%matplotlib inline
from matplotlib import pyplot
import matplotlib.transforms
import ot # for comparison
cuda_source =
#include <torch/extension.h>
#include <ATen/core/TensorAccessor.h>
#include <ATen/cuda/CUDAContex... | <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: The kernel
Step3: Incorporating it in PyTorch
Step4: We use this update step in a building block for the Sinkhorn iteration
Step5: We also de... |
9,507 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import tensorflow as tf
import numpy as np
from datetime import date
date.today()
author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises"
tf.__version__
np.__version__
sess = tf.InteractiveSession()
X = tf.constant(
[[[0, 0, 1],
[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: NOTE on notation
Step2: Q23. Given X below, reverse the last dimension.
Step3: Q24. Given X below, permute its dimensions such that the new te... |
9,508 | <ASSISTANT_TASK:>
Python Code:
% matplotlib inline
import numpy as np
import math
import nibabel as nib
import scipy.stats as stats
import matplotlib.pyplot as plt
from nipy.labs.utils.simul_multisubject_fmri_dataset import surrogate_3d_dataset
import palettable.colorbrewer as cb
from nipype.interfaces import fsl
impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Define formulae
Step2: Apply formulae to a range of x-values
Step3: Figure 1 from paper
Step4: Apply the distribution to simulated data
|
9,509 | <ASSISTANT_TASK:>
Python Code:
import numpy as py
import tensorflow as tf
import matplotlib as plt
W = tf.Variable([.3], dtype=tf.float32)
b = tf.Variable([-.3], dtype=tf.float32)
x = tf.placeholder(tf.float32)
linear_model = W * x + b
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
adder_node = a + b ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Variable
Step2: Place Holder
Step3: 除了variable和placeholder以外,还需要各种各样的node (常数,运算等)
Step4: add Node
Step5: 一切的grpth完成后,需要用session来执行graph以启动正... |
9,510 | <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... |
9,511 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False)
DO NOT MODIFY THIS CELL
def fully_connected(prev_layer, num_units):
Create a fully connectd layer w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: Batch Normalization using tf.layers.batch_normalization<a id="example_1"></a>
Step6: We'll use the following function to create convolutional l... |
9,512 | <ASSISTANT_TASK:>
Python Code:
from sklearn import grid_search
from sklearn.cross_validation import StratifiedShuffleSplit
from sklearn.cross_validation import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
from time import time
import numpy as np
import pandas as pd
impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SVM calibration
Step2: Now we check the parameters of the best estimator
|
9,513 | <ASSISTANT_TASK:>
Python Code:
# Import the print function that is compatible with Python 3
from __future__ import print_function
# Import numpy - the fundamental package for scientific computing with Python
import numpy as np
# Import plotting Python plotting from matplotlib
import matplotlib.pyplot as plt
# Generat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1D Optimal Classifier
Step2: Let's generate some data. Below we have provided you with a function that gives you two cases
Step3: Now, let's a... |
9,514 | <ASSISTANT_TASK:>
Python Code:
observations = np.array([20, 6, 6, 6, 6, 6])
with pm.Model():
probs = pm.Dirichlet('probs', a=np.ones(6)) # flat prior
rolls = pm.Multinomial('rolls', n=50, p=probs, observed=observations)
trace = pm.sample(5000)
pm.plot_posterior(trace);
pm.traceplot(trace)
# fair fwould be... | <SYSTEM_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 a 4-sided die and pull out hierarchial info
Step2: Build the whole thing out the Bernoulli dists
|
9,515 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import itertools
import warnings
warnings.simplefilter(action='ignore')
startbosshp = 104
bossdamage = 8
bossarmor = 1
startplayerhp = 100
playerdamage = 0
playerarmor = 0
from collections import namedtuple
Item = namedtuple('item', ['name', 'cost', 'damage', 'armor']... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Procedural code version
Step2: Named tuples tuples but BETTER!
Step3: Set up arrays
Step4: Use itertool package to get 15 combinations of 2 r... |
9,516 | <ASSISTANT_TASK:>
Python Code:
def is_possible(x , y ) :
if(x < 2 and y != 0 ) :
return false
y = y - x + 1
if(y % 2 == 0 and y >= 0 ) :
return True
else :
return False
if __name__== ' __main __' :
x = 5
y = 2
if(is_possible(x , y ) ) :
print("Yes ")
else :
print("No ")
... | <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,517 | <ASSISTANT_TASK:>
Python Code:
#|export
def make_date(df, date_field):
"Make sure `df[date_field]` is of the right date type."
field_dtype = df[date_field].dtype
if isinstance(field_dtype, pd.core.dtypes.dtypes.DatetimeTZDtype):
field_dtype = np.datetime64
if not np.issubdtype(field_dtype, np.da... | <SYSTEM_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 example if we have a series of dates we can then generate features such as Year, Month, Day, Dayofweek, Is_month_start, etc as shown below
S... |
9,518 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
from phoebe import u # units
import numpy as np
logger = phoebe.logger()
b = phoebe.default_binary()
help(phoebe.gaussian)
dist = phoebe.gaussian(6000, 100)
print(dist)
_ = dist.plot(show=True)
b.add_distribution('teff@primary', dist, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Top-level distl distribution creation functions
Step2: Note that, when passing a distribution object to b.add_distribution, the values of unit,... |
9,519 | <ASSISTANT_TASK:>
Python Code:
0.1 == 0.10000000000000000000001
0.1+0.1+0.1 == 0.3
(0.1).as_integer_ratio()
(0.10000000000000001).as_integer_ratio()
print(0.10000000000000001)
a = .1 + .1 + .1
b = .3
print(a.as_integer_ratio())
print(b.as_integer_ratio())
print(a == b)
round(a, 10) == round(b, 10)
print(round(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: IEEE 浮点数表示法
Step2: 也就是说 0.1 是通过 3602879701896397/36028797018963968 来近似表示的,很明显这样近似的表示会导致许多差距很小的数字公用相同的近似表示数,例如:
Step3: 在 Python 中所有这些可以用相同的近似数表... |
9,520 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('/Users/spacecoffin/Development')
import GravelKicker as gk
import librosa
import numpy as np
import os
import pandas as pd
from datetime import datetime
from supriya.tools import nonrealtimetools
this_dir = '/Users/spacecoffin/Development/GravelKicker/__gen_fil... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generation/rendering timing
Step2: Feature extraction timing
Step3: Thought
Step4: Preprocessing
|
9,521 | <ASSISTANT_TASK:>
Python Code:
import pyvinecopulib as pv
pv.Bicop()
pv.Bicop(family=pv.BicopFamily.gaussian)
pv.Bicop(family=pv.BicopFamily.clayton, rotation=90, parameters=[3])
cop = pv.Bicop(family=pv.BicopFamily.student, rotation=0, parameters=[0.5, 4])
u = cop.simulate(n=10, seeds=[1, 2, 3])
fcts = [cop.pdf, ... | <SYSTEM_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 an independence bivariate copula
Step2: Create a Gaussian copula
Step3: Create a 90 degrees rotated Clayon copula with parameter = 3
St... |
9,522 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cmcc', 'cmcc-cm2-sr5', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,523 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import pyplot as plt
import numpy as np
from IPython.display import SVG
from IPython.display import display
from IPython.html.widgets import interactive, fixed
s =
<svg width="100" height="100">
<circle cx="50" cy="50" r="20" fill="aquamarine" />
</svg>
SVG(s)
def dra... | <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: Interact with SVG display
Step5: Write a function named draw_circle that draws a circle using SVG. Your function should take the parameters of ... |
9,524 | <ASSISTANT_TASK:>
Python Code:
from mdp import *
from notebook import psource, pseudocode, plot_pomdp_utility
psource(MDP)
# Transition Matrix as nested dict. State -> Actions in state -> List of (Probability, State) tuples
t = {
"A": {
"X": [(0.3, "A"), (0.7, "B")],
"Y": [(1.0, "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: CONTENTS
Step2: The _init _ method takes in the following parameters
Step3: Finally we instantize the class with the parameters for our MDP i... |
9,525 | <ASSISTANT_TASK:>
Python Code:
name = "your-project-name"
apikey = "your-api-key" # profile.materialsproject.org
from mpcontribs.client import Client
from mp_api.matproj import MPRester
from refractivesqlite import dboperations as DB
from pandas import DataFrame
db = DB.Database("refractive.db")
#db.create_database_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Contribute data on Refractive Index
Step2: Explore and extract refractive index data
Step3: Prepare a single contribution for testing
Step4: ... |
9,526 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.misc
def mosaic(f,N,s=1.0):
f = np.asarray(f)
d,h,w = f.shape
N = int(N)
nLines = int(np.ceil(float(d)/N))
nCells = int(nLines*N)
# Add black slices to match the exact number of mosaic cells
fullf = np.resize(f, (nCells,h,w))
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Examples
Step2: Example 1
Step3: Example 2
|
9,527 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import sympy as sy
sy.init_printing(use_latex='mathjax', order='lex')
h,omega0 = sy.symbols('h,omega0', real=True, positive=True)
z = sy.symbols('z')
beta = sy.cos(omega0*h)
Phi = sy.Matrix([[2*beta, 1],[-1, 0]])
Gamma = sy.Matrix([[1-beta],[1-beta]])
C = sy.Matrix([[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: Choosing the sampling ratio $h$
Step2: Obervability
Step3: Observer design
Step4: The characteristic polynomial of the observer is given by
S... |
9,528 | <ASSISTANT_TASK:>
Python Code:
!nib-ls /data/ds102/sub-01/*/*.nii.gz
%pylab inline
from os.path import join as opj
from nipype.interfaces.fsl import MCFLIRT, FLIRT
from nipype.interfaces.afni import Resample
from nipype.interfaces.spm import Smooth
from nipype.interfaces.utility import IdentityInterface
from nipype.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: So, let's start!
Step2: Experiment parameters
Step3: Specify Nodes
Step4: Specify input & output stream
Step5: Specify Workflow
Step6: Visu... |
9,529 | <ASSISTANT_TASK:>
Python Code:
# Primero tenemos que importar las librerias que usaremos para recopilar datos
import base64
import json
import requests
# Si queremos imprimir los json de respuesta
# de una forma mas agradable a la vista podemos usar
def print_pretty(jsonstring, indent=4, sort_keys=False):
print(js... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Antes que todo, debemos preguntarnos
Step2: Como podemos notar, es posible que tengamos más de una página de issues, por lo que tendremos que a... |
9,530 | <ASSISTANT_TASK:>
Python Code:
# Inportant Packages
import pandas as pd
import matplotlib.pyplot as plt
import sys
import datetime as dt
print('Python version is:', sys.version)
print('Pandas version:', pd.__version__)
print('Date:', dt.date.today())
path = 'C:\\Users\\emeka_000\\Desktop\\Bootcamp_Emeka.xlsx'
odata = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading in and Cleaning up the Data
Step2: GDP Growth and GDP Growth Rate in Brazil
Step3: GDP Growth vs. GDP Growth Rate
Step4: Actual
Step5... |
9,531 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import Bio.Blast.NCBIXML
from cStringIO import StringIO
from __future__ import print_function
# convert RDP-style lineage to Greengenes-style lineage
def rdp_lineage_to_gg(lineage):
d = {}
linlist = lineage.split(';')
for i in np.arange(0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Run for 90-bp sequences (top 500 by prevalence in 90-bp biom table)
Step2: Run for 100-bp sequences (top 500 by prevalence in 100-bp biom table... |
9,532 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import train_test_split
X, y = make_classification(random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
lr = LogisticRegr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Grid-Search and Cross-Validation
Step2: Processing Pipelines
|
9,533 | <ASSISTANT_TASK:>
Python Code:
powers = (lambda x: pow(x, n) for n in range(-4,5))
phi = (1 + pow(5,0.5)) * 0.5 # golden proportion
for n, f in enumerate(powers, start=-4): # iterates through lambda expressions
print("phi ** {:2} == {:10.8f}".format(n, f(phi)))
class Any:
def __init__(self):
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: Any object expecting to be the target of a for loop, if not already an iterator, needs to either
Step3: The generator function below shows what... |
9,534 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
with open('./reviews.txt', 'r') as f:
reviews = f.read()
with open('./labels.txt', 'r') as f:
labels = f.read()
reviews[:2000]
from string import punctuation
all_text = ''.join([c for c in reviews if c not in punctuation])
reviews = all_... | <SYSTEM_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 preprocessing
Step2: Encoding the words
Step3: Encoding the labels
Step4: If you built labels correctly, you should see the next output.... |
9,535 | <ASSISTANT_TASK:>
Python Code:
!pip install python_speech_features
!pip install resampy
!pip install scipy
!pip install gdown
!pip install tqdm -U
PATH = '/content/drive/My Drive/DeepSpeechDistances'
SAMPLE_PATH = '/content/drive/My Drive/DeepSpeechDistances/abstract_samples'
NUM_SPLITS = 3 # number of data splits 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: Set up evaluation parameters and paths within the mounted Google Drive. Clone repository and download checkpoint.
Step2: Do other necessary imp... |
9,536 | <ASSISTANT_TASK:>
Python Code:
import keras
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
# Setting seed for reproducibility
np.random.seed(1234)
PYTHONHASHSEED = 0
from sklearn import preprocessing
from sklearn.metrics import confusion_matrix, recall_score, precision_score
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:
Step1: Data Ingestion
Step2: Data Preprocessing
Step4: LSTM
Step5: Model Evaluation on Test set
Step6: Model Evaluation on Validation set
Step7: R... |
9,537 | <ASSISTANT_TASK:>
Python Code:
import os
from pathlib import Path
testfolder = Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'Tutorial_01'
# Another option using relative address; for some operative systems you might need '/' instead of '\'
# testfolder = os.path.abspath(r'..\..\bifacial_radiance\TEMP... | <SYSTEM_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 will load bifacial_radiance and other libraries from python that will be useful for this Jupyter Journal
Step2: <a id='step2'></a>
Step3: ... |
9,538 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import numpy as np
from stingray import Lightcurve, Powerspectrum, AveragedPowerspectrum
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager
%matplotlib inline
font_prop = font_manager.FontProperties(size=16)
dt = 0.03125 # 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: 1. Create a light curve
Step2: Now let's turn noisy into a Lightcurve object.
Step3: Here we plot it to see what it looks like.
Step4: 2. Pas... |
9,539 | <ASSISTANT_TASK:>
Python Code:
import os
import nibabel as nb
import matplotlib.image as mpimg
from m2g.utils.gen_utils import get_braindata, get_filename
from m2g.utils.qa_utils import get_min_max, opaque_colorscale, pad_im
from argparse import ArgumentParser
from scipy import ndimage
from matplotlib.colors import Lin... | <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: Saving figures
Step4: Generating the qa overlay figures
Step5: Input and Graphs
Step6: This is a good example of well-registed images where p... |
9,540 | <ASSISTANT_TASK:>
Python Code:
! pip install --quiet -U pltvid # simple animation support by parrt
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression, Ridge, Lasso, LogisticRegression
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
from sklearn.ensemble 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: Wine data set
Step2: Synthetic data set
Step3: Animate num trees in RF
Step4: Animate decision tree max depth
Step5: Animate decision tree m... |
9,541 | <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-mr', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,542 | <ASSISTANT_TASK:>
Python Code:
import os
import zipfile
import numpy as np
import pandas as pd
from sklearn import linear_model
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('darkgrid')
%matplotlib inline
# Put files in current direction into a list
files_list = [f for 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: Unzipping files with house sales data
Step2: Polynomial regression, revisited
Step3: Let's use matplotlib to visualize what a polynomial regre... |
9,543 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow import keras
import tensorflow_hub as hub
from tensorflow.keras import layers
import tensorflow_decision_forests as tfdf
import matplotlib.pyplot as plt
# Turn .csv files into pandas DataFrame's
df = pd.read_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: Get the data
Step2: The dataset includes 7613 samples with 5 columns
Step3: Shuffling and dropping unnecessary columns
Step4: Printing inform... |
9,544 | <ASSISTANT_TASK:>
Python Code:
df = pd.read_csv("../data/coal_prod_cleaned.csv")
df.head()
df.shape
df.columns
qgrid_widget = qgrid.show_grid(
df[["Year", "Mine_State", "Labor_Hours", "Production_short_tons"]],
show_toolbar=True,
)
qgrid_widget
df2 = df.groupby('Mine_State').sum()
df3 = df.groupby('Mine_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: Github
|
9,545 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_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: IMDB データセットをダウンロードする
Step3: データの観察
Step4: 最初の 10 個のサンプルを出力しましょう。
Step5: 最初の 10 個のラベルも出力しましょう。
Step6: モデルを構築する
Step7... |
9,546 | <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, 40)
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,547 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def histogram(f):
return np.bincount(f.ravel())
def histogram_eq(f):
from numpy import amax, zeros, arange, sum
n = amax(f) + 1
h = zeros((n,),int)
for i in arange(n):
h[i] = sum(i == f)
return h
def histogram_eq1(f):
import numpy 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: Function Code for brute force implementation
Step2: Function code for bidimensional matrix implementation
Step3: Examples
Step4: Numerical ex... |
9,548 | <ASSISTANT_TASK:>
Python Code:
from pearce.mocks import cat_dict
import numpy as np
from os import path
from astropy.io import fits
from astropy import constants as const, units as unit
import george
from george.kernels import ExpSquaredKernel
import matplotlib
#matplotlib.use('Agg')
from matplotlib import pyplot as pl... | <SYSTEM_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 up the tptY3 buzzard mocks.
Step2: Load up a snapshot at a redshift near the center of this bin.
Step3: This code load a particular snaps... |
9,549 | <ASSISTANT_TASK:>
Python Code:
import veneer
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
%matplotlib inline
plt.plot(range(10))
%matplotlib notebook
plt.plot(range(10))
%matplotlib inline
v = veneer.Veneer()
# Equiavelent to
# v = veneer.Veneer(host='localhost',port=9876)... | <SYSTEM_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
Step2: Aside
Step3: The rest of this tutorial uses v to refer to current Veneer client
Step4: You can also perform some basic topologi... |
9,550 | <ASSISTANT_TASK:>
Python Code:
import scipy.stats as stats
from scipy.stats import binom
from __future__ import division
%pylab
%matplotlib inline
import seaborn as sns
plt.plot([1,2,3], [2,3,5])
pylab.rcParams['figure.figsize'] = 12, 6
nCells = 1e6
nDays = 10
nDivisions = np.log2(nCells)
time_per_division = nDays *... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Hematopoiesis
Step2: Defining properties of stem cells
Step3: Efficiency of the CFUs
Step4: Converting to actual CFU numbers
Step5: What's t... |
9,551 | <ASSISTANT_TASK:>
Python Code:
import shutil
import sys
import os.path
if not shutil.which("pyomo"):
!pip install -q pyomo
assert(shutil.which("pyomo"))
if not (shutil.which("glpk") or os.path.isfile("glpk")):
if "google.colab" in sys.modules:
!apt-get install -y -qq glpk-utils
else:
try... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From Pyomo, we use the following procedures for writing our LP models
Step3: Creating random 2D discrete measures
Step4: And to create two ran... |
9,552 | <ASSISTANT_TASK:>
Python Code:
'''
Trains a simple deep NN on the MNIST dataset.
You can get to 98.40% test accuracy after 20 epochs.
'''
from __future__ import print_function
import tensorflow as tf
import numpy as np
tf.reset_default_graph()
np.random.seed(1337) # for reproducibility
from keras.datasets import mnist... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Name generation with LSTM
Step2: Classical neural networks, including convolutional ones, suffer from two severe limitations
Step3: The simple... |
9,553 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
# Calculates the core hot spot temperature of the transformer
def core_hot_spot(ambient_temp, overload_ratio, t0=35, tc=30, N=1,
N0=0.5, Nc=0.8, L=1):
# ambient_temp is in Celsius
# overload_rat... | <SYSTEM_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 figure above demonstrates the core hot spot temperature from 0 to 100 degrees C, for five different overload ratios. Notice that the relatio... |
9,554 | <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: Reading PostgreSQL database from TensorFlow IO
Step2: Install and setup PostgreSQL (optional)
Step3: Setup necessary environmental variables
S... |
9,555 | <ASSISTANT_TASK:>
Python Code:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import numpy as np
np.set_printoptions(threshold=np.nan)
import tensorflow as tf
import time
import pandas as pd
import matplotlib.pyplot as plt
import progressbar
def calculate_contrast(window_orig, window_recon):
'''
calculates th... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now that we have the metrics in place we can load the data an run them iteratively at each size of the images.
Step2: data looks good. now we c... |
9,556 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from cs231n.classifiers.cnn import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check import eval_numerical_gradient_array, eval_numerical_gradient
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convolutional Networks
Step2: Convolution
Step4: Aside
Step5: Convolution
Step6: Max pooling
Step7: Max pooling
Step8: Fast layers
Step9: ... |
9,557 | <ASSISTANT_TASK:>
Python Code:
# Authors: Pierre Ablin <pierreablin@gmail.com>
#
# License: BSD (3-clause)
from time import time
import mne
from mne.preprocessing import ICA
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.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: Read and preprocess the data. Preprocessing consists of
Step2: Define a function that runs ICA on the raw MEG data and plots the components
Ste... |
9,558 | <ASSISTANT_TASK:>
Python Code:
# Setup feedback system
from learntools.core import binder
binder.bind(globals())
from learntools.time_series.ex3 import *
# Setup notebook
from pathlib import Path
from learntools.time_series.style import * # plot style settings
from learntools.time_series.utils import plot_periodogram,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Examine the following seasonal plot
Step2: And also the periodogram
Step3: 1) Determine seasonality
Step4: 2) Create seasonal features
Step5:... |
9,559 | <ASSISTANT_TASK:>
Python Code:
import os
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if os.getenv("IS_TESTING"):
!... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
9,560 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from cs231n.classifiers.neural_net import TwoLayerNet
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = '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: Implementing a Neural Network
Step2: We will use the class TwoLayerNet in the file cs231n/classifiers/neural_net.py to represent instances of o... |
9,561 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import pandas.io.data as web
import plotly.plotly as py
import cufflinks as cf
py.sign_in('Python-Demo-Account', 'gwt101uhh0')
symbols = ['AAPL', 'MSFT', 'YHOO']
data = pd.DataFrame()
for sym in symbols:
data[sym] = web.DataReader(sym, data_sour... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading Financial Data
Step2: Plotting the Data
|
9,562 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
train = pd.read_csv('https://gist.githubusercontent.com/ucals/'
'2cf9d101992cb1b78c2cdd6e3bac6a4b/raw/'
'43034c39052dcf97d4b894d2ec1bc3f90f3623d9/'
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the dataset, we were provided with a baseline chest CT scan and associated clinical information for a set of patients. A patient has an image... |
9,563 | <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: 创建和操控张量
Step2: 矢量加法
Step3: 输出张量不仅会返回其值,还会返回其形状(将在下一部分中讨论)以及存储在张量中的值的类型。调用张量的 numpy 方法会返回该张量的值(以 NumPy 数组形式):
Step4: 张量形状
Step5: 广播
Step6: 练... |
9,564 | <ASSISTANT_TASK:>
Python Code:
def stan_cache(model_code, model_name=None, **kwargs):
Use just as you would `stan`
code_hash = md5(model_code.encode('ascii')).hexdigest()
if model_name is None:
cache_fn = 'cached-model-{}.pkl'.format(code_hash)
else:
cache_fn = 'cached-{}-{}.pkl'.format(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Análisis de los sondeos electorales 2016
Step2: Leemos el fichero de datos obtenido de la Wikipedia y hacemos el parsing. Escogemos sólo aquell... |
9,565 | <ASSISTANT_TASK:>
Python Code:
import plotly
plotly.__version__
import numpy as np
import plotly.graph_objs as go
def rot_matrix(theta):
return np.array([[np.cos(theta), -np.sin(theta)],
[np.sin(theta), np.cos(theta)]])
def get_arrows(start, end, arrow_angle, plane=2, fract=0.1):
th... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Define a function that returns data to draw vectors of a vector field with values in the plane yOz or xOy (i.e. electric or magnetic field vec... |
9,566 | <ASSISTANT_TASK:>
Python Code:
# Run the following to import necessary packages and import dataset. Do not use any additional plotting libraries.
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.style.use('ggplot')
datafile = "dataset/icecream.csv"
df = pd.read_csv(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: The dataset above contains the ice cream sales, temperature, number of deaths by drowning and humidity level in a city during a timespan of 12 m... |
9,567 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
# Check that GPU is available: cf. https://colab.research.google.com/notebooks/gpu.ipynb
assert(tf.test.is_gpu_available())
tf.keras.backend.clear_session()
tf.config.optimizer.set_jit(False) # Start with XLA disabled.
def load_data():
(x_train, y_train), (x_test... | <SYSTEM_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 define the model, adapted from the Keras CIFAR-10 example
Step2: We train the model using the
Step3: Now let's train the model again, using... |
9,568 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import matplotlib.pyplot as plt
# The two statements below are used mainly to set up a plotting
# default style that's better than the default from matplotlib
#import seaborn as sns
plt.style.use('bmh')
from shapely.geometry import Point
#import pandas as pd
i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set file names and directories
Step2: Plot the glacier outlines based on their specific mass balance
|
9,569 | <ASSISTANT_TASK:>
Python Code:
# Python program to use AIM tools
from asymptotic import *
# symengine (symbolic) variables for lambda_0 and s_0
En, r = se.symbols("En, r")
r0, m, λ, γ = se.symbols("r0, m, λ, γ")
# lambda_0 and s_0
l0 = 2*r - 2*se.sqrt(λ)/r**(m+1) - (1 + m)/r
s0 = se.expand(2 + m + 2*se.sqrt(λ)/r**m ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Definitions
Step2: $\lambda_0$ and $s_0$
Step3: Case
Step4: Initialize AIM solver
Step5: Calculation necessary coefficients
Step6: The Solu... |
9,570 | <ASSISTANT_TASK:>
Python Code:
### START CODE HERE ### (≈ 1 line of code)
test = "Hello World"
### END CODE HERE ###
print ("test: " + test)
# GRADED FUNCTION: basic_sigmoid
import math
import numpy as np
def basic_sigmoid(x):
Compute sigmoid of x.
Arguments:
x -- A scalar
Return:
s -- sigmoid... | <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: Expected output
Step3: Expected Output
Step4: In fact, if $ x = (x_1, x_2, ..., x_n)$ is a row vector then $np.exp(x)$ will apply the exponent... |
9,571 | <ASSISTANT_TASK:>
Python Code:
# https://github.com/probml/pyprobml/blob/master/scripts/beta_binom_approx_post_pymc3.py
# 1d approixmation to beta binomial model
# https://github.com/aloctavodia/BAP
# import superimport
import pymc3 as pm
import numpy as np
import seaborn as sns
import scipy.stats as stats
import matpl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exact
Step2: Grid
Step3: Laplace
Step4: ADVI
Step5: HMC
|
9,572 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
#Lendo a base de dados
df = pd.read_csv('../datasets/titanic/train.csv')
print("Tabela Original")
df.head()
df = df.drop(['Name', 'Ticket', 'Cabin'], axis=1)
df = df.dropna()
df['Gender'] = df['Sex'].map({'female': 0, 'male':1}).astype(int)
df['Port'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Por fim, geramos nossa base de treino e teste no formato para o ScikitLearn
|
9,573 | <ASSISTANT_TASK:>
Python Code:
import jax
import jax.numpy as jnp
from jax.config import config
config.update("jax_enable_x64", True)
@jax.jit
def f(x, A, b):
res = A @ x - b
return res @ res
gradf = jax.grad(f, argnums=0, has_aux=False)
n = 1000
x = jax.random.normal(jax.random.PRNGKey(0), (n, ))
A = jax.ran... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: By default, JAX exploits single-precision numbers float32
Step2: Random numbers in JAX
Step3: Forward mode vs. backward mode
Step4: Forward m... |
9,574 | <ASSISTANT_TASK:>
Python Code:
%%bash
pip freeze | grep tensor
# Choose a version of TensorFlow that is supported on TPUs
TFVERSION='1.13'
import os
os.environ['TFVERSION'] = TFVERSION
%%bash
pip install tensor2tensor==${TFVERSION} gutenberg
# install from sou
#git clone https://github.com/tensorflow/tensor2tensor.git... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If the following cell does not reflect the version of tensorflow and tensor2tensor that you just installed, click "Reset Session" on the noteboo... |
9,575 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
import sklearn.metrics
import sklearn.datasets
import sklearn.manifold
import sklearn.decomposition
import sklearn.preprocessing
import sklearn.cluster
import sklearn.feature_selection
import skle... | <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: Features and high-dimensional spaces
Step3: 1.2 Non-linear transformations
Step4: 1.3 Projection to 2D via decomposition
Step5: 1.4 Clusterin... |
9,576 | <ASSISTANT_TASK:>
Python Code:
# import libraries
import torch
import numpy as np
from torchvision import datasets
import torchvision.transforms as transforms
# number of subprocesses to use for data loading
num_workers = 0
# how many samples per batch to load
batch_size = 20
# convert data to torch.FloatTensor
transf... | <SYSTEM_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 Visualize the Data
Step2: Visualize a Batch of Training Data
Step3: View an Image in More Detail
Step4: Define the Network Architect... |
9,577 | <ASSISTANT_TASK:>
Python Code:
%load_ext sql
%sql mysql://steinam:steinam@localhost/personal
%%sql
select MNr, MName, MVorname from Mitarbeiter
order by MName desc limit 1;
%%sql
select Mitarbeiter.MNr, MName, Stunden, Projektname, Firma
from Mitarbeiter inner join Projektbearbeitung
on MItarbeiter.MNr = Projek... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Welcher Mitarbeiter steht in einer alphabetisch sortierten Liste an letzter Stelle? Es sollen die Mitarbeiternummer, der Nachname und der Vornam... |
9,578 | <ASSISTANT_TASK:>
Python Code:
import requests
from bs4 import BeautifulSoup
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6',
'Cache-Control': 'no-cache',
'Conne... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 爬取所有的专辑信息(album_by _artist.py)
Step2: http
Step3: 根据专辑信息爬取所有的歌曲信息(music_by _album.py)
Step4: 根据歌曲信息爬取其评论条数(comments_by _music.py
Step5: 翻页的实... |
9,579 | <ASSISTANT_TASK:>
Python Code:
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from fastai.transforms import *
from fastai.conv_learner import *
from fastai.model import *
from fastai.dataset import *
from fastai.sgdr import *
from fastai.plots import *
import pandas as pd
import numpy as np
path = 'data/gloc/'... | <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: Custom ConvnetBuilder
Step3: NOTE
Step4: So, the numbers in the top layers are different from Yannet's, but the Conv layer pars are exactly th... |
9,580 | <ASSISTANT_TASK:>
Python Code:
star_wars = pd.read_csv('star_wars.csv', encoding="ISO-8859-1")
star_wars.head()
star_wars.columns
star_wars = star_wars.dropna(subset=['RespondentID'])
star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'].isnull().value_counts()
star_wars['Have you seen 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: Data Cleaning
Step2: Change the second and third columns.
Step3: The values for the second and third columns which are Have you seen any of th... |
9,581 | <ASSISTANT_TASK:>
Python Code:
!pip install -q flax
from typing import Sequence
import matplotlib.pyplot as plt
import jax
import jax.numpy as jnp
import flax.linen as nn
from flax.training import train_state
import optax
import functools
import scipy as sp
import math
rng = jax.random.PRNGKey(0)
@functools.partial(ja... | <SYSTEM_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 Generation
Step2: Plotting
Step3: Models and Training
Step4: The loss function for the discriminator is
Step5: The loss function for th... |
9,582 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
k = 30
start = '2014-01-01'
end = '2015-01-01'
pricing = get_pricing('PEP', fields='price', start_date=start, end_date=end)
fundamentals = init_fundamentals()
num_shares = get_fundamentals(query(fundamentals.earnings_r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: In order to use this in a strategy, we should wrap our momentum calculator in a function
Step3: Now we implement the strategy described in the ... |
9,583 | <ASSISTANT_TASK:>
Python Code:
# Import packages here:
import math as m
import numpy as np
from IPython.display import Image
import matplotlib.pyplot as plt
# Properties of Materials (engineeringtoolbox.com, Cengel, Tian)
# Conductivity
Kair = 0.026 # w/mk
Kptfe = 0.25 # w/mk
Kcf = 0.8 # transverse conductivity 0.5 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Heat Transfer Rate
Step2: Evaporation Rate
Step3: Time for total Evaporation
Step4: Finally, the amount of time that it takes for all 0.68kg ... |
9,584 | <ASSISTANT_TASK:>
Python Code:
loc_data = pd.read_csv('location_data_hw9.csv')
loc_data.head()
fig, axes = plt.subplots(2,2, figsize=[6, 4])
ylabels = [['red_pos_X', 'red_pos_Y'], ['blue_pos_X', 'blue_pos_Y']]
for i in range(2):
for j in range(2):
axes[i,j].plot(loc_data['t'], loc_data[ylabels[i][j]])
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Visualize data
Step2: value of slope and intercept from linear regression
Step3: model
Step4: a)
Step5: posterior of red speed
Step6: Blue ... |
9,585 | <ASSISTANT_TASK:>
Python Code::
dataFrame = dataFrame.drop(row)
<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:
|
9,586 | <ASSISTANT_TASK:>
Python Code:
class MPCORB:
class for accessing MRCORB database records
def __init__(self, file='MRCORB.DAT'):
self.file = file
class MPOrbit:
parse and process MPCORB entries
http://www.minorplanetcenter.org/iau/info/MPOrbitFormat.html
def __init__(self, line):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step6: Snatching asteroids. A hijacking guide to the galaxy!
Step7: Output format
|
9,587 | <ASSISTANT_TASK:>
Python Code:
2 + 3
2*3
2**3
sin(pi)
from math import sin, pi
sin(pi)
a = 10
a
# YOUR CODE HERE
raise NotImplementedError()
# YOUR CODE HERE
raise NotImplementedError()
from nose.tools import assert_equal
assert_equal(_, c)
print("Sin errores")
A = [2, 4, 8, 10]
A
A*2
f = lambda x: x**2 + 1
f(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:
Step1: Sin embargo no existen funciones trigonométricas cargadas por default. Para esto tenemos que importarlas de la libreria math
Step2: Variables
S... |
9,588 | <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... |
9,589 | <ASSISTANT_TASK:>
Python Code:
# Download data, unzip, etc.
import pandas as pd
import urllib
import tempfile
import shutil
import zipfile
temp_dir = tempfile.mkdtemp()
data_source = 'http://archive.ics.uci.edu/ml/machine-learning-databases/00275/Bike-Sharing-Dataset.zip'
zipname = temp_dir + '/Bike-Sharing-Dataset.zip... | <SYSTEM_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 matplotlib (and other useful libraries)
Step2: Exploring relationships between quantitative variables
Step3: Line plot
Step4: Line plo... |
9,590 | <ASSISTANT_TASK:>
Python Code:
message = "Hello Python world!"
print(message)
###highlight=[5,6]
message = "Hello Python world!"
print(message)
message = "Python is my favorite language!"
print(message)
message = "Thank you for sharing Python with the world, Guido!"
print(mesage)
###highlight=[3]
message = "Thank yo... | <SYSTEM_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 variable holds a value. You can change the value of a variable at any point.
Step2: Naming rules
Step3: Let's look through this error messag... |
9,591 | <ASSISTANT_TASK:>
Python Code:
import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
c.execute(
CREATE TABLE employees (
id int unsigned NOT NULL,
first_name string NOT NULL,
last_name string NOT NULL,
department_id int unsigned,
PRIMARY KEY (id)
))
c.execute(
CREATE TABLE departments (
id 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:
Step4: Вопросы
Step5: ORM - Object-Relational Mapping
Step6: Нужно добавить наше приложение в INSTALLED_APPS в settings.py
Step7: Создадим миграцию ... |
9,592 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image(filename="YoungTwoSlitExperiment.JPG")
from IPython.display import Image
Image(filename="ExperimentoYoung.jpg")
from matplotlib.pyplot import *
from numpy import *
%matplotlib inline
style.use('fivethirtyeight')
###################################... | <SYSTEM_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 experiments I am about to relate ... may be repeated with great ease,
Step2: Según la figura, $\Delta = r_2 - r_1$ lo podemos escribir c... |
9,593 | <ASSISTANT_TASK:>
Python Code:
def write_answer_to_file(answer, filename):
with open(filename, 'w') as f_out:
f_out.write(str(round(answer, 3)))
import pandas as pd
adver_data = pd.read_csv('advertising.csv')
adver_data.head(5)
adver_data.describe()
import numpy as np
X = np.array(adver_data.values[:,0:3... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Загрузите данные из файла advertising.csv в объект pandas DataFrame. Источник данных.
Step2: Посмотрите на первые 5 записей и на статистику ... |
9,594 | <ASSISTANT_TASK:>
Python Code:
import itertools
from pprint import pprint
from operator import getitem
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import numpy as np
import spacepy.plot as spp
import pymc as mc
import tqdm
from MCA_file_viewer_v001 import GetMCAfile
def plot_box(x, y, c='r', 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: Do some calculations to try and match Phil's analysis
Step4: Can we get a noise estimate?
Step5: Noise estimates
Step6: Maybe we should consi... |
9,595 | <ASSISTANT_TASK:>
Python Code:
# Basic imports
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
import scipy.optimize as spo
import sys
from time import time
from sklearn.metrics import r2_score, median_absolute_error
%matplotlib inline
%pylab inline
pylab.rcParams[... | <SYSTEM_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 first organize the results from the previous notebooks
Step2: Which is the best model before hyperparameter tuning?
Step3: Before hyperp... |
9,596 | <ASSISTANT_TASK:>
Python Code:
def AofT(time,T, ai, taui):
return ai*np.exp(-time/taui)/(1.+np.exp(-T/(2*taui)))
from SimPEG import *
import sys
sys.path.append("./DoubleLog/")
from plotting import mapDat
class LinearSurvey(Survey.BaseSurvey):
nD = None
def __init__(self, time, **kwargs):
self.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: Simple exponential basis
|
9,597 | <ASSISTANT_TASK:>
Python Code:
attend = sns.load_dataset("attention").query("subject <= 12")
g = sns.FacetGrid(attend, col="subject", col_wrap=4, size=2, ylim=(0, 10))
g.map(sns.pointplot, "solutions", "score", color=".3", ci=None);
tips = sns.load_dataset("tips")
with sns.axes_style("white"):
g = sns.FacetGrid(ti... | <SYSTEM_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 slide with just text
Step2: Here we show some code
|
9,598 | <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,599 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(8, 4), columns=['A', 'B', 'C', 'D'])
df["A"] #indexing
df.A #attribute
type(df.A)
df.A[0]
df[["A","B"]]
type(df[["A","B"]])
s = df["A"]
s[:5]
s[::2]
s[::-1]
df[:3] # for convenience as it is a common use
df["A"]
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: Slicing ranges
Step2: Watchout... this is a rather incoherent use of the indexinf method over rows. That's why it is said that loc provides a m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.