Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
7,300 | <ASSISTANT_TASK:>
Python Code:
bits = np.array([0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 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: Trim the data between the 0x7e7e flags. We skip Reed-Solomon decoding, since we are confident that there are no bit errors. We remove the 16 Ree... |
7,301 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pymc3 as pm
import pandas as pd
import seaborn as sns
sns.set(color_codes=True)
np.random.seed(20090425)
drug = (101,100,102,104,102,97,105,105,98,101,100,123,105,103,100,95,102,106,
109,102,82,102,100,102,102,101,102,102,103,103,97,97,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The first step in a Bayesian approach to inference is to specify the full probability model that corresponds to the problem. For this example, K... |
7,302 | <ASSISTANT_TASK:>
Python Code:
def fahr_to_celsius(temp):
return ((temp - 32) * (5/9))
fahr_to_celsius(32)
print('freezing point of water:', fahr_to_celsius(32), 'C')
print('boiling point of water:', fahr_to_celsius(212), 'C')
def celsius_to_kelvin(temp_c):
return temp_c + 273.15
print('freezing point of wate... | <SYSTEM_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 function definition opens with the keyword def followed by the name of the function (fahr_to_celsius) and a parenthesized list of parameter ... |
7,303 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
# load both sheets as new dataframes
shows_df = pd.read_csv("show_category.csv")
views_df = pd.read_excel("views.xls")
shows_df.head()
shows_df = shows_df.set_index('showname')
shows_df.head()
views_df.head()
views_df = views_df.set_index('viewer_id')
views_df.head()... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Change the index to be the showname
Step2: Do the same for views
Step3: Join on shows watched against category
|
7,304 | <ASSISTANT_TASK:>
Python Code:
def parseRaw(json_map):
url = json_map['url']
content = json_map['html']
return (url,content)
import json
import pprint
pp = pprint.PrettyPrinter(indent=2)
path = "./pixnet.txt"
all_content = sc.textFile(path).map(json.loads).map(parseRaw)
def parseImgSrc(x):
try:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 載入原始 RAW Data
Step2: 利用 LXML Parser 來分析文章結構
Step3: 取出 Image Src 的列表
Step4: 統計 Image Src 的列表
Step5: <span style="color
|
7,305 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
matplotlib.style.use('seaborn')
from animerec.data import get_data
users, anime = get_data()
from sklearn.model_selection import train_test_split
train, test = train_test_split(users, test_size = 0.1) #let's split up the... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's plot the objective and see how it decreases.
Step2: So by 50 iterations, the model hits a bend and from there we see incremental improvem... |
7,306 | <ASSISTANT_TASK:>
Python Code:
x = [ [2] * 3 ] * 3
x[0][0] = "ZZ"
print(*x, sep="\n")
out=[[0]*3]*3
print( id(out[0]) )
print( id(out[1]) ) # want to know what "id" is? Why not read the documentation!
a = [2] * 3
x = [a] * 3
print(*x, sep="\n")
print()
a[0] = "ZZ"
print(*x, sep="\n")
x = []
for i in range(3):
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: What I wanted to do was build a nested list, x is supposed to look like
Step2: To see what's happening lets rewrite the code to make the issue ... |
7,307 | <ASSISTANT_TASK:>
Python Code:
import pathlib # for filepath path tooling
import lzma # to decompress the iCOM file
import numpy as np # for array tooling
import matplotlib.pyplot as plt # for plotting
# Makes it so that any changes in pymedphys is automatically
# propagated into the notebook without needing a ker... | <SYSTEM_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 PyMedPhys
Step2: Patient ID Configuration
Step3: File Path Configurations
Step4: Output directories
Step5: MU Density and Gamma co... |
7,308 | <ASSISTANT_TASK:>
Python Code:
import math
import torch
import gpytorch
from matplotlib import pyplot as plt
%matplotlib inline
%load_ext autoreload
%autoreload 2
# Training data is 100 points in [0,1] inclusive regularly spaced
train_x = torch.linspace(0, 1, 100)
# True function is sin(2*pi*x) with Gaussian noise
trai... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Trace the Model
Step2: Compare Predictions from TorchScript model and Torch model
|
7,309 | <ASSISTANT_TASK:>
Python Code:
# Useful Libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
bushels = 15000
spot_symbol = 'CORN'
futures_contract = symbols('CNU16')
spot_prices = get_pricing(spot_symbol, start_date = '2016-06-01', end_date = '2016-09-15', fields = 'price')
futures_prices =... | <SYSTEM_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: We can clearly see that it would have been wiser for the farmer to sell his corn using a futures contract to lock in the pric... |
7,310 | <ASSISTANT_TASK:>
Python Code:
def hamming_dist(s1, s2):
if len(s1) < len(s2):
s1, s2, = s2, s1
dist = 0
for i in range(len(s1)):
if s1[i] != s2[i]:
dist+=1
return dist
hamming_dist('TGCATAT','ATCCGAT')
def normalize_string(text):
import string
text = text.lower... | <SYSTEM_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) Calculate the Edit distance between TGCATAT and ATCCGAT.
Step2: (c) Is there a unique Edit distance in b. If not then find the minimum dist... |
7,311 | <ASSISTANT_TASK:>
Python Code:
from typing import List
def string_xor(a: str, b: str) -> str:
def xor(i, j):
if i == j:
return '0'
else:
return '1'
return ''.join(xor(x, y) for x, y in zip(a, b))
<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:
|
7,312 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from ecell4.prelude import *
citation(125616)
citation(168932)
with reaction_rules():
2 * ATP > 2 * A13P2G + 2 * ADP | (3.2 * ATP / (1.0 + (ATP / 1.0) ** 4.0))
A13P2G > A23P2G | 1500
A23P2G > PEP | 0.15
A13P2G + ADP > PEP + ATP | 1.57e+4
PEP + ADP ... | <SYSTEM_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 Simple Model of the Glycolysis of Human Erythrocytes
Step2: The model consists of seven reactions and is at the steady state.
Step3: Metabol... |
7,313 | <ASSISTANT_TASK:>
Python Code:
# Python imports
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
series1 = pd.Series([1,2,3,4])
print(series1)
df1 = pd.DataFrame([[1,2,3,4],[10,20,30,40]])
print(df1)
df1
# Rename the columns
df1.columns = ['A','B','C','D']
df1.index = [... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pandas Series and DataFrame objects
Step2: Dataframes use the IPython display method to look pretty, but will show just fine when printed also.... |
7,314 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import glob
import tabulate
import pprint
import click
import numpy as np
import pandas as pd
from ray.tune.commands import *
from nupi... | <SYSTEM_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 and check data
Step2: ## Analysis
Step3: Plot accuracy over epochs
|
7,315 | <ASSISTANT_TASK:>
Python Code:
class MyIter(object):
def __init__(self, lst):
self.lst = lst
self.i = 0
def __iter__(self):
self.i = 0
return self
def __next__(self):
if self.i < len(self.lst):
nxt = self.lst[self.i]
self.i +=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: iter()
Step2: lets try another example, this time lets take a string
|
7,316 | <ASSISTANT_TASK:>
Python Code:
%%html
<video width="560" height="315" src="https://storage.googleapis.com/scanner-data/public/sample-clip.mp4?ignore_cache=1" controls />
import util
path = util.download_video()
print(path)
# Read all the frames
%matplotlib inline
import matplotlib.pyplot as plt
import cv2
from timeit ... | <SYSTEM_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've set up some scripts to help you download the video in the snippet below.
Step2: Take another look at the video and see if you can identif... |
7,317 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from ipp_macro_series_parser.agregats_transports.parser_cleaner_prix_carburants import prix_mensuel_carburants_90_15
from openfisca_france_indirect_taxation.examples.utils_example import graph_builder_carburants
prix_mensuel_carburants_90_15[['annee'] + ['mois']] = pri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Utilisation de la date comme index
Step2: Changement des noms des variables pour être plus explicites
Step3: Réalisation du graphique
|
7,318 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from matplotlib._png import read_png
# load the image
imageFileName = '../data/figure_3/3d_data/images/rough.png'
imRead = read_png(imageFileName)
# and 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: Figure 3(i)
Step2: Figure 3(ii)
Step4: Hysteresis Data
Step5: The plots are produced below, showing the results for t=70nm. The original data... |
7,319 | <ASSISTANT_TASK:>
Python Code:
import time
import numpy as np
import h5py
import matplotlib.pyplot as plt
import scipy
from PIL import Image
from scipy import ndimage
from dnn_app_utils_v2 import *
%matplotlib inline
plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots
plt.rcParams['image.interpolati... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2 - Dataset
Step2: The following code will show you an image in the dataset. Feel free to change the index and re-run the cell multiple times t... |
7,320 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import sys
import pandas as pd
import sqlalchemy as sa
import pudl
import warnings
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.StreamHandler(stream=sys.stdout)
formatter = logging.Formatter('%(message)s')
h... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get the original EIA 860 data
Step2: Validation Against Fixed Bounds
Step3: Capacity
Step4: Validating Historical Distributions
|
7,321 | <ASSISTANT_TASK:>
Python Code:
class Events():
def __init__(self, start_times, labels):
last item must be sentinel with no label
assert(len(labels) >= len(start_times) - 1)
if len(labels) < len(start_times):
labels = labels.append(pd.Series([np.nan]))
self._df = pd.DataFr... | <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: Representation of events
Step4: [Weighted] Chord Symbol Recall
|
7,322 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plot
import seaborn
from sklearn import datasets
from sklearn import svm
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import KFold
%matplotlib inline
digits = datasets.load_digits()
print(digits.DESCR)
k_folds = KFold(n_spl... | <SYSTEM_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
Step2: Set up 10 Folds Cross Validation
Step3: Set up the logarithmic C-values
Step4: Set up the linear Support Vector Classifier
St... |
7,323 | <ASSISTANT_TASK:>
Python Code:
# 第一步当然是引入PyTorch及相关包
import torch
import torch.nn as nn
import torch.optim
from torch.autograd import Variable
import numpy as np
import glob
import unicodedata
import string
# all_letters 即课支持打印的字符+标点符号
all_letters = string.ascii_letters + " .,;'-"
# Plus EOS marker
n_letters = len(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: 准备数据
Step2: 可以看到 "O'Néàl" 被转化成了以普通ASCII字符表示的 O'Neal。
Step3: 其中 all_letters 包含了我们数据集中所有可能出现的字符,也就是“字符表”。
Step4: 现在我们的数据准备好了,可以搭建神经网络了!
Step5: ... |
7,324 | <ASSISTANT_TASK:>
Python Code:
abbr = 'NLP'
full_text = 'Natural Language Processing'
# Enter your code here:
%%writefile contacts.txt
First_Name Last_Name, Title, Extension, Email
# Write your code here:
# Run fields to see the contents of contacts.txt:
fields
# Perform import
# Open the file as a binary objec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Files
Step2: 3. Open the file and use .read() to save the contents of the file to a string called fields. Make sure the file is closed at the ... |
7,325 | <ASSISTANT_TASK:>
Python Code:
t = 'Python'
t[0:2]
t[::2]
t[::-1]
import numpy as np
arr = np.array([[3, 6, 2, 1, 7],
[4, 1, 3, 2, 8],
[7, 9, 2, 1, 8],
[8, 6, 9, 6, 7],
[9, 1, 9, 2, 6],
[9, 8, 1, 5, 6],
[0, 4, 2, 0, 6],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <img src='./files/2dbase2.png', width="300">
Step2: <img src='./files/2dbase1.png', width="300">
Step3: <img src='./files/3darray.png' width="... |
7,326 | <ASSISTANT_TASK:>
Python Code:
# Это единственный комментарий который имеет смысл
# I s
def find_index(m,a):
try:
return a.index(m)
except :
return -1
def find_two_sum(a, s):
'''
>>> (3, 5) == find_two_sum([1, 3, 5, 7, 9], 12)
True
'''
if len(a)<2:
return (... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: https
Step2: Symmetric Difference
|
7,327 | <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: Create and convert a TensorFlow model
Step2: Generate data
Step3: Add some noise
Step4: Split our data
Step5: Design a model
Step6: Train t... |
7,328 | <ASSISTANT_TASK:>
Python Code:
from gensim.models import Word2Vec
from sklearn.manifold import TSNE
from nltk.corpus import genesis
import matplotlib.pyplot as plt
from textblob import TextBlob
from pprint import pprint
import pandas as pd
import numpy as np
import logging
import csv
import re
% matplotlib inline
loggi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: BIBLE (Genesis)
Step2: GOOGLE NEWS
Step3: GYANT
|
7,329 | <ASSISTANT_TASK:>
Python Code:
import os
import desc.monitor
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from lsst.sims.photUtils import calcNeff
%matplotlib inline
%load_ext autoreload
%autoreload 2
star_db_name = '../../twinkles_run1.1.db'
truth_dbConn = desc.monitor.TruthDBInterface(... | <SYSTEM_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 necessary database connections.
Step2: Then we'll establish a database connection to the NERSC MySQL database for the observed data from T... |
7,330 | <ASSISTANT_TASK:>
Python Code:
# The line below can be ignored but I didn't set up my environment properly
import sys ; sys.path.append('/home/mjuenemann/.virtualenvs/ciscoconfparse/lib/python3.6/site-packages')
import ciscoconfparse
CONFIG =
!
hostname router01
!
tacacs-server host 192.0.2.34
tacacs-server key chee... | <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: I am going to use a very stripped down version of the Secure IOS Template by Team Cymru. This is not a fully functional IOS configuration!
Step3... |
7,331 | <ASSISTANT_TASK:>
Python Code:
# Imports for this Python3 notebook
import numpy
import matplotlib.pyplot as plt
from osgeo import gdal
from osgeo import ogr
from osgeo import osr
from rios import rat
from rios import ratapplier
from tpot import TPOTRegressor
# Read Biomass library data from the csv file
fieldBiomass=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepare the training data
Step2: Build the Machine Learning Model
Step4: Predict Biomass using the RAT
Step5: Export the Biomass band to an i... |
7,332 | <ASSISTANT_TASK:>
Python Code:
data_dir = './data'
# FloydHub - Use with data ID "R5KrjnANiKVhLWAkpXhNBe"
#data_dir = '/input'
DON'T MODIFY ANYTHING IN THIS CELL
import helper
helper.download_extract('mnist', data_dir)
helper.download_extract('celeba', data_dir)
show_n_images = 25
DON'T MODIFY ANYTHING IN THIS CELL
%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: Face Generation
Step3: Explore the Data
Step5: CelebA
Step7: Preprocess the Data
Step10: Input
Step13: Discriminator
Step16: Generator
Ste... |
7,333 | <ASSISTANT_TASK:>
Python Code::
import LightGBM as lgb
def custom_loss(y_pred, data):
y_true = data.get_label()
error = y_pred-y_true
#1st derivative of loss function
grad = 2 * error
#2nd derivative of loss function
hess = 0 * error + 2
return grad, hess
params = {"learning_rate" ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
7,334 | <ASSISTANT_TASK:>
Python Code:
from Frame2D import Frame2D
from Frame2D.Members import Member
# because units are kips, inches
Member.E = 30000. #ksi
Member.G = 11500.
from IPython import display
display.Image('data/Beaufait-9-4-1.d/fig1.jpg')
frame = Frame2D('Beaufait-9-4-1') # Example 9.4.1, p. 460
frame.input_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: Compare Solution Here with that in the Book
|
7,335 | <ASSISTANT_TASK:>
Python Code:
7 // 3 # Floor division results in the quotient
7 % 3 # Modulus returns the remainder
5 == 5
5 == 4
True and True
True and False
True or True
True or False
False or False
True and (True or False)
x = 1
if( x > 0 ):
print( 'x is positive' )
if( 0 == x % 2 ):
print( 'x is even'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Boolean expressions
Step2: True and False are not strings, nor are the equivalent to strings
Step3: When combining multiple expresssions, don'... |
7,336 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib notebook
import sqlite3
conn = sqlite3.connect("intro.db")
cur = conn.cursor()
cur.execute( # complete
cur.execute(create table DSFPstudents(
Name text,
Institution text... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: At the most basic level - databases store your bytes, and later return those bytes (or a subset of them) when queried.
Step2: Without diving t... |
7,337 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_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 and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
7,338 | <ASSISTANT_TASK:>
Python Code:
from networkit import *
%matplotlib inline
cd ~/workspace/NetworKit/
G = readGraph("input/PGPgiantcompo.graph", Format.METIS)
n = G.numberOfNodes()
m = G.numberOfEdges()
print(n, m)
G.toString()
V = G.nodes()
print(V[:10])
E = G.edges()
print(E[:10])
edgeExists = G.hasEdge(42,11)
if ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In case a Python warning appears that recommends an update to Python 3.4, simply ignore it for this tutorial. Python 3.3 works just as fine for ... |
7,339 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
values = np.random.uniform(-10.0, 10.0, 100000)
plt.hist(values, 50)
plt.show()
from scipy.stats import norm
import matplotlib.pyplot as plt
x = np.arange(-3, 3, 0.001)
plt.plot(x, norm.pdf(x))
import numpy as np
impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Normal / Gaussian
Step2: Generate some random numbers with a normal distribution. "mu" is the desired mean, "sigma" is the standard deviation
S... |
7,340 | <ASSISTANT_TASK:>
Python Code:
import parselmouth
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set() # Use seaborn's default style to make attractive graphs
plt.rcParams['figure.dpi'] = 100 # Show nicely large images in this notebook
snd = parselmouth.Sound("audio/the_north_wind_and_the... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Once we have the necessary libraries for this example, we open and read in the audio file and plot the raw waveform.
Step2: snd is now a Parsel... |
7,341 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_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 and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
7,342 | <ASSISTANT_TASK:>
Python Code:
from pandas import Series
from igraph import *
from numba import jit
import numpy as np
import os
import time
# Gather all the files.
files = os.listdir('timeseries/')
# Concatenate (or stack) all the files.
# Approx 12.454981 seconds
i = 0
for f in files:
if i == 0:
ts_matri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Phase 1
Step3: Step 2
Step4: Step 3
Step5: Step 4
Step6: Phase 2
|
7,343 | <ASSISTANT_TASK:>
Python Code:
# You can store integers
x = 10
# You can store strings
y = "Hi, my name is Paul"
# A variable can be as long as you like. It is best to use variable names
# that express what the variable is.
long_variable_names_work_too = 1.3
hi = 'hello'
print("It will change")
# Here are some intege... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Printing
Step2: A Few Data Types
Step3: Floats
Step4: Note the trailing numbers. They are not extremely precise. Be careful
Step5: Getting a... |
7,344 | <ASSISTANT_TASK:>
Python Code:
# Author: Annalisa Pascarella <a.pascarella@iac.cnr.it>
#
# License: BSD (3-clause)
import os.path as op
import matplotlib.pyplot as plt
from nilearn import plotting
import mne
from mne.minimum_norm import make_inverse_operator, apply_inverse
# Set dir
data_path = mne.datasets.sample.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: Set up our source space
Step2: Get a surface-based source space, here with few source points for speed
Step3: Now we create a mixed src space ... |
7,345 | <ASSISTANT_TASK:>
Python Code:
def numberOfArithmeticSequences(L , N ) :
if(N <= 2 ) :
return 0
count = 0
res = 0
for i in range(2 , N ) :
if(( L[i ] - L[i - 1 ] ) ==(L[i - 1 ] - L[i - 2 ] ) ) :
count += 1
else :
count = 0
res += count
return res
L =[1 , 3 , 5 , 6 , 7 , 8 ]
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:
|
7,346 | <ASSISTANT_TASK:>
Python Code:
%%file vofz.scons
Flow('vel',None,'spike n1=501 nsp=4 mag=0.5 k1=101,201,301,401 | causint | add add=2')
Result('vel',
'''
graph min2=0 max2=5 label2=Velocity unit2=km/s plotfat=3
transp=y yreverse=y wanttitle=n wherexlabel=t
''')
from m8r import view
view('vel... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dix inversion
Step2: Questions
|
7,347 | <ASSISTANT_TASK:>
Python Code:
import ipywidgets as widgets
import os
image_path = os.path.abspath('../../data_files/trees.jpg')
with open(image_path, 'rb') as f:
raw_image = f.read()
ipyimage = widgets.Image(value=raw_image, format='jpg')
ipyimage
from bqplot import LinearScale, Figure, Lines, Axis, Image
# Creat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Displaying the image inside a bqplot Figure
Step2: Mixing with other marks
Step3: Its traits (attributes) will also respond dynamically to a c... |
7,348 | <ASSISTANT_TASK:>
Python Code:
# This is an example of a Python code cell.
# Note that I can include text as long as I use the # symbol (Python comment)
# Results of my code will display below the input
print 3+5
# We usually want to begin every notebook by setting up our tools:
# graphics in the notebook, rather ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Go ahead and edit the Python code cell above to do something different. To evaluate whatever is in the cell, just press shift-enter.
Step2: Que... |
7,349 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
import matplotlib.pyplot as plt
import seaborn as sns; sns.set() # prettify matplotlib
import numpy as np
import sklearn.gaussian_process as gp
# local modules
import turbo as tb
import turb... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Target Function
Step2: Helper Functions
Step3: Try optimising the same function with random search
|
7,350 | <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:
Step3: Forecasting with an RNN
Step4: Simple RNN Forecasting
Step5: Sequence-to-Sequence Forecasting
|
7,351 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import gpflow
import gpflowopt
import numpy as np
# Objective
def vlmop2(x):
transl = 1 / np.sqrt(2)
part1 = (x[:, [0]] - transl) ** 2 + (x[:, [1]] - transl) ** 2
part2 = (x[:, [0]] + transl) ** 2 + (x[:, [1]] + transl) ** 2
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We setup the Veldhuizen and Lamont multiobjective optimization problem 2 (vlmop2). The objectives of vlmop2 are very easy to model. Ideal for il... |
7,352 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'str': ['Aa', 'Bb', '?? ?', '###', '{}xxa;']})
def g(df):
df["new"] = df.apply(lambda p: sum(q.isalpha() for q in p["str"] ), axis=1)
return df
df = g(df.copy())
<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:
|
7,353 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
data = pd.read_csv('data/hki_liikennemaarat.csv', encoding='latin-1',delimiter=';')
data.head()
laru = data[data.nimi == 'LAUTTASAAREN SILTA']
laru = laru.loc[:,['suunta','aika','vuosi','autot','ha... | <SYSTEM_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 download the dataset and place it in the data/ folder
Step2: The columns are
Step3: Since the time series is at uneven intervals some re... |
7,354 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image, HTML, display
assert True # leave this to grade the import statements
Image(url='http://www.elevationnetworks.org/wp-content/uploads/2013/05/physics.jpeg', embed=True, width=600, height=600)
assert True # leave this to grade the image display
q = <tabl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic rich display
Step3: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi... |
7,355 | <ASSISTANT_TASK:>
Python Code:
%%bash
echo committees
ls -lah ../data/committees/dist/dist/committees | wc -l
echo factions
ls -lah ../data/committees/dist/dist/factions | wc -l
echo meetings
ls -lah ../data/committees/dist/dist/meetings/*/* | wc -l
echo members
ls -lah ../data/committees/dist/dist/members | wc -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: Run the generate-sitemap pipeline
Step2: View the sitemap
|
7,356 | <ASSISTANT_TASK:>
Python Code:
import math
def calculateSum(n ) :
a = int(n )
return(2 *(pow(n , 6 ) + 15 * pow(n , 4 ) + 15 * pow(n , 2 ) + 1 ) )
if __name__== ' __main __' :
n = 1.4142
print(math . ceil(calculateSum(n ) ) )
<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:
|
7,357 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
pd.set_option('max_rows', 10)
c = pd.Categorical(['a', 'b', 'b', 'c', 'a', 'b', 'a', 'a', 'a', 'a'])
c
c.describe()
c.codes
c.categories
c.as_ordered()
dta = pd.DataFrame.from_dict({'factor': c,
'x': np.random.randn(10)})
dta.head()
dta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Categorical Types
Step2: By default the Categorical type represents an unordered categorical
Step3: Support in DataFrames
Step4: Exercise
Ste... |
7,358 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
from oemof.solph import (Sink, Source, Transformer, Bus, Flow, Model,
EnergySystem)
import oemof.outputlib as outputlib
import pickle
solver = 'cbc'
# initialize and provide data
datetimeindex = pd.date_range('1/1/2016', periods=24*... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Specify solver
Step2: Create an energy system and optimize the dispatch at least costs.
Step3: Create and add components to energysystem
Step4... |
7,359 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
id=["Train A","Train A","Train A","Train B","Train B","Train B"]
arrival_time = ["0"," 2016-05-19 13:50:00","2016-05-19 21:25:00","0","2016-05-24 18:30:00","2016-05-26 12:15:00"]
departure_time = ["2016-05-19 08:25:00","2016-05-19 16:00:00","2016-05-20 07:45:00","2016-... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
7,360 | <ASSISTANT_TASK:>
Python Code:
raw_corpus = ["Human machine interface for lab abc computer applications",
"A survey of user opinion of computer system response time",
"The EPS user interface management system",
"System and human system engineering testing of EPS",
... | <SYSTEM_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 is a particularly small example of a corpus for illustration purposes. Another example could be a list of all the plays written by Shakespe... |
7,361 | <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: Assess privacy risks with the TensorFlow Privacy Report
Step2: Install TensorFlow Privacy.
Step3: Train two models, with privacy metrics
Step4... |
7,362 | <ASSISTANT_TASK:>
Python Code:
from infomap import infomap
infomapWrapper = infomap.Infomap("--two-level")
# Add link weight as an optional third argument
infomapWrapper.addLink(0, 1)
infomapWrapper.addLink(0, 2)
infomapWrapper.addLink(0, 3)
infomapWrapper.addLink(1, 0)
infomapWrapper.addLink(1, 2)
infomapWrapper.addL... | <SYSTEM_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 example
Step2: Memory networks
Step3: Overlapping modules
Step4: As seen in the expanded output above, node 2 is represented by four s... |
7,363 | <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... |
7,364 | <ASSISTANT_TASK:>
Python Code:
train.columns
train.drop(['type',
'mv',
'blockTime',
'difficulty',
'gasLimit_b',
'gasUsed_b',
'reward',
'size',
'totalFee',
'gasShare',
'gweiPaid',
'gw... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note
Step2: Prune out some more features
Step3: Split data into training and test sets
Step4: Random forest regressor
Step5: Plot predicted ... |
7,365 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import sys
# Load Yabox (from local)
# Comment this line to use the installed version
sys.path.insert(0, '../')
import yabox as yb
# Import the DE implementations
from yabox.algorithms import DE, PDE
print('Yabox versio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basics
Step2: In many scenarios, the function to optimize may depend on many other components or other fixed parameters. It is very convenient ... |
7,366 | <ASSISTANT_TASK:>
Python Code:
import spacy
import pandas as pd
%matplotlib inline
from ast import literal_eval
import numpy as np
import re
import json
from nltk.corpus import names
from collections import Counter
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [16, 6]
plt.style.use('ggplot')
nlp... | <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: Analysis of Anthologies
Step6: Quotation Length Statistics
Step7: Number of Quotes (and words Quoted) by Chapter
|
7,367 | <ASSISTANT_TASK:>
Python Code:
# Import relevant modules
%matplotlib inline
%load_ext autoreload
%autoreload 2
import numpy as np
from NPTFit import nptfit # module for performing scan
from NPTFit import create_mask as cm # module for creating the mask
from NPTFit import dnds_analysis # module for analysing the output
... | <SYSTEM_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: This time we add a non-Poissonian template correlated with the Galactic Center Excess and also one spatially distr... |
7,368 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
# 使用默认的seaborn设置
import seaborn as sns; sns.set()
np.random.seed(1)
X = np.dot(np.random.random(size=(2, 2)), np.random.normal(size=(2, 200))).T
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: 介绍主成分分析
Step2: 我们可以看出这一组数据有一个明显的趋势和走向。主成分分析(PCA)做的就是去寻找这一组数据中的最基本的轴,然后去解释这些轴是怎样影响数据分布的:
Step3: 我们把这些向量画在这些数据上来直观的看一看这些数字是什么意思:
Step4: 我们注意到一个... |
7,369 | <ASSISTANT_TASK:>
Python Code:
s = 'Fluent'
L = [10, 20, 30, 40, 50]
print(list(s)) # list constructor iterates over its argument
a, b, *middle, c = L # tuple unpacking iterates over right side
print((a, b, c))
for i in L:
print(i, end=' ')
len(s), len(L)
s.__len__(), L.__len__()
a = 2
b = 3
a * b, a.__mul__(b)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sizing with len()
Step2: Arithmetic
Step3: A simple but full-featured Pythonic class
|
7,370 | <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 = ?
testing_file = ?
with open(training_file, mode='rb') as f:
train = pickle.load(f)
with open(testing_file, mode='rb') as f:
test = pickle.load(f)
X_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: Step 1
Step2: Visualize the German Traffic Signs Dataset using the pickled file(s). This is open ended, suggestions include
Step3: Step 2
Step... |
7,371 | <ASSISTANT_TASK:>
Python Code:
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
import io
import os.path
import re
import tarfile
import smart_open
def extract_documents(url='https://cs.nyu.edu/~roweis/data/nips12raw_str602.tgz'):
fname = url.split('/')[-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: The purpose of this tutorial is to demonstrate how to train and tune an LDA model.
Step2: So we have a list of 1740 documents, where each docum... |
7,372 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import DecisionTreeRegressor
from sklearn.model_selection import KFold, cross_val_score
import nump... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Divisão do dataset em atributos e classes
Step2: Divisão do dataset em treino e teste
Step3: Deifinição do modelo
Step4: Treinamento do model... |
7,373 | <ASSISTANT_TASK:>
Python Code:
# The action to take upon a certain event is usually specified at the "source"
b = Button()
b.mouse_down.connect(some_callback)
...
def some_callback(event):
...
from flexx import react
@react.connect('name')
def greet(n):
print('hello %s!' % n)
@react.connect('first_name', 'las... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reactive Programming (in flexx)
Step2: Signals yield new values, thereby transforming or combining the upstream signals. Also, you can connect ... |
7,374 | <ASSISTANT_TASK:>
Python Code:
# Start the Spark Session
# This uses local mode for simplicity
# the use of findspark is optional
# install pyspark if needed
# ! pip install pyspark
# import findspark
# findspark.init("/home/luca/Spark/spark-3.3.0-bin-hadoop3")
from pyspark.sql import SparkSession
spark = (SparkSession... | <SYSTEM_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 a DataFrame with toy data for demo purposes
Step2: Compute the histogram
Step3: Histogram plotting
Step5: Note added
|
7,375 | <ASSISTANT_TASK:>
Python Code:
import pandas
import numpy
import toyplot
import toyplot.pdf
import toyplot.png
import toyplot.svg
print('Pandas version: ', pandas.__version__)
print('Numpy version: ', numpy.__version__)
print('Toyplot version: ', toyplot.__version__)
column_names = ['MPG',
'Cylinder... | <SYSTEM_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 the "auto" dataset. This is a fun collection of data on cars manufactured between 1970 and 1982. The source for this data can be found a... |
7,376 | <ASSISTANT_TASK:>
Python Code:
import os
# The Vertex AI Workbench Notebook product has specific requirements
IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME")
IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(
"/opt/deeplearning/metadata/env_version"
)
# Vertex AI Notebook requires dependencies to be install... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Restart the kernel
Step2: Before you begin
Step3: Region
Step4: Timestamp
Step5: Authenticate your Google Cloud account
Step6: Create a Clo... |
7,377 | <ASSISTANT_TASK:>
Python Code:
# remove after testing
%load_ext autoreload
%autoreload 2
import pickle
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from itertools import product
from sklearn.svm import SVC, LinearSVC
from sklearn.ensemble import RandomForestClassifier
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: Hyperparameter Optimization
Step2: Logistic Regression
Step3: Multinomial has the highest score, but it doesn't give us reliable probability e... |
7,378 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2018 The TensorFlow Hub Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Semantic Search with Approximate Nearest Neighbors and Text Embeddings
Step2: Import the required libraries
Step3: 1. Download Sample Data
Ste... |
7,379 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set_style('white')
from scipy.interpolate import griddata
# YOUR CODE HERE
#raise NotImplementedError()
#I worked with James Amarel
x=np.empty((1,))
x[0]=0
y=np.empty((1,))
y[0]=0
#hstack acts... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sparse 2d interpolation
Step2: The following plot should show the points on the boundary and the single point in the interior
Step3: Use meshg... |
7,380 | <ASSISTANT_TASK:>
Python Code:
print(__doc__)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
from sklearn.datasets import load_digits
from sklearn.model_selection import learning_curve
from sklearn.model_selection import ShuffleSplit
def plot_le... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plot learning curves of different classifiers
Step2: Pandas
Step3: Testing sklearn classifiers.
|
7,381 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cas', 'fgoals-g3', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
7,382 | <ASSISTANT_TASK:>
Python Code:
%xmode Minimal
from larray import *
# define some scalars, axes and arrays
variant = 'baseline'
country = Axis('country=Belgium,France,Germany')
gender = Axis('gender=Male,Female')
time = Axis('time=2013..2017')
population = zeros([country, gender, time])
births = zeros([country, gender,... | <SYSTEM_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 Kinds Of Sessions
Step2: CheckedSession
Step3: Loading and Dumping Sessions
Step4: 2) Call the load method on an existing session and p... |
7,383 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import seaborn as sns
from scipy import stats
import matplotlib.pyplot as plt
from sklearn import linear_model
from sklearn.decomposition import PCA
from sklearn.metrics import r2_score, mean_absolute_error
from sklearn.model_selection import train_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: PCA Modeling
Step2: According to the figure above, the majority of the variance within the model can be explained using only the first four pri... |
7,384 | <ASSISTANT_TASK:>
Python Code:
def parse(line):
Parses a line from the colors dataset.
items = tf.string_split([line], ",").values
rgb = tf.string_to_number(items[1:], out_type=tf.float32) / 255.0
color_name = items[0]
chars = tf.one_hot(tf.decode_raw(color_name, tf.uint8), depth=256)
length = tf.cast(tf.sh... | <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: Case study
Step7: To show the use of control flow, we write the RNN loop by hand, rather than using a pre-built RNN model.
Step9: We will now ... |
7,385 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'ec-earth3-lr', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contribu... | <SYSTEM_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... |
7,386 | <ASSISTANT_TASK:>
Python Code:
Initialization
'''
Standard modules
'''
import os
import pickle
import csv
import time
from pprint import pprint
import json
import pymongo
import multiprocessing
import logging
import collections
'''
Analysis modules
'''
%matplotlib inline
%config InlineBackend.figure_format = 'retina' #... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepare tweets and news data for IBM topic
Step3: Prepare multiprocessing and MongoDB scripts available in ibm_tweets_analysis project
Step5: ... |
7,387 | <ASSISTANT_TASK:>
Python Code:
%%time
with open("simhash_sorted.txt") as f:
simhashes = [int(line[:-1]) for line in f.readlines()]
simhashes = np.array(simhashes, dtype=np.uint64) # found out before that simhash fits uint64
SIMHASH_SIZE = 64
num_samples = len(simhashes)
print "Number of samples:", num_samples
prin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Поделим simhash-и на 4 части для индексирования.
Step2: Построим индексы.
Step3: Прокластеризуем хеши.
Step4: Отработав 6 часов, скрипт обеща... |
7,388 | <ASSISTANT_TASK:>
Python Code:
import findspark
findspark.init()
import pyspark
import numpy as np
conf = pyspark.SparkConf().\
setAppName('sentiment-analysis').\
setMaster('local[*]')
from pyspark.sql import SQLContext, HiveContext
sc = pyspark.SparkContext(conf=conf)
sqlContext = HiveContext(sc)
# dataframe 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: Introduction to dataframes
Step2: From the previous RDDs, we can call the toDF method and specify the name of columns
Step3: Spark will automa... |
7,389 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
n = 20
sigma = 1.0
xdata = np.linspace(-2, 2, n)
fdata = 3*xdata**2 + 2*xdata + 1 + np.random.randn(n)*sigma
plt.figure()
plt.plot(xdata, fdata, 'o')
plt.xlabel('x')
plt.ylabel('f')
plt.show()
Psi = np.zeros((n, 3))
Ps... | <SYSTEM_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 data is our training data and consists of two pairs
Step2: Ideally w would be [3, 2, 1] bsaed on our underlying polynomial, but it won't r... |
7,390 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
import pymc3 as pm
import seaborn as sns
SEED = 383561
np.random.seed(SEED) # from random.org, for reproducibility
N = 1000
W = np.array([0.35, 0.4, 0.25])
MU = np.array([0., 2., 5.])
SIGMA = np.array([0.5, 0.5, 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: Gaussian mixtures are a flexible class of models for data that exhibits subpopulation heterogeneity. A toy example of such a data set is shown ... |
7,391 | <ASSISTANT_TASK:>
Python Code:
def string_to_kmers(s, length):
return [s[i:i+length] for i in range(len(s)-length+1)]
def minimizer(k, l):
Given k-mer, return its minimal l-mer
assert l <= len(k)
return min(string_to_kmers(k, l))
minimizer('ABC', 2)
minimizer('abracadabra', 4)
minimizer('abracadabr',... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Minimizers
Step2: But if our goal is to partition the space of $k$-mers, couldn't we use a hash function instead? Say $k$ is 10 and $l$ is 4. ... |
7,392 | <ASSISTANT_TASK:>
Python Code:
import sys,os
%matplotlib inline
ia898path = os.path.abspath('/etc/jupyterhub/ia898_1s2017/')
if ia898path not in sys.path:
sys.path.append(ia898path)
import ia898.src as ia
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from numpy.fft import fft2
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Função iadftmatrix
Step2: Kernel images generated
Step3: Four first lines
Step4: Showing complex conjugates
|
7,393 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# for... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: Extract Features
Step3: Train SVM on features
Step4: Inline question 1
|
7,394 | <ASSISTANT_TASK:>
Python Code:
import sqlalchemy
print(sqlalchemy.__version__)
from sqlalchemy import create_engine
engine = create_engine('sqlite:///users_data.db', echo=True)
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
from sqlalchemy import Column, Integer, String
class User(... | <SYSTEM_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's SQLAlchemy and Declarative
Step2: we will use an in-memory-only SQLite database. To connect we use create_engine()
Step3: Now that we... |
7,395 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import time
import helper
source_path = 'data/letters_source.txt'
target_path = 'data/letters_target.txt'
source_sentences = helper.load_data(source_path)
target_sentences = helper.load_data(target_path)
source_sentences[:50].split('\n')
target_sentences[:50].split('\... | <SYSTEM_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 start by examining the current state of the dataset. source_sentences contains the entire input sequence file as text delimited by newline... |
7,396 | <ASSISTANT_TASK:>
Python Code:
from pysap.SAPCAR import *
from IPython.display import display
with open("some_file", "w") as fd:
fd.write("Some string to compress")
f0 = SAPCARArchive("archive_file.car", mode="wb", version=SAPCAR_VERSION_200)
f0.add_file("some_file")
f0._sapcar.canvas_dump()
f0._sapcar.files0[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: SAPCAR Archive version 2.00
Step2: The file is comprised of the following main structures
Step3: SAPCAR Entry Header
Step4: SAPCAR Data Block... |
7,397 | <ASSISTANT_TASK:>
Python Code:
# we need this for later:
%matplotlib inline
import json
INPUT_FILE = "all_the_data.json"
with open(INPUT_FILE, "r") as big_data_fd:
big_data = json.load(big_data_fd)
print "We have {} posts".format(len(big_data))
import os
print "The source file is {} bytes. Pathetic.".format(os.stat(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Is it big enough?
Step2: Wow! So data! Very big!
Step3: At the time this was written, the file was just about 3MB, and there were fewer than 2... |
7,398 | <ASSISTANT_TASK:>
Python Code:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import numpy as np
tf.logging.set_verbosity(tf.logging.ERROR)
# Data sets
# The Iris data set contains 150 rows of data, comprising 50 samples from each
# ... | <SYSTEM_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 linear classifier
Step2: Simple linear regression.
Step4: Custom model
Step5: keras
Step6: keras sequential mode
Step7: For a multi-... |
7,399 | <ASSISTANT_TASK:>
Python Code:
#projection 2014+
pop_projection = df.from_csv("NP2014_D1.csv", index_col='year')
pop_projection = pop_projection[(pop_projection.sex == 0) & (pop_projection.race == 0) & (pop_projection.origin == 0)]
pop_projection = pop_projection.drop(['sex', 'race', 'origin'], axis=1)
pop_projection =... | <SYSTEM_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 CBO baseline
Step2: Import IRS number of returns projection
Step3: Import SOI estimates (2008 - 2012)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.