Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k โ | cleaned_prompt stringlengths 168 30.3k โ |
|---|---|---|
2,400 | <ASSISTANT_TASK:>
Python Code:
import pycqed as pq
import numpy as np
from pycqed.measurement import measurement_control
from pycqed.measurement.sweep_functions import None_Sweep
import pycqed.measurement.detector_functions as det
from qcodes import station
station = station.Station()
MC = measurement_control.Measurem... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Creating an instance of MeasurementControl
Step2: The InstrumentMonitor can be used to see the parameters of any instrument connected to the st... |
2,401 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'sandbox-1', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
2,402 | <ASSISTANT_TASK:>
Python Code:
zero_steering = drive_log_df[drive_log_df.steering == 0].sample(frac=0.9)
drive_log_df = drive_log_df.drop(zero_steering.index)
plt.figure(figsize=(10,4))
drive_log_df.steering.hist(bins=100, color='r')
plt.xlabel('steering angle bins')
plt.ylabel('counts')
plt.show()
print("Current Datas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we start making changes to the driver log file and we create a new driver log file.
Step2: We sample (normal dist) 40% of example that are ... |
2,403 | <ASSISTANT_TASK:>
Python Code:
import seaborn as sns
iris = sns.load_dataset('iris')
iris.head()
%matplotlib inline
import seaborn as sns; sns.set()
sns.pairplot(iris, hue='species', size=1.5);
X_iris, y_iris = iris.drop('species', axis=1), iris['species']
X_iris.shape, y_iris.shape
import matplotlib.pyplot as plt
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: Each row is an observed flower. These rows are called samples and the number of rows is called n_samples.
Step2: Let's split the data according... |
2,404 | <ASSISTANT_TASK:>
Python Code:
p=Function('p')
m,s,h = symbols('m s h')
m=M(x,y,z)
q=Q(x,y,z,t)
d=D(x,y,z,t)
e=E(x,y,z)
# Choose dimension (2 or 3)
dim = 3
# Choose order
time_order = 2
space_order = 2
# half width for indexes, goes from -half to half
width_t = int(time_order/2)
width_h = int(space_order/2)
solvep = 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: Forward modelling
|
2,405 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cas', 'sandbox-3', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
2,406 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# Discretization
c1=20 # Number of grid points per dominant wavelength
c2=0.5 # CFL-Number
nx=2000 # Number of grid points
T=10 # Total propagation time
# Source Signal
f0= 10 # Center frequency Ricker-wave... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Input Parameter
Step2: Preparation
Step3: Create space and time vector
Step4: Source signal - Ricker-wavelet
Step5: Time stepping
Step6: Sa... |
2,407 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
%pylab inline
from pprint import pprint
import textwrap
import sys, re
old_displayhook = sys.displayhook
def displ(x):
if x is None: return
print "\n".join(textwrap.wrap(repr(x).replace(' ',''),width=80))
sys.displayhook=displ
def generate_samples(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: So far, we have considered parametric methods that reduce inference
Step2: The code uses the histogram function from Numpy.
Step3: The train_t... |
2,408 | <ASSISTANT_TASK:>
Python Code:
import lucene
print(lucene.VERSION)
# We can check all the Lucene packages included in this distribution of Pylucene
for p in sorted(lucene.CLASSPATH.split(':')):
print(p)
# Init
if not lucene.getVMEnv():
lucene.initVM(vmargs=['-Djava.awt.headless=true'])
test_strings = (
'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: The first operation is always to initialize the lucene backend. This only needs to be done once for each running Python process
Step2: Tests
St... |
2,409 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import Markdown, display, clear_output, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
%matplotlib notebook
%matplotlib inline
%env HDF5_USE_FILE_LOCKING=FALSE
import sys, os
#### add a path to your private code if not using production... | <SYSTEM_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. Set atlas, project and output directories from your nersc home directory
Step2: 3. Select groups and get QC files
Step3: 4. Get template QC... |
2,410 | <ASSISTANT_TASK:>
Python Code:
import psycopg2
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
conn = psycopg2.connect(database="postgres", user="postgres", password="***", host="127.0.0.1", port="5432")
query = SELECT fromnode, tonode, distance from ed... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: BASICS OF NETWORKX
Step2: PLOT GRAPH
Step3: PLOT GRAPH WITH SHORTEST PATH
Step4: SHORTEST PATHS
|
2,411 | <ASSISTANT_TASK:>
Python Code:
catalog_name = 'Landolt 1992'
observatory_name = 'Apache Point'
from astroquery.vizier import Vizier
from astropy.coordinates import SkyCoord
import astropy.units as u
catalog_list = Vizier.find_catalogs(catalog_name)
catalogs = Vizier.get_catalogs(catalog_list.keys())
Vizier.ROW_LIMIT = ... | <SYSTEM_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 an Observer and list of FixedTargets in astroplan.
Step2: Determine which standards are observable tonight.
|
2,412 | <ASSISTANT_TASK:>
Python Code:
# Basics for Data Manipulation
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
# Tensorflow and Keras tools
import tensorflow as tf
import tensorflow_hub as hub
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers ... | <SYSTEM_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 Overview of the Data
Step2: Embedding & Prepping the data
Step3: Metrics and Evaluation
Step4: What's a Recurrent Neural Network (RNN)?... |
2,413 | <ASSISTANT_TASK:>
Python Code:
import requests
Lil_response = requests.get('https://api.spotify.com/v1/search?query=Lil&type=artist&limit=50&country=US')
Lil_data = Lil_response.json()
#Lil_data
Lil_data.keys()
Lil_data['artists'].keys()
Lil_artists = Lil_data['artists']['items']
#With "Lil Wayne" and "Lil Kim" there ... | <SYSTEM_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.Searching and Printing a List of 50 'Lil' Musicians
Step2: 2 Genres Most Represented in the Search Results
Step3: More Spotify - LIL' GRAPHI... |
2,414 | <ASSISTANT_TASK:>
Python Code:
input_file = open('sample.txt', 'r') # IOError occured because we should put the write true direction.
input_file = open('data/sample.txt', 'r') # True direction, with folder inside.
print(input_file)
input_file.close()
output_file = open('data/mynewfile.txt', 'w') # I used data/name bec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: When you try to print the variable created, you will not get what you want. It is just an object created to use in later statements.
Step2: We... |
2,415 | <ASSISTANT_TASK:>
Python Code:
first_test = epsilon_field(domain.get_spacetime())
first_test.estimate_states(2,2,1)
first_test.filter_data()
print first_test.number_of_states()
for state in first_test.causal_states():
print state.plc_configs()
second_test = epsilon_field(domain.get_spacetime())
second_test.estimate... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Periodic, so probably not a good representation of the 18 domain
Step2: Look at same stuff at depth 4 light cones
Step3: Look at states for in... |
2,416 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import xarray as xr
xr.DataArray(np.random.randn(2, 3))
data = xr.DataArray(np.random.randn(2, 3), [('x', ['a', 'b']), ('y', [-2, 0, 2])])
data
xr.DataArray(pd.Series(range(3), index=list('abc'), name='foo'))
data.values
data.dims
data.coords
len(... | <SYSTEM_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 DataArray
Step2: If you supply a pandas Series or DataFrame, metadata is copied directly
Step3: Here are the key properties for a Dat... |
2,417 | <ASSISTANT_TASK:>
Python Code:
from sklearn.feature_extraction import DictVectorizer
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer, HashingVectorizer
from sklearn.metrics.pairwise import euclidean_distances
from sklearn import preprocessing
from nltk.stem.wordnet import WordNetLemmatizer
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: DictVectorizer
Step2: CountVectorizer
Step3: Stop Word Filtering
Step4: Stemming and Lemmatization
Step5: As we can see both sentences ar... |
2,418 | <ASSISTANT_TASK:>
Python Code:
def pretty_print_review_and_label(i):
print(labels[i] + "\t:\t" + reviews[i][:80] + "...")
g = open('reviews.txt','r') # What we know!
reviews = list(map(lambda x:x[:-1],g.readlines()))
g.close()
g = open('labels.txt','r') # What we WANT to know!
labels = list(map(lambda x:x[:-1].uppe... | <SYSTEM_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: Lesson
Step3: Project 1
Step4: We'll create three Counter objects, one for words from postive reviews, one for words from negativ... |
2,419 | <ASSISTANT_TASK:>
Python Code:
import re
import nose
# %timeit
from __future__ import print_function
# Before writing the parser, collect samples of
# the interesting lines. For now just
mail_sent = 'May 31 08:00:00 test-fe1 postfix/smtp[16669]: 7CD8E730020: to=<jon@doe.it>, relay=examplemx2.doe.it[222.33.44.555]:25,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parsing is hard...
Step3: Exercise I
Step4: Python Regexp
Step5: Achieve more complex splitting using regular expressions.
Step6: Benchmarki... |
2,420 | <ASSISTANT_TASK:>
Python Code:
import os
import pickle
import multiprocessing
import subprocess
import xml.etree.ElementTree as ET
import numpy as np
with open(__depends__[0],'rb') as f:
varying_tau_results = pickle.load(f)
tau_indices = [0,-1]
prefixes = ['tau20','tau500']
parameter_sets = {'single':('t','T','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: First, import the EBTEL results.
Step2: Next, reshape the EBTEL results into something readable by the IonPopSolver code and save them to a fil... |
2,421 | <ASSISTANT_TASK:>
Python Code:
z = np.linspace(-6, 6)
logรญstica = 1 / (1 + np.exp(-z))
plt.plot(z, logรญstica)
plt.xlabel('z')
plt.ylabel('logรญstica(z)')
plt.title('Figure 4.1');
iris = pd.read_csv('datos/iris.csv')
iris.head()
sns.stripplot(x="species", y="sepal_length", data=iris, jitter=True)
plt.title('Figure 4.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: El segundo paso consiste en usar como likelihood una distribuciรณn binomial y no una Gaussiana. De esta forma el modelo queda expresado como
Step... |
2,422 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
# Add your filename and uncomment the following line:
# Image(filename='yourfile.png')
Image('netfli.png')
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Violations of graphical excellence and integrity
|
2,423 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, unicode_literals, print_function
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np, pandas as pd
import os.path, os, sys, json, filecmp, copy
plt.rcParams.update({'font.size': 16, 'figure.figsize': [8.0, 6.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: Let's coarse grain an atomic PDB structure to the amino acid level
Step2: Create Input and run MC simulation
Step3: Analysis
|
2,424 | <ASSISTANT_TASK:>
Python Code:
# Useful Functions
class DiscreteRandomVariable:
def __init__(self, a=0, b=1):
self.variableType = ""
self.low = a
self.high = b
return
def draw(self, numberOfSamples):
samples = np.random.randint(self.low, self.high, numberOfSamples)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercise 1
Step2: Exercise 2
Step3: Exercise 3
Step4: b. Confidence Intervals.
Step5: Exercise 4
|
2,425 | <ASSISTANT_TASK:>
Python Code:
#Paquete Watershed Modelling Framework (WMF) para el trabajo con cuencas.
from wmf import wmf
# Lectura del DEM
DEM = wmf.read_map_raster('/media/nicolas/discoGrande/raster/dem_corr.tif',isDEMorDIR=True, dxp=30.0)
DIR = wmf.read_map_raster('/media/nicolas/discoGrande/raster/dirAMVA.tif',... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Este es como se leen los mapas de direcciones y dem para el trazado de cuencas y corrientes
Step2: Trazado de corrientes
Step3: El perfil de u... |
2,426 | <ASSISTANT_TASK:>
Python Code:
import numpy
import scipy.integrate
import pyfabm
#pyfabm.get_version()
yaml_file = 'fabm-bb-lorenz63.yaml'
model = pyfabm.Model(yaml_file)
model.findDependency('bottom_depth').value = 1.
model.checkReady(stop=True)
def dy(y,t0):
model.state[:] = y
return model.getRates()
t = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import pyfabm - the python module that contains the Fortran based FABM
Step2: Configuration
Step3: Model increment
Step4: Time axis and model... |
2,427 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
# Load all necessary modules here, for clearness
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
# from torchvision.datasets import MNIST
import torchvision
from torchvision import 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: 1.1 Required Module
Step7: 2. Classfication Model
Step8: 3. Training
Step11: 3.2 Initialize model parameters
Step15: ไฝไธ1
Step17: 3.3 Repeat... |
2,428 | <ASSISTANT_TASK:>
Python Code:
def toInt(s):
try:
return int(s)
except ValueError:
return s
toInt('123')
toInt('**')
import re
def tokenize(s):
regExp = r'[0-9]+|\*\*|[()+\-*%/]'
L = [ toInt(t) for t in re.findall(regExp, s) ]
return list(reversed(L))
re.findall(r'[0-9]+|\*\*|[(... | <SYSTEM_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 module re provides support for <a href='https
Step2: The function $\texttt{tokenize}(s)$ takes a string $s$ representing an arithmetic expr... |
2,429 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import mne
data_path = mne.datasets.sample.data_path()
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evokeds = mne.read_evokeds(fname, baseline=(None, 0), proj=True)
print(evokeds)
evoked = mne.read_evokeds(fname, condition='Left Auditory')
ev... | <SYSTEM_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
Step2: Notice that the reader function returned a list of evoked instances. This is
Step3: If you're gone through the tutorials of raw an... |
2,430 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
train_users = pd.read_csv('../data/train_users_sample.csv')
test_users = pd.read_csv('../data/test_users_sample.csv')
sessions = pd.read_csv('../data/sessions_sample.csv')
users = pd.concat([train_users, test_users], axis=0, ignore_index=True)
use... | <SYSTEM_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, in this case a sample data.
Step2: Make a single DataFrame containing all the users
Step3: Drop useless column(test_users don'... |
2,431 | <ASSISTANT_TASK:>
Python Code:
from tensorflow import keras
from tensorflow.keras import layers
import numpy as np
import random
import io
path = keras.utils.get_file(
"nietzsche.txt", origin="https://s3.amazonaws.com/text-datasets/nietzsche.txt"
)
with io.open(path, encoding="utf-8") as f:
text = f.read().low... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepare the data
Step2: Build the model
Step3: Prepare the text sampling function
Step4: Train the model
|
2,432 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from sklearn.metrics import roc_curve, roc_auc_score, auc, recall_score, accuracy_score, confusion_matrix
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
df = pd.read_csv('../data/pima-indians... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data and have initial look
Step2: Look at class distribution
Step3: Data in the table is organized the following way
Step4: Split the da... |
2,433 | <ASSISTANT_TASK:>
Python Code:
import capacitySpectrumMethod
from rmtk.vulnerability.common import utils
%matplotlib inline
capacity_curves_file = "../../../../../../rmtk_data/capacity_curves_Sa-Sd.csv"
capacity_curves = utils.read_capacity_curves(capacity_curves_file)
utils.plot_capacity_curves(capacity_curves)
gmr... | <SYSTEM_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 capacity curves
Step2: Load ground motion records
Step3: Load damage state thresholds
Step4: Obtain the damage probability matrix
Step5:... |
2,434 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import plotly.graph_objects as go
from IPython
def get_the_slice(x,y,z, surfacecolor):
return go.Surface(x=x,
y=y,
z=z,
surfacecolor=surfacecolor,
coloraxis='coloraxis')
def 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: Define a function that returns a slice as a Plotly Surface
Step2: Let us plot the slices z=0 and y=-0.5 in the volume defined by
Step3: In ord... |
2,435 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inm', 'sandbox-3', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
2,436 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import logging
import pyclamster
import pickle
import scipy
import scipy.misc
from skimage.feature import match_template
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logging.de... | <SYSTEM_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 pickled coordinates for the first Hungriger Wolf camera
Step2: Set the paramters for the image clustering
Step3: Load image and preproces... |
2,437 | <ASSISTANT_TASK:>
Python Code:
fd = open('README.md', 'r')
print(fd.readline(), end='') # \n is included in input string
for s in fd: # file object(descriptor) is iterable, and can be used in for loop
print(s.strip()) # strip() removes extra space and \n
# print(s.split()) # convert string to List ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data conversion
Step2: Standard In, Standard Out and Standard Error
|
2,438 | <ASSISTANT_TASK:>
Python Code:
p1.f(-.45)
p1.S_k(-1, 1, -.45, 10)
p1.f(-.45)
p1.S_k(-1, 1, -.45, 2)
p1.error(-1, 1, -.45, 2)
p1.S_k(-1, 1, -.45, 4)
p1.error(-1, 1, -.45, 4)
p1.S_k(-1, 1, -.45, 8)
p1.error(-1, 1, -.45, 8)
p1.S_k(-1, 1, -.45, 16)
p1.error(-1, 1, -.45, 16)
p2.sin_graph(0.2, 10)
p2.multigraph(0.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: Part 2
Step2: Error in approximation at q = 2
Step3: q = 4
Step4: Error in approximation at q = 4
Step5: q = 8
Step6: Error in approximatio... |
2,439 | <ASSISTANT_TASK:>
Python Code:
# Ignore
%load_ext sql
%sql sqlite://
%config SqlMagic.feedback = False
%%sql
-- Create a table of criminals_1
CREATE TABLE criminals_1 (pid, name, age, sex, city, minor);
INSERT INTO criminals_1 VALUES (412, 'James Smith', 15, 'M', 'Santa Rosa', 1);
INSERT INTO criminals_1 VALUES (234, ... | <SYSTEM_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 Table
Step2: View Table
Step3: Create New Empty Table
Step4: Copy Contents Of First Table Into Empty Table
Step5: View Previously Emp... |
2,440 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from qutip import *
import numpy as np
N = 10
w0 = 0.5 * 2 * np.pi
times = np.linspace(0, 15, 150)
dt = times[1] - times[0]
gamma = 0.25
A = 2.5
ntraj = 50
nsubsteps = 100
a = destroy(N)
x = a + a.dag()
H = w0 * a.dag() * a
psi0 = fock(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: Photo-count detection
Step2: Solve using stochastic master equation
Step3: Homodyne detection
Step4: Theory
Step5: $$
Step6: Solve problem ... |
2,441 | <ASSISTANT_TASK:>
Python Code:
# Run some setup code for this notebook.
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
# This is a bit of magic to make matplotlib figures appear inline in the
# notebook rather than in a new window.
%matplotlib inline
plt.rcPa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: CIFAR-10 Data Loading and Preprocessing
Step2: SVM Classifier
Step3: The grad returned from the function above is right now all zero. Derive a... |
2,442 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pyedflib # please check the "requirements.txt" file
import tqdm
import pathlib
import os
curr_dir = pathlib.Path("./")
edf_dir = (curr_dir / "raw_data/").resolve()
if not edf_dir.exists():
try:
edf_dir.mkdir()
except Exeption as err:
prin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fetch the dataset
Step2: Prepare dataset
Step3: Parse the baseline files for "eyes open"
Step4: Parse the baseline files for "eyes closed"
St... |
2,443 | <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... |
2,444 | <ASSISTANT_TASK:>
Python Code:
from ipywidgets import interact
import numpy as np
import random
PRIZES = ['Car', 'Goat 1', 'Goat 2']
def monty_hall(example_num=0):
'''
Simulates one round of the Monty Hall Problem. Outputs a tuple of
(result if stay, result if switch, result behind opened door) where
ea... | <SYSTEM_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 that the example_num argument is passed in but not used in the monty_hall function. Although it's unneeded for the function, it is easier t... |
2,445 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal
def logistic(x):
Returns the logistic of the numeric argument to the function.
return 1 / (1 + np.exp(-x))
def estimate_glm_params(X,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: Let's first implement sequential updates for GLMs.
Step5: Let's make a function which can sample from a multivariate normal distribution.
Step9... |
2,446 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import ttest_ind
import mne
from mne.channels import find_ch_adjacency, make_1020_channel_selections
from mne.stats import spatio_temporal_cluster_test
np.random.seed(0)
# Load the data
path = mne.datasets.kiloword.data_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: If we have a specific point in space and time we wish to test, it can be
Step2: Absent specific hypotheses, we can also conduct an exploratory
... |
2,447 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install -U google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if not os.getenv("IS_TESTING... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
2,448 | <ASSISTANT_TASK:>
Python Code:
# Import libraries necessary for this project
import numpy as np
import pandas as pd
from time import time
from IPython.display import display # Allows the use of display() for DataFrames
# Import supplementary visualization code visuals.py
import visuals as vs
# Pretty display for notebo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementation
Step2: Preparing the Data
Step3: For highly-skewed feature distributions such as 'capital-gain' and 'capital-loss', it is commo... |
2,449 | <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: Premade Estimators
Step2: The data set
Step3: Next, download and parse the Iris data set using Keras and Pandas. Note that you keep distinct d... |
2,450 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis Engemann <denis.engemann@gmail.com>
# Jona Sassenhagen <jona.sassenhagen@gmail.com>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import mne
from mne.stats import spatio_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: Set parameters
Step2: Read epochs for the channel of interest
Step3: Find the FieldTrip neighbor definition to setup sensor adjacency
Step4: ... |
2,451 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Eric Larson <larson.eric.d@gmail.com>
# Denis Engemannn <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
from numpy.random import randn
import matplotl... | <SYSTEM_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: Read epochs for all channels, removing a bad one
Step3: Transform to source space
Step4: Transform to common cortical s... |
2,452 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import cPickle as pickle
from copy import deepcopy
from sklearn.utils import shuffle
import sklearn_mmadsen.graphs as skmg
%matplotlib inline
plt.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 strategy, unlike our first attempt, requires a real train/test split in the dataset because we're going to fit an actual model (although a t... |
2,453 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import McNeuron
import matplotlib.pyplot as plt
%matplotlib inline
#loc1 = "/Volumes/Arch/Projects/Computational Anatomy/neuron_nmo/poorthuis/CNG version/060110-LII-III.CNG.swc"
loc1 = "../Generative-Models-of-Neuron-Morphology/Data/Pyramidal/poorthuis/CNG version/0601... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Class1
Step2: Morphology of the neurons
Step3: Feature of interneuron
Step4: Feature of Pyramidal
Step5: Sholl Diagram
Step6: histogram of ... |
2,454 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib as mpl
mpl.rcParams['figure.figsize'] = (10, 7)
import matplotlib.pyplot as plt
from scipy import integrate
import numpy.random as rd
import seaborn as sns
sns.set(context="notebook", style="whitegrid", palette="hls", font="sans-serif", font_scale=1.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: Importez les modules
Step2: Planche 160
Step3: On conjecture que $I_n$ est dรฉcroissante. C'est รฉvident puisque si on note $f_n(t)$ son intรฉgr... |
2,455 | <ASSISTANT_TASK:>
Python Code:
!uname -a
%lsmagic
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
matplotlib.style.use('ggplot')
from IPython.display import YouTubeVideo
YouTubeVideo('o8fmjaW9a0A') # Yes, it can also embed youtube videos.
a = np.array([4,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: A continuaciรณn mostramos los paquetes que usaremos regularmente para tratar datos, pandas, numpy, matplotlib. Al ser un programa en Python, se p... |
2,456 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input t... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Importing dependencies
Step3: Visualize data
Step4: Interactive pandas Dataframe
Step5: Grid and potential field
Step6: From potential field... |
2,457 | <ASSISTANT_TASK:>
Python Code:
import random
results = []
for trial in xrange(10000):
heads = 0
for i in xrange(100):
flip = random.randint(0,1)
if (flip == 0):
heads += 1
results.append(heads)
print results[1:10]
import matplotlib.pyplot as plt
plt.figure()
plt.hist(results)
plt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The binomial distribution is closely related to the normal distribution (aka Gaussian distribution)
Step2: Could we figure this out analyticall... |
2,458 | <ASSISTANT_TASK:>
Python Code:
time_extent = (0, .250)
num_trials = 500
sampling_frequency = 200
num_time_points = ((time_extent[1] - time_extent[0]) * sampling_frequency) + 1
time = np.linspace(time_extent[0], time_extent[1], num=num_time_points, endpoint=True)
signal_shape = (len(time), num_trials)
np.random.seed(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: x1 and x2 have spectral peaks at 40 Hz
Step2: Spectral Granger Causality
Steps
Step3: Compare with nitime version
Step4: Non-parametric versi... |
2,459 | <ASSISTANT_TASK:>
Python Code:
data = pd.read_csv('data/driving_log.csv', header=None,
names=['center', 'left', 'right', 'angle', 'throttle', 'break', 'speed'])
print(data.ix[0].center)
data.sample()
def img_id(path):
return path.split('/IMG/')[1]
image_paths = data.center.apply(img_id).values.t... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading and Preprocessing the Images with OpenCV
Step2: Building a Convnet in Keras
|
2,460 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format='retina' # for hi-dpi displays
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from lmfit import Model
import lmfit
print('lmfit: %s' % lmfit.__version__)
sns.set_style('whitegrid')
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: Create Noisy Data
Step2: Model Fitting
Step3: Two-peaks model
Step4: Fit results from an lmfit Model can be inspected with
Step5: This is go... |
2,461 | <ASSISTANT_TASK:>
Python Code:
import datetime
class Regiment(object):
def __init__(self, date=datetime.datetime.now()):
self.date = date
def __repr__(self):
return date
def __str__(self):
return str(date)
<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: Create A Simple Object
|
2,462 | <ASSISTANT_TASK:>
Python Code:
from pydrill.client import PyDrill
#Open a connection to Drill
drill = PyDrill(host='localhost', port=8047)
#Verify the connection is active, throw an error if not.
if not drill.is_active():
raise ImproperlyConfigured('Please run Drill first')
#Execute query in Drill
query_result = ... | <SYSTEM_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: Retrieving a DataFrame
|
2,463 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset if ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
2,464 | <ASSISTANT_TASK:>
Python Code:
#from IPython.display import HTML
#HTML('''<script>
#code_show=true;
#function code_toggle() {
# if (code_show){
# $('div.input').hide();
# } else {
# $('div.input').show();
# }#
# code_show = !code_show
#}
#$( ocument ).ready(code_toggle);
#</script>
#The raw code for this IPython note... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Crear un entorno
Step2: Notebooks
Step3: Como vรฉis, no hay puntos y coma al final de cada sentencia, le basta con fin de lรญnea. Y en vez de p... |
2,465 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
from xdgmm import XDGMM
from sklearn.model_selection import validation_curve
from sklearn.model_selection import ShuffleSplit
from demo_plots import *
'''
Due to AstroML still using the deprecated GMM class from
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: Next, generate some data to use for our fitting and plotting. This generates the same dataset as in the AstroML demo.
Step2: Component Number S... |
2,466 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sys # system module
import numpy as np # scientific computing
import pandas as pd # data package
import matplotlib as mpl
import matplotlib.pyplot as plt # graphics module
#Step 1: 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: Introduction
Step2: Mini-summary
Step3: Mini-summary
Step4: Mini-summary
Step5: Mini-summary
Step6: Mini-summary
Step7: Mini-summary
|
2,467 | <ASSISTANT_TASK:>
Python Code:
from aesop import Alascan, plotScan_interactive, plotNetwork_interactive
path_apbs = 'path\to\executable\apbs'
path_coulomb = 'path\to\executable\coulomb'
path_pdb2pqr = 'path\to\executable\pdb2pqr'
jobname = 'alascan'
pdbfile = 'barnase_barstar.pdb'
selstr = ['chain A', 'chain B']
ala... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Once Alascan is instantiated and finished running, we can plot the results. The plotScan_interactive function by default, outputs the results in... |
2,468 | <ASSISTANT_TASK:>
Python Code:
from Cincinnati311CSVDataParser import Cincinnati311CSVDataParser
from csv import DictReader
import os
import re
import urllib2
data_dir = "./Data"
csv_file_path = os.path.join(data_dir, "cincinnati311.csv")
if not os.path.exists(csv_file_path):
if not os.path.exists(data_dir):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download the Cincinnati 311 (Non-Emergency) Service Requests data
Step2: Parse the 1st record
Step3: Implement a class that parses and cleans ... |
2,469 | <ASSISTANT_TASK:>
Python Code:
print("Exemplo 4.6")
#trasforma fonte 1 (corrente -> tensao)
#vs1 = is*R = 12V
#Req em serie entre 4 e 2
#Req1 = 4 + 2 = 6
#transforma fonte 2 (tensao -> corrente)
#is2 = 12/3 = 4A
#transforma fonte 1 (tensao -> corrente)
#is1 = 12/6 = 2A
#Req paralelo entre 6 e 3
#Req2 = 6*3/(6 + 3) = 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: Problema Prรกtico 4.6
Step2: Exemplo 4.7
Step3: Problema Prรกtico 4.7
Step4: Teorema de Thรจvenin
Step5: Problema Prรกtico 4.8
Step6: Exemplo 4... |
2,470 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
mpl.style.use('ggplot')
mpl.rc('savefig', dpi=100)
np.random.seed(42)
# data
mu, sigma = 0, 1
x = mu + sigma * np.random.randn(100000)
# plot
pd.Series(x).plot(kind='hist', 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: This distribution was generated using 100,000 random data points with zero mean ($\mu = 0$) and unit variance ($\sigma^2 = 1$). Thus, the true A... |
2,471 | <ASSISTANT_TASK:>
Python Code:
train = pd.read_csv("data/train.csv")
train["dataset"] = "train"
train.head()
test = pd.read_csv("data/test.csv")
test["dataset"] = "test"
test.head()
#Combine both datasets to predict families
train = train.append(test)
train.set_index(train["PassengerId"],inplace=True)
name_tokenizer =... | <SYSTEM_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. Tokenize name into (surname, title, first name and maiden name)
Step2: 2.1 Extract features from Title variable
Step3: It seems we can extr... |
2,472 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
new_column_names = ['Agency', 'Station', 'OldDateTime', 'Timezone', 'Discharge_cfs', 'Discharge_stat', 'Stage_ft', 'Stage_stat']
url = 'http://waterservices.usgs.gov/nwis/iv/?format=rdb&sites=09380000&startDT=2016-01-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: The station number and date range we are interested in are part of the URL that we use to communicate with the web services. The specific file w... |
2,473 | <ASSISTANT_TASK:>
Python Code:
from gensim.corpora.wikicorpus import WikiCorpus
from gensim.models.word2vec import Word2Vec, LineSentence
from pprint import pprint
from copy import deepcopy
from multiprocessing import cpu_count
%%bash
wget https://dumps.wikimedia.org/archive/2010/2010-11/enwiki/20101011/enwiki-2010101... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download wikipedia dump files
Step2: Convert two wikipedia dump files
Step3: Initial training
Step4: Japanese new idol group, "Babymetal", we... |
2,474 | <ASSISTANT_TASK:>
Python Code:
# ์ด์์ฒด์
!ver
# ํ์ฌ ์์น ๋ฐ ํ์ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ
!dir
# ํ์ด์ ๋ฒ์
!python --version
# ๊ฐ์ํ๊ฒฝ ๋ฒ์
!virtualenv --version
# ์กด์ฌํ๋ ๊ฐ์ํ๊ฒฝ ๋ชฉ๋ก
!workon
# ๊ฐ์ํ๊ฒฝ kookmin1์ ์ง์
# workon kookmin1
# ๊ฐ์ํ๊ฒฝ kookmin1์ ์ค์น๋ ํจํค์ง
# ๋ฐ์ดํฐ ๋ถ์ : numpy, pandas
# ์๊ฐํ : matplotlib
!pip freeze
from IPython.display import Image
Image(filename=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TicTaeToe ๊ฒ์
Step2: TicTaeToe๊ฒ์์ ๊ฐ๋จ ๋ฒ์ ผ์ผ๋ก ๊ตฌํํ ๊ฒ์ผ๋ก ์ฌ์ฉ์๊ฐ ๋จผ์ ์ฐฉ์ํ์ฌ ์น๋ถ๋ฅผ ๊ฒจ๋ฃจ๊ฒ ๋ฉ๋๋ค.
|
2,475 | <ASSISTANT_TASK:>
Python Code:
from mcd import mcd
# This line configures matplotlib to show figures embedded in the notebook.
%matplotlib inline
req = mcd()
req.lat = -4.6 # latitude
req.lon = 137.4 # longitude
req.loct = 15. # local time
req.xz = 1. # vertical coordinate
req.xdate = 150.6 # areocentric longitude
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: Step 2 create your request
Step2: Step 3 set the coordinates for your request (for instance, let us choose Curiosity landing site)
Step3: Step... |
2,476 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
seed_x = 10
### return the tensor as variable 'result'
def g(seed_x):
tf.random.set_seed(seed_x)
return tf.random.uniform(shape=(10,), minval=1, maxval=5, dtype=tf.int32)
result = g(seed_x)
<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:
|
2,477 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import plotly.graph_objects as go
def arrow3d(headsize, theta):
r = headsize*np.tan(theta)
u = np.linspace(0,2*np.pi, 60)
v = np.linspace(0, 1, 15)
U,V = np.meshgrid(u,v)
#parameterization of the standard cone
x = r*V*np.cos(U)
y = r*V*np.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: A 3d arrow is designed as a right cone and a disk as its base. We define the standard cone, as the cone of vertex, Vert(0,0, headsize), and ang... |
2,478 | <ASSISTANT_TASK:>
Python Code:
# CODE HERE
import pandas as pd
df = pd.read_csv('bank.csv')
# CODE HERE
df.head()
# CODE HERE
df['age'].mean()
# CODE HERE
df['age'].idxmin()
df.iloc[503]['marital']
# CODE HERE
df['job'].nunique()
# CODE HERE
df['job'].value_counts()
#CODE HERE
# Many, many ways to do this one! H... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TASK
Step2: TASK
Step3: TASK
Step4: TASK
Step5: TASK
Step6: TASK
Step7: TASK
Step8: TASK
Step9: TASK
Step10: TASK
Step11: TASK
Step12:... |
2,479 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-1', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor... | <SYSTEM_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... |
2,480 | <ASSISTANT_TASK:>
Python Code:
# Define T and g
T = 40
y0 =50
g = 0
# Compute yT using the direct approach and print
# Initialize a 1-dimensional array called y that has T+1 zeros
# Set the initial value of y to equal y0
# Use a for loop to update the values of y one at a time
# Print the final value in the array 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: matplotlib
Step2: Next, we want to make sure that the plots that we create are displayed in this notebook. To achieve this we have to issue a c... |
2,481 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import warnings
import pandas as pd
import numpy as np
import os
import sys # error msg, add the modules
import operator # sorting
from math import *
import matplotlib.pyplot as plt
sys.path.append('../../')
import cuda_timeline
import read_trace
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: gpu info
Step2: Understand the input
Step3: Kernel Info from the single stream
Step4: model 3 cuda streams
Step5: start kernel from beginnin... |
2,482 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
asd = pd.read_csv("data/input.csv")
print type(asd)
asd.head()
# This is a Dataframe because we have multiple columns!
data = pd.read_csv("data/input.csv", usecols=["name"], squeeze=True)
print type(data)
data.head()
data.index
data = pd.read_csv("data/input_with_on... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To create a Series we need to set the column (using usecols) to use and set the parameter squeeze to True.
Step2: If the input file has only 1 ... |
2,483 | <ASSISTANT_TASK:>
Python Code:
# Ensure compatibility with Python 2 and 3
from __future__ import print_function, division
from IPython.display import YouTubeVideo
YouTubeVideo('As85L34fKYQ')
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import climlab
from climlab import constants as const
# ... | <SYSTEM_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: All these traveling weather systems tend to move warm, moist air poleward and cold, dry air equatorward. There is thus a net po... |
2,484 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import heartpy as hp
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('raw_ppg.csv')
df.keys()
plt.figure(figsize=(12,6))
plt.plot(df['ppg'].values)
plt.show()
signal = df['ppg'].values[14500:20500]
timer = df['timer'].values[14500:20500]
plt.plot(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exploring data file
Step2: Ok..
Step3: Now we need to know the sampling rate
Step4: So, the format seems to be 'hours
Step5: That's pretty l... |
2,485 | <ASSISTANT_TASK:>
Python Code:
%%writefile echo.py
#!/usr/bin/env python
import zmq
from zmq.eventloop import ioloop, zmqstream
def echo(stream, message):
stream.send_multipart(message)
io_loop = ioloop.IOLoop()
context = zmq.Context()
socket = context.socket(zmq.ROUTER)
stream = zmqstream.ZMQStream(socket, io_loop... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Echo client
Step2: Usage
Step3: Fibonacci example
Step4: Nacci client
Step5: Usage
Step6: Exercise
|
2,486 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
plt.ion()
from astropy import time
from poliastro.twobody.orbit import Orbit
from poliastro.bodies import Earth
from poliastro.plotting import OrbitPlotter
from poliastro.neos import neows
eros = neows.orbit_from_name('Eros')
frame = OrbitPlotter()
frame.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: NeoWS module
Step2: You can also search by IAU number or SPK-ID (there is a faster neows.orbit_from_spk_id() function in that case, although)
S... |
2,487 | <ASSISTANT_TASK:>
Python Code:
sns.set(context="notebook", style="ticks", font_scale=1.5)
sns.lmplot('test1', 'test2', hue='accepted', data=df,
size=6,
fit_reg=False,
scatter_kws={"s": 50}
)
plt.title('Regularized Logistic Regression')
x1 = np.array(df.test1)
x2 = np.array... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: feature mapping
Step2: regularized cost
Step3: this is the same as the not regularized cost because we init theta as zeros...
Step4: fit the ... |
2,488 | <ASSISTANT_TASK:>
Python Code:
import pyspark
sc = pyspark.SparkContext('local[*]')
# We define our input
l = range(10)
l
# We "upload" it as an RDD
rdd = sc.parallelize(l)
rdd
# We define a map function
def power_of_2(k):
return 2**k
# And we apply it to our RDD
rdd.map(power_of_2)
# So we use collect() to retrie... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: map()
Step2: reduce()
Step3: pipelining
Step4: Ok, too easy, this is supposed to be a map & reduce tutorial...
Step5: RDD
Step6: flatMap() ... |
2,489 | <ASSISTANT_TASK:>
Python Code:
from math import inf
import regraph.attribute_sets as atsets
ints = atsets.IntegerSet({(0, 8), (11, inf)})
print(ints.contains(5))
print(ints.contains(9))
a = atsets.IntegerSet({(0, 3), (20, 30)})
print(a.issubset(ints))
b = atsets.IntegerSet({(0, 10)})
print(b.issubset(ints))
a_and_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: Define an infinite integer set
Step2: Test if interger value is in the set
Step3: Test if another integer set is a subset
Step4: Find the int... |
2,490 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy.integrate import odeint
from IPython.html.widgets import interact, fixed
def solve_euler(derivs, y0, x):
Solve a 1d ODE using Euler's method.
Parameters
----------
... | <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: Euler's method
Step4: The midpoint method is another numerical method for solving the above differential equation. In general it is more accura... |
2,491 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
from __future__ import print_function
from builtins import range
from past.utils import old_div
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from singa import tensor
a, b = 3, 2
f = lambda x: a * x + b
gx = np.linspace(0.,1,100)
g... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To import the tensor module of PySINGA, run
Step2: The ground-truth
Step3: Generating the trainin data
Step4: Training via SGD
Step5: SINGA ... |
2,492 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.optimize as opt
# YOUR CODE HERE
data = np.load('decay_osc.npz')
tdata = data['tdata']
ydata = data['ydata']
dy = data['dy']
data.close
plt.figure(figsize=(7,5))
plt.errorbar(tdata, ydata, dy, fmt='og', ec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fitting a decaying oscillation
Step2: Now, using curve_fit to fit this model and determine the estimates and uncertainties for the parameters
|
2,493 | <ASSISTANT_TASK:>
Python Code:
# Import and create a locationDB
from miasm.core.locationdb import LocationDB
loc_db = LocationDB()
print(repr(loc_db))
# Create a location with default attributes (no offset, no symbol name)
loc_a = loc_db.add_location()
print(loc_a)
# Create a second location with an offset
loc_b = loc_... | <SYSTEM_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 that
Step2: Those locations are also used in intermediate representation
Step3: In miasm, each expression embeds its size. The location d... |
2,494 | <ASSISTANT_TASK:>
Python Code:
import numpy
import theano
import theano.tensor as T
from logistic_sgd import LogisticRegression
from mlp import HiddenLayer
from theano.tensor.signal import downsample
from theano.tensor.nnet import conv
class LeNetConvPoolLayer(object):
def __init__(self, rng, input, filter_shape, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we can start to define the actual convolution code. We start by defining an object that represents a single layer of convolution that does ... |
2,495 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-3', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "emai... | <SYSTEM_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... |
2,496 | <ASSISTANT_TASK:>
Python Code:
# If we're running on Colab, install empiricaldist
# https://pypi.org/project/empiricaldist/
import sys
IN_COLAB = 'google.colab' in sys.modules
if IN_COLAB:
!pip install empiricaldist
# Get utils.py
import os
if not os.path.exists('utils.py'):
!wget https://github.com/AllenDowney... | <SYSTEM_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 Red Line is a subway that connects Cambridge and Boston, Massachusetts. When I was working in Cambridge I took the Red Line from Kendall Squ... |
2,497 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import pymc3 as pm
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
warnings.filterwarnings("ignore", category=FutureWarning)
from scipy.stats import norm, t
from IPython.display import Image
%matplotlib inline
plt.style.use('sea... | <SYSTEM_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
Step2: 16.1 - Estimating the mean and standard deviation of a normal distribution
Step3: Figure 16.3
Step4: 16.2 - Outliers and robust e... |
2,498 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import mne
from mne.datasets import sample
data_path = sample.data_path()
# the raw file containing the channel location + types
sample_dir = op.join(data_path, 'MEG', 'sample',)
raw_fname = op.join(sample_dir, 'sample_audvis_raw.fif')
# The paths to Freesurfer recons... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Computing the forward operator
Step2: Visualizing the coregistration
Step3: Compute Source Space
Step4: The surface based source space src co... |
2,499 | <ASSISTANT_TASK:>
Python Code:
import os
DEN_CLIENT_ID = os.environ["DEN_CLIENT_ID"]
DEN_CLIENT_SECRET = os.environ["DEN_CLIENT_SECRET"]
import uuid
def _get_state():
Get a unique id string.
return str(uuid.uuid1())
_get_state()
API_PROTOCOL = "https"
API_LOCATION = "home.nest.com"
from urlparse import SplitR... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Get Authorization URL
Step5: Create Authorization URL Helper
Step6: Get Authorization Code
Step7: Cut and paste that PIN here
Step9: Get Acc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.