Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
1,800 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
xs = np.arange(10, 14)
ys = np.arange(20, 25)
print(xs, ys)
n = len(xs)
m = len(ys)
indices = np.arange(n)
array = np.tile(ys, (n, 1))
print(array)
[np.random.shuffle(array[i]) for i in range(n)]
print(array)
counts = np.full_like(xs, m)
print(counts)
weights = 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: Here are some example values for x and y. I assume that there are no repeated values in x.
Step2: indices is the list of indices I'll choose f... |
1,801 | <ASSISTANT_TASK:>
Python Code:
# we'll use the pythonic pyplot interface
import matplotlib.pyplot as plt
# necessary for the notebook to render the plots inline
%matplotlib inline
import numpy as np
np.random.seed(42)
x = np.linspace(0, 40, 1000)
y = np.sin(np.linspace(0, 10*np.pi, 1000))
y += 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: The default plots created with matplotlib aren't bad, but they do have elements that are, at best, unnecessary. At worst, these elements detract... |
1,802 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn import decomposition
from sklearn import datasets
tabela = pd.read_csv("exemplo_7/iris.data",header=None,sep=',')
tabela
tabela.columns=['sepal_len', 'sepal_wid', 'petal_len', 'petal_wid', 'class']
tabela
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Agora, vamos separar os dados entre as medidas e as espécies.
Step2: Agora, vamos calcular a decomposição em componentes principais
Step3: pca... |
1,803 | <ASSISTANT_TASK:>
Python Code:
def hex_key(num):
primes = ('2', '3', '5', '7', 'B', 'D')
total = 0
for i in range(0, len(num)):
if num[i] in primes:
total += 1
return total
<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:
|
1,804 | <ASSISTANT_TASK:>
Python Code:
from CesiumWidget import CesiumWidget
from IPython import display
import numpy as np
cesium = CesiumWidget()
cesium
cesium.kml_url = '/nbextensions/CesiumWidget/cesium/Apps/SampleData/kml/gdpPerCapita2008.kmz'
for lon in np.arange(0, 360, 0.5):
cesium.zoom_to(lon, 0, 36000000, 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: Create widget object
Step2: Display the widget
Step3: Cesium is packed with example data. Let's look at some GDP per captia data from 2008.
St... |
1,805 | <ASSISTANT_TASK:>
Python Code:
import subprocess
import os
import sys
from dask_jobqueue import PBSCluster
from distributed import Client, progress
from datetime import datetime, timedelta
from pkg_resources import load_entry_point
from distributed import progress
def exec_adi(info_dict):
This function will ca... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Installation instructions
Step2: This will start a distributed cluster on the arm_high_mem queue. I have set it to have 6 adi_cmac2 processes p... |
1,806 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from netCDF4 import Dataset
import holoviews as hv
from postladim import ParticleFile
hv.extension('bokeh')
# Read bathymetry and land mask
with Dataset('../data/ocean_avg_0014.nc') as ncid:
H = ncid.variables['h'][:, :]
M = ncid.variables['mask_rho'][:, :]
jma... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Background map
Step3: Particle plot function
Step4: Still images
Step5: Dynamic map
|
1,807 | <ASSISTANT_TASK:>
Python Code:
district = 'http://www.cian.ru/cat.php?deal_type=sale&district%5B0%5D=13&district%5B1%5D=14&district%5B2%5D=15&district%5B3%5D=16&district%5B4%5D=17&district%5B5%5D=18&district%5B6%5D=19&district%5B7%5D=20&district%5B8%5D=21&district%5B9%5D=22&engine_version=2&offer_type=flat&p={}&room1=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: Собираем ссылки на все квартиры первых тридцати страниц выдачи
Step2: Cтандартный блок, в котором мы получаем по ссылке текст страницы в удобно... |
1,808 | <ASSISTANT_TASK:>
Python Code:
from scipy import misc
from scipy.ndimage import rotate
import numpy as np
data_orig = misc.face()
x0,y0 = 580,300 # left eye; (xrot,yrot) should point there
angle = np.random.randint(1, 360)
def rot_ans(image, xy, angle):
im_rot = rotate(image,angle)
org_center = (np.array(image... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
1,809 | <ASSISTANT_TASK:>
Python Code:
import scipy as sp
import scipy.stats as stats
import matplotlib.pyplot as plt
import pandas as pd
%pylab inline
def h(x, w): return sp.dot(x, w)
def plot_decision_boundary(h, boundary=0, margins=None):
x = linspace(-10, 10)
y = linspace(-10, 10)
X1, X2 = np.meshgrid(x, y)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sadržaj
Step2: Poopćeni linearan model
Step3: Odabir funkcije $f$ nema utjecaja na linearnost granice, budući da će, očigledno, funkcija $f$ z... |
1,810 | <ASSISTANT_TASK:>
Python Code:
%%file mr_s3_log_parser.py
import time
from mrjob.job import MRJob
from mrjob.protocol import RawValueProtocol, ReprProtocol
import re
class MrS3LogParser(MRJob):
Parses the logs from S3 based on the S3 logging format:
http://docs.aws.amazon.com/AmazonS3/latest/dev/LogFormat.html
... | <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: This notebook was prepared by Donne Martin. Source and license info is on GitHub.
Step3: Running Amazon Elastic MapReduce Jobs
Step4: Run a Ma... |
1,811 | <ASSISTANT_TASK:>
Python Code:
#untar and compile ms and sample_stats
!tar zxf ms.tar.gz; cd msdir; gcc -o ms ms.c streec.c rand1.c -lm; gcc -o sample_stats sample_stats.c tajd.c -lm
#I get three compiler warnings from ms, but everything should be fine
#now I'll just move the programs into the current working dir
!mv 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: Install scikit-learn
Step2: or if you don't use conda, you can use pip to install scikit-learn with
Step3: Step 1
Step4: Step 2
Step5: That'... |
1,812 | <ASSISTANT_TASK:>
Python Code:
try:
%load_ext watermark
watermark = True
except ImportError:
watermark = False
pass
import sys
sys.path.append("../") # Add parent dir in the Path
from hyperstream import HyperStream
from hyperstream import TimeInterval
from hyperstream.utils import UTC
from hyperstream 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: Reading the data
Step3: Once the csv_reader has created the instances in the country plate, we will modify the dictionaries applying a function... |
1,813 | <ASSISTANT_TASK:>
Python Code:
ls
pwd
cd 2017oct04
ls
pwd
ls M52*fit
ls M52-001*fit
ls *V*
cd ..
# Make a new directory, "temporary"
# Move into temporary
# Move the test_file.txt into this current location
# Create a copy of the test_file.txt, name the copy however you like
# Delete the original test_file.txt
#... | <SYSTEM_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're in a new folder now, so issue commands in the next two cells to look at the folder content and list your current path
Step2: Now test out... |
1,814 | <ASSISTANT_TASK:>
Python Code:
import pubchempy as pcp
c = pcp.Compound.from_cid(5090)
c
print(c.molecular_formula)
print(c.molecular_weight)
print(c.isomeric_smiles)
print(c.xlogp)
print(c.iupac_name)
print(c.synonyms)
results = pcp.get_compounds('Glucose', 'name')
results
for compound in results:
print compou... | <SYSTEM_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 get the Compound with CID 5090
Step2: Now we have a Compound object called c. We can get all the information we need from this object
Ste... |
1,815 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import json
from pandas.io.json import json_normalize
# define json string
data = [{'state': 'Florida',
'shortname': 'FL',
'info': {'governor': 'Rick Scott'},
'counties': [{'name': 'Dade', 'population': 12345},
{'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: imports for Python, Pandas
Step2: JSON example, with string
Step3: JSON example, with file
Step4: JSON exercise
Step5: Top 10 Countries with... |
1,816 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image('images/12_adversarial_noise_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
# We also... | <SYSTEM_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: Load Data
Step4: The MNIST data-set has now bee... |
1,817 | <ASSISTANT_TASK:>
Python Code:
import Lib.subdivision as sub
Method_subdivision=sub.WellGrid(Rect0=(0,0),Rect1=(50,50),Qw=1000,Qe=(200,400,300,100),h=26.25,phi=0.2)
Method_subdivision.Subdivision()
SL,TOF,SL_end,TOF_end=Method_subdivision.SLTrace(NSL=80)
Method_subdivision=sub.WellGrid(Rect0=(0,0),Rect1=(50,50),Qw=1000... | <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: Quick Start-Embedded Method
Step7: Fill-Grid Method
|
1,818 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
#%matplotlib notebook
import matplotlib
matplotlib.rcParams['figure.figsize'] = (9, 9)
import pandas as pd
def conv_func(s):
s = s.replace('<', '')
if s == 'ND':
return np.nan
elif s.strip() == '':
return np.nan
else:
return float... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Infos diverses sur le DataFrame
Step2: Analyse de la concentration en particules fines (PM10)
|
1,819 | <ASSISTANT_TASK:>
Python Code:
# グラフが文章中に表示されるようにするおまじない
%matplotlib inline
from sklearn import datasets
digits = datasets.load_digits()
print(digits.data.shape)
import matplotlib.pyplot as plt
plt.figure(1, figsize=(3, 3))
plt.imshow(digits.images[0], cmap=plt.cm.gray_r, interpolation='nearest')
plt.show()
from skl... | <SYSTEM_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 Data
Step2: 1797は行数、64は次元数です。手書き文字の画像データが8×8のサイズであるため、その中のピクセル情報は64となります。
Step3: Create the Model
Step4: Training the Model
Step5: ... |
1,820 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Exercício 1 - Crie um objeto a partir da classe abaixo, chamado roc1, passando 2 parâmetros e depois faça uma chamada
# aos atributos e 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: Exercícios
|
1,821 | <ASSISTANT_TASK:>
Python Code:
# utility imports
from __future__ import print_function
from pprint import pprint
from matplotlib import pyplot as plt
# main imports
import numpy as np
import distarray.globalapi as da
from distarray.plotting import plot_array_distribution
# output goodness
np.set_printoptions(precision=... | <SYSTEM_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 the parameter space for our study. We will perform GE on matrices that are block distributed in any one or both dimensions, while ... |
1,822 | <ASSISTANT_TASK:>
Python Code:
def find_tile(tile, State):
n = len(State)
for row in range(n):
for col in range(n):
if State[row][col] == tile:
return row, col
to_list = lambda State: [list(row) for row in State]
to_tuple = lambda State: tuple(tuple(row) for row in 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: Since breadth first search stores the set of states that have been visited, we have to represent states by immutable objects and hence we repres... |
1,823 | <ASSISTANT_TASK:>
Python Code:
plt.hist(values.map(len))
def pad_smiles(smiles_string, smile_max_length):
if len(smiles_string) < smile_max_length:
return smiles_string + " " * (smile_max_length - len(smiles_string))
padded_smiles = [pad_smiles(i, smile_max_length) for i in values if pad_smiles(i, smi... | <SYSTEM_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 some keras version stuff. 1.0 uses keras.losses to store its loss functions. 2.0 uses objectives. we'll just have to be consistent
Step2: He... |
1,824 | <ASSISTANT_TASK:>
Python Code:
from pprint import pprint
from IPython.display import Image
from sklearn.pipeline import Pipeline
from sklearn.pipeline import FeatureUnion
from sklearn.preprocessing import FunctionTransformer
from sklearn.preprocessing import StandardScaler
from dstoolbox.utils import get_nodes_edges
fr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Nodes and edges of a pipeline
Step2: Visualizing a pipeline
|
1,825 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
plt.plot(range(20))
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
plt.scatter(x, y)
plt.show()
y = np.random.rand(5)
x = np.arange(5)
plt.bar(x,y)
plt.show()
N = 50
x = np.random.rand(N)
y = np.random.rand(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: Libraries we will be using
Step2: A basic matplotlib using Python's range function for data
Step3: A scatter plot with using NumPy's random fu... |
1,826 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
%matplotlib inline
import xarray as xr
import datetime
import numpy as np
from dask.distributed import LocalCluster, Client
import s3fs
import cartopy.crs as ccrs
import cartopy.io.shapereader as shpreader
import cartopy
import boto3
import matplotlib.pyplot as plt
im... | <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: First we define some variables for reading zarr
Step3: Here we define some functions to read in zarr data.
Step4: This is where we read in the... |
1,827 | <ASSISTANT_TASK:>
Python Code:
from pysismo.pspreprocess import Preprocess
from obspy.signal.cross_correlation import xcorr
from obspy import read
from obspy.core import Stream
import matplotlib.pyplot as plt
import numpy as np
import os
%matplotlib inline
# list of example variables for Preprocess class
FREQMAX = 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:
Step2: The Preprocess class requires many input parameters to function. Below is a list of examples.
Step3: Now perform a cross-correlation using obsp... |
1,828 | <ASSISTANT_TASK:>
Python Code:
tmax = .2
t = np.linspace(0., tmax, 1000)
x0, y0 = 0., 0.
vx0, vy0 = 1., 1.
g = 10.
x = vx0 * t
y = -g * t**2/2. + vy0 * t
fig = plt.figure()
ax.set_aspect("equal")
plt.plot(x, y, label = "Exact solution")
plt.grid()
plt.xlabel("x")
plt.ylabel("y")
plt.legend()
plt.show()
dt = 0.02... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reformulation
Step2: Runge Kutta 4
Step3: Using ODEint
|
1,829 | <ASSISTANT_TASK:>
Python Code:
3 # a rank 0 tensor; this is a scalar with shape []
[1. ,2., 3.] # a rank 1 tensor; this is a vector with shape [3]
[[1., 2., 3.], [4., 5., 6.]] # a rank 2 tensor; a matrix with shape [2, 3]
[[[1., 2., 3.]], [[7., 8., 9.]]] # a rank 3 tensor with shape [2, 1, 3]
import tensorflow as tf
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TensorFlow Core tutorial
Step2: This gives Python access to all of TensorFlow's classes, methods, and symbols. Most of the documentation assume... |
1,830 | <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, DuPont, http://www.dtic.mil/dtic/tr/fulltext/u2/438718.pdf)
# Coefficient of Thermal Expansion
alp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ASME Pressure Vessel Code Equations
Step2: Change in Liner Thickness Necessary to Achieve Seating Stress
Step3: To know if this can be achieve... |
1,831 | <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... |
1,832 | <ASSISTANT_TASK:>
Python Code:
! pip install google-cloud
! pip install google-cloud-storage
! pip install requests
! pip install tensorflow_datasets
import sys
# If you are running this notebook in Colab, run this cell and follow the
# instructions to authenticate your Google Cloud account. This provides access
# 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 your Google Cloud project
Step2: Install CloudTuner
Step3: Restart the Kernel
Step4: Import libraries and define constants
Step5: Tut... |
1,833 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
from scipy.stats import norm
import statsmodels.api as sm
import matplotlib.pyplot as plt
from datetime import datetime
import requests
from io import BytesIO
# Dataset
wpi1 = requests.get('http://www.stata-press.com/data/r12/wpi1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ARIMA Example 1
Step2: Thus the maximum likelihood estimates imply that for the process above, we have
Step3: To understand how to specify thi... |
1,834 | <ASSISTANT_TASK:>
Python Code:
def double(number):
bigger = number * 2
return bigger
double(5)
lst = list(range(1,5))
for n in lst:
print(double(n))
elem = input('Wie heisst Du?')
length = len(elem)
print('Hallo '+ elem+ ','+ ' Dein Name hat '+ str(length)+ ' Zeichen.')
def km_rechner(m):
m = m * 1.6... | <SYSTEM_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.Baue einen for-loop, der durch vordefinierte Zahlen-list geht, und mithilfe der eben kreierten eigenen Funktion, alle Resultate verdoppelt aus... |
1,835 | <ASSISTANT_TASK:>
Python Code:
# loading packages
%pylab inline
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def mle_gauss_mu(samples):
Calculates the Maximum Likelihood Estimate for a mean vector
from a multivariate Gaussian distribution.
Keyword... | <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: Sebastian Raschka
Step3: Sample training data for MLE
Step5: Estimate parameters via MLE
Step8: <a name='uni_rayleigh'></a>
Step11: <a name... |
1,836 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x = np.arange(10.)
y = 5*x+3
np.random.seed(3)
y+= np.random.normal(scale=10,size=x.size)
plt.scatter(x,y);
def lin_reg(x,y):
Perform a linear regression of x vs y.
x, y are 1 dimensional numpy arrays
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:
Step1: Linear regression
Step3: We could also implement it with the numpy covariance function. The diagonal terms represent the variance.
Step5: Codi... |
1,837 | <ASSISTANT_TASK:>
Python Code:
# Author: Ivana Kojcic <ivana.kojcic@gmail.com>
# Eric Larson <larson.eric.d@gmail.com>
# Kostiantyn Maksymenko <kostiantyn.maksymenko@gmail.com>
# Samuel Deslauriers-Gauthier <sam.deslauriers@gmail.com>
# License: BSD (3-clause)
import os.path as op
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: In order to simulate source time courses, labels of desired active regions
Step2: Create simulated source activity
Step3: Simulate raw data
St... |
1,838 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
matches = pd.read_csv('/Users/mtetkosk/Google Drive/Data Science Projects/data/processed/EPL_matches.csv')
print len(matches)
print matches.head()
matches.columns[:11] # Columns 1 - 10 identif... | <SYSTEM_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 step is to read in the csv files created by the extraction notebook
Step2: Lets remove any variables from matches df that we won't need f... |
1,839 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inpe', 'sandbox-1', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
1,840 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.warn("This is a deprecation warning", DeprecationWarning)
warnings.warn("This is a syntax warning", SyntaxWarning)
x = 5
warnings.warn("This is a unicode warning", UnicodeWarning)
<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: A header
Step2: A subheader
|
1,841 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import pandas
import seaborn
from openfisca_france_indirect_taxation.examples.utils_example import graph_builder_bar
from openfisca_france_indirect_taxation.surveys import SurveyScenario
seaborn.set_palette(seaborn.color_palette("Set2", 12))
%matplotlib 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: Import de modules spécifiques à Openfisca
Step2: Import d'une nouvelle palette de couleurs
Step3: Construction de la dataframe et réalisation ... |
1,842 | <ASSISTANT_TASK:>
Python Code:
def create_examples(N, batch_size):
A = np.random.binomial(n=1, p=0.5, size=(batch_size, N))
B = np.random.binomial(n=1, p=0.5, size=(batch_size, N,))
X = np.zeros((batch_size, 2 *N,), dtype=np.float32)
X[:,:N], X[:,N:] = A, B
Y = (A ^ B).astype(np.float32)
return ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Xor cannot be solved with single layer of neural network
Step2: Notice that the error is far from zero.
Step3: Accuracy is not that hard to pr... |
1,843 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import scipy.io
import scipy.misc
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from PIL import Image
from nst_utils import *
import numpy as np
import tensorflow as tf
%matplotlib inline
model = load_vgg_model("pretrained-model/imagenet-vgg-ve... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1 - Problem Statement
Step2: The model is stored in a python dictionary where each variable name is the key and the corresponding value is a te... |
1,844 | <ASSISTANT_TASK:>
Python Code:
import feets
class MaxMagMinTime(feets.Extractor): # must inherit from Extractor
data = ['magnitude', 'time'] # Which data is needed
# to calculate this feature
features = ["magmax", "mintime"] # The names of the expected
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Finally to make the extractor available for the FeaturSpace class, you need to register it with the command
Step2: Now the extractor are availa... |
1,845 | <ASSISTANT_TASK:>
Python Code:
from nltk.stem.wordnet import WordNetLemmatizer
from nltk.stem import LancasterStemmer
stemmer = LancasterStemmer()
lemmer = WordNetLemmatizer()
print(stemmer.stem('dictionaries'))
print(lemmer.lemmatize('dictionaries'))
from gensim import models
import numpy as np
from pandas import D... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A visible example of how do they work
Step2: So, what approach will be better for the given task? Let's see.
Step3: And a little bit more of t... |
1,846 | <ASSISTANT_TASK:>
Python Code:
from datetime import datetime as dt
import time as tm
import pytz as tz
import calendar as cal
dto = dt.strptime ('2014-09-06 07:16 +0000', "%Y-%m-%d %H:%M %z")
dto
tto = tm.strptime ('2014-09-06 07:16 +0000', "%Y-%m-%d %H:%M %z")
tto
dto.timetuple() == tto
dt.fromtimestamp(tm.mktime(tto... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generating times from a string
Step2: Missing timezone information in the string
Step3: Epoch related functions
Step4: Current-time related f... |
1,847 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
x = np.array([ 1.00201077, 1.58251956, 0.94515919, 6.48778002, 1.47764604,
5.18847071, 4.21988095, 2.85971522, 3.40044437, 3.74907745,
1.18065... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Estimation
Step2: Fitting data to probability distributions
Step3: The first step is recognixing what sort of distribution to fit our data to.... |
1,848 | <ASSISTANT_TASK:>
Python Code:
# We'll be doing some examples, so let's import the libraries we'll need
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Set a seed so we can play with the data without generating new random numbers every time
np.random.seed(123)
normal = np.random.randn(500)
pri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example
Step2: Notice that, although the probability of getting closer to 0 and 1 for the mean and standard deviation, respectively, increases ... |
1,849 | <ASSISTANT_TASK:>
Python Code:
# Import libraries: NumPy, pandas, matplotlib
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib import rc
# Tell iPython to include plots inline in the notebook
%matplotlib inline
# Set styles for seaborn
%config InlineBackend.... | <SYSTEM_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 Exploration
Step2: Feature Transformation
Step3: 2) How quickly does the variance drop off by dimension? If you were to use PCA on this d... |
1,850 | <ASSISTANT_TASK:>
Python Code:
# Read in the list of 250 movies, making sure to remove commas from their names
# (actually, if it has commas, it will be read in as different fields)
import csv
movies = []
with open('movies.csv','r') as csvfile:
myreader = csv.reader(csvfile)
for index, row in enumerate(myreader... | <SYSTEM_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 in the list of questions
Step2: Read in the training data
Step3: Your turn
Step4: Use the trained classifier to play a 20 questions game... |
1,851 | <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: Post-training integer quantization
Step2: Generate a TensorFlow Model
Step3: Convert to a TensorFlow Lite model
Step4: It's now a TensorFlow ... |
1,852 | <ASSISTANT_TASK:>
Python Code:
# Add MOSQITO to the Python path
import sys
sys.path.append('..')
# To get inline plots (specific to Jupyter notebook)
%matplotlib notebook
# Import numpy
import numpy as np
# Import plot function
import matplotlib.pyplot as plt
# Import load function
from mosqito.utils import load
# 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: Load signal from .wav file
Step2: Load signal from a .mat file
Step3: Load signal from a .uff file
Step4: Compute nth octave band spectrum
St... |
1,853 | <ASSISTANT_TASK:>
Python Code:
import hashlib
import os
import pickle
from urllib.request import urlretrieve
import numpy as np
from PIL import Image
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
from sklearn.utils import resample
from tqdm import tqdm
from zipfil... | <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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this... |
1,854 | <ASSISTANT_TASK:>
Python Code:
try:
count_datasets
except:
assert False
else:
assert True
c = count_datasets("submission_partial.json")
assert c == 4
c = count_datasets("submission_full.json")
assert c == 9
try:
c = count_datasets("submission_nonexistent.json")
except:
assert False
else:
assert ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: B
Step2: C
Step3: D
|
1,855 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from math import pi, sin, cos
import numpy as np
import openmc
fuel = openmc.Material(name='fuel')
fuel.add_element('U', 1.0)
fuel.add_element('O', 2.0)
fuel.set_density('g/cm3', 10.0)
clad = openmc.Material(name='zircaloy')
clad.add_element('Zr', 1.0)
clad.set_density... | <SYSTEM_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 begin by creating the materials that will be used in our model.
Step2: With our materials created, we'll now define key dimensions in our... |
1,856 | <ASSISTANT_TASK:>
Python Code:
try:
import scipy.optimize
except ImportError:
print("Vous avez lu le paragraphe précédent...?")
print("Je t'envoie sur https://scipy.org/install.html et tu auras plus d'informations...")
import webbrowser
webbrowser.open_new_tab("https://scipy.org/install.html")
# Ob... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Quelques petits problèmes linéaires
Step2: On utilise les fonctionnalités de scipy pour les problèmes linéaires (doc), et pour commencer la seu... |
1,857 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%pylab inline --no-import-all
pylab.rcParams['figure.figsize'] = (18, 10)
from ntfdl import Dl
stl = Dl('STL', exchange='OSE', download=False)
history = stl.get_history()
history.tail()
fig, ax = plt.subplots()
ax.tick_params(labeltop=False, labelright=True)
history.clo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Including moving averages
Step2: Busy chart, let's instead slice the pandas with the [from
|
1,858 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from pylab import *
%matplotlib inline
from scipy.stats.stats import spearmanr
from scipy.stats.mstats import normaltest
import warnings
warnings.filterwarnings('ignore')
import sys
sys.path.append("/Users/rfinn/Dropbox/pythonCode/")
sys.path.append("/anaconda/lib/pytho... | <SYSTEM_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 Plot Dennis is referring to
Step2: Fixing the spearman rank correlation
|
1,859 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import re
from os import path
from scipy.ndimage import imread
from nltk.util import ngrams
from collections import Counter
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
from IPython... | <SYSTEM_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 Data
Step2: The confession column is the original raw text, and the clean_tokens_secret is the result of some preprocessing that I did. For... |
1,860 | <ASSISTANT_TASK:>
Python Code:
import numpy
import numpy as np
m=6
n=4
k=5
a = np.array(range(11,41)).reshape((k,m)).T
print(a)
b = np.array(range(11,31)).reshape((n,k)).T
print(b)
c = np.array(range(11,35)).reshape((n,m)).T
print(c)
np.matmul(a,b)
np.diag(range(11,15))
np.ones(m*n)
# bias_broadcasted
np.matmul( np.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: cf. Matrix computations
|
1,861 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
#commands that start with "%" are called "magic words" and are used in Jupyter
%config InlineBackend.figure_format = 'retina'
import numpy as np #is a library that helps to manage arrays www.numpy.org/
import pandas as pd #a library to analyze and show data. http://pand... | <SYSTEM_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... |
1,862 | <ASSISTANT_TASK:>
Python Code:
#@title
# Copyright 2020 Google LLC.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Author - @SauravMaheshkar
Step2: Introduction
Step3: Pre-Processing
Step4: Creating a Vocabulary File
Step5: Creating a Dictionary for Vocab... |
1,863 | <ASSISTANT_TASK:>
Python Code:
np.random.seed(8675309)
sim_pa = np.arange(20,175)
sim_c = 890*np.sin(np.deg2rad(sim_pa))**0.8
# at each point draw a poisson variable with that mean
sim_c_n = np.asarray([np.random.poisson(v) for v in sim_c ])
prob=0.1
sim_c_n2 = np.asarray([np.random.negative_binomial((v*prob)/(1-prob),... | <SYSTEM_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 then serve as the background
|
1,864 | <ASSISTANT_TASK:>
Python Code:
df = pd.read_excel('Data.xlsx', sheetname=None)
df['Run 1']
keys = ['Run 1', 'Run 2', 'Run 3', 'Run 4']
# Fall time in seconds when V = 0
tf = np.array([df[key]['t_f (s)'] for key in keys])
tf
# Average Fall times for each run (seconds)
avg_tf = np.array([np.mean(tf[i]) for i in np.arange... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mask points that lie outside 2.5$\sigma$
Step2: Uncertainty
Step3: Fall Speed
Step4: \begin{equation}
Step5: E Field
Step6: Air Viscosity
S... |
1,865 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
iris = pd.read_csv('../datasets/iris.csv')
# Print some info about the dataset
iris.info()
iris['Class'].unique()
iris.describe()
# Create a scatterplot for sepal length and sepal width
import matplotlib.pyplot as plt
%matplotlib inline
sl = iris['Sepal_length']
sw = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Visualizing data
Step2: Classifying species
Step3: Inspecting classification results
Step4: Another useful technique to inspect the results g... |
1,866 | <ASSISTANT_TASK:>
Python Code:
import py2neo
import pandas as pd
graph = py2neo.Graph()
query = "MATCH (a:Method) RETURN a"
result = graph.data(query)
result[0:3]
df = pd.DataFrame.from_dict([data['a'] for data in result]).dropna(subset=['name'])
df.head()
# filter out all the constructor "methods"
df = df[df['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: Step 2
Step2: Step 3
Step3: Step 4
Step4: Step 5
Step5: Step 6
Step6: Step 7
|
1,867 | <ASSISTANT_TASK:>
Python Code:
# Load the digits dataset
digits = load_digits()
X = digits.images.reshape((len(digits.images), -1))
y = digits.target
# Create the RFE object and rank each pixel
svc = SVC(kernel="linear", C=1)
rfe = RFE(estimator=svc, n_features_to_select=1, step=1)
rfe.fit(X, y)
ranking = rfe.ranking_... | <SYSTEM_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*8的手寫數字影像,總共有1797筆資料。預設為0~9十種數字類型,亦可由n_class來設定要取得多少種數字類型。
Step2: 可以用方法ranking_來看輸入的特徵權重關係。而方法estimator_可以取得訓練好的分類機狀態。比較特別的是當我們核函數是... |
1,868 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.2,<2.3"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
times = np.linspace(0,1,51)
b.add_dataset('lc', compute_times=times, dataset='lc01')
b.add_dataset('orb', ... | <SYSTEM_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. See Building a System for more details.
Step2: Default Animations
Step3:... |
1,869 | <ASSISTANT_TASK:>
Python Code:
import os
from datetime import datetime
import numpy as np
import pandas as pd
import bokeh.charts as bk
import bokeh.plotting as bk_plt
import bokeh.models as bk_md
bk.output_notebook()
import urllib.request
# Download the file from `url` and save it locally under `file_name`:
zip_url ... | <SYSTEM_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. Dataset Loading & Visualition
Step2: As we can see, it is a fairly simple file with only two columns
Step3: Here are the information availa... |
1,870 | <ASSISTANT_TASK:>
Python Code:
# Load pickled data
import pickle
# TODO: Fill this in based on where you saved the training and testing data
training_file = './traffic-signs-data/train.p'
validation_file = './traffic-signs-data/valid.p'
testing_file = './traffic-signs-data/test.p'
with open(training_file, mode='rb... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1
Step2: 3. Include an exploratory visualization of the dataset
Step3: Step 2
Step4: 5. Show a sample of the augmented dataset
Step6: 6... |
1,871 | <ASSISTANT_TASK:>
Python Code:
%%capture
#Instalando o tweepy
!pip install tweepy
import tweepy
import math
import os.path
import pandas as pd
import json
from random import shuffle
import string
#Dados de autenticação do twitter:
#Coloque aqui o identificador da conta no twitter: @fulano
#leitura do arquivo no 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: Importando as Bibliotecas que serão utilizadas. Esteja livre para adicionar outras.
Step2: Autenticando no Twitter
Step3: Coletando Dados
Ste... |
1,872 | <ASSISTANT_TASK:>
Python Code:
import os
imgList = ['../training/%s'%x for x in os.listdir('../training/')]; imgList.sort()
imgList
import seaborn as sns
import matplotlib.pylab as plt
%matplotlib inline
from nilearn import image, datasets, input_data, plotting
plotting.plot_stat_map(imgList[-1],title=imgList[-1],thr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Wir können uns - wie gewohnt - die Bilder anschauen
Step2: Hier schauen wir uns als Beispiel das letzte Bild an
Step3: Wir extrahieren nun die... |
1,873 | <ASSISTANT_TASK:>
Python Code:
from datetime import datetime
import requests
def requests_get(index=None):
response = requests.get("https://httpbin.org/delay/1")
response.raise_for_status()
print(f"{index} - {response.status_code} - {response.elapsed}")
requests_get()
before = datetime.now()
for index in 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:
Step1: Using httpbin.org
|
1,874 | <ASSISTANT_TASK:>
Python Code:
i1 = [1, 2, 3]
a1 = [1, 3, 5]
assert set(a1) == set(add_index(i1))
i2 = [0, 0, 0, 9, 10, 11]
o2 = 12
a2 = [12, 13, 14, 24, 26, 28]
assert set(a2) == set(add_index(i2, o2))
i1 = [1, 2, 3]
a1 = [2]
assert set(a1) == set(remove_odds(i1))
i2 = [0, 0, 0, 9, 10, 11]
a2 = [0, 0, 0, 10]
assert 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: B
Step2: C
Step3: D
|
1,875 | <ASSISTANT_TASK:>
Python Code:
import itertools
import random
from collections import deque
from copy import deepcopy
import numpy
from nupic.bindings.math import SparseBinaryMatrix, GetNTAReal
def makeSparseBinaryMatrix(numRows, numCols):
Construct a SparseBinaryMatrix.
There is a C++ constructor that do... | <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: Functionality that could be implemented in SparseBinaryMatrix
Step10: This SetMemory docstring is worth reading
Step11: Experiment code
Step12... |
1,876 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pylab as plt
%matplotlib inline
import numpy as np
import os
import pandas as pd
import seaborn as sns
sns.set_style('white')
sns.set_context('notebook')
from scipy.stats import kurtosis
import sys
%load_ext autoreload
%autoreload 2
sys.path.append('../SCRIPTS/')
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: Get the data
Step2: Motion measures
Step3: We can see from the plot above that we have a data set of people who do not move all that much and ... |
1,877 | <ASSISTANT_TASK:>
Python Code:
import gmql as gl
import matplotlib.pyplot as plt
genes = gl.load_from_path("../data/genes/")
promoters = genes.reg_project(new_field_dict={
'start':genes.start-2000,
'stop':genes.start + 2000})
gl.set_remote_address("http://gmql.eu/gmql-rest/")
gl.login... | <SYSTEM_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 code begins by loading a local dataset of gene annotations and extracting their promotorial regions (here defined as regions at $\left[gene_... |
1,878 | <ASSISTANT_TASK:>
Python Code:
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("HELK Reader") \
.master("spark://helk-spark-master:7077") \
.enableHiveSupport() \
.getOrCreate()
es_reader = (spark.read
.format("org.elasticsearch.spark.sql")
.option("inferSchema", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create a SparkSession instance
Step2: Read data from the HELK Elasticsearch via Spark SQL
Step3: Read Sysmon Events
Step4: Register Sysmon SQ... |
1,879 | <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: Keras를 사용한 반복적 인 신경망 (RNN)
Step2: 내장 RNN 레이어
Step3: 내장 RNN은 여러 유용한 기능을 지원합니다.
Step4: 또한 RNN 레이어는 최종 내부 상태를 반환할 수 있습니다. 반환된 상태는 나중에 RNN 실행을 재개... |
1,880 | <ASSISTANT_TASK:>
Python Code:
from functions import connect, touch, light, sound, ultrasonic, disconnect, next_notebook
connect()
touch() # Per a executar repetidament, useu Ctrl + Enter
light() # Per a executar repetidament, useu Ctrl + Enter
sound() # Per a executar repetidament, useu Ctrl + Enter
ultrasonic() #... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sensor de tacte
Step2: Sensor de llum
Step3: Sensor de so (micròfon)
Step4: Sensor ultrasònic
Step5: <img src="img/interrupt.png" align="rig... |
1,881 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
import numpy as np
import scipy.io
import time
import theano
import theano.tensor as T
import theano.sparse as Tsp
import lasagne as L
import lasagne.layers as LL
import lasagne.objectives as LO
from lasagne.layers.normalization import batch_norm
sys.path.append('..')... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data loading
Step2: Network definition
Step3: Define the update rule, how to train
Step4: Compile
Step5: Training (a bit simplified)
Step6: ... |
1,882 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.io
import math
import sklearn
import sklearn.datasets
from opt_utils import load_params_and_grads, initialize_parameters, forward_propagation, backward_propagation
from opt_utils import compute_cost, predict, predict_dec, plo... | <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: 1 - Gradient Descent
Step4: Expected Output
Step6: Expected Output
Step8: Expected Output
Step10: Expected Output
Step12: Expected Output
S... |
1,883 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.colors as colors
%matplotlib inline
# Get the data
### Subdivide the data into a feature table
local_path = '/home/irockafe/Dropbox (MIT)/Alm_Lab/projects/'
data_path = local_path + '/revo_healthc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Start with MTBLS315, the malaria vs fever dataset. Could get ~0.85 AUC for whole dataset.
Step2: Almost everything is below 30sec rt-window
Ste... |
1,884 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import csv
import io
import urllib.request
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from datetime import datetime
url = 'https://radwatch.berkeley.edu/sites/default/files/dosenet/etch.csv'
response = urllib.request.urlopen(ur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Measures of central tendency identify values that lie on the center of a sample and help statisticians summarize their data. The most measures o... |
1,885 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
from datetime import datetime
import tensorflow as tf
print "TensorFlow : {}".format(tf.__version__)
(train_data, train_labels), (eval_data, eval_labels) = tf.keras.datasets.mnist.load_data()
NUM_CLASSES = 10
print "Train data shape: {}".format(train_data.sha... | <SYSTEM_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. Train and Export a Keras Model
Step2: 1.2 Estimator
Step3: 1.2.2 Convert Keras model to Estimator
Step4: 1.3 Train and Evaluate
Step5: 1.... |
1,886 | <ASSISTANT_TASK:>
Python Code:
!pip install --user apache-beam[gcp]==2.16.0
!pip install --user tensorflow-transform==0.15.0
!pip download tensorflow-transform==0.15.0 --no-deps
%%bash
pip freeze | grep -e 'flow\|beam'
import tensorflow as tf
import tensorflow_transform as tft
import shutil
print(tf.__version__)
# 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: NOTE
Step2: <b>Restart the kernel</b> (click on the reload button above).
Step8: Input source
Step12: Create ML dataset using tf.transform an... |
1,887 | <ASSISTANT_TASK:>
Python Code:
import mne
from mne.preprocessing import maxwell_filter
data_path = mne.datasets.sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
ctc_fname = data_path + '/SSS/ct_sparse_mgh.fif'
fine_cal_fname = data_path + '/SSS/sss_cal_mgh.dat'
raw = mne.io.read_raw_fif(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: Preprocess with Maxwell filtering
Step3: Select events to extract epochs from, pick M/EEG channels, and plot evoked
|
1,888 | <ASSISTANT_TASK:>
Python Code:
! gunzip -d ../data/result.vot_01.gz
#! head -n 200 ../data/result.vot_01.gz
import pandas as pd
import numpy as np
import seaborn as sns
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
import matplotlib.pyplot as plt
from astropy.io import votable
votable.is_votable('.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Apparently not in gzip format, despite the file extension
Step2: Attempt 2
|
1,889 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
from statsmodels.compat import urlopen
import numpy as np
np.set_printoptions(precision=4, suppress=True)
import statsmodels.api as sm
import pandas as pd
pd.set_option("display.width", 100)
import matplotlib.pyplot as plt
from stat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Take a look at the data
Step2: Fit a linear model
Step3: Have a look at the created design matrix
Step4: Or since we initially passed in a Da... |
1,890 | <ASSISTANT_TASK:>
Python Code:
issubclass(bool, int)
isinstance(False, int)
the_list = list()
nada_dict = dict(the_list) # converting
empty_set = set() # can't use {} as that means empty dict
empty_tuple = tuple()
print(the_list, nada_dict, empty_set, empty_tuple)
import decimal # needs to be imported
# lets creat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Calling types
Step3: print( ) is an example of a built-in Python function. It sends strings to the console, converting objects to strings... |
1,891 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
tf.__version__
%%sql -d standard
SELECT
timestamp,
borough,
latitude,
longitude
FROM
`bigquery-public-data.new_york.nypd_mv_collisions`
ORDER BY
timestamp DESC
LIMIT
15
%%sql --module nyc_collisions
SELECT
IF(borough = 'MANHATTAN', 1, 0) AS is_mt,... | <SYSTEM_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 codelab requires TensorFlow 1.0 or above. If you see older versions such as 0.11.0rc0, please follow the instruction below to update your l... |
1,892 | <ASSISTANT_TASK:>
Python Code:
# Set up code checking
from learntools.core import binder
binder.bind(globals())
from learntools.machine_learning.ex2 import *
print("Setup Complete")
import pandas as pd
# Path of the file to read
iowa_file_path = '../input/home-data-for-ml-course/train.csv'
# Fill in the line below 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: Step 1
Step2: Step 2
|
1,893 | <ASSISTANT_TASK:>
Python Code:
a = "string"
b = "string1"
print a, b
print "The return value is", a
print(a, b)
print("The return value is", a)
print(a+' '+b)
print("The return value is" + " " + a)
print(a),; print(b)
print(a+b)
print("{}{}".format(a,b))
print("%s%s%d" % (a, b, 10))
from math import pi
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: 주의
Step2: 하지만 위와 같이 괄호를 사용하지 않는 방식은 파이썬 3.x에서는 지원되지 않는다.
Step3: 아래와 같이 할 수도 있다
Step4: 그런데 위 경우 a와 b를 인쇄할 때 스페이스가 자동으로 추가된다.
Step5: 서식이 있는 인... |
1,894 | <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: Custom training
Step2: Variables
Step3: TensorFlow, however, has stateful operations built in, and these are often more pleasant to use than l... |
1,895 | <ASSISTANT_TASK:>
Python Code:
desired_contigs = ['Contig' + str(x) for x in [1131, 3182, 39106, 110, 5958]]
desired_contigs
grab = [c for c in contigs if c.name in desired_contigs]
len(grab)
import os
print(os.getcwd())
write_contigs_to_file('data2/sequences_desired.fa', grab)
[c.name for c in grab[:100]]
import os
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If you have a genuinely big file then I would do the following
Step2: Ya! There's two contigs.
|
1,896 | <ASSISTANT_TASK:>
Python Code:
import sympy as sp
from matplotlib import pyplot as plt
%matplotlib inline
# Customize figure size
plt.rcParams['figure.figsize'] = 25, 15
#plt.rcParams['lines.linewidth'] = 1
#plt.rcParams['lines.color'] = 'g'
plt.rcParams['font.family'] = 'monospace'
plt.rcParams['font.size'] = '16.0'
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: Let $a_n = \sum_{n=1}^{\infty} \frac{1}{n + 7^n}$.
|
1,897 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from scipy import linalg
from scipy import optimize
import functools
import tensorly
from tensorly.decomposition import partial_tucker
from tensorly.decomposition import tucker
tensorly.set_backend('numpy')
tensor_steam_length = 300
factors_tensor_... | <SYSTEM_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: 3.3 $\sum$ 循环向量化
Step3: 循环tucker分解
Step4: 连接张量流
Step5: 暂时没有找到较好的批次处理tucker分解的方法,这里特例处理
Step6: 二次规划优化估计修正矩阵$V_k$
Step7: $V_1$
... |
1,898 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras import layers
from keras.layers import Input, Add, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D, AveragePooling2D, MaxPooling2D, GlobalMaxPooling2D
from keras.models import Model, load_model
from keras.preprocessing import image
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: 1 - The problem of very deep neural networks
Step4: Expected Output
Step6: Expected Output
Step7: Run the following code to build the model's... |
1,899 | <ASSISTANT_TASK:>
Python Code:
# useful additional packages
import random
import math
from sympy.ntheory import isprime
# importing QISKit
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import Aer, IBMQ, execute
from qiskit.wrapper.jupyter import *
from qiskit.backends.ibmq import le... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We then use QISKit to program the algorithm.
Step2: The qfa_algorithm function returns the Quantum Circuit qfaCircuit.
Step3: Insert your own ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.