Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
13,800 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import io
from mne.datasets import sample
from mne.minimum_norm import read_inverse_operator, source_induced_power
print(__doc__)
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: Set parameters
|
13,801 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({
'Column1': [1, 2, 3, 4, 5, 6, 7, 8, 9],
'Column2': [4, 3, 6, 8, 3, 4, 1, 4, 3],
'Column3': [7, 3, 3, 1, 2, 2, 3, 2, 7],
'Column4': [9, 8, 7, 6, 5, 4, 3, 2, 1],
'Column5': [1, 1, 1, 1, 1, 1, 1, 1, 1]})
def get_relation(df, col1, 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:
|
13,802 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
assert os.path.isfile('yearssn.dat')
# YOUR CODE HERE
data = np.loadtxt("yearssn.dat")
year = data[:,0]
ssc = data[:,1]
print(year)
print(ssc)
assert len(year)==315
assert year.dtype==np.dtype(float)
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: Line plot of sunspot data
Step2: Use np.loadtxt to read the data into a NumPy array called data. Then create two new 1d NumPy arrays named year... |
13,803 | <ASSISTANT_TASK:>
Python Code:
JACOCO_CSV_FILE = r'input/spring-petclinic/jacoco.csv'
with open (JACOCO_CSV_FILE) as log:
[print(line, end='') for line in log.readlines()[:4]]
import pandas as pd
coverage= pd.read_csv(JACOCO_CSV_FILE)
coverage.head(3)
coverage = coverage[['PACKAGE', 'CLASS', 'LINE_MISSED', 'LINE_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: It contains the package and class name as well as diverse measures that show use the coverage.
Step2: Nice, Pandas recognizes the format of the... |
13,804 | <ASSISTANT_TASK:>
Python Code:
# Astro-example
####################
#Cosmic cleanning of an image of 12 detectors
#Uses L.A. Cosmic from P. van Dokkum
#Requires python version of la_cosmic
#http://www.astro.yale.edu/dokkum/lacosmic/
#it also uses Parallel python PP
##################
#
# La_cosmic must be in the same ... | <SYSTEM_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 image of this example is an IFU science exposure taken with GMOS Hamamatsu CCD
Step2: limpia_cosmicos calls la_cosmic from P. van Dokkum
|
13,805 | <ASSISTANT_TASK:>
Python Code::
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25)
model = LinearRegression()
model.fit(X_train, y_train)
<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:
|
13,806 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'awi-cm-1-0-hr', 'ocean')
# 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... |
13,807 | <ASSISTANT_TASK:>
Python Code:
import os
from sklearn.datasets.base import Bunch
from yellowbrick.download import download_all
## The path to the test data sets
FIXTURES = os.path.join(os.getcwd(), "data")
## Dataset loading mechanisms
datasets = {
"hobbies": os.path.join(FIXTURES, "hobbies")
}
def load_data(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: Words in Space
Step2: Vectorize the Documents
Step3: About t-SNE
Step4: Euclidean Distance
Step5: As you've probably heard, Euclidean distan... |
13,808 | <ASSISTANT_TASK:>
Python Code:
import statsmodels.api as sm
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from io import StringIO
raw = StringIO(0.05,0.00,1.25,2.50,5.50,1.00,5.00,5.00,17.50
0.00,0.05,1.25,0.50,1.00,5.00,0.10,10.00,25.00
0.00,0.05,2.50,0.01,6.00,5.00,5.00,5.00,42.50
0.10,0.30,... | <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 raw data, expressed as percentages. We will divide by 100
Step3: The regression model is a two-way additive model with
Step4: Fit the qua... |
13,809 | <ASSISTANT_TASK:>
Python Code:
!pip install --upgrade pip
!pip install -q -U tensorflow_transform
# This cell is only necessary because packages were installed while python was running.
import pkg_resources
import importlib
importlib.reload(pkg_resources)
import pathlib
import pprint
import tempfile
import tensorflo... | <SYSTEM_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 TensorFlow Transform
Step2: Restart the kernel to use updated packages. (On the Notebook menu, select Kernel > Restart Kernel > Restart... |
13,810 | <ASSISTANT_TASK:>
Python Code:
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("data/", one_hot=True)
import numpy as np
from scipy.special import expit
def __init__():
pass
def query():
pass
def train():
pass
class NeuralNetwork():
pass
n_inodes = 1
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: 2. Building an ANN from Sratch
Step2: We're going to build a ANN class, called NeuralNetwork, this will contain two functions, and an initializ... |
13,811 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
train_data,test_data = sales.random_split(.8,seed=0)
example_features = ['sqft_living', 'bedrooms', 'bathrooms']
example_model = graphlab.linear_regression.create(train_data, target = 'price', features = example_features,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in house sales data
Step2: Split data into training and testing.
Step3: Learning a multiple regression model
Step4: Now that we have fit... |
13,812 | <ASSISTANT_TASK:>
Python Code:
import bokeh
from bokeh.models.util import generate_structure_plot
from bokeh.plotting import figure
from bokeh.io import output_notebook, show
output_notebook()
import numpy as np
X = np.linspace(-1,1,100)
Y = X + np.random.normal(size=X.shape)
f=figure(width=400,height=400)
_=f.line(x=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create a figure
Step2: Simple Public API
Step3: The _BokehStructureGraph class
Step4: Properties of the Structure Graph
Step5: Dataframe of... |
13,813 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
W = sp.exp1
kD = 600 # m2/d
S = 0.2 # [-]
x0 = 250 # m # distance from river
Q = 1200 # m3/d, extraction of te real well
r0 = 0.25 # well radius
t = 1.0 # d
a = 125 # m distance between well and river shore
# lo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Many observation points
Step2: Compute the flow across a ring with radius r
Step3: Inflow from the river
Step4: Compute the total inflow for ... |
13,814 | <ASSISTANT_TASK:>
Python Code:
print(tf.nn.softmax_cross_entropy_with_logits.__doc__)
import tensorflow as tf
from keras.layers.advanced_activations import LeakyReLU, PReLU
def LeakyRelu(x, alpha):
return tf.maximum(alpha*x, x)
with tf.Session() as sess:
inp = tf.Variable(initial_value=tf.random_uniform(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: Definition
|
13,815 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
def print_sum(a, b):
c = a + b
print (c)
interact(print_sum, a = (-10.0,10.0,1.0), b = (-8.0,8.0,2.0));
as... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Interact basics
Step2: Use the interact function to interact with the print_sum function.
Step3: Write a function named print_string that prin... |
13,816 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -a 'Sebastian Raschka' -u -d -v -p numpy,matplotlib,theano,keras
# to install watermark just uncomment the following line:
#%install_ext https://raw.githubusercontent.com/rasbt/watermark/master/watermark.py
import theano
from theano import tensor as T
# ini... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sections
Step2: <br>
Step3: To change the float type globally, execute
Step4: You can run a Python script on CPU via
Step5: Updating shared... |
13,817 | <ASSISTANT_TASK:>
Python Code:
coin = bernoulli(0.7)
samples = coin.rvs(20)
num_heads = sum(samples)
num_tails = len(samples) - num_heads
prior_1 = beta(1,1)
likelihood = beta(num_heads+1, num_tails+1)
posterior_1 = beta(num_heads+1, num_tails+1)
prior_2 = beta(2, 5)
posterior_2 = beta(num_heads + 2, num_tails + 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: As bayesians, we model the problem as finding the parameter $\theta$ of a bernoulli distribution given the data. For this, we start with an unif... |
13,818 | <ASSISTANT_TASK:>
Python Code:
import sys, time, os
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
from landlab.components import FlowAccumulator, PriorityFloodFlowRouter, ChannelProfiler
from landlab.io.netcdf import read_netcdf
from landlab.utils import get_watershed_mask
from landlab imp... | <SYSTEM_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 function to download and save SRTM images using BMI_topography.
Step2: Make function to plot DEMs and drainage accumulation with shad... |
13,819 | <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: Fairness Indicators on TF-Hub Text Embeddings
Step2: Import other required libraries.
Step3: Dataset
Step4: By default, the notebook download... |
13,820 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from ecell4.prelude import *
with species_attributes():
A | B | C | {'D': 1, 'radius': 0.005}
with reaction_rules():
A + B == C | (0.01, 0.3)
m = get_model()
show(m)
from ecell4.extra.unit import getUnitRegistry
ureg = getUnitRegistry()
Q_ = ureg.Quantity
wi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: With no units
Step2: The species_attributes section defines a diffusion constant and radius of Species, A, B and C. For example, the diffusion ... |
13,821 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
% matplotlib inline
import numpy as np
import scipy
import scipy.stats as stats
import scipy.optimize as optimize
import scipy.integrate as integrate
from __future__ import print_function, division
import os
import math
from nipy.labs.utils.simul_multisubject_fmri_datase... | <SYSTEM_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 peak density function
Step2: Simulate and export data from 10 subjects
Step3: Perform group analysis and extract peaks from Tstat-map
S... |
13,822 | <ASSISTANT_TASK:>
Python Code:
import requests
import json
from IPython.display import display
from IPython.display import Image
# Basic Setup
PORT_NUMBER = 1234
BASE = 'http://localhost:' + str(PORT_NUMBER) + '/v1/'
HEADERS = {'Content-Type': 'application/json'}
# Utility function to print result (JSON Printer)
def jp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 0. Start from scratch
Step2: 1. Load a network from file / URL
Step3: 2. Get the current network view as a PNG image (embedded)
Step4: 3. Get... |
13,823 | <ASSISTANT_TASK:>
Python Code:
# These are your stellar temperatures, you're welcome!
temp = [5809, 16589, 4698, 1869, 37809, 8634]
# Fill in the parentheses. Don't forget indentation!
n = random_number(50,250) # this should be given!
if ():
#print statement here
elif ():
#print statement here
else:
#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: Using if-elif for discrete classification
Step2: Test your statement a few times so that you see if it works for various numbers.
|
13,824 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
from sklearn.metrics import accuracy_score, confusion_matrix
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import matplotlib.pyplot as plt
import os
import shutil
%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: Prepare Data
Step2: Define Network
Step3: Train Network
Step4: Evaluate Network
|
13,825 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'sandbox-1', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
13,826 | <ASSISTANT_TASK:>
Python Code:
from lib.rnn import *
from lib.layer_utils import *
from lib.grad_check import *
from lib.optim import *
from lib.train import *
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['ima... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Recurrent Neural Networks
Step2: Vanilla RNN
Step3: Vanilla RNN
Step4: Vanilla RNN
Step5: Word embedding
Step6: Word embedding
Step7: Inli... |
13,827 | <ASSISTANT_TASK:>
Python Code:
for number in [0, 1, 2, 3, 4, 5, 6]:
if number % 2 == 0:
print "Even number:", number
(50 - 5.0 * 6) / 4
5 ** 2
"I can eat glass it doesn't hurt me"
'I can eat glass it doesn\'t hurt me'
print 'I can eat glass.\nIt doesn\'t hurt me'
print '---------------'
print r'I can 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: What do we see?
Step2: <code>**</code> operator can be used to calculate powers
Step3: String
Step4: Print a string using <code>print</code> ... |
13,828 | <ASSISTANT_TASK:>
Python Code:
# Importamos pandas
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import HTML
HTML('<iframe src="http://www.juntadeandalucia.es/agriculturaypesca/ifapa/ria/servlet/FrontController?action=Static&url=coordenadas.jsp&c_provincia=4&c_estacion=4" ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Cargando los datos y explorándolos
Step2: Vemos que los datos no están en formato CSV, sino que la delimitación son espacios. Si intentamos car... |
13,829 | <ASSISTANT_TASK:>
Python Code::
from sklearn.preprocessing import StandardScaler
#Initalise standard scaler
scaler = StandardScaler()
#Fit the scaler using X_train data
scaler.fit(X_train)
#Transform X_train and X_test using the scaler and convert back to DataFrame
X_train = pd.DataFrame(scaler.transform(X_train), colu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
13,830 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-3', 'atmos')
# 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... |
13,831 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
# RMS Titanic data visualization code
from titanic_visualizations import survival_stats
from IPython.display import display
%matplotlib inline
# Load the dataset
in_file = 'titanic_data.csv'
full_data = pd.read_csv(in_file)
# Print the first few ent... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship
Step3: The very same sample of th... |
13,832 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Credit.csv', index_col=0)
data.head(10)
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
sns.pairplot(data,hue='Gender',palette="husl",markers="+")
# splitting data
male_= data[data.Gend... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Usually, this kind of data it's commonly used to create scoring models. With the tools already studied, we could achieve this task easily. Howev... |
13,833 | <ASSISTANT_TASK:>
Python Code:
Show examples of matplotlib artists
http://matplotlib.org/api/artist_api.html
Several examples of standard matplotlib graphics primitives (artists)
are drawn using matplotlib API. Full list of artists and the
documentation is available at
http://matplotlib.org/api/artist_api.html
Copyrigh... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Artists
Step2: Containers are objects like Figure and Axes. Containers are given primitives to draw. The plotting functions we discussed back i... |
13,834 | <ASSISTANT_TASK:>
Python Code:
def plot_fibo_ratio(series):
ratios = []
for i in range(len(series)-1):
ratios.append(series[i+1]/series[i])
plt.plot(ratios, 'b*')
plt.ylabel('Ratio')
plt.xlabel('No.')
def plot_km_miles_ratio(kms):
miles_km = [1.6094*km/km for km in kms]
plt.plot(mile... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The above graph shows that the ratio between consecutive Fibonacci numbers and a distance measurement in kilometer and mile is close to being th... |
13,835 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
from mpl_toolkits.mplot3d import Axes3D
import plotBL
HTML('../style/code_toggle.html')
ant1 = np.array([-500e3,500e3,0]) # in m
ant2 ... | <SYSTEM_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 section specific modules
Step2: 4.5.1 UV coverage
Step3: Let's express the corresponding physical baseline in ENU coordinates.
Step4: ... |
13,836 | <ASSISTANT_TASK:>
Python Code:
run_folder = r""
from interop import py_interop_run_metrics, py_interop_run, py_interop_table
import numpy
import pandas as pd
run_metrics = py_interop_run_metrics.run_metrics()
valid_to_load = py_interop_run.uchar_vector(py_interop_run.MetricCount, 0)
py_interop_table.list_imaging_tabl... | <SYSTEM_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 SAV Imaging Tab-like Metrics
Step2: By default, the run_metrics class loads all the InterOp files.
Step3: The run_metrics class can us... |
13,837 | <ASSISTANT_TASK:>
Python Code:
from IPython.html.widgets import interact, interactive, fixed
from IPython.html.widgets import FloatSlider
from CO2simulation import CO2simulation
def plot_CO2plume(time):
import param as param
CO2 = CO2simulation(param)
x = CO2.extract_state(int(time/3))
data = CO2.extrac... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Kalman filtering
Step2: Results
|
13,838 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import itertools
from scipy import stats
from statsmodels.stats.descriptivestats import sign_test
from statsmodels.stats.weightstats import zconfint
%pylab inline
data = np.array([49,58,75,110,112,132,151,276,281,362])
pylab.hist(data)
pylab.show()
... | <SYSTEM_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 4
Step2: Task 5
Step3: Task 6
Step4: Task 7
|
13,839 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
data = {'a': [1, 2, 3, 4, 5], 'b': [2, -6, 0, -4, 100]}
df = pd.DataFrame(data)
result = np.where((df.a<= 4)&(df.a>1), df.b,np.nan)
<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:
|
13,840 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from __future__ import print_function
from poppy.creatures import PoppyErgoJr
poppy = PoppyErgoJr()
poppy.rest_posture.start()
poppy_ergo_jr.motors
for m in poppy.motors:
print(m.name)
#print ("terminé")
poppy.m1
poppy.m1.present_position
[m.present_position for 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: % pylab inline est une commande python qui importe les modules numpy et matplotlib. L'option inline indique que les figures Matplotlib seront in... |
13,841 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def comb(shape, delta, offset):
shape = np.array(shape)
assert shape.size <= 3
g = np.zeros(shape)
if shape.size == 1:
g[offset::delta] = 1
elif shape.size == 2:
g[offset[0]::delta[0], offset[1]::delta[1]] = 1
elif shape.size == ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Examples
Step2: Example 1
Step3: Example 2
Step4: Example 3
Step5: Equation
|
13,842 | <ASSISTANT_TASK:>
Python Code:
from thinkbayes2 import Pmf, Suite
import thinkplot
import math
% matplotlib inline
# calculate number of male-male dizygotic twins using the percentage of dizygotic and percentage of male-male
DiMM = 100 * .92 * .25
# calculate number of male-male monozygotic twins using the percentage ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Twin brothers and bayes theorem
Step2: So, we can conclude that Elvis had a 14.8% chance to identical twins with his brother.
Step3: The Dice ... |
13,843 | <ASSISTANT_TASK:>
Python Code:
from dakotathon import Dakota
d = Dakota(method='centered_parameter_study', plugin='hydrotrend')
d.variables.descriptors = ['starting_mean_annual_temperature', 'total_annual_precipitation']
d.variables.initial_point = [15.0, 2.0]
d.method.steps_per_variable = [2, 5]
d.method.step_vector... | <SYSTEM_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 Dakota instance to perform a centered parameter study with HydroTrend.
Step2: Define the HydroTrend input variables to be used in the ... |
13,844 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import quantities as pq
import neo
import elephant
import viziphant
np.random.seed(4542)
spiketrains = elephant.spike_train_generation.compound_poisson_process(
rate=5*pq.Hz, A=[0]+[0.98]+[0]*8+[0.02], t_stop=10*pq.s)
len(spiketrains)
for i in range(90):
spiket... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate correlated data
Step2: In a second step, we add 90 purely random Poisson spike trains using the homogeneous_poisson_process()| functio... |
13,845 | <ASSISTANT_TASK:>
Python Code:
x = 5
print(x > 2)
x = 5
print(x < 2)
x = 20
print (x > 2)
x = 5
if x > 2:
print(x)
x = 0
if x > 2:
print(x)
x = 0
if x > 2:
print(x)
print("hello")
x = 20
if x < 5:
print(x)
x = 2
if x < 5 and x > 10:
print("condition met")
x = 2
if x < 5 or x > 10:
print("co... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Summarize
Step2: Predict what this code will do.
Step3: Predict what this code will do.
Step4: Summarize
Step5: Implement
Step6: Summarize
... |
13,846 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
import numpy as np # note this allows us to refer to numpy as np instead
def feature_derivative_ridge(errors, feature, weight, l2_penalty, feature_is_constant):
# If feature_is_constant is True, derivative is twice the 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: Load in house sales data
Step2: If we want to do any "feature engineering" like creating new features or adjusting existing ones we should do t... |
13,847 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from sys import path
path.append('..')
from zf_function_wrappers import *
from zf_common import *
from zf_macro_functions import *
FAR_AWAY = 9999
BIG = 2000
SIZE_0 = 0
# store all commands here (these go into the "AI, lives" window in http://zetaflow.skylogic.ca/game/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:
Step2: Overview
Step3: machine guns "spreads"
Step4: BR corner
Step5: Parts for the triggers, walls, and guns
Step6: 2. Flying assistant ("ship2")
... |
13,848 | <ASSISTANT_TASK:>
Python Code:
import random
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
print random.randint(0,1)
import random
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: But as you'll see today, we can accomplish the same thing like this
Step2: ..or this
Step3: These two code blocks are called the while loop an... |
13,849 | <ASSISTANT_TASK:>
Python Code:
from datalab.stackdriver import monitoring as gcm
# set_datalab_project_id('my-project-id')
import collections
# Initialize the query for CPU utilization over the last week, and read in its metadata.
query_cpu = gcm.Query('compute.googleapis.com/instance/cpu/utilization', hours=7*24)
cpu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Find the most common instance name prefixes
Step2: Select the instance name prefix to filter on
Step3: Load the time series data
Step4: Split... |
13,850 | <ASSISTANT_TASK:>
Python Code:
from keras.datasets import imdb
idx = imdb.get_word_index()
type(idx)
# Let's look at the word list
sorted(iterable, *, key=None, reverse=False):
built-in function; Return a new sorted list from the items in iterable.
idx_list = sorted(idx, key=idx.get)
print(idx_list[:5])
from iter... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup data
Step2: Create a mapping dict from id to word
Step4: Get the reviews file
Step5: The labels are 1 for positive, 0 for negative
Step... |
13,851 | <ASSISTANT_TASK:>
Python Code:
# A bit of setup
# Usual imports
import time
import numpy as np
import matplotlib.pyplot as plt
# Notebook plotting magic
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simple CNN
Step3: Function to load data
Step5: Function to build network
Step7: Dataset iteration
Step8: Main function
|
13,852 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from sklearn import linear_model
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="white", color_codes=True)
%matplotlib inline
data_dir = './'
kpi_files = [data_dir + kpi for kpi in ['kpis_1998_2003.csv',
... | <SYSTEM_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: I want to be sure that headers are consistent for all KPI files. I raise an exception if that is not the case.
Step3: I lo... |
13,853 | <ASSISTANT_TASK:>
Python Code:
# Alphabetical order is standard
# We're doing "import superlongname as abbrev" for our laziness - this way we don't have to type out the whole thing each time.
# Python plotting library
import matplotlib.pyplot as plt
# Numerical python library (pronounced "num-pie")
import numpy as np
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We'll read in the data using pandas and look at the first 5 rows of the dataframe with the dataframe-specific function .head(). Whenever I read ... |
13,854 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import sys
import glob
import pprint
import numpy as np
import scipy as sp
import pandas as pd
import scipy.stats as sps
import statsmodels.api as sm
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import matplotlib.tic... | <SYSTEM_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 all the Python modules we will use for the analysis. Note that both RADICAL Utils and RADICAL Pilot need to be loaded alongside RADICAL Ana... |
13,855 | <ASSISTANT_TASK:>
Python Code:
%%capture
!pip install git+https://github.com/deepmind/dm-haiku
import haiku as hk
%%capture
!pip install git+git://github.com/deepmind/optax.git
import optax
import haiku as hk
import jax
import jax.numpy as jnp
import numpy as np
# Here is a function that takes in data x, and meta-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: Haiku function transformations
Step2: Transforming stateful functions
Step3: Modules
Step4: Nested and built-in modules
Step5: Stochastic mo... |
13,856 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import tensorflow_data_validation as tfdv
print('TF version: {}'.format(tf.__version__))
print('TFDV version: {}'.format(tfdv.__version__))
PROJECT = 'cloud-training-demos' # Replace with your PROJECT
BUCKET = 'cloud-training-demos-ml' # Replace with your BUCKE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <img valign="middle" src="images/tfx.jpeg">
Step2: 1. Data Analysis
Step3: 1.2 Infer Schema
Step4: 1.3 Configure Schema
Step5: 1.4 Validate ... |
13,857 | <ASSISTANT_TASK:>
Python Code:
# To visualize plots in the notebook
%matplotlib inline
# Imported libraries
import csv
import random
import matplotlib
import matplotlib.pyplot as plt
import pylab
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from sklearn.preprocessing import PolynomialFeatures
from sklearn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Logistic Regression
Step2: 2.2. Classifiers based on the logistic model.
Step3: 3.3. Nonlinear classifiers.
Step4: 3. Inference
Step5: Now, ... |
13,858 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: テキスト生成のフェデレーテッドラーニング
Step2: トレーニング済みモデルを読み込む
Step3: トレーニング済みモデルの読み込みとテキストの生成
Step4: Shakespere のフェデレーテッドデータを読み込んで事前処理する
Step5: shakespeare.l... |
13,859 | <ASSISTANT_TASK:>
Python Code:
!pip install keras-tuner -q
from tensorflow import keras
from tensorflow.keras import layers
import keras_tuner
import numpy as np
def build_model(hp):
model = keras.Sequential()
model.add(layers.Flatten())
model.add(
layers.Dense(
units=hp.Int("units", mi... | <SYSTEM_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 this guide, we will show how to tailor the search space without changing the
Step2: We will reuse this search space in the rest of the tutor... |
13,860 | <ASSISTANT_TASK:>
Python Code:
from sklearn import preprocessing
filename = '../facies_vectors.csv'
train = pd.read_csv(filename)
# encode well name and formation features
le = preprocessing.LabelEncoder()
train["Well Name"] = le.fit_transform(train["Well Name"])
train["Formation"] = le.fit_transform(train["Formation"]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Impute PE
Step2: Impute PE through random forest regression
Step3: This approach gives us an expected RMSE of about 0.575 - now let's impute t... |
13,861 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import pints
import pints.plot
class BadLogisticModel(pints.ForwardModel):
Logistic model of population growth with unidentifiable parameters.
def __init__(self):
super(BadLogisticModel, self).__init__()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Optimisation
Step2: We can still easily generate some data
Step3: And we can define a log likelihood, and use optimisation to try and find bac... |
13,862 | <ASSISTANT_TASK:>
Python Code:
import urllib2
import json
import pandas as pd
url = urllib2.urlopen('http://api.nytimes.com/svc/books/v3/lists/2015-10-01/hardcover-fiction.json?callback=books&sort-by=rank&sort-order=DESC&api-key=efb1f6ff386ce33c0b913d44bce40fd8%3A10%3A73015082')
data = json.load(url)
clean_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: I would like to get the Best Seller list for the Month of October 2015. First I signed up to the New York Times API, and afterwards received a k... |
13,863 | <ASSISTANT_TASK:>
Python Code:
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
simple_seq = Seq("GATC")
simple_seq_r = SeqRecord(simple_seq)
simple_seq_r.id
simple_seq_r.id = "AC12345"
simple_seq_r.description = "Made up sequence I wish I could write a paper about"
print(simple_seq_r.description)
simple_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: The SeqRecord Object
Step2: Additionally, you can also pass the id, name and description to the initialization function, but if not they will b... |
13,864 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import pm4py
df = pm4py.format_dataframe(pd.read_csv('data/running_example.csv', sep=';'), case_id='case_id',activity_key='activity',
timestamp_key='timestamp')
bpmn_model = pm4py.discover_bpmn_inductive(df)
pm4py.view_bpmn(bpmn_model)
pro... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Observe that the process model that we discovered, describes the same behavior as the model that we have shown above.
Step2: We'll analyze the ... |
13,865 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import sys
from casadi import *
# Add do_mpc to path. This is not necessary if it was installed via pip
sys.path.append('../../../')
# Import do_mpc package:
import do_mpc
model_type = 'continuous' # either 'discrete' or 'continuous'
model = do_mpc.model.Model(model_ty... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model
Step2: States and control inputs
Step3: The control input is the feed flow rate $u_{\text{inp}}$ of $S_{\text{s}}$
Step4: ODE and param... |
13,866 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
pd.set_option('max_columns', 50)
mpl.rcParams['lines.linewidth'] = 2
%matplotlib inline
data = pd.read_csv('/Users/crucker/Desktop/clv_transactions.csv')
data.head(6)
data.tail(6)
Transactions... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <span style="color
Step2: <span style="color
Step3: <span style="color
Step4: <span style="color
Step5: <span style="color
|
13,867 | <ASSISTANT_TASK:>
Python Code:
show_html_expl(explain_prediction(clf, test['data'][2], vec, target_names=train['target_names']),
force_weights=True)
show_html_expl(explain_prediction(clf, test['data'][4], vec, target_names=train['target_names']), force_weights=False)
import numpy as np
for doc in test[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can hide weights by passing force_weights=False (they still will be shown if it's impossible to highlight text)
Step2: Show explanations for... |
13,868 | <ASSISTANT_TASK:>
Python Code:
from learntools.core import binder
binder.bind(globals())
from learntools.game_ai.ex3 import *
#_COMMENT_IF(PROD)_
q_1.hint()
# Check your answer (Run this code cell to receive credit!)
q_1.solution()
# Fill in the blank
num_leaves = ____
# Check your answer
q_2.check()
#%%RM_IF(PROD)%%... | <SYSTEM_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) A closer look
Step2: 2) Count the leaves
Step3: 3) Which move will the agent select?
Step4: 4) Examine the assumptions
Step5: 5) Submit t... |
13,869 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
index = pd.date_range('1/1/2000', periods=8)
s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])
df = pd.DataFrame(np.random.randn(8, 3), index=index, columns=['A', 'B', 'C'])
wp = pd.Panel(np.random.randn(2,5,4), items=['Item1', 'Ite... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Head() Tail()
Step2: 属性和 ndarray
Step3: 只想得到对象中的数据而忽略index和columns,使用values属性就可以
Step4: 如果DataFrame或Panel对象的数据类型相同(比如都是 int64),修改object.value... |
13,870 | <ASSISTANT_TASK:>
Python Code:
# Load the needed packages
from glob import glob
import matplotlib.pyplot as plt
import numpy as np
import awot
from awot.graph.common import create_basemap
from awot.graph import RadarHorizontalPlot, RadarVerticalPlot, FlightLevel
%matplotlib inline
# Set the project name
Project="DYNAM... | <SYSTEM_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>Supply input data and set some plotting parameters.</b>
Step2: <b>Set up some characteristics for plotting.</b>
Step3: <b>Read in the fligh... |
13,871 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
pd?
pd.Categorical
cdr = pd.read_csv('data/CDR_data.csv')
cdr.head()
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
matplotlib.style.use('ggplot') # Look Pretty
df.info()
df.CallTimestamp = pd.to_datetime(df.CallTimestamp)
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: Interaktive Hilfe
Step2: Die weitere Funktionalität der Pandas-Bibliothek können wir erkunden, indem wir die Methoden von Pandas ansehen. Dazu ... |
13,872 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
img = mnist.train.images[2]
plt.imshow(img.reshape((28, 28)), cmap='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: Network Architecture
Step2: Training
Step3: Denoising
Step4: Checking out the performance
|
13,873 | <ASSISTANT_TASK:>
Python Code:
from pyspark import SparkContext
from pyspark.streaming import StreamingContext
from pyspark.sql import SQLContext
from pyspark.sql.functions import desc
from collections import namedtuple
# Namedtuple: https://pymotw.com/2/collections/namedtuple.html, http://stackoverflow.com/questions/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: Crear el contexto de Streaming. Con la configuración
Step2: Una vez instanciados los contextos, nos conectamos a la fuente de datos
Step3: Sop... |
13,874 | <ASSISTANT_TASK:>
Python Code:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline
# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'
# import functions from the modsim.py module
from modsim import *
# set the ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: One queue or two?
Step3: Test this function by creating a System object with lam=1/8 and mu=1/5.
Step5: Write an update function that takes as... |
13,875 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
names=['dt', 'east', 'north', 'elev', 'code'] # column names in csv input file
data = pd.read_csv('https://raw.githubusercontent.com/OSGeoLabBp/tutorials/master/english/data_processing/lessons/code/one_day.csv',
sep=',', names=names, parse_dates=['dt... | <SYSTEM_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 examine some statistical values of the elevations (e.g. mean, min, max, standard deviation)
Step2: The mean error (standard deviation) lo... |
13,876 | <ASSISTANT_TASK:>
Python Code:
from sklearn import datasets
from sklearn.decomposition import PCA
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from mpl_toolkits.mplot3d import Axes3D
# %matplotlib inline
%matplotlib notebook
iris = datasets.load_iris()
X = pd.DataFrame(iris.data, columns=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: Load Iris dataset
Step2: PCA
Step3: The P.C. #0 explained variance is one order of magnitude higher than P.C. #1 and #2, and two orders of mag... |
13,877 | <ASSISTANT_TASK:>
Python Code:
import datetime
import six
print( "packages imported at " + str( datetime.datetime.now() ) )
%pwd
%run ../django_init.py
# start to support python 3:
from __future__ import unicode_literals
from __future__ import division
#===============================================================... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup - virtualenv jupyter kernel
Step2: Setup - Initialize Django
Step3: Setup R
|
13,878 | <ASSISTANT_TASK:>
Python Code:
from numpy.linalg import inv
import numpy as np
from math import pi, sqrt, gamma
from scipy.stats import t
import matplotlib.pyplot as plt
%matplotlib inline
def my_t(x, df):
_ = (df + 1.)/2.
return gamma(_) / (sqrt(pi* df) * gamma(df/2.) * (1. + x**2/df) ** (_))
def my_t(x, df):... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: t-distribution
Step2: Multivariate t-distribution
Step3:
Step4:
Step5: https
|
13,879 | <ASSISTANT_TASK:>
Python Code:
import zeep
import numpy as np
client = zeep.Client('http://turbulence.pha.jhu.edu/service/turbulence.asmx?WSDL')
ArrayOfFloat = client.get_type('ns0:ArrayOfFloat')
ArrayOfArrayOfFloat = client.get_type('ns0:ArrayOfArrayOfFloat')
SpatialInterpolation = client.get_type('ns0:SpatialInterpol... | <SYSTEM_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 GetData_Python, Function_name could be
Step2: In GetPosition_Python, Function_name could be
Step3: In GetFilter_Python, Function_name could... |
13,880 | <ASSISTANT_TASK:>
Python Code:
from datetime import datetime, timedelta
pivot = datetime.strptime('11/18/2014', '%m/%d/%Y')
today = datetime.strptime('1/18/2016', '%m/%d/%Y')
print today - pivot
period = timedelta(days=426)
print pivot - period
import pandas as pd
url = 'https://data.cityofchicago.org/api/views/qa42-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: This was run on 1/26/2016, 434 days after November 18, 2014. But the Data Portal only has data up to 1/18/2016, so we want to go to 426 days bef... |
13,881 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
img = mnist.train.images[2]
plt.imshow(img.reshape((28, 28)), cmap='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: Network Architecture
Step2: Training
Step3: Denoising
Step4: Checking out the performance
|
13,882 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate
def trapz(f, a, b, N):
Integrate the function f(x) over the range [a,b] with N points.
N = N+1
a = a
b = b
h = (b-a)/N
k1 = np.arange(a, b, N)
k2 = np.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:
Step3: Trapezoidal rule
Step4: Now use scipy.integrate.quad to integrate the f and g functions and see how the result compares with your trapz functio... |
13,883 | <ASSISTANT_TASK:>
Python Code:
t = np.arange(50)*0.05
input_data = np.sign(np.array([np.sin(2*np.pi*t),np.sin(2*np.pi*t)]).T).astype(float)
input_data += np.random.normal(size=input_data.shape)*0.1
output_data = (np.sign(np.sin(2*np.pi*t*2+np.pi)).astype(float)+1)/2
print('Input Data', input_data)
print('Output 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: Let's plot that data, just to make it clearer
Step2: Now we need to make our network and train it.
Step3: Now we create our network. I don't ... |
13,884 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
model = LinearRegression(normalize=True)
print(model.normalize)
print(model)
model2 = LinearRegression()
model?
x = np.arange(10)
y = 2 * x + 1
print(x)
print(y)
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 Scikit-learn Estimator Object
Step2: Estimator parameters
Step3: Estimated Model parameters
Step4: The model found a line with a slope 2 ... |
13,885 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, LeakyReLU, Dropout, ReLU, GRU, TimeDistributed, Conv2D, MaxPooling2D, Flatten
from tensorflow.keras.preprocessing.sequence import pad_s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load up and prep the datasets
Step2: Construct the training data and targets
Step4: Validation Dataset
Step6: Multi-layer GRU Model with LReL... |
13,886 | <ASSISTANT_TASK:>
Python Code:
# Package imports
import numpy as np
import matplotlib.pyplot as plt
from testCases import *
import sklearn
import sklearn.datasets
import sklearn.linear_model
from planar_utils import plot_decision_boundary, sigmoid, load_planar_dataset, load_extra_datasets
%matplotlib inline
np.random.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: 2 - Dataset
Step2: Visualize the dataset using matplotlib. The data looks like a "flower" with some red (label y=0) and some blue (y=1) points.... |
13,887 | <ASSISTANT_TASK:>
Python Code:
# import packages
import pandas as pd # data management
import matplotlib.pyplot as plt # graphics
import matplotlib as mpl # graphics parameters
import numpy as np # numerical calculations
# IPython command, puts plots in noteboo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Population by age
Step2: Exercise. What do you see here? What else would you like to know?
Step3: Exercise. What do you see here? What els... |
13,888 | <ASSISTANT_TASK:>
Python Code:
import jax
import numpy as np
import pymc as pm
import pymc.sampling_jax
import blackjax
print(f"Running on PyMC v{pm.__version__}")
# Data of the Eight Schools Model
J = 8
y = np.array([28.0, 8.0, -3.0, 7.0, -1.0, 1.0, 18.0, 12.0])
sigma = np.array([15.0, 10.0, 16.0, 11.0, 9.0, 11.0, 10... | <SYSTEM_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: Model
Step3: Sampling using PyMC NUTS Sampler
Step4: Sampling using PyMC JAX Numpyro NUTS sampler
Step5: Sampling using BlackJax... |
13,889 | <ASSISTANT_TASK:>
Python Code:
%%bash
cp ~/Library/Safari/History.db ~/Workspace/web_browsing/hs.db
%%script sqlite3 hs.db
.tables
%%script sqlite3 hs.db
.schema history_items
%%script sqlite3 hs.db
.schema history_visits
%%script sqlite3 hs.db
SELECT id, url, visit_count FROM history_items ORDER BY visit_count 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: Now let us fire up sqlite3 and see what tables are inside the database.
Step2: Among the four (4) tables above, we'll be using 'history_items' ... |
13,890 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from IPython.display import Image
Image(filename='../figures/workflow02.png')
import csv
with open('../database.csv', 'rb') as csvfile:
spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in spamreader:
print ', '.join(row)
import pan... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Objetivos
|
13,891 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time, os, json
import numpy as np
import skimage.io
import matplotlib.pyplot as plt
from skynet.neural_network.classifiers.pretrained_cnn import PretrainedCNN
from skynet.utils.data_utils import load_tiny_imagenet
from skynet.utils.image_utils import blur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introducing TinyImageNet
Step2: TinyImageNet-100-A classes
Step3: Visualize Examples
Step4: Pretrained model
Step5: Pretrained model perform... |
13,892 | <ASSISTANT_TASK:>
Python Code:
bf.set_network('generate_questions')
bf.set_snapshot('aristaevpn')
result = bf.q.userProvidedLayer1Edges().answer().frame()
result.head(5)
result.iloc[0]
bf.set_network('generate_questions')
bf.set_snapshot('generate_questions')
result = bf.q.layer3Edges().answer().frame()
result.hea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: User Provided Layer 1 Topology
Step2: Return Value
Step3: Print the first row of the returned Dataframe
Step4: Layer 3 Topology
Step5: Retur... |
13,893 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
%config InlineBackend.figure_format = "retina"
import pandas as pd
sns.set_context("talk")
names = ['byte_range', 'data_type', 'col_ID', 'desc']
fwf_cols = pd.read_fwf('../data/synthetic/gum_mw_co... | <SYSTEM_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 data
Step2: I had to modify the raw data to get it to read in conveniently. I try not to modify raw data formats (for reproducibil... |
13,894 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import seaborn, time
seaborn.set_style('whitegrid')
from sklearn.naive_bayes import GaussianNB
from pomegranate import *
def create_dataset(n_samples, n_dim, n_classes):
Create a random dataset with n_samples in each class.
X = numpy.concatenate([numpy.random.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:
Step3: Lets first define a function which will create a dataset to train on. We want to be able to test a range of datasets, from very small to very la... |
13,895 | <ASSISTANT_TASK:>
Python Code:
%load_ext pymatbridge
import cobra.test
m = cobra.test.create_test_model("textbook")
from cobra.io.mat import model_to_pymatbridge
model_to_pymatbridge(m, variable_name="model")
%%matlab
model
%%matlab --silent
warning('off'); % this works around a pymatbridge bug
addpath(genpath('~/co... | <SYSTEM_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 model_to_pymatbridge function will send the model to the workspace with the given variable name.
Step2: Now in the MATLAB workspace, the va... |
13,896 | <ASSISTANT_TASK:>
Python Code:
from os import sys, path
sys.path.append(path.abspath('../src/regression'))
import linear_regression
from linear_regression import *
%matplotlib inline
# We use the london market to get the stock values of gold and silver
gold = quandl.get("LBMA/GOLD", returns="numpy", start_date="2015-01... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Format Data
Step2: Linear Regression
|
13,897 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import pdfplumber
import re
pdf = pdfplumber.open("2014-bulletin-first-10-pages.pdf")
print(len(pdf.pages))
first_page = pdf.pages[0]
chars = pd.DataFrame(first_page.chars)
chars.head(15)
pd.DataFrame(first_page.crop((0, 37, first_page.width / 2, 44 )).chars)
def ge... | <SYSTEM_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 PDF in PDFPlumber
Step2: Let's look at the first 15 characters on the first page of the PDF
Step3: Extract the precint ID
Step4: We ... |
13,898 | <ASSISTANT_TASK:>
Python Code:
# SDK Imports
import boto3
cformation_east = boto3.client('cloudformation', region_name='us-east-1')
cformation_west = boto3.client('cloudformation', region_name='us-west-2')
gw_east = boto3.client('apigateway', region_name='us-east-1')
gw_west = boto3.client('apigateway', region_name='us... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Application Context
Step2: Global Database Replication Group
Step3: Key Synchronization
Step4: Custom Domain Names
Step5: East
Step6: West
... |
13,899 | <ASSISTANT_TASK:>
Python Code:
# Author: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD-3-Clause
import os.path as op
import mne
import numpy as np
from mne import find_events, fit_dipole
from mne.datasets.brainstorm import bst_phantom_elekta
from mne.io import read_raw_fif
print(__doc__)
dipole_number = 1
dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plot the phantom data, lowpassed to get rid of high-frequency artifacts.
Step2: Now we can clean the data with OTP, lowpass, and plot. The flux... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.