Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
6,400 | <ASSISTANT_TASK:>
Python Code:
import quantecon as qe
import numpy as np
import scipy.linalg as la
import matplotlib.pyplot as plt
%matplotlib inline
np.set_printoptions(suppress=True, precision=4)
# Possible parameters
# alpha, beta, rho1, rho2, sigma
params = [[10.0, 0.95, 1.2, -0.3, 1.0],
[10.0, 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: Plan of the notebook
Step2: It turns out that the bliss level of consumption $\gamma$ in the utility function $-.5 (c_t -\gamma)^2$
Step3: Now... |
6,401 | <ASSISTANT_TASK:>
Python Code:
pip install pyschedule
# Load pyschedule and create a scenario with ten steps planning horizon
from pyschedule import Scenario, solvers, plotters
S = Scenario('hello_pyschedule',horizon=10)
# Create two resources
Alice, Bob = S.Resource('Alice'), S.Resource('Bob')
# Create three tasks wi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here is a hello world example, you can also find this document as a <a href="https
Step2: In this example we use a makespan objective which mea... |
6,402 | <ASSISTANT_TASK:>
Python Code:
PROJECT = !(gcloud config get-value core/project)
PROJECT = PROJECT[0]
%env PROJECT=$PROJECT
!bq mk movielens
%%bash
rm -r bqml_data
mkdir bqml_data
cd bqml_data
curl -O 'http://files.grouplens.org/datasets/movielens/ml-20m.zip'
unzip ml-20m.zip
yes | bq rm -r $PROJECT:movielens
bq --loc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import the dataset and trained model
Step2: And create a cleaned movielens.movies table.
Step3: Next, copy over the trained recommendation mod... |
6,403 | <ASSISTANT_TASK:>
Python Code:
data_reduced_genus = pd.read_csv(MAIN_DIR + "results/reduced_data--genus_only.csv")
abundance_utils.filter_by_abundance(data=data_reduced_genus,
abundance_column='fraction of reads', high=1, low=0.5).head()
data_reduced_genus.head()
# Change 'other' to 'other & unkno... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Demo plot_heatmap()
Step2: Run plot_heatmap_genus() across broad conditions
Step3: heatmap_from_taxa_dict()
Step4: 170313 add bar plots of th... |
6,404 | <ASSISTANT_TASK:>
Python Code:
from time import sleep
def V_idg(N, p, kT, cost=0):
sleep(cost)
return N * kT / p
def compute_volume(job):
print('compute volume', job)
V = V_idg(cost=1, **job.statepoint())
job.document['V'] = V
with open(job.fn('V.txt'), 'w') as file:
file.write(str(V) +... | <SYSTEM_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 useful to think of each modification of the workspace, that includes addition, modification, and removal of data, in terms of an operation... |
6,405 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
vp_path = os.path.abspath('../../')
if not vp_path in sys.path:
sys.path.append(vp_path)
import vampyre as vp
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
# Parameters
nz0 = 1000 # number of components of z0
nz1 = 500... | <SYSTEM_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 also load the other packages we will use in this demo. This could be done before the above import.
Step2: Generating Synthetic Data
St... |
6,406 | <ASSISTANT_TASK:>
Python Code:
import os
# A comma-delimited list of the words you want to train for.
# The options are: yes,no,up,down,left,right,on,off,stop,go
# All other words will be used to train an "unknown" category.
os.environ["WANTED_WORDS"] = "yes,no"
# The number of steps and learning rates can be specified... | <SYSTEM_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 dependencies
Step2: We'll also clone the TensorFlow repository, which contains the scripts that train and freeze the model.
Step3: Loa... |
6,407 | <ASSISTANT_TASK:>
Python Code:
nodes = pd.read_pickle("cachenodes.pkl")
edges = pd.read_pickle("edges.pkl")
comp_nodes = pd.read_pickle("comp_nodes.pkl")
def build_topology(nodes, edges):
topology = nx.Graph()
# add all nodes
for index, row in nodes.iterrows():
node_name = row["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: Build topology
Step2: Calculate shortest path for every pair of computational nodes
Step3: Actually do the work
Step10: Calculate feature lis... |
6,408 | <ASSISTANT_TASK:>
Python Code:
w_412 = 0.56
w_443 = 0.73
w_490 = 0.71
w_510 = 0.36
w_560 = 0.01
run_id = '0000000-150630000034908-oozie-oozi-W'
run_meta = 'http://sb-10-16-10-55.dev.terradue.int:50075/streamFile/ciop/run/participant-c/0000000-150630000034908-oozie-oozi-W/results.metalink?'
participant = 'participant-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: Run
Step2: Define all imports in a single cell
Step3: Manage run results
Step4: Number of points extracted from MERIS level 2 products
Step5:... |
6,409 | <ASSISTANT_TASK:>
Python Code:
import os
import urllib
import zipfile
if not os.path.exists("char_lstm.zip"):
urllib.urlretrieve("http://data.mxnet.io/data/char_lstm.zip", "char_lstm.zip")
with zipfile.ZipFile("char_lstm.zip","r") as f:
f.extractall("./")
with open('obama.txt', 'r') as f:
print f.read(... | <SYSTEM_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 a few utility functions to pre-process the dataset.
Step3: Create LSTM Model
Step4: Train
Step5: Then we can train with the st... |
6,410 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
ecom = pd.read_csv('Ecommerce Purchases')
ecom.head()
ecom.info()
ecom['Purchase Price'].mean()
ecom['Purchase Price'].max()
ecom['Purchase Price'].min()
ecom[ecom['Language'] == 'en'].count()
ecom[ecom['Job'] =='Lawyer'].info()
ecom['AM or PM'].value_counts()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Check the head of the DataFrame.
Step2: How many rows and columns are there?
Step3: What is the average Purchase Price?
Step4: What were the ... |
6,411 | <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: ファッションMNISTデータセットのロード
Step3: ロードしたデータセットは、NumPy配列になります。
Step4: データの観察
Step5: 同様に、訓練用データセットには60,000個のラベルが含まれま... |
6,412 | <ASSISTANT_TASK:>
Python Code:
import os
import csv
import codecs
import string
TRAINSET_PATH = '../data/train/'
TESTSET_PATH = '../data/test/'
LINGSPAM_TRAIN_CSV_PATH = TRAINSET_PATH + 'lingspam_train.csv'
LINGSPAM_TEST_CSV_PATH = TESTSET_PATH + 'lingspam_test.csv'
def generate_trainset(input_dir, output_path):
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: We can't really run the above code in this notebook since it's hard to upload the dataset folders to colab. So I run this script offline and gen... |
6,413 | <ASSISTANT_TASK:>
Python Code:
input_node = ak.ImageInput()
output_node = ak.Normalization()(input_node)
output_node1 = ak.ConvBlock()(output_node)
output_node2 = ak.ResNetBlock(version="v2")(output_node)
output_node = ak.Merge()([output_node1, output_node2])
output_node = ak.ClassificationHead()(output_node)
auto_mode... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Whild building the model, the blocks used need to follow this topology
Step2: For multiple input nodes and multiple heads search space, you can... |
6,414 | <ASSISTANT_TASK:>
Python Code:
from openhunt.mordorutils import *
spark = get_spark()
sd_file = "https://raw.githubusercontent.com/OTRF/Security-Datasets/master/datasets/atomic/windows/defense_evasion/host/empire_enable_rdp.tar.gz"
registerMordorSQLTable(spark, sd_file, "sdTable")
df = spark.sql(
'''
SELECT `@timesta... | <SYSTEM_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 Security Dataset
Step2: Analytic I
|
6,415 | <ASSISTANT_TASK:>
Python Code:
import pypsa
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
%matplotlib inline
plt.rc("figure", figsize=(8, 8))
network = pypsa.examples.ac_dc_meshed(from_master=True)
# get current type (AC or DC) of the lines from the buses
li... | <SYSTEM_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 inspect the topology of the network. Therefore use the function determine_network_topology and inspect the subnetworks in network.sub_network... |
6,416 | <ASSISTANT_TASK:>
Python Code:
from os.path import join
adaptor_cleanup_dir = '/path/to/output/cleanup_dir/'
closed_ref_output = '/path/to/closed_ref_output/'
gg_ref_fna = '/path/to/greengenes/97_otus.fasta'
gg_ref_tax = '/path/to/greengenes/97_otu_taxonomy.txt'
silva_ref_fna = '/path/to/silva/Silva_123_rep_set97.fna'
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Greengenes 13.8
Step2: Silva123
|
6,417 | <ASSISTANT_TASK:>
Python Code:
x = 15
def func():
print(x)
func()
y = 15
def modify():
y = 20
print(y)
modify()
print(y)
z = 15
def modify_global():
global z
z = 20
print(z)
modify_global()
print(z)
def modify_define_global():
global var
var = 34
print(var)
modify_define_global()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 在函数的局部作用域中可以访问到全局作用域中的变量x,但是需要注意的是这里的访问是读去x的值,下面我们试一试,如果在函数中写全局变量会怎么样
Step2: 我们可以看到,在modify函数中对y变量进行赋值,但是在全局作用域中打印y的值,发现全局变量y并没有被modify函数修改。
St... |
6,418 | <ASSISTANT_TASK:>
Python Code:
class BernoulliBandit:
def __init__(self, n_actions=5):
self._probs = np.random.random(n_actions)
np.random.seed(1234)
@property
def action_count(self):
return len(self._probs)
def pull(self, action):
if np.any(np.random.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:
Step5: Bernoulli Bandit
Step6: Epsilon-greedy agent
Step7: UCB Agent
Step8: Thompson sampling
Step9: Submit to coursera
|
6,419 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import graphlab
import math
import string
products = graphlab.SFrame('amazon_baby.gl/')
products
products[269]
def remove_punctuation(text):
import string
return text.translate(None, string.punctuation)
review_without_punctuation = products['re... | <SYSTEM_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: Now, let us see a preview of what the dataset looks like.
Step3: Build the word count vector for each review
Step4: N... |
6,420 | <ASSISTANT_TASK:>
Python Code:
import eex
import os
import pandas as pd
import numpy as np
# Create empty data layer
dl = eex.datalayer.DataLayer("butane", backend="Memory")
dl.summary()
First, we add atoms to the system. Atoms have associated metadata. The possible atom metadata is listed here.
dl.list_valid_atom_prop... | <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: Demo - Storing information in EEX
Step8: Storing force field information
Step9: Alternatively, these could have been set directly as pairs wit... |
6,421 | <ASSISTANT_TASK:>
Python Code:
# source1: web
df_breed = pd.read_csv("breed_nick_names.txt",names=['breed_info'])
df_breed.head()
df_breed.shape
breeds_info = df_breed['breed_info'].values
breed_dict = {}
for breed in breeds_info:
temp = breed.lower()
temp = re.findall('\d.\s+(\D*)', temp)[0]
temp = temp.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: for poodles
Step2: Save intermediate import dictionaries and results
Step3: Get breed scores
|
6,422 | <ASSISTANT_TASK:>
Python Code:
# "pip install ml_insights" in terminal if needed
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import ml_insights as mli
%matplotlib inline
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metri... | <SYSTEM_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 next few cells, we load in some data, inspect it, select columns for our features and outcome (mortality) and fill in missing values with... |
6,423 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
a_1d = np.array ([0, 1, 2, 3]) # a vector
print a_1d
b_1d = np.array ([4, 5, 6, 7]) # another vector
print b_1d
print a_1d + b_1d
print 5*a_1d
print a_1d**2
# Append '?' to get help on a specific routine
np.array?
# Search for key text
np.lookfor ("creating array")
# ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Numpy provides some natural types and operations on arrays. For instance
Step2: Getting help. By the way, if you need help getting documentatio... |
6,424 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
x = np.arange(-5,5.01,0.5)
y1 = 1*x + 1.5 +np.random.normal(0, 1, len(x))
y2 = 2*x +np.random.normal(0, 1, len(x))
plt.figure()
plt.plot(x, y1)
plt.show()
#plt.savefig("path/to/plot.png")
plt.close()
plt.figure()
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: Diese nächste Linie ist nur um plots in jupyter notebooks zu darstellen
Step2: Zuerst generieren wir daten für die plots
Step3: Daten plotten
... |
6,425 | <ASSISTANT_TASK:>
Python Code:
!pip install smt
%matplotlib inline
from math import exp
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors
from mpl_toolkits.mplot3d import Axes3D
from scipy.stats import norm
from scipy.optimize import minimize
import scipy
import six
from smt.application... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Definition of the plot function
Step2: Local minimum trap
Step3: On this 1D test case, 4 iterations are required to find the global minimum, e... |
6,426 | <ASSISTANT_TASK:>
Python Code:
# Define the Markov transition matrix for serially correlated unemployment
unemp_length = 5 # Averange length of unemployment spell
urate_good = 0.05 # Unemployment rate when economy is in good state
urate_bad = 0.12 # Unemployment rate when economy is in bad state
bust_prob = 0.01 # ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Several variant examples of the model will be illustrated below such that
Step2: Note that $\texttt{MarkovConsumerType}$ currently has no metho... |
6,427 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image(filename='entity_extraction_process.png')
# Note: this image is taken from NLTK Book and requires citation
# Importing NLTK Dependencies
import nltk, re
from nltk import word_tokenize, pos_tag, ne_chunk
from nltk.tokenize.punkt import PunktSentence... | <SYSTEM_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
Step2: Loading the data
Step3: Converting the rawtext into sentences
Step4: Task 1
Step5: Task 2
Step6: Entity Extraction
Step7: ... |
6,428 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from matplotlib.pylab import *
from pymc3 import *
import numpy as np
d = np.random.normal(size=(3, 30))
d1 = d[0] + 4
d2 = d[1] + 4
yd = .2*d1 +.3*d2 + d[2]
lam = 3
with Model() as model:
s = Exponential('s', 1)
tau = Uniform('tau', 0, 1000)
b = lam * tau
... | <SYSTEM_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 define the random variables.
Step2: For most samplers, including Metropolis and HamiltonianMC, simply pass a list of variables to sample a... |
6,429 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
from matplotlib import rcParams
rcParams["figure.figsize"] = (14, 5)
from pyke import LightCurve
lc = LightCurve(time=[1, 2, 3], flux=[78.4, 79.6, 76.5])
from pyke import KeplerLightCurveFile
lcfile = KeplerLightCurveFile("https://ar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introducing a generic LightCurve class
Step2: A LightCurve object provides easy access to a range of common operations, such as fold(), flatten... |
6,430 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('home_data.gl/')
sales.head(5)
graphlab.canvas.set_target('ipynb')
sales.show(view="Scatter Plot", x="sqft_living", y="price")
train_data,test_data = sales.random_split(.8,seed=123)
sqft_model = graphlab.linear_regression.create(train_data, tar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data and exploring the data
Step2: exploring the data let's visualize few rows of data with the head()
Step3: Exploring the data for hous... |
6,431 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import warnings
from inet import DataLoader, __version__
from inet.motifs import iicounter
from inet.utils import II_slice
print('Inet version {}'.format(__version__))
# use filenames in the dataset to read list of distances to be read
mydataset = DataLoader('../data/PV')
pv... | <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: <H2> Load all distances from connected PV cells</H2>
Step4: <H2>Distances in recurrently connected inhibitory neurons</H2>
|
6,432 | <ASSISTANT_TASK:>
Python Code:
# Standard Python libraries
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import time
import numpy as np
import glob
import matplotlib.pyplot as plt
import PIL
import imageio
from IPython import display
import sklearn
import seaborn as sns
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: Estimators
Step2: Data preprocessing <a class="anchor" id="preprocess"></a>
Step5: One-hot encoding for Autompg <a class="anchor" id="preproce... |
6,433 | <ASSISTANT_TASK:>
Python Code:
!conda list |grep -i torch
from torchvision.models.resnet import resnet50
model = resnet50(pretrained=True)
from clipper_admin import ClipperConnection, DockerContainerManager
clipper_conn = ClipperConnection(DockerContainerManager())
clipper_conn.start_clipper(cache_size=1) # Disable ... | <SYSTEM_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 a pretrained PyTorch model(ResNet50)
Step2: Initialize the Clipper cluster
Step3: Define 'predict' function
Step4: Deploy PyTorch model ... |
6,434 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import seaborn as sns
import random
%matplotlib inline
AlleDaten = "AlleDaten.csv"
with open(AlleDaten, "r") as infile:
AlleDaten = pd.DataFrame.from_csv(infile, sep=",")
print(All... | <SYSTEM_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. Start
Step2: Genauerer Blick in die Daten
Step3: Aufteilung der Daten in zwei Gruppen
Step4: 3. Auswählen eine Suchanfrage
Step5: Jetzt n... |
6,435 | <ASSISTANT_TASK:>
Python Code:
import graphlab
products = graphlab.SFrame('amazon_baby_subset.gl/')
products['sentiment']
products.head(10)['name']
print '# of positive reviews =', len(products[products['sentiment']==1])
print '# of negative reviews =', len(products[products['sentiment']==-1])
import json
with open... | <SYSTEM_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 review dataset
Step2: One column of this dataset is 'sentiment', corresponding to the class label with +1 indicating a review with positiv... |
6,436 | <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: Eager Execution
Step2: Now you can run TensorFlow operations and the results will return immediately
Step3: Enabling eager execution changes h... |
6,437 | <ASSISTANT_TASK:>
Python Code:
from os import path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.forward import make_forward_dipole
from mne.evoked import combine_evoked
from mne.simulation import simulate_evoked
from nilearn.plotting import plot_anat
from nilearn.datasets import load_mni... | <SYSTEM_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 localize the N100m (using MEG only)
Step2: Plot the result in 3D brain with the MRI image using Nilearn
Step3: Calculate and visualise m... |
6,438 | <ASSISTANT_TASK:>
Python Code:
def solvent_langevin(system, kT, gamma):
'''
Implicit solvation model based on Langevin dynamics (Rouse model).
'''
system.thermostat.set_langevin(kT=kT, gamma=gamma, seed=42)
def solvent_lbm(system, kT, gamma):
'''
Lattice-based solvation model based on the LBM (Z... | <SYSTEM_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. Simulating the polymer
Step2: 3. Data analysis
Step3: 3.1 Distance-based macromolecular properties
Step4: Plot the radius of gyration $R_g... |
6,439 | <ASSISTANT_TASK:>
Python Code:
t0 = time.time()
datapath = '/Users/jorgecastanon/Documents/github/w2v/data/tweets.gz'
tweets = sqlContext.read.json(datapath)
tweets.registerTempTable("tweets")
twr = tweets.count()
print "Number of tweets read: ", twr
# this line add ~7 seconds (from ~24.5 seconds to ~31.5 seconds)
# 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: Read Keywords
Step2: Use Spark SQL to Filter Tweets
Step3: Parse Tweets and Remove Stop Words
Step4: Word2Vec
Step5: Find top N closest word... |
6,440 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import matplotlib.pyplot as plt
%matplotlib notebook
from keras.datasets import mnist
# load data...
(X_train, y_train), (X_test, y_test) = mnist.load_data()
# check dimensions...
print('Train: ', X_train.shape, y_train.shape)
print('Test: ', X_test.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import the MNIST dataset using the keras api
Step2: Looks like we have 60k images of 28, 28 pixels. These images are single-channel, i.e. blac... |
6,441 | <ASSISTANT_TASK:>
Python Code:
from ambry import get_library
l = get_library()
b = l.bundle('cdph.ca.gov-hci-0.0.2')
w = b.warehouse('hci_counties')
w.clean()
print w.dsn
w.query(
-- Get only counties in California
CREATE VIEW geo AS SELECT gvid, name AS county_name, geometry FROM census.gov-tiger-2015-counties
WHERE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: First, create a set of views to limit the individual indicators to one record per county. The Ambry SQL parser is
Step4: Now we can run a quer... |
6,442 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
import thinkstats2
import thinkplot
import pandas as pd
import numpy as np
import statsmodels.formula.api as smf
%matplotlib inline
names = ['year', 'mager9', 'restatus', 'mbrace', 'mhisp_r',
'mar_p', 'dmar', 'meduc', 'fagerrec11', ... | <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: Trivers-Willard
Step3: I have to recode sex as 0 or 1 to make logit happy.
Step4: All births are from 2014.
Step5: Mother's age
Step6: Resid... |
6,443 | <ASSISTANT_TASK:>
Python Code:
lasso = Lasso(random_state=1, max_iter=10000)
lasso.fit(X_train_std, y_train)
rmse(y_test, lasso.predict(X_test_std))
scores = cross_val_score(cv=10, estimator = lasso, scoring="neg_mean_squared_error", X=X_train_std, y = y_train)
scores = np.sqrt(-scores)
scores
from sklearn import line... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This rmse score seems reasonable. Find cross validation scores.
|
6,444 | <ASSISTANT_TASK:>
Python Code:
array1 = np.array([1, 2, 3, 4])
array2 = np.array([[1, 2], [3, 4]])
print type(array1), '\n', array1
print type(array2), '\n', array2
array3 = np.arange(1, 4)
print array3, type(array3)
# 0 ~ 10의 범위를 5등분
array4 = np.linspace(0, 10, 5)
print array4
print np.zeros((3, 5))
print np.zeros(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: arange
Step2: linspace(start, end, n)
Step3: np.zeros((x, y))
Step4: np.ones((x, y))
Step5: random sub package
Step6: ()
Step7: seed(n)
S... |
6,445 | <ASSISTANT_TASK:>
Python Code:
# เรียกใช้ไลบรารี่ที่จำเป็น
%matplotlib inline
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from sklearn import datasets
from __future__ import unicode_literals
matplotlib.rc('font', family='Garuda')
np.random.seed(2)
iris = datasets.load_iris()
# X เป็น array 150x... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: จะเห็นว่าตัวอย่างดอกไม้แต่ละประเภทเกาะกลุ่มกัน แปลว่าปัญหาการจำแนกประเภทอันนี้ไม่ยากมากนัก ขอเสริมอีกหน่อย หากลองเทียบกับข้อมูลต่อไปนี้ (ข้อมูลเ... |
6,446 | <ASSISTANT_TASK:>
Python Code:
from lightning import Lightning
from numpy import random
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')
states = ["NA", "AK", "AL", "AR", "AZ", "CA", "CO","CT",
"DC","DE","FL","GA","HI","IA","ID","IL","IN",
"KS","KY","LA","MA","MD","ME","MI","M... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Connect to server
Step2: <hr> US Map
Step3: Discrete values are automatically handled for appriopriate colormaps
Step4: Including our custom ... |
6,447 | <ASSISTANT_TASK:>
Python Code:
# imports
import pandas
import matplotlib.pyplot as plt
from timeit import default_timer as timer
from sklearn.cross_validation import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.grid_search import GridSearchCV
# load dataset from task 1
url = "https:... | <SYSTEM_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 we load the iris data from task 1 and split it into training and validation set.
Step2: Then we specify our parameter space and performan... |
6,448 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('YbNE3zhtsoo', width=800, height=450)
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.python import keras
from tensorflow.python.keras.models import Sequential
from tensorflo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sample Code
|
6,449 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Migrate early stopping
Step2: TensorFlow 1
Step3: In TensorFlow 1, early stopping works by setting up an early stopping hook with tf.estimator... |
6,450 | <ASSISTANT_TASK:>
Python Code:
# Python built in support for TCP sockets
import socket
# this just opens a 'porthole' out from my computer
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# this connects me to the other computer
mysock.connect(('www.py4inf.com', 80))
import socket
mysock = socket.socket(sock... | <SYSTEM_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 write a browser
Step2: Now make the same thing easier with another library
Step3: Doing the assignment
|
6,451 | <ASSISTANT_TASK:>
Python Code:
from nltk.corpus import stopwords
import string
from transform.normalizer import *
from transform.parser import *
from match.match import *
import inspect
import jellyfish
from retrieve.search import *
punctuation = set(string.punctuation)
language = 'portuguese'
prefix_file = '../data/p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First, let's read the data that we're going to use to normalize and parse the addresses
Step2: punctuation is the file with the punctuation cha... |
6,452 | <ASSISTANT_TASK:>
Python Code:
preamble = np.array([1,0,0,0,1,0,1,1], dtype = 'uint8')
preamble_detect = np.where(np.abs(np.correlate(2*bits.astype('int')-1, 2*preamble.astype('int')-1)) == 8)[0]
preamble_offset = np.argmax(np.histogram(preamble_detect % subframe_size, bins = np.arange(0,subframe_size))[0])
subframes =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Most subframes do not have valid parity, as shown below. We use a weaker heuristic, where only parity of TLM and HOW words are required to be va... |
6,453 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from pydiffexp import DEAnalysis
test_path = "/Users/jfinkle/Documents/Northwestern/MoDyLS/Python/sprouty/data/raw_data/all_data_formatted.csv"
raw_data = pd.read_csv(test_path, index_col=0)
# Initialize analysis object with data. Data is retained
'''
The hierarchy 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: Load Data
Step2: Let's look at the data that has been added to the object. Notice that the columns are a Multiindex in which the levels corresp... |
6,454 | <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: TFP 확률적 계층
Step2: 빠르게 처리하세요!
Step3: 참고
Step4: 위의 preprocess()는 image가 아닌 image, image를 반환합니다. Keras는 (example, label) 입력 형식, 즉 $p\theta(y|x)$... |
6,455 | <ASSISTANT_TASK:>
Python Code:
!apt-get install libsdl2-dev
!apt-get install libosmesa6-dev
!apt-get install libffi-dev
!apt-get install gettext
!apt-get install python3-numpy-dev python3-dev
BAZEL_VERSION = '3.6.0'
!wget https://github.com/bazelbuild/bazel/releases/download/{BAZEL_VERSION}/bazel-{BAZEL_VERSION}-insta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bazel
Step2: DeepMind Lab
Step3: Python dependencies
Step11: Imports and Utils
Step12: Experiment
Step13: Learning
Step14: Evaluation
|
6,456 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/kc_house_data.gl')
import numpy as np # note this allows us to refer to numpy as np instead
def get_numpy_data(data_sframe, features, output):
data_sframe['constant'] = 1 # this is how you add a constant column to an SFrame... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in house sales data
Step2: If we want to do any "feature engineering" like creating new features or adjusting existing ones we should do t... |
6,457 | <ASSISTANT_TASK:>
Python Code:
# reprodução do ia898:conv com alterações para ilustrar o tutorial
import numpy as np
import sys,os
ia898path = os.path.abspath('../')
if ia898path not in sys.path:
sys.path.append(ia898path)
#import ia898.src as ia
def iaconvdemo(f,h):
f, h = np.asarray(f), np.asarray(h,float)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ilustração da convolução 1D
Step2: Ilustração da convolução 2D
Step3: Ilustração com imagem
|
6,458 | <ASSISTANT_TASK:>
Python Code:
attendance106 = ia.attendance_tables(106)
attendance106.groupby('Organization') \
.count()['First Name'] \
.sort_values(ascending=False)[:30]
attendance106['Organization'].dropna().unique().shape
N = 250
topN = attendance106.groupby('Organization')\
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: What organizations are best represented?
Step2: Even in this short list, there are repeat names. We need to apply entity resolution.
Step3: Th... |
6,459 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
INDEX = ['Boiling point of He',
'Boiling point of N',
'Melting point of H2O',
'Body temperature',
'Boiling point of H2O']
X = np.array([-452.1, -320.4, 32.0, 98.6, 212.0])
Y = np.array([4.22, 77.36, 273.2, 310.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: Our data set
Step2: Show our data set in a table
Step3: Model - linear regression
Step4: How good is our guess?
Step7: Reducing the error
St... |
6,460 | <ASSISTANT_TASK:>
Python Code:
from second_folio import (all_repos)
all_repos[:5]
len(all_repos)
repo_name = all_repos[0]
repos = all_repos[:]
def status_for_repo(repo_name):
rs = GitenbergJob(username=username, password=password, repo_name=repo_name,
repo_owner='GITenberg',
update_trav... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: gitenberg for book metadata
Step2: changes to make in metadata file to initialize it
Step3: next step
Step4: create test parameters for travi... |
6,461 | <ASSISTANT_TASK:>
Python Code:
# add intercept=1 for x0
X = np.insert(raw_X, 0, values=np.ones(raw_X.shape[0]), axis=1)
X.shape
# y have 10 categories here. 1..10, they represent digit 0 as category 10 because matlab index start at 1
# I'll ditit 0, index 0 again
y_matrix = []
for k in range(1, 11):
y_matrix.append... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: train 1 model
Step2: Is this real......
Step3: making prediction
|
6,462 | <ASSISTANT_TASK:>
Python Code:
def ins_sort(k):
for i in range(1,len(k)): #since we want to swap an item with previous one, we start from 1
j = i #because we need 2 indexes as one will reduce and we do not want to affect i
while j > 0 and k[j] < k[j-1]: #j>... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mergesort
Step2: sorted()
Step3: Python has sorting methods built into its standard library.
|
6,463 | <ASSISTANT_TASK:>
Python Code:
import pandas
import collections
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats
import igraph
sif_data = pandas.read_csv("shared/pathway_commons.sif",
sep="\t", names=["species1","interaction_type","species2"])
interaction_types_ppi = 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: Step 1
Step2: Step 2
Step3: Step 3
Step4: Since iterating is reasonably fast in Python, you could also do this using a for loop through all o... |
6,464 | <ASSISTANT_TASK:>
Python Code:
# Author: Marijn van Vliet <w.m.vanvliet@gmail.com>
# Roman Goj <roman.goj@gmail.com>
# Denis Engemann <denis.engemann@gmail.com>
# Stefan Appelhoff <stefan.appelhoff@mailbox.org>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
import mne
from m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading the raw data and creating epochs
Step2: We are interested in the beta band. Define a range of frequencies, using a
Step3: Computing th... |
6,465 | <ASSISTANT_TASK:>
Python Code:
F_1 = Matrix( [4,0] )
F_2 = Matrix( [5*cos(30*pi/180), 5*sin(30*pi/180) ] )
F_net = F_1 + F_2
F_net # in Newtons
F_net.evalf() # in Newtons
F_net.norm().evalf() # |F_net| in [N]
(atan2( F_net[1],F_net[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: To express the answer in length-and-direction notation,
Step2: The net force on the object is $\vec{F}_{\textrm{net}}= 8.697\angle 16.7^\circ$[... |
6,466 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
print(np.sin(np.deg2rad(21)))
import numpy as np
stu1 = 80.0
stu2 = 90.0
stu3 = 66.5
ave = (stu1 + stu2 + stu3)/3
print("Student scores:")
print(stu1)
print(stu2)
print(stu3)
print("Average: %f" %ave)
n1, lef1 = divmod(32,5)
n2, lef2 = divmod(45,7)
n3, lef3 = divmod(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: Exercise 2
Step2: Exercise 3
|
6,467 | <ASSISTANT_TASK:>
Python Code:
# Imports the functionality that we need to display YouTube videos in a Jupyter Notebook.
# You need to run this cell before you run ANY of the YouTube videos.
from IPython.display import YouTubeVideo
# WATCH THE VIDEO IN FULL-SCREEN MODE
YouTubeVideo("fF841G53fGo",width=640,height=360... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Some possibly useful links
Step2: Tutorial on functions in python
Step3: Question 3
Step5: Assignment wrapup
|
6,468 | <ASSISTANT_TASK:>
Python Code:
import gammalib
import ctools
import cscripts
%matplotlib inline
import matplotlib.pyplot as plt
obsfile = 'obs_crab_selected.xml'
emin = 0.66
emax = 100.0
skymap = ctools.ctskymap()
skymap['inobs'] = obsfile
skymap['proj'] = 'CAR'
skymap['coordsys'] = 'CEL'
skyma... | <SYSTEM_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 use the matplotlib package to display the results.
Step2: We will use the events selected in the previous step. Since the data correspo... |
6,469 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import os
import matplotlib.pyplot as plt
%matplotlib inline
baseball_dir = "lahman-csv_2015-01-24/"
salaries = pd.read_csv(baseball_dir + "Salaries.csv", sep=",")
batting = pd.read_csv(baseball_dir + "Batting.csv", sep=",")
batting.dropna(inplace=Tr... | <SYSTEM_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 are combining the two sheets by linking by player ID below and combines them into one giant table, then create a plot of all data points of b... |
6,470 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'sandbox-3', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("nam... | <SYSTEM_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... |
6,471 | <ASSISTANT_TASK:>
Python Code:
dfnum = pd.read_csv('transformed_numerical_dataset_imputed.csv', index_col=['Dataset','Id'])
dfnum.head()
dfcat = pd.read_csv('cleaned_categorical_vars_with_colz_sorted_by_goodness.csv', index_col=['Dataset','Id'])
dfcat.head()
dfcat.head()
df = pd.concat([dfnum, dfcat.iloc[:, :ncat]], ax... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Recreate transformed (standardized) sale price
Step2: Ordinary Least Squares
Step3: As can be seen below, using more numerical values improves... |
6,472 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import sys
from casadi import *
# Add do_mpc to path. This is not necessary if it was installed via pip
sys.path.append('../../../')
# Import do_mpc package:
import do_mpc
import matplotlib.pyplot as plt
model_type = 'continuous' # either 'discrete' or 'continuous'
mod... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model
Step2: States and control inputs
Step3: The control inputs are the feed $F$ and the heat flow $\dot{Q}$
Step4: ODE and parameters
Step5... |
6,473 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
x_dists = np.array([[ 0, -1, -2],
[ 1, 0, -1],
[ 2, 1, 0]])
y_dists = np.array([[ 0, -1, -2],
[ 1, 0, -1],
[ 2, 1, 0]])
dists = np.vstack(([x_dists.T], [y_dists.T])).T
<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:
|
6,474 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import json
import time
import pickle
import requests
from io import BytesIO
from zipfile import ZipFile
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_ext... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loading the data from the UCI Machine Learning Repository
Step2: Data Exploration
Step3: Since the data is labeled for us, we can do further d... |
6,475 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.integrate import odeint
from matplotlib import rc
import matplotlib.pyplot as plt
%matplotlib inline
rc("text", usetex=True)
rc("font", size=18)
rc("figure", figsize=(6,4))
rc("axes", grid=True)
# Constantes del problema:
M1 = 3
M2 = 3
g = 9.81
# Condiciones... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problema físico
Step2: Todo muy lindo!!
Step3: Ven cómo los distintos métodos van modificando más y más la curva de $r(t)$ a medida que van pa... |
6,476 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import numpy as np
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
from keras.utils import np_utils
from keras impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configure Model
Step2: Load data, shuffle it, and split between test and training sets
Step3: Convert class vectors to binary class matrices
S... |
6,477 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('..')
import socnet as sn
sn.graph_width = 320
sn.graph_height = 180
g = sn.load_graph('3-bellman.gml', has_pos=True)
for n, m in g.edges():
g.edge[n][m]['label'] = g.edge[n][m]['c']
sn.show_graph(g, elab=True)
from math import inf, isinf
s = 0
for n in g... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A seguir, vamos configurar as propriedades visuais
Step2: Por fim, vamos carregar e visualizar um grafo
Step3: Passeios de custo mínimo
Step4:... |
6,478 | <ASSISTANT_TASK:>
Python Code:
from lea import *
# the canonical random variable : a fair coin
faircoin = Lea.fromVals('Head', 'Tail')
# toss the coin a few times
faircoin.random(10)
# Amitabh Bachan's coin from Sholay
sholaycoin = Lea.fromVals('Head', 'Head')
# Amitabh always wins (and, heroically, sacrifices himself ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Summary
Step2: Summary
Step3: Summary
|
6,479 | <ASSISTANT_TASK:>
Python Code:
from pomegranate import *
%pylab inline
d1 = DiscreteDistribution({'A': 0.10, 'C': 0.40, 'G': 0.40, 'T': 0.10})
d2 = ConditionalProbabilityTable([['A', 'A', 0.10],
['A', 'C', 0.50],
['A', 'G', 0.30],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Markov chains have log probability, fit, summarize, and from summaries methods implemented. They do not have classification capabilities by them... |
6,480 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from sklearn import neighbors
df = pd.read_csv('datasets/exam_dataset1.csv', encoding='utf-8')
n_neighbors = 5
X = np.array(df[['exam1','exam2']])
y = np.array(df[['admissio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Logistic Regression
Step2: <br>
Step3: <br>
Step4: Regularization Example
|
6,481 | <ASSISTANT_TASK:>
Python Code:
## Loading the model with `gensim`
# import wrod2vec model from gensim
from gensim.models.word2vec import Word2Vec
# load Google News pre-trained network
model = Word2Vec.load_word2vec_format('GNvectors.bin', binary=True)
pp(model['table'])
plt.plot(model['car'][:50], label = 'car')
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: Continuous representation of words
Step2: Semantically related words have similar representations
Step3: Vector representation similarity = se... |
6,482 | <ASSISTANT_TASK:>
Python Code:
# sphinx_gallery_thumbnail_number = 9
# Authors: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import find_events, fit_dipole
from mne.datasets.brainstorm import bst_phantom_ele... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data were collected with an Elekta Neuromag VectorView system at 1000 Hz
Step2: Data channel array consisted of 204 MEG planor gradiometers... |
6,483 | <ASSISTANT_TASK:>
Python Code:
import hashlib
import os
import pickle
from urllib.request import urlretrieve
import numpy as np
from PIL import Image
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
from sklearn.utils import resample
from tqdm import tqdm
from zipfil... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this... |
6,484 | <ASSISTANT_TASK:>
Python Code:
import formulae as fm
import numpy as np
import pandas as pd
fm.model_description('y ~ x')
fm.model_description('y ~ 0 + x') # same with -1
fm.model_description('1|x')
fm.model_description('a + (1|x)')
fm.model_description('(x | g1 + g2)')
fm.model_description('y ~ a + b - c')
fm.mo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Operator precedence
Step2: Group specific terms (a.k.a random terms)
Step3: Note that if we don't use parenthesis here, formulae will understa... |
6,485 | <ASSISTANT_TASK:>
Python Code:
2+2
san = 2
print san
diego = 2
san + diego
string = "Hello"
decimal = 1.2
list_of_strings = ["a", "b", "c", "d"]
list_of_integers = [1, 2, 3, 4]
list_of_whatever = ["a", 2, "c", 4]
my_phonebook = {'Mom': '713-555-5555', 'Chinese Takeout': '573-555-5555'}
data_file = open("./first-p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: There. You've just written your first Python code. You've entered two integers (the 2's) and added them together using the plus sign operator. N... |
6,486 | <ASSISTANT_TASK:>
Python Code:
import xgboost as xgb
import pandas as pd
from sklearn import *
import matplotlib.pyplot as plt
%matplotlib inline
df_train = pd.read_csv("/data/churn-bigml-80.csv")
df_train.head()
df_train.info()
df_train.Churn.value_counts()
df_train.Churn.value_counts()/len(df_train)
df_train.colum... | <SYSTEM_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 training data
Step2: Let's check number of records, number of columns, types of columns and whether the data contains NULL values.
Ste... |
6,487 | <ASSISTANT_TASK:>
Python Code:
%%writefile server.py
from flask import Flask, request, jsonify
import tempfile
app = Flask(__name__)
@app.route('/pitch_track', methods=['POST'])
def pitch_track():
import parselmouth
# Save the file that was sent, and read it into a parselmouth.Sound
with tempfile.NamedTempo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Normally, we can then run the server typing FLASK_APP=server.py flask run on the command line, as explained in the Flask documentation. Please d... |
6,488 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
# For presentation purposes only.
%matplotlib inline
x = [1, 2, 3, 5] # List of x coordinates.
y = [4, 3, 6, 2] # List of y coordinates.
y_error = [0.1, 0.5, .2, 0.25] # Errors associated with the y readings.
plt.scatter(x, y)
plt.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plotting Datapoints
Step2: Three functions were called during the generation of this plot
Step3: Let's say we wanted a line drawn between the ... |
6,489 | <ASSISTANT_TASK:>
Python Code:
import json
import great_expectations as ge
import great_expectations.jupyter_ux
from great_expectations.datasource.types import BatchKwargs
import datetime
context = ge.data_context.DataContext()
context.list_expectation_suite_names()
expectation_suite_name = # TODO: set to a name fro... | <SYSTEM_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 a DataContext
Step2: 2. Choose an Expectation Suite
Step3: 3. Load a batch of data you want to validate
Step5: 4. Validate the batch w... |
6,490 | <ASSISTANT_TASK:>
Python Code:
def compute_sum(n):
total = 0
for i in range(n):
m = int(input('请输入一个正整数为加数,以回车结束。 '))
total += m
return total
n = int(input('请输入一个正整数为次数,以回车结束。 '))
print ('total=',compute_sum(n))
def computer_sum(num):
total = 1
for i in range(1,num+1):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 以前的:
Step2: 以前的:
Step3: 以前的:
Step4: 以前的:
Step5: 以前的:
Step6: 以前的:
Step7: 6.8 习题
Step8: 6.8 习题
Step9: 6.8 习题
Step10: 6.8 习题
Step11: 6.8 ... |
6,491 | <ASSISTANT_TASK:>
Python Code:
# Importamos todas las librerías que usaremos. Explicación...
%matplotlib inline
import matplotlib.pyplot as plt
from scipy import special
import numpy as np
from ipywidgets import *
# Graficamos funciones de Bessel de orden n = 0,1,...,4
r = np.linspace(0, 10,100)
for n in range(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: Por simplicidad vamos a suponer que $a = 1$ y determinar los ceros, significa encontrar todas las intersecciones de las curvas anteriores con ... |
6,492 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from dillinger.gaussian_process import GaussianProcess
from dillinger.kernel_functions import PeriodicKernel
%matplotlib inline
sns.set(font_scale=1.3, palette='deep', color_codes=True)
np.random.seed(0)
# setting up... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The plot of the GP shows the mean in black, along with confidence intervals in purple. The plot above shows a blank prior.
Step2: The model obj... |
6,493 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import os
import sys
import scipy.io as sio
sys.path.append('../scripts/')
import bicorr as bicorr
import bicorr_e as bicorr_e
import bicorr_math as bicorr_math
%load_ext autoreload
%autoreload 2
data_path = '../datar'
os.listdir(data_pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Look at what I did before
Step2: Import time offset data, build channel lists
Step3: The syntax for calling a value from timeOffsetData is
Ste... |
6,494 | <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: Image classification with TensorFlow Lite Model Maker
Step2: Import the required packages.
Step3: Simple End-to-End Example
Step4: You could ... |
6,495 | <ASSISTANT_TASK:>
Python Code:
# 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 writing, sof... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simple Activation Atlas
Step2: Load model and activations
Step3: Whiten
Step5: Dimensionality reduction
Step6: Feature visualization
Step7: ... |
6,496 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from welly import Well
% matplotlib inline
ls
data_dir = 'data/'
fname = 'L30.las'
file = data_dir + '/' + fname
# your code here
# it should looks like this
well
pslow = well.data['DT']
rhob = well.data['RHOB']
gr = well.data['GRD']
# ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Q
Step2: Q. Write a function that converts slowness (us/m) into velocity (m/s) your code here
Step3: Q. Create an acoustic impedance log
Step4... |
6,497 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.random.seed(113) #set seed before any keras import
import pandas as pd
import random
from sklearn.model_selection import train_test_split
from collections import defaultdict
from keras.preprocessing import sequence
from collections import Counter
import pydot
seed=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: Dataset
Step2: Baseline
Step3: Results
Step4: Neural network
Step6: Text representation
Step7: My model
|
6,498 | <ASSISTANT_TASK:>
Python Code:
import gym
env = gym.make('Blackjack-v0')
STICK = 0
HIT = 1
print(env.observation_space)
print(env.action_space)
for i_episode in range(3):
state = env.reset()
while True:
print(state)
action = env.action_space.sample()
state, reward, done, info ... | <SYSTEM_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 元组:
Step2: 通过运行以下代码单元格进行验证。
Step3: 执行以下代码单元格以按照随机策略玩二十一点。
Step4: 第 1 部分:MC 预测 - 状态值
Step5: 执行以下代码单元格以按照该策略玩二十一点。
Step6: ... |
6,499 | <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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.