Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
9,400 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.cluster import KMeans
from scipy.spatial.distance import cdist
import matplotlib.pyplot as plt
df = pd.read_csv('Wholesale customers data.csv')
df['Total'] = df['Fresh... | <SYSTEM_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, it is from the UCI Wholesale Customer Dataset at
Step2: Create a feature for total customer size. Note
Step3: Add a function... |
9,401 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# 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 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: TensorFlow Probability 둘러보기
Step2: 개요
Step3: 하드웨어 가속
Step4: 자동 미분
Step5: TensorFlow Probability
Step6: 단순 스칼라 변량 Distribution
Step7: 분포와 형... |
9,402 | <ASSISTANT_TASK:>
Python Code:
actual = [1, 2, 3 , 5, 10, 11]
predicted = [1, 10, 11, 3, 2, 5 ]
from sklearn import metrics
labels_true = [0, 0, 0, 1, 1, 1]
labels_pred = [0, 0, 1, 1, 1, 2]
metrics.adjusted_rand_score(labels_true, labels_pred)
labels_pred = [1, 1, 0, 0, 3, 3]
metrics.adjusted_rand_score(labels_true,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: It is defined as the number of pairs of objects that are either in the same group or in different groups in both partitions divided by the total... |
9,403 | <ASSISTANT_TASK:>
Python Code:
flowers = "pink primrose,hard-leaved pocket orchid,canterbury bells,sweet pea,english marigold,tiger lily,moon orchid,bird of paradise,monkshood,globe thistle"
print(type(flowers))
print(flowers)
flowers_list = ["pink primrose", "hard-leaved pocket orchid", "canterbury bells", "sweet pea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Even better is to represent the same data in a Python list. To create a list, you need to use square brackets ([, ]) and separate each item wit... |
9,404 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
dataset = load_data()
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(dataset.iloc[:, :-1], dataset.iloc[:, -1], test_size=0.4,
random_state=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
9,405 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
import zipfile
from IPython.display import display, Image
from scipy import ndimage
from sklearn.linear_model import LogisticRegression
from six.moves.urllib.request import urlret... | <SYSTEM_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 original Keras ResNet50 model without the top layer.
Step2: Add a Pooling layer at the top to extract the CNN coded (aka bottleneck)
Step3... |
9,406 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from time import time
import cobra.test
from cobra.flux_analysis import calculate_phenotype_phase_plane
model = cobra.test.create_test_model("textbook")
data = calculate_phenotype_phase_plane(model, "EX_glc__D_e", "EX_o2_e")
data.plot_matplotlib();
data.plot_matplotli... | <SYSTEM_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 want to make a phenotype phase plane to evaluate uptakes of Glucose and Oxygen.
Step2: If brewer2mpl is installed, other color schemes can b... |
9,407 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
# Load data
dataset_essay_1 = pd.read_csv("/data/data/automated_scoring_public_dataset.csv")
dataset_essay_1.shape
dataset_essay... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Essay 5 prompt text and passage refer to the word document in data folder
Step2: Let us this data for features and model building
Step3: 2. Le... |
9,408 | <ASSISTANT_TASK:>
Python Code:
import mwxml
import glob
paths = glob.glob('/public/dumps/public/nlwiki/20151202/nlwiki-20151202-pages-meta-history*.xml*.bz2')
paths
import re
EXTS = ["png", "gif", "jpg", "jpeg"]
# [[(file|image):<file>.<ext>]]
IMAGE_LINK_RE = re.compile(r"\[\[" +
r"(file|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: Step 1
Step2: Step 2
Step3: Step 3
Step4: OK. Now that everything is defined, it's time to run the code. mwxml has a map() function that ap... |
9,409 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-hh', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
9,410 | <ASSISTANT_TASK:>
Python Code:
from openhunt.mordorutils import *
spark = get_spark()
mordor_file = "https://raw.githubusercontent.com/OTRF/mordor/master/datasets/small/windows/credential_access/host/empire_dcsync_dcerpc_drsuapi_DsGetNCChanges.zip"
registerMordorSQLTable(spark, mordor_file, "mordorTable")
df = spark.... | <SYSTEM_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 & Process Mordor Dataset
Step2: Analytic I
Step3: Analytic II
|
9,411 | <ASSISTANT_TASK:>
Python Code:
# match data with aggregated individual data
import pandas as pd
match_path = '/Users/t_raver9/Desktop/projects/aflengine/analysis/machine_learning/src/player_data/data/matches_with_player_agg.csv'
players_path = '/Users/t_raver9/Desktop/projects/aflengine/analysis/machine_learning/src/pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data Preparation
Step2: To keep model simple, exclude draws. Mark them as victories for the away team instead.
Step3: We want to split the dat... |
9,412 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'dwd', 'sandbox-3', 'seaice')
# 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: 2... |
9,413 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Criando uma classe chamada Livro
class Livro():
# Este método vai inicializar cada objeto criado a partir desta classe
# O 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: Classes
|
9,414 | <ASSISTANT_TASK:>
Python Code:
#$HIDE$
import pandas as pd
from sklearn.model_selection import train_test_split
# Read the data
data = pd.read_csv('../input/melbourne-housing-snapshot/melb_data.csv')
# Separate target from predictors
y = data.Price
X = data.drop(['Price'], axis=1)
# Divide data into training and valida... | <SYSTEM_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 take a peek at the training data with the head() method below.
Step2: Next, we obtain a list of all of the categorical variables in the trai... |
9,415 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# for... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: Extract Features
Step3: Train SVM on features
Step4: Inline question 1
Step5: | Learning Rate| Regularization Rate | Valida... |
9,416 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import numpy as np
df = pd.read_csv("data/hanford.csv")
df
df.describe()
df.hist()
df.corr()
df.plot(kind='scatter',x='Exposure',y='Mortality')
lm = LinearRegressio... | <SYSTEM_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. Read in the hanford.csv file
Step2: 3. Calculate the basic descriptive statistics on the data
Step3: 4. Calculate the coefficient of correl... |
9,417 | <ASSISTANT_TASK:>
Python Code:
# Imports
import sys
sys.path.append('../') # This is where all the python files are!
from importlib import reload
import utils; reload(utils)
from utils import *
import keras_models; reload(keras_models)
from keras_models import *
import losses; reload(losses)
from losses import crps_c... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set up data
Step2: The arrays have dimensions [sample, time step, feature]
Step4: So we get a better train score and a worse validation score.... |
9,418 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from IPython.display import Image
assert True # leave this to grade the import statements
Image(url='http://easyscienceforkids.com/wp-content/uploads/2013/06/ICI.jpg', embed=True, width=600, height=600)
assert True # leave this to grade the image displ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic rich display
Step2: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi... |
9,419 | <ASSISTANT_TASK:>
Python Code:
# Authors: Clemens Brunner <clemens.brunner@gmail.com>
# Felix Klotzsche <klotzsche@cbs.mpg.de>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import TwoSlopeNorm
import pandas as pd
import seaborn as sns
import mne
from mne.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: As usual, we import everything we need.
Step2: First, we load and preprocess the data. We use runs 6, 10, and 14 from
Step3: Now we can create... |
9,420 | <ASSISTANT_TASK:>
Python Code:
import re
DATAFILE_PATTERN = '^(.+),"(.+)",(.*),(.*),(.*)'
def removeQuotes(s):
Remove quotation marks from an input string
Args:
s (str): input string that might have the quote "" characters
Returns:
str: a string without the quote characters
return ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step4: version 1.0.0
Step5: Let's examine the lines that were just loaded in the two subset (small) files - one from Google and one from Amazon
Step7:... |
9,421 | <ASSISTANT_TASK:>
Python Code:
import mne
from mne.datasets import sample
data_path = sample.data_path()
raw_fname = data_path / 'MEG' / 'sample' / 'sample_audvis_filt-0-40_raw.fif'
raw = mne.io.read_raw_fif(raw_fname, preload=True)
events = mne.find_events(raw, stim_channel='STI 014')
event_id = {'auditory/left': 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: Raw data with whitening
Step2: Epochs with whitening
Step3: Evoked data with whitening
Step4: Evoked data with scaled whitening
Step5: Topog... |
9,422 | <ASSISTANT_TASK:>
Python Code:
x = data.as_matrix()
y = target.as_matrix()
x = np.array([np.concatenate((v,[1])) for v in x]) #add column of ones to the end of the data set
print x
linreg = LinearRegression()
linreg.fit(x,y)
p = linreg.predict(x)
p
err = abs(p-y)
err
total_error = np.dot(err,err)
rmse_train = np.sqrt(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: whoa! linear regression rmse on 10-fold cross validation is terrible!! let's try something else
Step2: The best regression method was Lasso wit... |
9,423 | <ASSISTANT_TASK:>
Python Code:
omg=numpy.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1])
tPCG = numpy.array([5.72, 4.54, 3.78, 3.14, 2.71, 2.38, 2.06, 1.95, 2.49, 10.15])
tPCGF = numpy.array([2.48, 2.14, 2.03, 2.6, 10.7])
tPBICGSTAB = numpy.array([2.79, 2.58, 2.48, 3, 12.1])
pyplot.plot(omg, tPCG, label="PCG")
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test set 2
Step2: Test set 3
Step3: Test set 4
Step4: Test set 5
Step5: Test set 6
Step6: 3D Poisson Problem
Step7: Strong Scaling Test
|
9,424 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'dwd', '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... |
9,425 | <ASSISTANT_TASK:>
Python Code:
# load all necessary libraries
import numpy
from matplotlib import pyplot, cm
from mpl_toolkits.mplot3d import Axes3D
from numba import jit
%matplotlib notebook
# spatial discretization
nx = 601
ny = 601
dh = 5.0
x = numpy.linspace(0, dh*(nx-1), nx)
y = numpy.linspace(0, dh*(ny-1), ny)
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: Because we are currently dealing with a homogeneous block model, we don't have to care about the artihmetic and harmonic averaging of density an... |
9,426 | <ASSISTANT_TASK:>
Python Code:
# only necessary if you're running Python 2.7 or lower
from __future__ import print_function
from __builtin__ import range
import numpy as np
# import plotting utility and define our naming alias
from matplotlib import pyplot as plt
# plot figures within the notebook rather than externall... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Galaxy Model
Step2: In addition to the "standard" way of defining functions shown above, Python has an additional method that can be used to de... |
9,427 | <ASSISTANT_TASK:>
Python Code:
import numpy,pandas
%matplotlib inline
import matplotlib.pyplot as plt
import scipy.stats
from sklearn.model_selection import LeaveOneOut,KFold
from sklearn.preprocessing import PolynomialFeatures,scale
from sklearn.linear_model import LinearRegression,LassoCV,Ridge
import seaborn as sns
... | <SYSTEM_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 notebook provides an introduction to some of the basic concepts of machine learning.
Step2: What is the simplest story that we could tell ... |
9,428 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.__version__
x = np.ones([10, 10, 3])
out = np.reshape(x, [-1, 150])
print out
assert np.allclose(out, np.ones([10, 10, 3]).reshape([-1, 150]))
x = np.array([[1, 2, 3], [4, 5, 6]])
out1 = np.ravel(x, order='F')
out2 = x.flatten(order="F")
assert np.allclose(out1, ou... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Q1. Let x be a ndarray [10, 10, 3] with all elements set to one. Reshape x so that the size of the second dimension equals 150.
Step2: Q2. Let ... |
9,429 | <ASSISTANT_TASK:>
Python Code:
#Import toolboxes
from scipy import sparse #Allows me to create sparse matrices (i.e. not store all of the zeros in the 'A' matrix)
from scipy.sparse import linalg as linal
from numpy import * #To make matrices and do matrix manipulation
import matplotlib.pyplot as plt
import matplotlib.... | <SYSTEM_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 - 1$^{st}$order in space and time
Step2: 1.2 - 1$^{st}$order in time and 4$^{th}$order in space
Step3: 1.3 - 2$^{nd}$order in time and 4$^... |
9,430 | <ASSISTANT_TASK:>
Python Code:
from anypytools import AnyPyProcess
app = AnyPyProcess(num_processes=1)
macro = [
'load "Knee.any"',
'operation Main.MyStudy.InverseDynamics',
'run',
]
macrolist = [macro]*20
app.start_macro(macrolist);
app.start_macro(macrolist);
from anypytools import AnyPyProcess
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here we stopped the simulation using the Notebook interrupt button. Calling the start_macro() function again continues the processing and re-run... |
9,431 | <ASSISTANT_TASK:>
Python Code:
# Import libraries necessary for this project
import numpy as np
import pandas as pd
from IPython.display import display # Allows the use of display() for DataFrames
# Import supplementary visualizations code visuals.py
import visuals as vs
# Pretty display for notebooks
%matplotlib inlin... | <SYSTEM_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... |
9,432 | <ASSISTANT_TASK:>
Python Code:
#exercise
show_image('fig12_5.png')
show_image('fig12_10.png')
show_image('fig12_11.png')
show_image('fig12_12.png')
#Exercise
<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: 12.2 Perceptrons
Step2: 12.2.2 Convergence of Perceptrons
Step3: 12.2.7 Problems With Perceptrons
Step4: 12.2.8 Parallel Implementation of Pe... |
9,433 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy as sp
import openpnm as op
np.random.seed(10)
ws = op.Workspace()
ws.settings["loglevel"] = 40
pn = op.network.Cubic(shape=[20, 20, 10], spacing=0.0001, connectivity=8)
Ps1 = pn.pores(['top', 'bottom'])
Ts1 = pn.find_neighbor_throats(pores=Ps1, mode='unio... | <SYSTEM_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 generate a cubic network again, but with a different connectivity
Step2: This Network has pores distributed in a cubic lattice, but conne... |
9,434 | <ASSISTANT_TASK:>
Python Code:
%pylab notebook
RP = 5.0 #[Ohm]
RS = 0.005 #[Ohm]
XP = 6.0j #[Ohm]
XS = 0.006j #[Ohm]
RC = 50e3 #[Ohm]
XM = 10e3j #[Ohm]
V_high = 8000 #[V]
V_low = 277 #[V]
S = 100e3 #[VA]
a = V_high/V_low
print('a = {:.2f}'.format(a))
R_P = RP / a**2
X_P = XP / a**2
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: Description
Step2: The excitation branch impedances are given referred to the high-voltage side of the transformer.
Step3: Therefore, the prim... |
9,435 | <ASSISTANT_TASK:>
Python Code:
sc
# Chargement des fichiers si ce n'est déjà fait
#Renseignez ici le dossier où vous souhaitez stocker le fichier téléchargé.
DATA_PATH=""
import urllib.request
# fichier réduit
f = urllib.request.urlretrieve("http://www.math.univ-toulouse.fr/~besse/Wikistat/data/ml-ratings100k.csv",DAT... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Les données sont lues comme une seule ligne de texte avant d'être restructurées au bon format d'une matrice creuse à savoir une liste de triplet... |
9,436 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
from math import sqrt
from qutip import sigmax, sigmaz
from ncpol2sdpa import flatten, SdpRelaxation, generate_variables
from time import time
from sympy import S
from local_tools import generate_commuting_measurements, get_W_reduced, \
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then we define the scenario we are considering. In full generality we define it with the three parameters $(N,m,d)$, corresponding to the case o... |
9,437 | <ASSISTANT_TASK:>
Python Code:
s_pattern = 2000 # number of data points in the pattern
t = np.arange(s_pattern)*0.001 # time points for the elements in the patter
pattern1 = np.sin(t*np.pi*2)
pattern2 = np.sin(0.5*t*np.pi*2)
plt.plot(t, pattern1, label='pattern1')
plt.plot(t, pattern2, label='pattern2')... | <SYSTEM_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's create a network that represents a rolling window in time (Aaron's "delay network"). The process determines what sort of pattern the ... |
9,438 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
#Creating sample array
arr = np.arange(0, 11)
#Show
arr
#Get a value at an index
arr[8]
#Get values in a range
arr[1:5]
#Get values in a range
arr[0:5]
#Setting a value with index range (Broadcasting)
arr[0:5] = 100
#Show
arr
# Reset array, we'll see why I had to rese... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bracket Indexing and Selection
Step2: Broadcasting
Step3: Now note the changes also occur in our original array!
Step4: Data is not copied, i... |
9,439 | <ASSISTANT_TASK:>
Python Code:
# Authors: Jean-Remi King <jeanremi.king@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import matplotlib.pyplot as plt
from sklearn.pipeline import make_pipeline
from sklearn.preproce... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We will train the classifier on all left visual vs auditory trials
Step2: Score on the epochs where the stimulus was presented to the right.
St... |
9,440 | <ASSISTANT_TASK:>
Python Code:
import json
input = '''[
{ "id" : "01",
"status" : "Instructor",
"name" : "Hrant"
} ,
{ "id" : "02",
"status" : "Student",
"name" : "Jimmy"
}
]'''
# parse/load string
data = json.loads(input)
# data is a usual list
type(data)
print(data)
from pprint import pprint... | <SYSTEM_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 create a sample JSON fie and save it to some variable called input.
Step2: As you can see here, our JSON documents is nothing else than a... |
9,441 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
from six.moves import range
%matplotlib inline
# function to compute the luminosity distance.
def d_L(zs, Omega_m=0.3, Omega_L=0.7,
Omega_r=0.0, H0=100., N=1000, zgrid=None):
Compute luminosity distance. See `cosmocalc`
... | <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: Setting up the Problem
Step4: Note that these functions have a bunch of arguments that are optional. If you do not provide them, they will be f... |
9,442 | <ASSISTANT_TASK:>
Python Code:
import pickle
import random
import numpy as np
import theano
import theano.tensor as T
import lasagne
from collections import Counter
from lasagne.utils import floatX
dataset = pickle.load(open('coco_with_cnn_features.pkl'))
allwords = Counter()
for item in dataset:
for sentence in ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the preprocessed dataset containing features extracted by GoogLeNet
Step2: Count words occuring at least 5 times and construct mapping int... |
9,443 | <ASSISTANT_TASK:>
Python Code:
# this is a comment and will not run in the code
'''this is just a mulit line comment'''
pwd
#addition
2+1
# substraction
2-1
1-2
2*2
3/2
3.0/2
float(3)/2
3/float(2)
from __future__ import division
3/2
1/2
2/3
root(2)
sqrt(2)
4^2
4^.5
4**.5
a=5
a=6
a+a
a
0.1+0.2-0.3
'hello'
'this entire 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: strings yoiu can use the %s to format strings into your print statements
|
9,444 | <ASSISTANT_TASK:>
Python Code:
# Create the matrix that diagonalizes A
diagonalizer = qt.Qobj(np.array([eigenvecs[i].full().T.flatten()
for i in range(len(eigenvals))]))
b = diagonalizer * b
A = diagonalizer.dag() * A * diagonalizer
T = prec
t0 = κ / ϵ # It should be O(κ/ϵ), whateve... | <SYSTEM_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 2-1
Step3: STEP 3-1
Step4: STEP 3-2
Step5: $\left|finalstate\right\rangle$ is essentially a pure state (it should be if a... |
9,445 | <ASSISTANT_TASK:>
Python Code:
GET SF ZIP CODES from http://www.city-data.com/zipmaps/San-Francisco-California.html
import itertools
sf_zip_codes = [94102, 94103, 94104, 94105, 94107, 94108, 94109, 94110, 94111, 94112, 94114, 94115, 94116, 94117, 94118, 94121, 94122, 94123, 94124, 94127, 94129, 94131, 94132, 94133... | <SYSTEM_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. Get zip code from wikipedia
Step6: 2. Convert zip code to coordinates
Step7: 3. Sanity check
Step8: 4. Get bussiness type and # of establi... |
9,446 | <ASSISTANT_TASK:>
Python Code:
import os,sys
import numpy
%matplotlib inline
import matplotlib.pyplot as plt
sys.path.insert(0,'../utils')
from mkdesign import create_design_singlecondition
from nipy.modalities.fmri.hemodynamic_models import spm_hrf,compute_regressor
from make_data import make_continuous_data
data=make... | <SYSTEM_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's add on an activation signal to both voxels
Step2: How can we address this problem? A general solution is to first run a general linea... |
9,447 | <ASSISTANT_TASK:>
Python Code:
import SimPEG as simpeg
from SimPEG import NSEM
import MT_poster_utils
from IPython.display import HTML
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
HTML("Figures/Magnetotelluric_Movie_ThibautAstic.html")
# Load the geological discretized model
mesh, modelDict ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Scipy 2016 Poster
Step2: Details of the physics at
Step3: Paraview view
Step4: Types of data
Step5: Run the inversions on a cluster
|
9,448 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import re
import numpy as np
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
%matplotlib inline
#%qtconsole
!rm train.vw.cache
!rm mnist_train_nn.model
!vw -d data/mnist_train_pca.vw --cache_file train.vw.cache -f mnist_train_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: Train
Step2: Predict
Step4: Analyze
|
9,449 | <ASSISTANT_TASK:>
Python Code::
import tensorflow as tf
model = tf.keras.models.load_model('filename')
pred = model.predict(X_val)
<END_TASK>
| <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
9,450 | <ASSISTANT_TASK:>
Python Code:
from instance_based.tagvote import TagVoteTagger
trainCollection = 'train10k'
annotationName = 'concepts130.txt'
feature = 'vgg-verydeep-16-fc7relu'
tagger = TagVoteTagger(collection=trainCollection, annotationName=annotationName, feature=feature, distance='cosine')
from basic.constant 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: Open feature file of mirflickr08
Step2: Load image ids of mirflickr08
Step3: Perform tag relevance learning on the test set
Step4: Evaluation... |
9,451 | <ASSISTANT_TASK:>
Python Code:
# Import standard Python modules
import numpy as np
import pandas
import matplotlib.pyplot as plt
# Import the FrostNumber PyMT model
import pymt.models
frost_number = pymt.models.FrostNumber()
config_file, config_folder = frost_number.setup(T_air_min=-13., T_air_max=19.5)
frost_number.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: Part 1
Step2: Part 2
Step3: Questions
|
9,452 | <ASSISTANT_TASK:>
Python Code:
# Ignore
%load_ext sql
%sql sqlite://
%config SqlMagic.feedback = False
%%sql
-- Create a table of criminals
CREATE TABLE criminals (pid, name, age, sex, city, minor);
INSERT INTO criminals VALUES (412, 'James Smith', 15, 'M', 'Santa Rosa', 1);
INSERT INTO criminals VALUES (234, 'Bill Ja... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create Data
Step2: Delete A Table
Step3: View Table
|
9,453 | <ASSISTANT_TASK:>
Python Code:
def cumulative_product(start_list):
out_list = []
### BEGIN SOLUTION
### END SOLUTION
return out_list
inlist = [89, 22, 3, 24, 8, 59, 43, 97, 30, 88]
outlist = [89, 1958, 5874, 140976, 1127808, 66540672, 2861248896, 277541142912, 8326234287360, 73270861728... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: B
Step2: C
|
9,454 | <ASSISTANT_TASK:>
Python Code:
import ga4gh_client.client as client
c = client.HttpClient("http://1kgenomes.ga4gh.org")
dataset = c.search_datasets().next()
print dataset
data_set_id = dataset.id
dataset_via_get = c.get_dataset(dataset_id=data_set_id)
print dataset_via_get
<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: We will continue to refer to this client object for accessing the remote server.
Step2: NOTE
|
9,455 | <ASSISTANT_TASK:>
Python Code:
import h5py
import csv
import numpy as np
import os
import gdal
import matplotlib.pyplot as plt
import sys
from math import floor
import time
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
def h5refl2array(h5_filename):
hdf5_file = h5py.File(h5_filename,'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: As well as our function to read the hdf5 reflectance files and associated metadata
Step2: Define the location where you are holding the data fo... |
9,456 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image('images/02_network_flowchart.png')
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from sklearn.metrics import confusion_matrix
import time
from datetime import timedelta
import math
# We also need Pret... | <SYSTEM_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 input image is processed in the first convolutional layer using the filter-weights. This results in 16 new images, one for each filter in th... |
9,457 | <ASSISTANT_TASK:>
Python Code:
# Write code to import required libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# For visualzing plots in this notebook
%matplotlib inline
# We start by importing the data using pandas
# Hint: use "read_csv" method, Note that comma (",") is the field 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: Housing Price Dataset
Step2: Statistical summary of the data
Step3: Visualize the data
Step4: Training a Univariate Linear Regression Model
S... |
9,458 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
# Add your filename and uncomment the following line:
Image(filename='alcohol-consumption-by-country-pure-alcohol-consumption-per-drinker-2010_chartbuilder-1.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: Graphical excellence and integrity
|
9,459 | <ASSISTANT_TASK:>
Python Code:
import vcsn
%%automaton a
context = "lal_char(abc), b"
$ -> 0
0 -> 1 a
1 -> $
2 -> 0 a
1 -> 3 a
a.is_coaccessible()
a.coaccessible()
a.coaccessible().is_coaccessible()
<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: State 3 of the following automaton cannot reach a final state.
Step2: Calling accessible returns a copy of the automaton without non-accessible... |
9,460 | <ASSISTANT_TASK:>
Python Code:
raw_dataset = pd.read_csv(source_path + "Speed_Dating_Data.csv",encoding = "ISO-8859-1")
raw_dataset.head(2)
raw_dataset_copy = raw_dataset
columns_by_types = raw_dataset.columns.to_series().groupby(raw_dataset.dtypes).groups
raw_dataset.dtypes.value_counts()
raw_dataset.isnull().sum().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: Data exploration
Step3: Data processing
Step5: Feature engineering
Step6: Modelling
Step7: Variables selection
Step8: Tuning
Step9: Traini... |
9,461 | <ASSISTANT_TASK:>
Python Code:
def MagneticMonopoleField(obsloc,poleloc=(0.,0.,0.),Q=1):
# relative obs. loc. to pole, assuming pole at origin
dx, dy, dz = obsloc[0]-poleloc[0], obsloc[1]-poleloc[1], obsloc[2]-poleloc[2]
r = np.sqrt(dx**2+dy**2+dz**2)
Bx = Q * 1e-7 / r**2 * dx
By = Q * 1e-7 / r**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: Define a magnetic dipole
Step2: Define the Earth's magnetic field $B_0$
Step3: Define the observations
Step4: Calculate data for plotting
Ste... |
9,462 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/data/MNIST/",one_hot=True)
sess = tf.InteractiveSession()
def weight_variable(shape):
initial = tf.truncated_normal(shape,stddev=0.1)
return tf.Variable(initial)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Helper functions
Step2: First Convolution Layer
Step3: Second Convolution Layer
Step4: Densely Connected Layer
Step5: Dropout Layer
Step6: ... |
9,463 | <ASSISTANT_TASK:>
Python Code:
def taylor(f, x, var, max_terms=6, x0=0):
def taylor_terms():
for k in range(max_terms):
term = (sp.diff(f, var, k).subs(var, x0).evalf()/np.math.factorial(k)) * (x - x0)**k
yield term
serie = 0
for term in taylor_terms():
serie... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example 1
Step2: It is clear from the figure below that the higher the order of polynomial (or the number of terms in the summation) more preci... |
9,464 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TF-Hub によるベンガル語の記事分類
Step2: データセット
Step3: 事前トレーニング済み単語ベクトルを TF-Hub モジュールにエクスポートする
Step4: 次に、エクスポートスクリプトを埋め込みファイル上で実行します。fastText Embedding には... |
9,465 | <ASSISTANT_TASK:>
Python Code:
descripciones = {
'P0610': 'Ventas de electricidad',
'P0701': 'Longitud total de la red de carreteras del municipio (excluyendo las autopistas)'
}
# Librerias utilizadas
import pandas as pd
import sys
import urllib
import os
import csv
import zipfile
# Configuracion del sistema
pr... | <SYSTEM_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. Descarga de datos
Step2: Extraccion de indices
Step3: Los índices obtenidos de esta manera recibirán una limpieza manual desde Excel.
Step4... |
9,466 | <ASSISTANT_TASK:>
Python Code:
import ast
import numpy as np
import pandas as pd
import seaborn as sns
from scipy import stats
# load the data
df = pd.read_csv('../../data/LA_County_Covid19_CSA_case_death_table.csv')
df.shape
# what do you see in the raw data?
df
# check the data types: do we need to change/convert an... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Data cleaning
Step2: 1.2. LA County Top Earners
Step3: Idea
Step4: 1.3. LA City Active Businesses
Step5: So, the location column contains... |
9,467 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
from sklearn.metrics import confusion_matrix
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets("data/MNIST/", one_hot=True)
print("Size of:")
print("- Training-set:\t\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: This was developed using Python 3.6.4 (Anaconda) and TensorFlow.
Step2: The MNIST data set has now been loaded and it consists of 70,000 images... |
9,468 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist_data = input_data.read_data_sets("MNIST_data/", one_hot=True)
# Hyper parameters
training_epochs = 100
learning_rate = 0.01
batch_size = 256
print_loss_for_each_epoch = 10
test_validation_size = 512... | <SYSTEM_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 data
Step2: Define parameters
Step3: Create TF Graph
Step4: Launch TF Graph
|
9,469 | <ASSISTANT_TASK:>
Python Code:
mafft_linsi = AlnConf(pj, # The Project
method_name='mafftLinsi', # Any unique method name,
# 'mafftDefault' by default
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 3.6.1.2 Example 2
Step2: 3.6.2 Executing sequence alignment processes
Step3: When the process is done, the AlnConf objects will be stored in p... |
9,470 | <ASSISTANT_TASK:>
Python Code:
import graphlab
loans = graphlab.SFrame('lending-club-data.gl/')
loans['safe_loans'] = loans['bad_loans'].apply(lambda x : +1 if x==0 else -1)
loans = loans.remove_column('bad_loans')
features = ['grade', # grade of the loan
'term', # the term of ... | <SYSTEM_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 LendingClub Dataset
Step2: reassign the labels to have +1 for a safe loan, and -1 for a risky (bad) loan.
Step3: use 4 categorical featur... |
9,471 | <ASSISTANT_TASK:>
Python Code:
print("Hello World!")
print("Hello Again")
print("I like typing this.")
print("This is fun.")
print('Yay! Printing.')
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')
'''
Notes:
octothorpe, mesh, or pund #
'''
# A comment, this is so you can read your program ... | <SYSTEM_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 2
Step2: Exercise 3
Step3: Exercise 4
Step4: Exercise 5
Step5: Exercise 6
Step6: Exercise 7
Step7: Exercise 8
Step8: Exercise 9
|
9,472 | <ASSISTANT_TASK:>
Python Code:
both = cast[(cast.character=='Superman') | (cast.character == 'Batman')].groupby(['year','character']).size().unstack().fillna(0)
diff = both.Superman - both.Batman
print("Superman: " + str(len(diff[diff>0])))
both = cast[(cast.character=='Superman') | (cast.character == 'Batman')].group... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How many years have been "Batman years", with more Batman characters than Superman characters?
Step2: Plot the number of actor roles each year ... |
9,473 | <ASSISTANT_TASK:>
Python Code:
from proxy.core.connection import TcpServerConnection
from proxy.common.utils import build_http_request
from proxy.http.methods import httpMethods
from proxy.http.parser import HttpParser, httpParserTypes
request = build_http_request(
method=httpMethods.GET,
url=b'/',
headers=... | <SYSTEM_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 use TcpServerConnection to make a HTTP web server request.
Step2: Let's use TcpServerConnection to make a HTTPS web server request.
|
9,474 | <ASSISTANT_TASK:>
Python Code:
import os
import json
import sys
import tempfile
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import mxnet as mx
from mxnet.contrib.svrg_optimization.svrg_module import SVRGModule
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.datasets 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: Read Data
Step2: Create Linear Regression Network
Step3: SVRGModule with SVRG Optimization
Step4: Module with SGD Optimization
Step5: Traini... |
9,475 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(color_codes=True)
%matplotlib inline
df = pd.read_csv('iris.data')
df.head()
pd.read_csv?
df = pd.read_csv('iris.data', header=-1)
df.head()
col_name = ['sepal length', 'sepal width', 'pet... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Iris Data from Seaborn
Step2: Visualisation
Step3: Key Points
|
9,476 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.integrate import odeint
import quantities as pq
import neo
from elephant.spike_train_generation import inhomogeneous_poisson_process
def integrated_oscillator(dt, num_steps, x0=0, y0=1, angular_frequency=2*np.pi*1e-3):
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:
Step5: Tutorial
Step6: 2. Harmonic Oscillator Example
Step7: Let's see how the trajectory and the spike trains look like.
Step8: Thus, we have gener... |
9,477 | <ASSISTANT_TASK:>
Python Code:
#!conda install -c conda-forge ogh libgdal gdal pygraphviz ncurses matplotlib=2.2.3 --yes
# silencing warning
import warnings
warnings.filterwarnings("ignore")
# data processing
import os
import pandas as pd, numpy as np, dask
# data migration library
import ogh
import ogh_xarray_landlab ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Establish a secure connection with HydroShare by instantiating the hydroshare class that is defined within hs_utils. In addition to connecting w... |
9,478 | <ASSISTANT_TASK:>
Python Code:
# Serialization
import pickle
# Numbers
import numpy as np
import pandas as pd
# Plotting
import seaborn as sns
sns.set(color_codes=True)
from matplotlib import pyplot as plt
%matplotlib inline
# Machine learning
from sklearn.preprocessing import LabelEncoder, StandardScaler
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: 1. data loading
Step2: 2. data exploration
Step3: 3. data preprocessing for ML
Step4: Tests con features x e y
|
9,479 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -vm -p tensorflow,numpy,scikit-learn
import tensorflow as tf
graph = tf.get_default_graph()
graph.get_operations()
input_value = tf.constant(1.0, name='input_value')
graph.get_operations()
ops = graph.get_operations()
len(ops), ops[0].__class__
op = op... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 텐서플로우의 디폴트 그래프는 직접 접근을 할 수 없고 get_default_graph 메소드를 이용합니다.
Step2: 초기에는 디폴트 그래프에 아무런 연산도 들어 있지 않고 비어 있습니다.
Step3: 실수 1.0 값을 가지는 상수 input_value... |
9,480 | <ASSISTANT_TASK:>
Python Code:
db = 'stoqs_rovctd_mb'
from django.contrib.gis.geos import fromstr
from django.contrib.gis.measure import D
mars = fromstr('POINT(-122.18681000 36.71137000)')
near_mars = Measurement.objects.using(db).filter(geom__distance_lt=(mars, D(km=.1)))
mars_dives = Activity.objects.using(db).filt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Count all of the the ROV dives whose Measurements are near MARS
Step2: Near surface ROV location data is notoriously noisy (because of fundamen... |
9,481 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import os
import numpy as np
import pandas as pd
PROJ_ROOT = os.path.abspath(os.path.join(os.pardir, os.pardir))
data = np.random.normal(0.0, 1.0, 1000000)
assert np.mean(data) == 0.0
np.testing.assert_almost_equal(np.mean(data), 0.0, decimal=2)
a = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: numpy.testing
Step2: engarde decorators
|
9,482 | <ASSISTANT_TASK:>
Python Code:
from phidl import Path, CrossSection, Device
import phidl.path as pp
import numpy as np
P = Path()
P.append( pp.arc(radius = 10, angle = 90) ) # Circular arc
P.append( pp.straight(length = 10) ) # Straight section
P.append( pp.euler(radius = 3, angle = -90) ) # Euler bend (aka ... | <SYSTEM_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 also modify our Path in the same ways as any other PHIDL object
Step2: We can also check the length of the curve with the length() metho... |
9,483 | <ASSISTANT_TASK:>
Python Code:
category = Counter(df['category']).keys()
values = Counter(df['category']).values()
plt.bar(category, values)
plt.xticks(rotation='vertical')
plt.show()
category = Counter(df['intervention']).keys()
values = Counter(df['intervention']).values()
plt.bar(category, values)
plt.xticks(rotati... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Number of bridges with repect to interventions identified by NDOT flow chart
Step2: Number of bridges with respect to 'Yes' or 'No' interventio... |
9,484 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
X = [0,1,2,3,4]
Fx = [x**2 for x in X]
fig = plt.figure()
ax = fig.add_axes([0., 0., 1., 1., ]) # define a rectangle
ax.plot(X,Fx) # plots happen inside Axes objects
plt.show(fig)
fig,axes = plt.subplots(2,2)
F0 = [x**0 for x in X]
F1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Even though we can dispose the Axes how we want inside the figure,
Step2: Another useful way to create grids of plots is by creating a figure a... |
9,485 | <ASSISTANT_TASK:>
Python Code:
%pylab notebook
r1 = 0.641 # Stator resistance
x1 = 1.106 # Stator reactance
r2 = 0.332 # Rotor resistance
x2 = 0.464 # Rotor reactance
xm = 26.3 # Magnetization branch reactance
v_phase = 460 / sqrt(3) #... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First, initialize the values needed in this program.
Step2: Calculate the Thevenin voltage and impedance from Equations 7-41a
Step3: Now calcu... |
9,486 | <ASSISTANT_TASK:>
Python Code:
def euler(f, x, y0):
h = x[1] - x[0]
y = np.empty_like(x)
y[0] = y0
for i in range(1, len(x)):
y[i] = y[i - 1] + h * f(x[i - 1], y[i - 1])
return y
dy = lambda x, y: x*x + y*y
x = np.linspace(0, 0.5, 100)
y0 = 0
y = euler(dy, x, y0)
y_ans = np.tan(x) - x
plt.f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To check correctness we are going to solve simple differential equation
Step2: The next method we are going to use is Runge-Kutta method family... |
9,487 | <ASSISTANT_TASK:>
Python Code:
import csv
from scipy.stats import kurtosis
from scipy.stats import skew
from scipy.spatial import Delaunay
import numpy as np
import math
import skimage
import matplotlib.pyplot as plt
import seaborn as sns
from skimage import future
import networkx as nx
from ragGen import *
%matplotlib... | <SYSTEM_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 start with just looking at analysis in euclidian space, then thinking about weighing by synaptic density later. Since we hypothesize that ... |
9,488 | <ASSISTANT_TASK:>
Python Code:
# number of neurons, time-points and stimuli
N,T,S = 100,250,6
# noise-level and number of trials in each condition
noise, n_samples = 0.2, 10
# build two latent factors
zt = (arange(T)/float(T))
zs = (arange(S)/float(S))
# build trial-by trial data
trialR = noise*randn(n_samples,N,S,T)
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: We then instantiate a dPCA model where the two parameter axis are labeled by 's' (stimulus) and 't' (time) respectively. We set regularizer to '... |
9,489 | <ASSISTANT_TASK:>
Python Code:
from selenium import webdriver
help(webdriver)
#browser = webdriver.Firefox() # 打开Firefox浏览器
browser = webdriver.Chrome() # 打开Chrome浏览器
from selenium import webdriver
browser = webdriver.Chrome()
browser.get("http://www.baidu.com")
print(browser.page_source)
#browser.close()
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: PhantomJS
Step2: 访问页面
Step3: 查找元素
Step4: 这里我们通过三种不同的方式去获取响应的元素,第一种是通过id的方式,第二个中是CSS选择器,第三种是xpath选择器,结果都是相同的。
Step5: 多个元素查找
Step6: 当然上面的方式也是... |
9,490 | <ASSISTANT_TASK:>
Python Code:
# Start with some imports!
from __future__ import print_function
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
# Very basic function
def f(x):
return x
help(interact)
# Generate a slider to interact with
interact(f, x=10);
interact(f, x=10,);
# Boo... | <SYSTEM_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 the semicolon
Step2: Booleans create checkbox
Step3: Using decorators
Step4: From Portilla's notes
Step5: Function Annotations
Step6: ... |
9,491 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import HTML
import os
def css_styling():
Load default custom.css file from ipython profile
base = os.getcwd()
styles = "<style>\n%s\n</style>" % (open(os.path.join(base,'files/custom.css'),'r').read())
return HTML(styles)
css_styling()
import num... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <i class="fa fa-diamond"></i> Primero pimpea tu libreta!
Step2: <i class="fa fa-book"></i> Primero librerias
Step3: <i class="fa fa-database">... |
9,492 | <ASSISTANT_TASK:>
Python Code:
#$HIDE$
import numpy as np
from itertools import product
def show_kernel(kernel, label=True, digits=None, text_size=28):
# Format kernel
kernel = np.array(kernel)
if digits is not None:
kernel = kernel.round(digits)
# Plot kernel
cmap = plt.get_cmap('Blues_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: Introduction
Step2: We can understand these parameters by looking at their relationship to the weights and activations of the layer. Let's do t... |
9,493 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib
import matplotlib as mpl
import lightkurve as lk
import k2sc
from k2sc.standalone import k2sc_lc
from astropy.io import fits
%pylab inline --no-import-all
matplotlib.rcParams['image.origin'] = 'lower'
matplotlib.rcParams['figure.figsize']=(10.0,10.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: Reading in data.
Step2: Let's now try K2SC!
Step3: Now we run with default values!
Step4: Now we plot! See how the k2sc lightcurve has such b... |
9,494 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import itertools
import math
import pandas as pd
import csv
import time
from sklearn.cross_validation import train_test_split, KFold
from sklearn.naive_bayes import MultinomialNB
from sklearn.linear_model import LogisticRegression, SGDClassifier
from sklearn.model_selec... | <SYSTEM_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 training data
Step2: Separate tweets into two sets
Step3: Split the data into the training set and test set for crossvalidation
Step4: ... |
9,495 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import networkx as nx
K_5=nx.complete_graph(5)
nx.draw(K_5)
def complete_deg(n):
Return the integer valued degree matrix D for the complete graph K_n.
z=np.zeros((n,n), dtype=int)
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: Complete graph Laplacian
Step3: The Laplacian Matrix is a matrix that is extremely important in graph theory and numerical analysis. It is defi... |
9,496 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.integrate import quad, dblquad
%matplotlib inline
import matplotlib.pyplot as plt
import scipy.optimize as opt
thetamin = 25.6*np.pi/180
thetamax = 33.7*np.pi/180
t = 1*10**-6 #Cell Thickness
tempsC = np.array([26, 27, 29, 31, 33, 35, 37])
voltages = np.arr... | <SYSTEM_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 notebook calculates and plots the theoretical tilt angles. It will also plot the alpha and p0 factors vs temperature that are given in the ... |
9,497 | <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: Auto MPG データセット
Step3: pandasを使ってデータをインポートします。
Step4: データのクレンジング
Step5: この最初のチュートリアルでは簡単化のためこれらの行を削除します。
Step6: "Origin"の列は数値ではなく... |
9,498 | <ASSISTANT_TASK:>
Python Code:
import cobra
from utils import findBiomarkers
import pandas as pd
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
M = cobra.io.load_json_model('models/recon_2_2_simple_medium.json')
model = M.copy() # this way we can edit model bu... | <SYSTEM_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
|
9,499 | <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 en... | <SYSTEM_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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.