Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
5,000 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import Model
from tensorflow.keras.layers import Dense, Embedding, Input, Flatten, Conv2D, MaxPooling2D
from sklearn.utils import shuffle
from sklearn.preprocessing import Mul... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Building a multilabel model with simgoid output
Step2: 🥑🥑🥑
Step3: Parsing sigmoid results
Step4: Sigmoid output for binary classification
... |
5,001 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import string
import numpy as np
import pandas as pd
print pd.__version__
# Dimensions
nb_rand_var = 8
nb_dates = 220
np.random.seed(4321)
# Random choice letters
pickme = lambda x: np.random.choice(26, x, replace=False)
labels = np.array(list(string.ascii_uppercase))[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Build a DataFrame with a timeseries
Step2: Plotting with matplotlib
Step3: Even if the figure is nicer than the matplotlib default style, I th... |
5,002 | <ASSISTANT_TASK:>
Python Code:
# for colab
!pip install -q tf-nightly-gpu-2.0-preview
import tensorflow as tf
print(tf.__version__)
# a small sanity check, does tf seem to work ok?
hello = tf.constant('Hello TF!')
print("This works: {}".format(hello))
# this should return True even on Colab
tf.test.is_gpu_available()
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: load data
Step2: pre-process data into chunks
Step3: Recurrent Neural Networks
Step4: Convert Model into tfjs format
|
5,003 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
pd.set_option('display.float_format', lambda x: '%.2f' % x)
dtype = {
'Title': str,
'First Name': str,
'Last Name': str,
'Speciality': str,
'Institution Name': str
}
df = pd.read_csv('./data/payments.csv', dtype=dtype)
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: Basic statistics
Step2: Quickly calculate the breakdown between payments to individuals and payments to organisations.
Step3: Most payments ar... |
5,004 | <ASSISTANT_TASK:>
Python Code:
!pip3 install bs4
from bs4 import BeautifulSoup
from urllib.request import urlopen
html_str = urlopen("http://static.decontextualize.com/widgets2016.html").read()
document = BeautifulSoup(html_str, "html.parser")
h3_tags = document.find_all('h3')
print("There is", len(h3_tags), "“h3” tag... | <SYSTEM_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, in the cell below, use Beautiful Soup to write an expression that evaluates to the number of <h3> tags contained in widgets2016.html.... |
5,005 | <ASSISTANT_TASK:>
Python Code:
%run Regexp-2-NFA.ipynb
%run RegExp-Parser.ipynb
r = parse('(ab + ba)*')
r
converter = RegExp2NFA({'a', 'b'})
nfa = converter.toNFA(r)
nfa
%run FSM-2-Dot.ipynb
d = nfa2dot(nfa)
d.render(view=True)
%run NFA-2-DFA.ipynb
dfa = nfa2dfa(nfa)
dfa
d, S = dfa2dot(dfa)
S
d
<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: If the regular expression r that is defined below is written in the style of the lecture notes, it reads
Step2: We use converter to create a no... |
5,006 | <ASSISTANT_TASK:>
Python Code:
DATA_PATH = '~/Desktop/sdss_dr7_photometry_source.csv.gz'
import itertools
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sklearn.neighbors
%matplotlib inline
PSF_COLS = ('psfMag_u', 'psfMag_g', 'psfMag_r', 'psfMag_i', 'psfMag_z')
def load_data(x_cols=PSF_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: First import the training and testing sets
Step2: Fit the training data.
Step3: Sanity checks
Step4: Two variables
|
5,007 | <ASSISTANT_TASK:>
Python Code:
# Necessary package imports
import time
import numpy as np
%matplotlib nbagg
import matplotlib.pyplot as plt
from varanneal import va_ode # The ODE version of VarAnneal
def l96(t, x, k):
# Define this as you would any ODE system in Python, when x is a *time series*
# of states.... | <SYSTEM_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: Action/annealing (hyper)parameters
Step3: Load observed data
Step4: Set $\Delta t_f$ based on $\Delta t$.
Step5: Initial path/pa... |
5,008 | <ASSISTANT_TASK:>
Python Code:
# First let's install the module
!pip install thermocouples_reference
from thermocouples_reference import thermocouples
typeK = thermocouples['K']
print(typeK)
print(typeK.emf_mVC(42, Tref=0))
print(typeK.emf_mVC([-3.14159, 42, 54], Tref=0))
print(typeK.inverse_CmV(1.1, Tref=23.0))
# 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: Below, the first computation shows that the type K thermocouple emf at 42 °C, with reference junction at 0 °C, is 1.694 mV (compare to NIST tabl... |
5,009 | <ASSISTANT_TASK:>
Python Code:
import sys
def function(): pass
print type(1)
print type("")
print type([])
print type({})
print type(())
print type(object)
print type(function)
print type(sys)
# first.py
class First:
pass
fr = First()
print type(fr)
print type(First)
class Dog:
def __init__(self, name):
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: Python programs can have different styles
Step2: This is our first class. The body of the class is left empty for now. It is a convention to gi... |
5,010 | <ASSISTANT_TASK:>
Python Code:
# import essentia in streaming mode
import essentia
import essentia.streaming as es
# import matplotlib for plotting
import matplotlib.pyplot as plt
import numpy as np
# algorithm parameters
framesize = 1024
hopsize = 256
inputFilename = 'singing-female.wav'
outputFilename = 'singing-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: After importing Essentia library, let's import other numerical and plotting tools
Step2: Define the parameters of the STFT workflow
Step3: Spe... |
5,011 | <ASSISTANT_TASK:>
Python Code:
from keras.datasets import mnist
(X_raw, y_raw), (X_raw_test, y_raw_test) = mnist.load_data()
n_train, n_test = X_raw.shape[0], X_raw_test.shape[0]
import matplotlib.pyplot as plt
import random
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
for i in range(15):
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: 可视化 mnist
Step2: 练习:合成数据
Step3: 问题 1
Step4: 问题 2
Step5: 问题 3
Step6: 问题 4
Step7: 保存模型
|
5,012 | <ASSISTANT_TASK:>
Python Code:
# imports
import sys # for stderr
import numpy as np
import pandas as pd
import sklearn as skl
from sklearn import metrics
import matplotlib.pyplot as plt
%matplotlib inline
# settings
plt.style.use('ggplot')
# plt.rcParams['figure.figsize'] = (10.0, 10.0)
# pd.set_option('display.max_ro... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Overall screening percentage
Step2: Screening by Age, Ethnicity, Household income, and Education level
Step3: Interaction with the Medical Sys... |
5,013 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
from IPython.display import Image
Image('images/decision-tree.png')
from sklearn.datasets import make_blobs
X, y = make_blobs(n_samples=300, centers=4,
random_state=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: Motivating Random Forests
Step2: The binary splitting makes this extremely efficient (Given a proper tree). Why?
Step3: A simple decision tre... |
5,014 | <ASSISTANT_TASK:>
Python Code:
all_data_list = []
for year in range(1990,2017):
data = pd.read_csv('{}_Output.csv'.format(year), header=None)
all_data_list.append(data) # list of dataframes
data = pd.concat(all_data_list, axis=0)
data.columns = ['id','date','headline', 'lead']
data.head()
data.shape
data.dropn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Removing missing data
Step2: Adding 'yearmonth'
Step3: Stemming
Step4: Extracting Unigrams and Bigrams
Step5: It's useful to be able to save... |
5,015 | <ASSISTANT_TASK:>
Python Code:
df['Gender'] = df['Sex'].map( {'female': 0, 'male': 1} ).astype(int)
df.head()
df['Age'].dropna().hist(bins=16, range=(0,80), alpha = .5)
P.show()
median_ages = np.zeros((2,3))
median_ages
for i in range(0, 2):
for j in range(0, 3):
median_ages[i,j] = df[(df['Gender'] == 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: Fill missing Age values
Step2: Fill missing Embarked
Step3: Feature Engineering
|
5,016 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# -*- coding:utf-8 -*-
from __future__ import print_function
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
# データ読み込み
data = pd.read_csv('example/k0901.csv')
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: 例題9-2 「係数ダミー」
Step2: 例題9-3 「t検定による構造変化のテスト」
|
5,017 | <ASSISTANT_TASK:>
Python Code:
# Import packages
%run startup.py
bf = Session(host="localhost")
# Initialize the example network and snapshot
NETWORK_NAME = "example_network"
BASE_SNAPSHOT_NAME = "base"
SNAPSHOT_PATH = "networks/failure-analysis"
bf.set_network(NETWORK_NAME)
bf.init_snapshot(SNAPSHOT_PATH, name=BASE_SN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: bf.fork_snapshot
Step2: In the code, bf.fork_snapshot accepts four parameters
Step3: Great! We have confirmed that Paris can still reach PoP v... |
5,018 | <ASSISTANT_TASK:>
Python Code:
import numpy as np # modulo de computo numerico
import matplotlib.pyplot as plt # modulo de graficas
import pandas as pd # modulo de datos
# esta linea hace que las graficas salgan en el notebook
%matplotlib inline
xurl="http://spreadsheets.google.com/pub?key=phAwcNAVuyj2tPLxKvvnNPA&outp... | <SYSTEM_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 graficas (plot)
Step2: Arreglando los Datos
Step3: Entonces ahora podemos ver la calidad de vida en Mexico atravez del tiempo
Step4: de... |
5,019 | <ASSISTANT_TASK:>
Python Code:
from k2datascience import classification
from k2datascience import plotting
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline
weekly = classification.Weekly()
weekly.data.info()
weekly.data.describe()
weekly.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: Exercise 1
Step2: FINDINGS
Step3: FINDINGS
Step4: FINDINGS
Step5: FINDINGS
Step6: FINDINGS
Step7: FINDINGS
Step8: FINDINGS
Step9: FINDIN... |
5,020 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'cnrm-cm6-1-hr', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("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: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
5,021 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
from pandas.tools.plotting import scatter_matrix
import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns
import matplotlib.colors as colors
import xgboost as xgb
import numpy as np
from sklearn.metrics import confusion_matrix, ... | <SYSTEM_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 and Model Selection
Step2: The accuracy function and accuracy_adjacent function are defined in the following to quatify the pr... |
5,022 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn;
from sklearn import neighbors, datasets
import pylab as pl
seaborn.set()
iris = datasets.load_iris()
X, y = iris.data, iris.target
from sklearn.decomposition import PCA
pca = PCA(n_components=2)
pca.fit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dimensionality Reduction
Step2: We can see that there is a definite trend in the data. What PCA seeks to do is to find the Principal Axes in th... |
5,023 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
#%config InlineBackend.figure_format = 'pdf'
import kgof
import kgof.data as data
import kgof.density as density
import kgof.goftest as gof
import kgof.kernel as ker
import kgof.util as util... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problem
Step2: Test original implementation
Step3:
|
5,024 | <ASSISTANT_TASK:>
Python Code:
from pomegranate import *
import numpy as np
model = NaiveBayes( MultivariateGaussianDistribution, n_components=2 )
X = np.array([[ 6, 180, 12 ],
[ 5.92, 190, 11 ],
[ 5.58, 170, 12 ],
[ 5.92, 165, 10 ],
[ 6, 160, 9 ],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Since we are simply using two Multivariate Gaussian Distributions, our Naive Bayes model is very simple to initialize.
Step2: Of course current... |
5,025 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -a "Sebastian Raschka" -d -v
import pandas as pd
import numpy as np
import matplotlib.ticker as ticker
np.random.seed(123)
variables = ['A','B','C','X','Y','Z']
labels = ['ID_0','ID_1','ID_2','ID_3','ID_4','ID_5','ID_6',
'ID_7','ID_8','ID_9','ID_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: Hierarchical Agglomerative Clustering - Complete Linkage Clustering
Step2: <br>
Step3: <br>
Step4: b) Condensed distance matrix (correct)
Ste... |
5,026 | <ASSISTANT_TASK:>
Python Code:
from landlab import RasterModelGrid
import numpy as np
mg = RasterModelGrid((4, 4))
mg.status_at_node
mg.imshow(mg.status_at_node)
mg.status_at_node[2] = mg.BC_NODE_IS_CLOSED
mg.imshow(mg.status_at_node, color_for_closed="blue")
mg.set_status_at_node_on_edges(
right=mg.BC_NODE_IS... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Instantiate a grid.
Step2: The node boundary condition options are
Step3: The default conditions are for the perimeter to be fixed value (stat... |
5,027 | <ASSISTANT_TASK:>
Python Code:
mps_to_mmph = 1000 * 3600
from cmt.components import Meteorology
met = Meteorology()
%cd input
met.initialize('meteorology-P-linear.cfg')
bprecip = met.get_value('atmosphere_water__precipitation_leq-volume_flux')
print type(bprecip)
print bprecip.size
print bprecip.shape
bprecip * mps_... | <SYSTEM_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 the Babel-wrapped Meteorology component and create an instance
Step2: Initialize the model.
Step3: The initial model precipitation volu... |
5,028 | <ASSISTANT_TASK:>
Python Code:
import sympy as sp
sp.init_printing(use_latex=True)
from sympy.matrices import zeros
tau_m, tau_s, C, h = sp.symbols('tau_m, tau_s, C, h')
A = sp.Matrix([[-1/tau_s,0,0],[1,-1/tau_s,0],[0,1/C,-1/tau_m]])
PA = sp.simplify(sp.exp(A*h))
PA
As = sp.Matrix([[-1/tau_m,0,0],[1,-1/tau_m,0],[0,1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For alpha-shaped currents we have
Step2: Non-singular case ($\tau_m\neq \tau_s$)
Step3: Note that the entry in the third line and the second c... |
5,029 | <ASSISTANT_TASK:>
Python Code:
# restart your notebook if prompted on Colab
try:
import verta
except ImportError:
!pip install verta
HOST = "app.verta.ai"
PROJECT_NAME = "Wine Multiclassification"
EXPERIMENT_NAME = "Boosted Trees"
# import os
# os.environ['VERTA_EMAIL'] =
# os.environ['VERTA_DEV_KEY'] =
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: This example features
Step2: Imports
Step3: Log Workflow
Step4: Prepare Hyperparameters
Step5: Instantiate Client
Step6: Run Validation
Ste... |
5,030 | <ASSISTANT_TASK:>
Python Code:
from sympy.abc import rho
rho, u, c = symbols('rho u c')
A = Matrix([[u, rho, 0], [0, u, rho**-1], [0, c**2 * rho, u]])
A
A.eigenvals()
R = A.eigenvects() # this returns a tuple for each eigenvector with multiplicity -- unpack it
r = []
lam = []
for (ev, _, rtmp) in R:
r.append(rt... | <SYSTEM_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 eigenvalues are the speeds at which information propagates with. SymPy returns them as a
Step2: The right eigenvectors are what SymPy give... |
5,031 | <ASSISTANT_TASK:>
Python Code:
import gammalib
import ctools
import cscripts
%matplotlib inline
import matplotlib.pyplot as plt
caldb = 'prod2'
irf = 'South_0.5h'
emin = 0.1 # TeV
emax = 160.0 # TeV
evfile = 'events.fits'
obssim = ctools.ctobssim()
obssim['ra'] = 83.63
obssim['dec'] = 22.51
obssim... | <SYSTEM_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 import the matplotlib package for plotting.
Step2: Simulated dataset
Step3: Now proceed to simulate the dataset. It consists of an hour of... |
5,032 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import sys
sys.path.append(os.path.expanduser("~/nta/nupic.research/projects/"))
# general imports
import os
import numpy as np
# torch imports
import torch
import torch.optim as optim
import torch.optim.lr_scheduler as schedulers
import torch.nn as nn
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: Large dense
Step2: Large sparse
Step3: Large dynamic sparse
Step4: Small dense
Step5: Comparing all
Step6: Test with kwinners
Step7: test_... |
5,033 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-4, 4, 0.02)
y = np.exp(-(x * x)/2)
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.show()
def f(x):
return np.exp(-x*x/2)
# first derivative
def f_d(x):
return -x * f(x)
# second derivative
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: $ f(x) = e^{- \frac{x^2}{2} }$ is an un-normalized gaussian distribution whose maximum is at x=0
Step2: The <b>Taylor series</b> (quadratic) ap... |
5,034 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
df = pd.read_csv("https://github.com/chris1610/pbpython/blob/master/data/sales_data_types.csv?raw=True")
df
df.info()
df['2016'] + df['2017']
df['Customer Number'].astype('int')
df.dtypes
df["Customer Number"] = df['Customer Number'].astype('int... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Use df.info and df.dtypes to look at the types that pandas automatically infers based on the data
Step2: df.dtypes
Step3: The simplest way to ... |
5,035 | <ASSISTANT_TASK:>
Python Code:
import sklearn
import mglearn
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn.linear_model import LogisticRegression
from sklearn.svm import LinearSVC
X, y = mglearn.datasets.make_forge()
fig, axes = plt.subplots(1, 2, figsize=(10,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: Figure 1. Decision boundaries of linear SVM and logistic regresison on forge data with default parameters
Step2: Figure 2.
Step3: Logistic Reg... |
5,036 | <ASSISTANT_TASK:>
Python Code:
import graphlab as gl
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# import wiki data
wiki = gl.SFrame('people_wiki.gl/')
wiki
wiki_docs = gl.text_analytics.count_words(wiki['text'])
wiki_docs = wiki_docs.dict_trim_by_keys(gl.text_analytics.stopwords(), exclude=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the original data, each Wikipedia article is represented by a URI, a name, and a string containing the entire text of the article. Recall fro... |
5,037 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from sympy import init_printing
from sympy import symbols, as_finite_diff, solve, latex
from sympy import Function, Eq
fg, f0, f1, f2 = symbols('f_g, f_0, f_1, f_2')
z, h = symbols('z, h')
a, b = symbols('a, b')
f = Function('f')
init_printing()
extraP... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Extrapolation of $f(0) = a$ to the ghost point yields (see ghost4thOrder for calculation) yields
Step2: Which can be rewritten to
Step3: Furth... |
5,038 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import num... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
5,039 | <ASSISTANT_TASK:>
Python Code:
dv = DenseVector([1.0,0.,0.,0.,4.5,0])
dv
sv = SparseVector(6, {0:1.0, 4:4.5})
sv
DenseVector(sv.toArray())
active_elements_dict = {index: value for index, value in enumerate(dv) if value != 0}
active_elements_dict
SparseVector(len(dv), active_elements_dict)
<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: Three components of a sparse vector
Step2: Convert sparse vector to dense vector
Step3: Convert dense vector to sparse vector
|
5,040 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.random.seed(777)
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (10, 6)
noise_level = 0.1
def f(x, noise_level=noise_level):
return np.sin(5 * x[0]) * (1 - np.tanh(x[0] ** 2)) + np.random.randn() * noise_level
# Plot f(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: Problem statement
Step2: Note. In skopt, functions $f$ are assumed to take as input a 1D vector $x$ represented as an array-like and to return ... |
5,041 | <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... |
5,042 | <ASSISTANT_TASK:>
Python Code:
###### 0123456789012345678901234567890123456789012345678901234567890'
record = '....................100 .......513.25 ..........'
cost = int(record[20:32]) * float(record[40:48])
print(cost)
SHARES = slice(20,32)
PRICE = slice(40,48)
cost = int(record[SHARES]) * float(rec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Why use slice()
Step2: In addition, you can map a slice onto a sequence of a specific size by using its indices(size) method.
|
5,043 | <ASSISTANT_TASK:>
Python Code:
# suposing the datset is downloaded here
# workdir = '/media/samuel/dataspikesorting/DataSpikeSortingHD2/kampff/polytrode Impedance/'
workdir = '/home/samuel/Documents/projet/DataSpikeSorting/kampff/polytrode Impedance/'
# Input file
filename = workdir + 'amplifier2017-02-02T17_18_46/ampl... | <SYSTEM_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 DataIO (and remove if already exists)
Step2: CatalogueConstructor
Step3: Noise measurement
Step4: Inspect waveform quality at catalo... |
5,044 | <ASSISTANT_TASK:>
Python Code:
try:
flip
except:
assert False
else:
assert True
np.testing.assert_allclose(flip(1.0), 1.0, rtol = 0.01)
np.testing.assert_allclose(flip(0.0), 0.0, rtol = 0.01)
results = np.zeros(10000, dtype = np.int)
for i in range(10000):
results[i] = flip(0.5)
np.testing.assert_allclo... | <SYSTEM_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
|
5,045 | <ASSISTANT_TASK:>
Python Code:
import csv
import urllib2
def pr_min_max(ip_addr):
mintemp = {'Value': 1000.0}
maxtemp = {'Value': 0.0}
cr = csv.DictReader(urllib2.urlopen("http://%s:7645/data.csv" % ip_addr))
for row in cr:
temp = float(row['Value'])
var = row['Variable']
if var... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: pr_min_max
Step2: Analyze the Data
|
5,046 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'sandbox-3', 'aerosol')
# 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... |
5,047 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import numpy as np
x = np.linspace(-np.pi, np.pi, 256,endpoint=True)
y,z = np.sin(x), np.cos(x)
plt.plot(x,y)
plt.plot(x,z)
plt.show()
plt.plot(x, y, color="blue", linewidth=2.5, linestyle="-")
# Plot sine using green ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Improving the range of the plot
Step2: Intuitive Mapping from Data to Visualization
|
5,048 | <ASSISTANT_TASK:>
Python Code:
!pip uninstall systemml --y
!pip install --user https://repository.apache.org/content/groups/snapshots/org/apache/systemml/systemml/1.0.0-SNAPSHOT/systemml-1.0.0-20171201.070207-23-python.tar.gz
!pip show systemml
from systemml import MLContext, dml, dmlFromResource
ml = MLContext(sc)
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:
Step2: Import SystemML API
Step3: Import numpy, sklearn, and define some helper functions
Step5: Example 1
Step6: Load diabetes dataset from scikit-... |
5,049 | <ASSISTANT_TASK:>
Python Code:
ls -1
! ls -1 | wc -l
! gunzip --help
! gunzip -f *gz
3+3
asdf = 'beyonce'
asdf
asdf + ' runs the world'
ls
! head GSM1657872_1772078217.C04.csv
import glob
import pandas as pd
pd.read_table('GSM1657872_1772078217.C04.csv')
pd.read_table('GSM1657872_1772078217.C04.csv', index_col=0)
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: oof, this is in pure bytes and I can't convert to multiples of 1024 easily in my head (1024 bytes = 1 kilobyte, 1024 kilobytes = 1 megabtye, etc... |
5,050 | <ASSISTANT_TASK:>
Python Code:
def check_length(n ) :
ans = 0
while(n ) :
n = n >> 1
ans += 1
return ans
def check_ith_bit(n , i ) :
if(n &(1 <<(i - 1 ) ) ) :
return True
else :
return False
def no_of_flips(n ) :
ln = check_length(n )
ans = 0
right = 1
left = ln
while(rig... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
5,051 | <ASSISTANT_TASK:>
Python Code:
wadiz_df_original = pd.read_csv('wadiz_df_0329_1.csv', index_col=0)
user_comment = pd.read_csv('user_data_all_0329.csv', index_col=0)
provider_comment = pd.read_csv('provider_data_all_0329.csv', index_col=0)
wadiz_df = pd.read_csv('wadiz_provider_analysis_0329.csv', index_col=0)
provider_... | <SYSTEM_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: Kolmogorov-Smirnov test
Step3: 모든 test-statistics의 p-value들이 0.05이상이므로 귀무가설(null hypothesis
Step4: 지역별 샘플개수가 작아서 분포의 차이 검정... |
5,052 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
from google.cloud import bigquery
PROJECT = !(gcloud config get-value core/project)
PROJECT = PROJECT[0]
BUCKET = PROJECT
REGION = "us-central1"
%env PROJECT = {PROJECT}
%env BUCKET = {BUCKET}
%env REGION = {REGION}
%%bash
gcloud config set project $PROJECT
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Replace the variable values in the cell below
Step2: Create a Dataset from BigQuery
Step3: Let's do some regular expression parsing in BigQuer... |
5,053 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from pprint import pprint
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pymc3 as mc
import spacepy.toolbox as tb
import spacepy.plot as spp
import tqdm
from scipy import stats
import seaborn as sns
sns.set(font_scale=1.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: Generate Poisson process data and generate exponential
Step2: This is consistent with a Poisson of parameter 20! But there seems to be an under... |
5,054 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'csir-csiro', 'sandbox-2', 'aerosol')
# 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... |
5,055 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
matplotlib.use('TkAgg')
from utils import *
# Had to run 'jupyter nbextension enable --py --sys-prefix widgetsnbextension'
fig, ax = plt.subplots()
environment1 = ArmBall()
def movement(m1=0., m2=0., m3=0., m4=0., m5=0., m6=0., m7=0., m8=0., m9=0.):
environment1.upd... | <SYSTEM_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. Exploring by hand the movements of a robotic arm
Step2: II. Random Motor Babbling
Step3: We first implement the Random Motor Babbling strat... |
5,056 | <ASSISTANT_TASK:>
Python Code:
! pip3 install -U google-cloud-automl --user
! pip3 install google-cloud-storage
import os
if not os.getenv("AUTORUN"):
# Automatically restart kernel after installs
import IPython
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
PROJECT_ID = "[your-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: Install the Google cloud-storage library as well.
Step2: Restart the Kernel
Step3: Before you begin
Step4: Region
Step5: Timestamp
Step6: A... |
5,057 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import os
import glob
import numpy as np
from statsmodels.tsa.tsatools import detrend
def make_gen_index(data_folder, time='Monthly'):
Read and combine the state-level generation and inde... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Seasonal correlation of CO<sub>2</sub> intensity across NERC regions
Step2: All index values over time for reference
Step3: Viewing all of the... |
5,058 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import pandas as pd
# read CSV file in pandas
mydf = pd.read_csv('.data/Julie_R1_Bef_S4_cell123_Position.csv', skiprows=2)
mydf.head()
# get basic information
print('Number of samples %d'%len(mydf))
print('Number of particles = %d'%len(mydf['TrackID'].unique()))
print('Dis... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <H2>Show basic file information</H2>
Step3: <H2>Compute euclidian distances </H2>
Step4: <H2>Velocities</H2>
Step5: <H2>Particle information<... |
5,059 | <ASSISTANT_TASK:>
Python Code:
no_elves = 5
elves = [elf for elf in range(1, no_elves + 1)]
print(elves)
def play_round(elves):
_elves = []
elf = 0
while elf < len(elves):
_elves.append(elves[elf])
elf += 2
if len(elves) % 2 == 1:
_elves.pop(0)
return _elves
while len(elves... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simulate one round of stealing presents
Step2: Continue simulating rounds until only one elf is remaining
Step3: Run on the given input
Step4:... |
5,060 | <ASSISTANT_TASK:>
Python Code:
with open("input/day7.txt", "r") as f:
inputLines = tuple(line.strip() for line in f)
import re
def isABBA(text):
# Use a negative lookahead assertion to avoid matching four equal characters.
return re.search(r"(.)(?!\1)(.)\2\1", text) is not None
assert isABBA("abba")
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: Part 1
Step2: Part 2
|
5,061 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import matplotlib.pyplot as plt
import healpy as hp
from astropy.io import fits
from astropy.coordinates import SkyCoord
from astropy.wcs import WCS
import cygrid
imkw... | <SYSTEM_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 attempt to limit our dependencies as much as possible, but astropy, healpy, and wcsaxes needs to be available on your machine if you want to... |
5,062 | <ASSISTANT_TASK:>
Python Code:
!pip install -U numpy matplotlib Ipython ipywidgets pycroscopy
# Ensure python 3 compatibility
from __future__ import division, print_function, absolute_import
# Import necessary libraries:
# General utilities:
import sys
import os
# Computation:
import numpy as np
import h5py
# Visualiza... | <SYSTEM_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 some basic parameters for computation
Step2: Make the data pycroscopy compatible
Step3: Inspect the contents of this h5 data file
Step4: ... |
5,063 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
%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'
# Data 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: Training
Step2: Visualization
|
5,064 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
data_set_size = 15
low_mu, low_sigma = 50, 4.3
low_data_set = low_mu + low_sigma * np.random.randn(data_set_size)
high_mu, high_sigma = 57, 5.2
high_data_set = high_mu + high_sigma * np.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: <h2>random low and high temperature data</h2>
Step2: Next example from
|
5,065 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import sys
from scipy.signal import medfilt
# Add a new path with needed .py files.
sys.path.insert(0, 'C:\Users\Dowa\Desktop\Hiwi\kt-2015-DSPHandsOn\MedianFilter\Python')
import funct... | <SYSTEM_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 you can see, the resolution gets higher with a higher window length until the window legth is multiple of the sample rate.
|
5,066 | <ASSISTANT_TASK:>
Python Code:
!wget http://mlr.cs.umass.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data
!wget http://mlr.cs.umass.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.names
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
!head -40 auto-mpg.data
def missingIsNan(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: First, take a look at auto-mpg.names. There you will learn that there are 398 samples, each with 8 numerical attributes and one string attribut... |
5,067 | <ASSISTANT_TASK:>
Python Code:
from footballdataorg.fd import FD
import json
fd = FD()
pl = fd.get_competition(league_code='PL')
print(json.dumps(pl, indent=2))
teams = fd.get_teams(competition=pl)
teams = fd.search_teams('madrid')
print(json.dumps(teams, indent=2))
manchester_united = fd.get_team('66')
print(json... | <SYSTEM_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 FD object
Step2: Get Premier League competition object
Step3: Get the teams of the competition
Step4: Search teams by name
Step5: Get... |
5,068 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
from skynet.utils.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'... | <SYSTEM_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
|
5,069 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
from sklearn import linear_model
import matplotlib.pyplot as plt
import matplotlib as mpl
# read data in pandas frame
dataframe = pd.read_csv('datasets/house_dataset2.csv', encoding='utf-8')
# check data by printing first few rows
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Feature Scaling and Mean Normalization
Step2: Initialize Hyper Parameters
Step3: Model/Hypothesis Function
Step5: Cost Function
Step7: Gradi... |
5,070 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from preamble import *
plt.rcParams['savefig.dpi'] = 100 # This controls the size of your figures
# Comment out and restart notebook if you only want the last output of each cell.
InteractiveShell.ast_node_interactivity = "all"
# This is a temporary read-only OpenML ke... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Kernel selection (4 points (1+2+1))
Step2: Results
Step3: Robots and SVMs (4 points (2+1+1))
Step4: A benchmark study (3 points (2+1))
|
5,071 | <ASSISTANT_TASK:>
Python Code:
import pandas ## data file loading
import numpy
import sklearn.covariance ## for covariance matrix calculation
import matplotlib.pyplot
import matplotlib
import pylab
import scipy.stats ## for calculating the CDF of normal distribution
import igraph ## for network visualization and fi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read the tab-deliminted text file of gene expression measurements (rows correspond to genes, columns correspond to bladder tumor samples). (use ... |
5,072 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
sns.set(palette = sns.dark_palette("skyblue", 8, reverse=True))
!wget 'https://docs.google.com/spreadsheets/d/1N_Hc-xKr7DQc8bZAvLROGWr5Cr-A6MfGnH91fFW3ZwA/export?format=xlsx&id=1N_Hc-xKr7DQc8bZAv... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting the data
Step2: First issue with the data, right away we can see the wide range of dates. Let's look at the date distribution. We proba... |
5,073 | <ASSISTANT_TASK:>
Python Code:
import os
class Params:
pass
# Set to run on GCP
Params.GCP_PROJECT_ID = 'ksalama-gcp-playground'
Params.REGION = 'europe-west1'
Params.BUCKET = 'ksalama-gcs-cloudml'
Params.PLATFORM = 'local' # local | GCP
Params.DATA_DIR = 'data/news' if Params.PLATFORM == 'local' else 'gs://{}/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: Importing libraries
Step2: 1. Define Metadata
Step3: 2. Define Input Function
Step4: 3. Create feature columns
Step5: 4. Create a model usin... |
5,074 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import scipy.stats
%pylab inline
csv = pd.read_csv("single_family_home_values.csv", parse_dates=["last_sale_date"])
print csv.shape
csv.head()
#scale the data
from sklearn import preprocessing
from scipy import stats
# fill missing values (0's) w/ 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: Data Preprocessing
Step2: Location/Address Information
Step3: Transform Dates
Step4: Number of rooms
Step5: Outliers
Step6: Skewedness
Step... |
5,075 | <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: Using TensorBoard in Notebooks
Step2: Import TensorFlow, datetime, and os
Step3: TensorBoard in notebooks
Step4: Create a very simple model
S... |
5,076 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
%matplotlib inline
import os
SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data')
from scipy.io import loadmat
from shogun import features, MulticlassLabels, Math
# load the dataset
dataset = loadmat(os.path.join(SHOGUN_DATA_DIR, 'multiclass/usps.mat'))
Xall = datas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Creating the network
Step2: We can also visualize what the network would look like. To do that we'll draw a smaller network using networkx. The... |
5,077 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
% matplotlib inline
def ErrorPlot( waveNumber,windowLength ):
data = np.fromfunction( lambda x: np.sin((x-windowLength / 2)/128 * 2 * np.pi * waveNumber), (128 + windowLength /... | <SYSTEM_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 plot the error of the filtered wave. I use the absulte values of the difference between sine wave and median filtered wave and calculate the m... |
5,078 | <ASSISTANT_TASK:>
Python Code:
import o2sclpy
import matplotlib.pyplot as plot
import numpy
import sys
plots=True
if 'pytest' in sys.modules:
plots=False
link=o2sclpy.linker()
link.link_o2scl()
fc=o2sclpy.find_constants(link)
ħc=fc.find_unique('ħc','MeV*fm')
print('ħc = %7.6e\n' % (ħc))
cu=link.o2scl_settings.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: Link the O$_2$scl library
Step2: Get the value of $\hbar c$ from an O$_2$scl find_constants object
Step3: Get a copy (a pointer to) the O$_2$s... |
5,079 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
# hyp... | <SYSTEM_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 Dataset
Step2: LogisticRegressionはlogitsを返してsoftmaxを通さないので注意
Step3: MNIST
|
5,080 | <ASSISTANT_TASK:>
Python Code:
!pip install thinc syntok "ml_datasets>=0.2.0a0" tqdm
from syntok.tokenizer import Tokenizer
def tokenize_texts(texts):
tok = Tokenizer()
return [[token.value for token in tok.tokenize(text)] for text in texts]
import ml_datasets
import numpy
def load_data():
train_data, dev... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For simple and standalone tokenization, we'll use the syntok package and the following function
Step2: Setting up the data
Step3: Defining the... |
5,081 | <ASSISTANT_TASK:>
Python Code:
# Import some libraries that will be necessary for working with data and displaying plots
# To visualize plots in the notebook
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import scipy.io # To read matlab files
from scipy import spatial
im... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Introduction
Step2: 2. The stocks dataset.
Step3: After running this code, you will have inside matrix Xtrain the evolution of (normalized)... |
5,082 | <ASSISTANT_TASK:>
Python Code:
import numpy as np # numpy namespace
from timeit import default_timer as timer # for timing
from matplotlib import pyplot # for plotting
import math
def step_numpy(dt, prices, c0, c1, noises):
return prices * np.exp(c0 * dt + c1 * noises)
def mc_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: Configurations
Step2: Driver
Step3: Result
Step4: Basic Vectorize
Step5: Parallel Vectorize
Step6: CUDA Vectorize
Step7: In the above simp... |
5,083 | <ASSISTANT_TASK:>
Python Code:
import metaknowledge as mk
import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
import metaknowledge.contour.plotting as mkv
RC = mk.RecordCollection('../savedrecs.txt')
CoCitation = RC.networkCoCitation()
print(mk.graphStats(CoCitation, makeString = True)) #makestr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: And so we can visualize the graphs
Step2: Before we start we should also get a RecordCollection to work with.
Step3: Now lets look at the diff... |
5,084 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
DON'T MODIFY AN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
5,085 | <ASSISTANT_TASK:>
Python Code:
from niwidgets import NiWidget
from niwidgets import examplet1 # this is an example T1 dataset
my_widget = NiWidget(examplet1)
my_widget.nifti_plotter()
from niwidgets import examplezmap # this is an example statistical map from neurosynth
import nilearn.plotting as nip
my_widget = Ni... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Default plotting function
Step2: Custom plotting functions
|
5,086 | <ASSISTANT_TASK:>
Python Code:
import functools
import matplotlib.pyplot as plt
import numpy as np
import operator
import seaborn as sns
np.random.seed(sum(map(ord, 'hm2')))
# list available fonts: [f.name for f in matplotlib.font_manager.fontManager.ttflist]
plt.rc('font', family='DejaVu Sans')
dataset_6_to_4 = [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: draw result
Step2: (d)
Step3: Maximum a Posteriori Probability Estimation
|
5,087 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%pylab inline
# We will use the Inside AirBnB dataset from here on
df = pd.read_csv('data/sf_listings.csv')
df.head()
df.room_type.value_counts().plot.bar()
# Since SF doesn't have many neighborhoods (comparatively)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Scatterplot Matrix
Step2: Interesting insights from the scatter matrix
Step3: Extra!
Step4: Lets try to only show the 10 neighborhoods with t... |
5,088 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import json
from pandas.io.json import json_normalize
# define json string
data = [{'state': 'Florida',
'shortname': 'FL',
'info': {'governor': 'Rick Scott'},
'counties': [{'name': 'Dade', 'population': 12345},
{'name... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: imports for Python, Pandas
Step2: JSON example, with string
Step3: JSON example, with file
Step4: JSON exercise
|
5,089 | <ASSISTANT_TASK:>
Python Code:
# Load pickled data
import pickle
# TODO: Fill this in based on where you saved the training and testing data
training_file = 'traffic-signs-data/train.p'
validating_file = 'traffic-signs-data/valid.p'
testing_file = 'traffic-signs-data/test.p'
with open(training_file, mode='rb') as 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: Step 1
Step2: Include an exploratory visualization of the dataset
Step3: Train data
Step4: Step 2
Step5: Model Architecture
Step6: Train, V... |
5,090 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn.metrics import confusion_matrix, f1_score
from utils import accuracy, accuracy_adjacent, display_cm, facies_labels
PRED = pd.read_csv('prediction_depths.csv')
PRED.set_index(["Well 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:
Step2: Using globals. I am a miserable person.
Step3: Look more closely at LA Team
|
5,091 | <ASSISTANT_TASK:>
Python Code::
import catboost as cb
#Create datasets
train_dataset = cb.Pool(X_train,y_train, cat_features=categorical_indicies)
eval_dataset = cb.Pool(X_val,y_val, cat_features=categorical_indicies)
model = cb.CatBoostClassifier(iterations=1000,
loss_function='Logloss',... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
5,092 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-2', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributo... | <SYSTEM_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... |
5,093 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
#Dont import matplotlib until we get to histogram example
import matplotlib.pyplot as plt
#This next line tells jupyter to plot it in the same space
%matplotlib inline
table = pd.read_excel("GASISData.xls")
table.head()
table['PLAYNAME']
table['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: Use pd.read_excel in order to open file. If it says file not found, then make sure your directory is correct
Step2: Lets say we want to see the... |
5,094 | <ASSISTANT_TASK:>
Python Code:
# Install necessary Python libraries and restart your kernel after.
!python -m pip install -r ../requirements.txt
# TODO(developer): Fill these variables with your values before running the sample
PROJECT_ID = "YOUR_PROJECT_ID_HERE"
LOCATION = "us" # Format is 'us' or 'eu'
PROCESSOR_ID ... | <SYSTEM_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 your Processor Variables
Step3: Now let's define the function to process the document with Document AI Python client
Step4: We can now run... |
5,095 | <ASSISTANT_TASK:>
Python Code:
n = 20 #number of coupons
mu = 1/n #this is the mean coupon probability
sigma = mu/2 #this is the std dev parameter we will play around with - it seems to make sense to express it in terms of the mean
x = np.arange(n)+0.5 #arange goes from 0 to n-1, and I want it to go from 1 to n
p_x = 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: Notice that as we decreased the standard deviation (from half of the mean to a tenth of the mean) our spread of probabilities got a lot smaller.... |
5,096 | <ASSISTANT_TASK:>
Python Code:
from dipy.reconst.dti import fractional_anisotropy, color_fa
from argparse import ArgumentParser
from scipy import ndimage
import os
import re
import numpy as np
import nibabel as nb
import sys
import matplotlib
matplotlib.use('Agg') # very important above pyplot import
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:
Step2: Subsampling
Step3: Results
|
5,097 | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import exists
filename = 'modsim.py'
if not exists(filename):
from urllib.request import urlretrieve
url = 'https://raw.githubusercontent.com/A... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the previous chapter we developed a model of the flight of a
Step2: range_func makes a new System object with the given value of
Step3: And... |
5,098 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from matplotlib.image import imread
import tensorflow as tf
import numpy as np
import sys
import os
tf.__version__
import knifey
from knifey import img_size, img_size_flat, img_shape, num_classes, num_channels
# knifey.data_dir = "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: This was developed using Python 3.6 (Anaconda) and TensorFlow version
Step2: Load Data
Step3: The data dimensions have already been defined in... |
5,099 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import timeit
help('numpy.random.randint')
data = pd.DataFrame(data=np.random.randint(1,10,1000),columns=['value'])
data.describe()
np.median(a=data['value'])
setup = '''
import pandas as pd
import numpy as np
data = pd.DataFrame(data=np.random.ra... | <SYSTEM_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 panda data frame with 1000 values randomly 1 <= x < 10. Uniform random?
Step2: Could also use np.random.normal for some statistical f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.