Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
8,800 | <ASSISTANT_TASK:>
Python Code:
import cv2
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
# TFlearn libraries
import tflearn
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regressio... | <SYSTEM_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 My Saved CNN
Step2: Import Function To View Convolutional Filters
Step3: First Convolutional Layer Filters
Step4: Alrighty then... th... |
8,801 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
sorted(plt.style.available)
def make_title(s):
return s.replace('-', ' ').replace('_', ' ').title()
def make_plots(style_str=None):
fig, axes_array = plt.subplots(2, 2)
((ax1, ax2), (ax3, ax4)) = axes_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: And what do they look like?
Step2: Things you'll note
|
8,802 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import json
def get_article(title):
for line in open('jawiki-country.json', 'r'):
data = json.loads(line)
if data['title'] == title:
return data['text'].split('\n')
England = get_article('イギリス')
print(type(England), England)
ca... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 21. カテゴリ名を含む行を抽出
|
8,803 | <ASSISTANT_TASK:>
Python Code:
# Notebook dependencies
from __future__ import print_function
import datetime
import json
import os
import ipyleaflet as ipyl
import ipywidgets as ipyw
from IPython.core.display import HTML
from IPython.display import display
import pandas as pd
from planet import api
from planet.api 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: Define AOI
Step2: Build Request
Step3: Search Planet API
Step4: In processing the items to scenes, we are only using a small subset of the pr... |
8,804 | <ASSISTANT_TASK:>
Python Code:
metadata_tb = Table.read_table('../09-Topic-Modeling/data/txtlab_Novel150_English.csv')
fiction_path = '../09-Topic-Modeling/data/txtlab_Novel150_English/'
novel_list = []
# Iterate through filenames in metadata table
for filename in metadata_tb['filename']:
# Read in novel 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: Pre-Processing
Step2: Due to memory and time constraints we'll use our quick and dirty tokenizer
Step3: First get the sentences
Step4: Now th... |
8,805 | <ASSISTANT_TASK:>
Python Code:
import sympy as sym
x = sym.symbols("x") # spremenljivka x je matematični simbol
enacba = sym.Eq(x+2/x,3)
enacba
sym.init_printing() # lepši izpis formul
enacba
# vse člene damo na levo stran in pomnožimo z x
leva = (enacba.lhs - enacba.rhs)*x
leva
# levo stran razpišemo/zmnožimo
leva =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Za začetek povsem sledimo korakom, ki smo jih naredili „na roke“. Povzamimo „algoritem“
Step2: Vključimo izpis formul v lepši obliki, ki ga omo... |
8,806 | <ASSISTANT_TASK:>
Python Code:
# Ensure python 3 compatibility
from __future__ import division, print_function, absolute_import
# Import necessary libraries:
import h5py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from IPython.display import display
import ipywidgets as widge... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Stephen Jesse, Suhas Somnath, and Chris R. Smith,
Step1: Load pycroscopy compatible ptychography dataset
Step2: Inspect the contents of this h5 data f... |
8,807 | <ASSISTANT_TASK:>
Python Code:
# Import Numpy, TensorFlow, TFLearn, and MNIST data
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
# Retrieve the training and test data
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
# Visualizing the data
import matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Retrieving training and test data
Step2: Visualize the training data
Step3: Building the network
Step4: Training the network
Step5: Testing
|
8,808 | <ASSISTANT_TASK:>
Python Code:
url = "http://en.wikipedia.org/wiki/Jurassic" # Line 1
import requests # I don't count these lines.
r = requests.get(url) # Line 2
r.text[7400:7600] # I don't count these lines either.
import re
s = re.search(r'<i>(.+?million years ago)</i>', r.text)
text = s.group(1)
text
start, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I used View Source in my browser to figure out where the age range is on the page, and what it looks like. The most predictable spot, that will ... |
8,809 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import quantities as pq
import neo
import elephant
from elephant import asset
%load_ext autoreload
plt.style.use('dark_background')
plt.rcParams['figure.autolayout'] = False
plt.rcParams['figure.figsize'] = 20, 12
plt.rcParams['axes.label... | <SYSTEM_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 download the data, packed in NixIO structure, from https
Step2: The data is represented as a neo.Block with one neo.Segment inside, w... |
8,810 | <ASSISTANT_TASK:>
Python Code:
import cifar10
cifar10.maybe_download_and_extract()
class_names = cifar10.load_class_names()
class_names
images_train, cls_train, labels_train = cifar10.load_training_data()
images_test, cls_test, labels_test = cifar10.load_test_data()
print("Size of:")
print("- Training-set:\t\t{}".... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set the path for storing the data-set on your computer.
Step2: Load the class-names.
Step3: Load the training-set. This returns the images, th... |
8,811 | <ASSISTANT_TASK:>
Python Code:
# system functions that are always useful to have
import time, sys, os
import warnings
# basic numeric setup
import numpy as np
# inline plotting
%matplotlib inline
# plotting
import matplotlib
from matplotlib import pyplot as plt
# seed the random number generator
rstate = np.random.defa... | <SYSTEM_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 multi-modal LogGamma distribution is useful for stress testing the effectiveness of bounding distributions. It is defined as
Step2: We will... |
8,812 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d, Axes3D # Objects for 3D charts
%matplotlib inline
df = pd.read_csv('../datasets/evasao.csv') # School dropout data I collected
df.head()
df2 = df[['periodo','repetiu','desempenho']][df.abandonou ... | <SYSTEM_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 explanations. To start, let's look at the columns in this dataset
Step2: I simply used Axes3D to obtain a three-dimensional chart object. ... |
8,813 | <ASSISTANT_TASK:>
Python Code:
data = pd.read_table("./1.data", sep=" ")
plt.plot(data['multiplier'], data['avg_speed'], '-o')
data = pd.read_table("./2.data", sep=" ")
plt.plot(data['it'], data['avg_speed'], '-o')
data = pd.read_table("./3.data", sep=" ")
data = data.sort(columns='it')
plt.plot(data['it'], data['avg... | <SYSTEM_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: Посмотрим на влияние phaseOffset на величину ср... |
8,814 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import io
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
meg_path = data_path / 'MEG' / 'sample'
raw... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: Show event-related fields images
|
8,815 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('./banklist.csv')
# CODE HERE
df.head()
# CODE HERE
df.columns
# CODE HERE
df['ST'].unique().shape[0]
# or
# len(df['ST'].unique())
# CODE HERE
df['ST'].unique()
# CODE HERE
df['ST'].value_counts().head()
# CODE HERE
df['Acquiring Institution'].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: Show the head of the dataframe
Step2: What are the column names?
Step3: How many States (ST) are represented in this data set?
Step4: Get a l... |
8,816 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
% matplotlib inline
import warnings
warnings.filterwarnings('ignore')
import numpy as np
from thinkbayes2 import Hist, Pmf, Cdf, Suite, Beta
import thinkplot
prior = Beta(2, 3)
thinkplot.Pdf(prior.MakePmf())
prior.Mean()
posterior = Beta(3... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Part One
Step2: In its first test, the new Alien Blaster 9000 takes 10 shots and hits 2 targets. Taking into account this data, what is the po... |
8,817 | <ASSISTANT_TASK:>
Python Code:
import skxray.core.roi as roi
import skxray.core.correlation as corr
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from matplotlib.ticker import MaxNLocator
from matplotlib.colors import LogNorm
import xray_vision.mpl_plotting as mpl_plot
interactive_mode = False
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Easily switch between interactive and static matplotlib plots
Step2: Rectangle region of interests.
Step3: Draw annual (ring-shaped) regions o... |
8,818 | <ASSISTANT_TASK:>
Python Code:
# Plots will be displaying plots within the notebook
%matplotlib notebook
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
# NumPy is a package for manipulating N-dimensional array objects
import numpy as np
# Pandas is a data analysis package
import pandas as pd... | <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: Data Pre-Processing
Step3: Task II
Step5: Target Pre-Processing
Step6: Now that we have both added an extra dimension to the input data as we... |
8,819 | <ASSISTANT_TASK:>
Python Code:
import this
print("Hello, World!")
# Import relevant libraries from the SciPy Stack
import numpy as np
# Specify parametrization
num_agents = 1000
num_covars = 3
betas_true = np.array([0.22, 0.30, -0.1]).T
# Set a seed to ensure recomputability in light of randomness
np.random.seed(4292... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Why Python for Scientific Computing?
Step2: SciPy Stack<br>
Step3: Statistical Analysis
Step4: Data Visualization
Step5: Integrated Developm... |
8,820 | <ASSISTANT_TASK:>
Python Code:
# To activate interactive matplolib in notebook
# %matplotlib notebook
from ocelot import *
from ocelot.gui import *
import time
#Initial Twiss parameters
tws0 = Twiss()
tws0.beta_x = 29.171
tws0.beta_y = 29.171
tws0.alpha_x = 10.955
tws0.alpha_y = 10.955
tws0.gamma_x = 4.148367385417024... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Also we can found the main parameters of the chicane with chicane_RTU(yoke_len, dip_dist, r, type)
Step2: <a id='compression'></a>
Step3: Now ... |
8,821 | <ASSISTANT_TASK:>
Python Code:
import os
import urllib.request
import boto3, botocore
import sagemaker
from sagemaker import get_execution_role
import mxnet as mx
mxnet_path = mx.__file__[ : mx.__file__.rfind('/')]
print(mxnet_path)
role = get_execution_role()
print(role)
sess = sagemaker.Session()
BUCKET = 'deeplens-... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Amazon S3 bucket info
Step2: We are going to check if we have the right bucket and if we have the right permissions.
Step3: Prepare data
Step4... |
8,822 | <ASSISTANT_TASK:>
Python Code:
import hail as hl
hl.utils.get_movie_lens('data/')
users = hl.read_table('data/users.ht')
users.filter(users.occupation == 'programmer').count()
users.aggregate(hl.agg.filter(users.occupation == 'programmer', hl.agg.count()))
users.aggregate(hl.agg.counter(users.occupation == 'programmer... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We can also express this query in multiple ways using aggregations
Step2: Annotate
Step3: Compare this to what we had before
Step4: Note
Step... |
8,823 | <ASSISTANT_TASK:>
Python Code:
import pdfplumber
print(pdfplumber.__version__)
pdf = pdfplumber.open("../pdfs/background-checks.pdf")
p0 = pdf.pages[0]
im = p0.to_image()
im
im.reset().debug_tablefinder()
table_settings = {
"vertical_strategy": "lines",
"horizontal_strategy": "text",
"snap_y_tolerance":... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the PDF
Step2: Get the first page
Step3: What data would we get if we used the default settings?
Step4: The default settings correctly i... |
8,824 | <ASSISTANT_TASK:>
Python Code:
Widget()
from ga4gh.client import protocol
from ga4gh.client import client
c = client.HttpClient("http://1kgenomes.ga4gh.org")
dataset = c.search_datasets().next()
reference_set = c.search_reference_sets().next()
references = [r for r in c.search_references(reference_set_id= reference_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: Description
Step2: Make reference to the data from the server
Step3: ReferenceSet Name (chromosome) & ReadGroupSet Reads
Step4: Functions to ... |
8,825 | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import exists
filename = 'modsim.py'
if not exists(filename):
from urllib.request import urlretrieve
url = 'https://raw.githubusercontent.com/A... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Can we predict salmon populations?
Step2: To get this data into a Pandas Series, I'll also make a range of years to use as an index.
Step3: An... |
8,826 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
import numpy as np
from sklearn.datasets import load_iris
# Load iris data
iris = load_iris()
# Create feature matrix
X = iris.data
# Create target vector
y = iris.target
# Remove first 40 observations
X = X[40:,:]
y = y[40:]
# Create binary target vector indicating 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: Load Iris Dataset
Step2: Make Iris Dataset Imbalanced
Step3: Upsampling Minority Class To Match Majority
|
8,827 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('olympics.csv', index_col=0, skiprows=1)
for col in df.columns:
if col[:2]=='01':
df.rename(columns={col:'Gold'+col[4:]}, inplace=True)
if col[:2]=='02':
df.rename(columns={col:'Silver'+col[4:]}, inplace=True)
if col[:2]=='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: Question 0 (Example)
Step2: Question 1
Step3: Question 2
Step4: Question 3
Step5: Question 4
Step6: Part 2
Step7: Question 6
Step8: Quest... |
8,828 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import gspread
import json
# rtc50_settings.py holds URL related to the Google spreadsheet
from rtc50_settings import (g_name, g_url, g_key)
OFFICIAL_NAME_KEY = "Name in rtc/books.json, Official Name"
g_url
import json
import gspread
from oauth2clie... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting access to the spreadsheet (Method 1)
Step3: Calculations on the spreadsheet
Step4: cloning repos
Step7: rtc covers
Step8: Getting co... |
8,829 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
# Provides better color palettes
import seaborn as sns
from pandas import DataFrame,Series
import matplotlib as mpl
import matplotlib.pyplot as plt
# Command to display the plots in the iPython Notebook
%matplotlib inline
import matplotlib.patches as... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Who is involved ?
Step3: The best is to have one function drawing the same plots for different input dataframes, i.e. for different conditions.... |
8,830 | <ASSISTANT_TASK:>
Python Code:
!pip3 install bs4
from bs4 import BeautifulSoup
from urllib.request import urlopen
html_str = urlopen("http://static.decontextualize.com/kittens.html").read()
print(html_str)
document = BeautifulSoup(html_str,"html.parser")
type(document)
h1_tag = document.find('h1')
h1_tag.string
img_tag... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: But first, an aside about joining strings
Step2: Another Aside
Step3: Scraping the Faculty, how many percentage of the CJ faculty are adjunct ... |
8,831 | <ASSISTANT_TASK:>
Python Code:
tr = np.array(model.monitor.channels['valid_y_y_1_nll'].time_record) / 3600.
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(111)
ax1.plot(model.monitor.channels['valid_y_y_1_nll'].val_record)
ax1.plot(model.monitor.channels['train_y_y_1_nll'].val_record)
ax1.set_xlabel('Epochs')
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: Plot ratio of update norms to parameter norms across epochs for different layers
|
8,832 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import numpy as np
center1 = np.array([3.0,3.0])
center2 = np.array([-3.0,-3.0])
X = np.zeros((100,2)); Y = np.zeros((100,))
X[:50,:] = np.random.multivariate_normal(center1, np.eye(2),(50,))
Y[:50] = +1
X[50:,:] = np.random.multivariate_normal(center2, np.eye(2),(50,))
Y[50... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problem
Step2: Problem
Step3: OSMH Dual Formulation
|
8,833 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import time as tm
import matplotlib.pyplot as plt
# Discretization
c1=20 # Number of grid points per dominant wavelength
c2=0.5 # CFL-Number
nx=200 # Number of grid points in X
ny=200 # Number of grid points in Y
T=1 # Total propagation time
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Input Parameter
Step2: Preparation
Step3: Create space and time vector
Step4: Source signal - Ricker-wavelet
Step5: Time stepping
Step6: Sa... |
8,834 | <ASSISTANT_TASK:>
Python Code:
PROJECT_ID = "YOUR PROJECT ID"
BUCKET_NAME = "gs://YOUR BUCKET NAME"
REGION = "YOUR REGION"
SERVICE_ACCOUNT = "YOUR SERVICE ACCOUNT"
! gsutil ls -al $BUCKET_NAME
content_name = "pt-img-cls-multi-node-ddp-cust-cont"
hostname = "gcr.io"
image_name = content_name
tag = "latest"
custom_conta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Vertex Training using Vertex SDK and Custom Container
Step2: Initialize Vertex SDK
Step3: Create a Vertex Tensorboard Instance
Step4: Option
... |
8,835 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import torch
torch.manual_seed(42)
# create uninitialized 3-D tensor (values can be anything that is in memory!)
x = torch.Tensor(2, 3, 3)
print(x)
# a randomly initialized 2-D tensor (a matrix)
x = torch.rand(4, 3)
print(x)
# how to get its size
print(x.size())
# or ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Random Seed
Step2: Tensors
Step3: Operations
Step4: Matrix multiplication
Step5: More operations
Step6: Automatic differentiation with Auto... |
8,836 | <ASSISTANT_TASK:>
Python Code:
from pylab import *
from ase.build import graphene_nanoribbon
from thermo.gpumd.data import load_hac
from thermo.gpumd.io import ase_atoms_to_gpumd
gnr = graphene_nanoribbon(60, 36, type='armchair', sheet=True, vacuum=3.35/2, C_C=1.44)
gnr.euler_rotate(theta=90)
l = gnr.cell.lengths()
gn... | <SYSTEM_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. Preparing the Inputs
Step2: The first few lines of the xyz.in file are
Step3: Plot HAC (heat current autocorrelations) & RTC (running therm... |
8,837 | <ASSISTANT_TASK:>
Python Code:
from linearset import Set
smith = Set()
smith.add("CSCI-112")
smith.add("MATH-121")
smith.add("HIST-340")
smith.add("ECON-101")
robert = Set()
robert.add('POL-101')
robert.add('ANTH-230')
robert.add('CSCI-112')
robert.add('ECON-101')
if smith == robert:
print("Smith and Robert are tak... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Maps
|
8,838 | <ASSISTANT_TASK:>
Python Code:
print("Hello, World")
5 + 3
9 + 16
400*321
height = 1.8
weight = 78
(height+weight)*2
# This is a comment
# We can store the result of calculation in a new variable
bmi = weight / height ** 2
bmi
string_variable = "test" # A string
int_variable = 4 # An intenger
float_variable = 3.14 ... | <SYSTEM_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 python syntax
Step2: Excercise
Step3: Variables
Step4: Variable types
Step5: When writing python code we very often will run into this... |
8,839 | <ASSISTANT_TASK:>
Python Code:
import seaborn as sns
iris = sns.load_dataset('iris')
iris.head()
iris.shape
iris['species'].value_counts().plot(kind='bar')
%matplotlib inline
sns.pairplot(iris, hue='species')
X_iris = iris.drop('species', axis=1)
X_iris.shape
y_iris = iris['species']
y_iris.shape
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create features and labels
|
8,840 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# All the imports
from __future__ import print_function, division
import pom3_ga, sys
import pickle
# TODO 1: Enter your unity ID here
__author__ = "<sbiswas4>"
def normalize(problem, points):
Normalize all the objectives
in each point and return them
meta... | <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: To compute most measures, data(i.e objectives) is normalized. Normalization is scaling the data between 0 and 1. Why do we normalize?
Step10: D... |
8,841 | <ASSISTANT_TASK:>
Python Code:
import pynucastro as pyrl
files = ["c12-pg-n13-ls09",
"c13-pg-n14-nacr",
"n13--c13-wc12",
"n13-pg-o14-lg06",
"n14-pg-o15-im05",
"n15-pa-c12-nacr",
"o14--n14-wc12",
"o15--n15-wc12",
"o14-ap-f17-Ha96c",
"f17-... | <SYSTEM_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 collection of rates has the main CNO rates plus a breakout rate into the hot CNO cycle
Step2: To evaluate the rates, we need a composition... |
8,842 | <ASSISTANT_TASK:>
Python Code:
## You can use Python as a calculator:
5*7 #This is a comment and does not affect your code.
#You can have as many as you want.
#No worries.
5+7
5-7
5/7
a = 5
b = 7
print(a)
print(b)
print(a*b , a+b, a/b)
a = 5.
b = 7
print(a*b, a+b, a/b)
c = [0,1,2,3,4,5,6,7,8,9]
print(c)
len(c)
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: These simple operations on numbers in Python 3 works exactly as you'd expect, but that's not true across all programming languages.
Step2: Next... |
8,843 | <ASSISTANT_TASK:>
Python Code:
import hashlib
m = hashlib.sha256()
m.update(b"Nobody inspects")
m.update(b" the spammish repetition")
m.digest()
result = hashlib.sha256(b"Nobody inspects the spammish repetition").hexdigest()
result
print("Digest size", m.digest_size)
print("Block size ", m.block_size)
# Uncomment me ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Expected
Step2: In class, we looked at a passwords database that doesn't save actual passwords, only hashes thereof. Even system administrator... |
8,844 | <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: Integrated gradients
Step2: Download Inception V1 from TF-Hub
Step4: From the TF Hub module page, you need to keep in mind the following about... |
8,845 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time, os, json
import numpy as np
import skimage.io
import matplotlib.pyplot as plt
from cs231n.classifiers.pretrained_cnn import PretrainedCNN
from cs231n.data_utils import load_tiny_imagenet
from cs231n.image_utils import blur_image, deprocess_image
%ma... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introducing TinyImageNet
Step2: TinyImageNet-100-A classes
Step3: Visualize Examples
Step4: Pretrained model
Step5: Pretrained model perform... |
8,846 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import scipy.optimize as scopt
import scipy.linalg as sclin
USE_COLAB = False
if not USE_COLAB:
plt.rc("text", usetex=True)
def NewtonLinConstraintsFeasible(f, gradf, hessf, A, x0, line_search, linsys_solver, args=(... | <SYSTEM_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: Выбор начального приближения допустимого по ограничениям и области определения целевой функции
St... |
8,847 | <ASSISTANT_TASK:>
Python Code:
def frm(vp1, vs1, rho1, rho_f1, k_f1, rho_f2, k_f2, k0, phi):
vp1 = vp1 / 1000.
vs1 = vs1 / 1000.
mu1 = rho1 * vs1**2.
k_s1 = rho1 * vp1**2 - (4./3.)*mu1
# The dry rock bulk modulus
kdry = (k_s1 * ((phi*k0)/k_f1+1-phi)-k0) / ((phi*k0)/k_f1+(k_s1/k0)-1-phi)
... | <SYSTEM_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 this function does is to get the relevant inputs which are
Step2: I can use the same function to also compute the fluid bulk modulus log w... |
8,848 | <ASSISTANT_TASK:>
Python Code:
# Basic imports
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
import scipy.optimize as spo
import sys
from time import time
from sklearn.metrics import r2_score, median_absolute_error
from multiprocessing import Pool
%matplotlib inl... | <SYSTEM_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 show the symbols data, to see how good the recommender has to be.
Step2: Let's run the trained agent, with the test set
Step3: And now a... |
8,849 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
%matplotlib inline
import openpathsampling as paths
import numpy as np
from IPython.display import SVG
import openpathsampling.visualize as vis
old_store = paths.AnalysisStorage("mstis_bootstrap.nc")
print("PathMovers: "+ str(len(old_store.pathmover... | <SYSTEM_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 things from storage
Step2: A lot of information can be recovered from the old storage, and so we don't have the recreate it. However, w... |
8,850 | <ASSISTANT_TASK:>
Python Code:
# Define a list of columns to drop.
drop_cols = [
'Fragment Noted',
'Depth Notes',
'Supplement Note',
'Fabric Description',
'Description',
'Size',
]
df.drop(columns=drop_cols, inplace=True)
# The API returns 'False' if a citation URI is not defined, it's better
# ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using the already cached JSON obtained from the Open Context API, we can make a second dataframe that is "wider" (has many more columns"). This ... |
8,851 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
D = 0.9
nusigf = 0.70
siga = 0.066
#Lx = np.pi*((nusigf-siga)/D)**(-0.5)
Lx = 15.0
N = 50;
h = Lx/(N-1)
x = np.zeros(N)
for i in range(N-1):
x[i+1] = x[i] + h
L = np.zeros((N,N))
A = np.zeros((N,N))
M = np.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: Material Properties
Step2: Slab Geometry Width and Discretization
Step3: Generation of Leakage and Absorption Matrices
Step4: Boundary Condit... |
8,852 | <ASSISTANT_TASK:>
Python Code:
# !curl -O http://www.ssa.gov/oact/babynames/names.zip
# !mkdir -p data/names
# !mv names.zip data/names/
# !cd data/names/ && unzip names.zip
!ls data/names
!head data/names/yob1880.txt
names1880 = pd.read_csv('data/names/yob1880.txt')
names1880.head()
names1880 = pd.read_csv('data/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: Now we should have a data/names directory which contains a number of text files, one for each year of data
Step2: Let's take a quick look at on... |
8,853 | <ASSISTANT_TASK:>
Python Code:
import math
import torch
import gpytorch
import tqdm
from matplotlib import pyplot as plt
# Make plots inline
%matplotlib inline
import urllib.request
import os
from scipy.io import loadmat
from math import floor
# this is for running the notebook in our testing framework
smoke_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: Loading Data
Step2: LOVE can be used with any type of GP model, including exact GPs, multitask models and scalable approximations. Here we demo... |
8,854 | <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... |
8,855 | <ASSISTANT_TASK:>
Python Code:
# load packages we will be using for this lesson
import pandas as pd
# use pd.read_csv to open data into python
df = pd.read_csv("uncapher_2016_repeated_measures_dataset.csv")
df.head()
df.shape
df.columns
df = df[["subjNum", "groupStatus", "adhd", "hitRate", "faRate", "dprime"]]
df.he... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Open Dataset and Load Package
Step2: Familiarize Yourself with the Data
Step3: Selecting Relevant Variables
Step4: Basic Descriptives
Step5: ... |
8,856 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
from unityagents import UnityEnvironment
%matplotlib inline
env_name = "3DBall" # Name of the Unity environment binary to launch
train_mode = True # Whether to run the environment in training or inference mode
env = UnityEnvironment(fil... | <SYSTEM_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. Set environment parameters
Step2: 3. Start the environment
Step3: 4. Examine the observation and state spaces
Step4: 5. Take random action... |
8,857 | <ASSISTANT_TASK:>
Python Code:
import graphlab;
graphlab.product_key.set_product_key("7348-CE53-3B3E-DBED-152B-828E-A99E-F303");
products = graphlab.SFrame('amazon_baby.gl/')
products.head()
products['word_count'] = graphlab.text_analytics.count_words(products['review'])
products... | <SYSTEM_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 some product review data
Step2: Let's explore this data together
Step3: Build the word count vector for each review
Step4: Examining the... |
8,858 | <ASSISTANT_TASK:>
Python Code:
# libraries
import numpy as np # numpy
import scipy as sp # scipy
import scipy.constants as sp_c # scientific constants
import sys # sys to add py_matrix to the path
# matplotlib inline plots
import matplotlib.pylab as plt
%matplotlib inline
# adding py_matrix parent folder to python pat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: MCD functions as found in
Step2: Inputs
Step3: Scalar MCD calculations following Nano Lett. 2013, 13, 4785–4789
Step4: Full Transfer Matrix ... |
8,859 | <ASSISTANT_TASK:>
Python Code:
import queue
import numpy
from matplotlib import pylab
# %matplotlib inline
pylab.rcParams['figure.figsize'] = (8.0, 8.0)
pylab.rcParams['image.cmap'] = 'rainbow'
import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord
from astropy import units as u
from data_models.polar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Define the data to be generated
Step2: Create two queues, an input and output. Call them CSP (in) and TM (out).
Step3: Now populate the CSP qu... |
8,860 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn
plt.rcParams['figure.figsize'] = 9, 6
from sklearn.feature_selection import VarianceThreshold
X = np.array([[0, 2, 0, 3], [0, 1, 4, 3], [0, 1, 1, 3]])
X
selector = VarianceThreshold(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: Filter
Step2: Potom mozeme vyberat atributy na zaklade zavislosti atributu a predikovanej hodnoty
Step3: Daju sa pouzivat rozne metriky
Step4:... |
8,861 | <ASSISTANT_TASK:>
Python Code:
import bs4
import requests
jbindexurl = lambda page: "http://www.amnesty.de/laenderbericht/australien?page=%d&country=&topic=&node_type=ai_annual_report&from_month=0&from_year=&to_month=0&to_year=&submit_x=103&submit_y=13&submit=Auswahl+anzeigen&result_limit=50&form_id=ai_core_search_form... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 2
Step3: Step 3
|
8,862 | <ASSISTANT_TASK:>
Python Code:
# Import Numpy, TensorFlow, TFLearn, and MNIST data
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
# mnist fails to load, so got this patch from the nd101 slack
def patched_read32(bytestream):
dt = np.dtype(np.uint32).newbyteorder('>'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Retrieving training and test data
Step2: Visualize the training data
Step3: Building the network
Step4: Training the network
Step5: Testing
|
8,863 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import csv
from datetime import datetime, timedelta
def timeparse(ds):
timestamp = datetime.strptime(ds, "%Y%m%d%H%M%S")
#return "{0}-{1}-{2}T{3}:{4}:{5}Z".format(year, month, day, hh, mm, ss)
return timestamp
counts = [0] * 24
trips = []
times = []
last = d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: My niece is always complaining there was no service between 11
Step2: That's actually not so bad. There is a lull in service at 1
Step3: Now t... |
8,864 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [10, 10]
import skrf as rf
from skrf.media import DistributedCircuit
f = rf.Frequency(0.4, 2, 101)
tem = DistributedCircuit(f, z0=50)
# import the scattering parameters/noise data for the transistor
bjt = ... | <SYSTEM_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 smith chart for it
Step2: Now let's calculate the source and load stability curves.
Step3: So we can see that we need to avoid ... |
8,865 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from seabird.cnv import fCNV
from gsw import z_from_p
!wget https://raw.githubusercontent.com/castelao/seabird/master/sampledata/CTD/dPIRX003.cnv
profile = fCNV('dPIRX003.cnv')
print("Header: %s" % profile.attributes.keys())
print("Data: %s" % profile.keys())
z = z_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: Let's first download an example file with some CTD data
Step2: The profile dPIRX003.cnv.OK was loaded with the default rule cnv.yaml
Step3: We... |
8,866 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import qgrid
qgrid.nbinstall()
from biokbase import data_api
from biokbase.data_api import display
display.nbviewer_mode(True)
import os
os.environ['KB_AUTH_TOKEN'] = open('/tmp/kb_auth_token.txt').read().strip()
b = data_api.browse(101... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Authorization
Step2: Find and load an object
Step3: Get the contigs for the assembly
Step4: View the contigs
|
8,867 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'uhh', 'sandbox-3', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,868 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x = np.arange(10.)
y = 5*x+3
np.random.seed(3)
y+= np.random.normal(scale=10,size=x.size)
plt.scatter(x,y);
def lin_reg(x,y):
Perform a linear regression of x vs y.
x, y are 1 dimensional numpy arrays
r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linear regression
Step3: We could also implement it with the numpy covariance function. The diagonal terms represent the variance.
Step5: Codi... |
8,869 | <ASSISTANT_TASK:>
Python Code:
def get_data(url, access, file_name):
This function takes an url, parameter for the key
'access'/'access-site' depends on getting pageviews
or pagecounts dataset. Then save the data as json
file with the name as given file_name to your directory.
Args:
... | <SYSTEM_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: 1.1 Get the Pageviews Data, desktop
Step3: 1.2 Get the Pageviews Data, mobile-web
Step4: 1.3 Get the Pageviews Data, mobile-app... |
8,870 | <ASSISTANT_TASK:>
Python Code:
# Import findspark
import findspark
# Initialize and provide path
findspark.init("/home/henrique/Downloads/spark")
# Or use this alternative
#findspark.init()
# Import SparkSession
from pyspark.sql import SparkSession
# Build the SparkSession
spark = SparkSession.builder \
.master... | <SYSTEM_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 directly from the csv
Step2: Excluding rows that are not needed
Step3: Now, we need to start using MLlib - spark ml library
Step4: Se... |
8,871 | <ASSISTANT_TASK:>
Python Code:
from thermostate import State, Q_, units
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
substance = 'air'
p_1 = Q_(1.0, 'bar')
T_1 = Q_(300.0, 'K')
mdot = Q_(6.0, 'kg/s')
T_3 = Q_(1400.0, 'K')
p2_p1 = Q_(10.0, 'dimensionless')
T_3_low = Q_(1000.0, 'K')
T_3_high = Q... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Definitions
Step2: Problem Statement
Step3: Summarizing the states,
Step4: <div class="alert alert-success">
Step5: <div class="alert alert-... |
8,872 | <ASSISTANT_TASK:>
Python Code:
from noodles.tutorial import display_text
import pickle
function = pickle.dumps(str.upper)
message = pickle.dumps("Hello, Wold!")
display_text("function: " + str(function))
display_text("message: " + str(message))
pickle.loads(function)(pickle.loads(message))
import noodles
def registry(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: However pickle cannot serialise all objects ... "Use dill!" you say; still the pickle/dill method of serializing is rather indiscriminate. Some ... |
8,873 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import copy
import os
import pandas as pd
import matplotlib.pyplot as plt
import tsam.timeseriesaggregation as tsam
%matplotlib inline
raw = pd.read_csv('testdata.csv', index_col = 0)
raw.head()
raw.shape
def plotTS(data, periodlength, vmin, vmax):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Input data
Step2: Show a slice of the dataset
Step3: Show the shape of the raw input data
Step4: Create a plot function for the temperature f... |
8,874 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
import numpy as np
import mne
from mne import io
from mne.stats import permutation_t_test
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
raw_fname = data_path + '/MEG/samp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: View location of significantly active sensors
|
8,875 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import os, pickle, random
import pandas as pd
import numpy as np
import cvxopt
import seaborn as sns
random.seed(1234554321)
np.random.seed(123456789)
cvxopt.base.setseed(123456789)
%run 'ssvm_ml.ipynb'
#dump_vars = True
#fname = os.pat... | <SYSTEM_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 notebook ssvm.ipynb.
Step2: Step 1 - Generate new dataset
Step3: Compute feature scaling parameters
Step4: Generating trajectories
Step5:... |
8,876 | <ASSISTANT_TASK:>
Python Code:
import requests
from bs4 import BeautifulSoup
from IPython.display import display_html, HTML
HTML('<iframe src= http://bbs.tianya.cn/list.jsp?item=free&nextid=%d&order=8&k=PX width=1000 height=500></iframe>')
# the webpage we would like to crawl
page_num = 0
url = "http://bbs.tianya.cn/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: 一般的数据抓取,使用urllib2和beautifulsoup配合就可以了。
Step2: http
Step3: 抓取天涯论坛PX帖子列表
Step4: 抓取作者信息
Step5: http
Step6: http
Step7: 作者:柠檬在追逐 时间:2012-10-28... |
8,877 | <ASSISTANT_TASK:>
Python Code:
data_path = "/data/datasets/taxi/"
meta = pd.read_csv(data_path+'metaData_taxistandsID_name_GPSlocation.csv', header=0)
meta.head()
train = pd.read_csv(data_path+'train/train.csv', header=0)
train.head()
train['ORIGIN_CALL'] = pd.Series(pd.factorize(train['ORIGIN_CALL'])[0]) + 1
train['O... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Replication of 'csv_to_hdf5.py'
Step2: The array of long/lat coordinates per trip (row) is read in as a string. The function ast.literal_eval(x... |
8,878 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import cv2
import matplotlib.pyplot as plt
import os
import glob
import random as rnd
from scipy.ndimage import filters
from PIL import Image
from numpy import *
from pylab import *
from pandas import *
np.seterr(divide='ignore', invalid='ignore')
#C... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First off, Harris detector computes a squared matrix M comprised basically of derivatives of image pixels on both x and y axis.
Step3: Afterwar... |
8,879 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
sns.set_context('poster')
# Use MOMA's ID as index
# Parse `DateAcquired` column as a datetime
moma = pd.read_csv('Artworks.csv', index_col=12, parse_dates=[10])
# Show the fir... | <SYSTEM_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 and clean the data
Step2: Most of the plots below depend on the DateAcquired field being valid, so I'm going to cheat and dump all the rec... |
8,880 | <ASSISTANT_TASK:>
Python Code:
# Set up code checking
import os
if not os.path.exists("../input/train.csv"):
os.symlink("../input/home-data-for-ml-course/train.csv", "../input/train.csv")
os.symlink("../input/home-data-for-ml-course/test.csv", "../input/test.csv")
from learntools.core import binder
binder.bi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In this exercise, you will work with data from the Housing Prices Competition for Kaggle Learn Users.
Step2: Use the next code cell to print t... |
8,881 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
from sklearn.neighbors import KNeighborsClassifier
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn.grid_search import GridSearchCV
# read in the iris data
iris = load_iris()
# create X (features) and y (response)
X = iris.data
y = iri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 我们可以知道,这里的grid search针对每个参数进行了10次交叉验证,并且一共对30个参数进行相同过程的交叉验证
Step2: 3. 同时对多个参数进行搜索
Step3: 4. 使用最佳参数做出预测
Step4: 这里使用之前得到的最佳参数对模型进行重新训练,在训练时,就可以... |
8,882 | <ASSISTANT_TASK:>
Python Code:
def getSubSeq(s , n ) :
res = ""
cr = 0
while(cr < n ) :
mx = s[cr ]
for i in range(cr + 1 , n ) :
mx = max(mx , s[i ] )
lst = cr
for i in range(cr , n ) :
if(s[i ] == mx ) :
res += s[i ]
lst = i
cr = lst + 1
return res
if __name__== ' __main __' ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
8,883 | <ASSISTANT_TASK:>
Python Code:
import nltk
nltk.download("movie_reviews")
nltk.download()
from nltk.corpus import movie_reviews
len(movie_reviews.fileids())
movie_reviews.fileids()[:5]
movie_reviews.fileids()[-5:]
negative_fileids = movie_reviews.fileids('neg')
positive_fileids = movie_reviews.fileids('pos')
len(neg... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You can also list and download other datasets interactively just typing
Step2: The fileids method provided by all the datasets in nltk.corpus g... |
8,884 | <ASSISTANT_TASK:>
Python Code:
import snappy
from snappy import ProductIO
file_path = 'C:\Program Files\snap\S2A_MSIL1C_20170202T090201_N0204_R007_T35SNA_20170202T090155.SAFE\MTD_MSIL1C.xml'
product = ProductIO.readProduct(file_path)
list(product.getBandNames())
B4 = product.getBand('B4')
B5 = product.getBand('B5')
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: According to the S-2 data product specifics, band 4 and band 5 are represented with rasters of different sizes and that can be easily verified
... |
8,885 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
from phoebe import u # units
logger = phoebe.logger(clevel='WARNING')
b = phoebe.default_binary()
b.set_value(qualifier='teff', component='primary', value=6500)
b.add_dataset('lc', compute_times=phoebe.linspace(0,1,101))
b.run_comput... | <SYSTEM_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 get started with some basic imports
Step2: If running in IPython notebooks, you may see a "ShimWarning" depending on the version of Jupyt... |
8,886 | <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: Root Search
Step2: This notebook demonstrates the use of low level Tensorflow Quant Finance tools for root finding using Brent's method with em... |
8,887 | <ASSISTANT_TASK:>
Python Code:
py = ConceptModel(['Python'])
py.concepts()
py.explode()
len(py.concepts())
py.edges()
database = ConceptModel(['Database'])
database.explode(limit=2000, level=1)
len(database.concepts())
database.edges()[:20]
py.edges()[:20]
py.augment('Standard Library')
len(py.concepts())
py.neighbo... | <SYSTEM_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 I am going to explode the and see what it does...
Step2: The next operation explores the edges of the concept
Step3: Expansion
Step4: Let... |
8,888 | <ASSISTANT_TASK:>
Python Code:
!pip install requests
!pip install pandas
import requests
import pandas as pd
import calendar, datetime, time
url = 'https://earthquake.usgs.gov/fdsnws/event/1/count?starttime=2017-09-20&endtime=2017-09-21'
response = requests.get(url)
response
response.text
url = 'https://earthquake.u... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Unsere Imports
Step2: Zur Dokumentation von requestst geht es hier lang.
Step3: Wieviele hat es letzte Nacht von 22 bis 6 Uhr morgens gegeben?... |
8,889 | <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
|
8,890 | <ASSISTANT_TASK:>
Python Code:
from osm_dataauditor import OSMDataAuditor
osm_data = OSMDataAuditor('jakarta_indonesia.osm')
# Basic element check
osm_data.count_element()
# Check the tag key and element
tag_keys = osm_data.get_tag_keys()
sorted(tag_keys, key=lambda x: x[1], reverse=True)[:20]
import re
# Name vs Na... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: OSM allows a very flexible tagging system, which gives user freedom but causing problem with consistency.
Step2: Below I list the top 20 tag ke... |
8,891 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from time import time
import datetime
import lightgbm as lgb
import gc, warnings, json
import seaborn as sns
from sklearn.metrics import precision_score, recall_score, confusion_matrix, accuracy_score
from sklearn.metrics import roc_auc_score, f1_sco... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Feature Evaluation Pipeline
Step2: The function above does a few things. First, it downsamples the negative values. This was reported by a numb... |
8,892 | <ASSISTANT_TASK:>
Python Code:
! curl https://www.tesla.com/sites/default/files/tesla-model-s.pdf > /tmp/tsla.pdf
! pdftotext /tmp/tsla.pdf # saves into /tmp/tsla.txt
! head -10 /tmp/tsla.txt
with open('/tmp/tsla.txt') as f:
print(f.read().split()[:100])
! tr -s '\n' ' ' < /tmp/tsla.txt | head -c 200
! tr -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: That command downloads the file and because of the redirection operator, >, the output gets written to tsla.pdf up in /tmp directory.
Step2: ... |
8,893 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'miroc', 'miroc-es2h', 'ocean')
# 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: 1... |
8,894 | <ASSISTANT_TASK:>
Python Code:
def expand(X):
X_ = tf.zeros((X.shape[0], 6))
X0 = tf.transpose(tf.gather(tf.transpose(X), [0]))
X1 = tf.transpose(tf.gather(tf.transpose(X), [1]))
X_ = tf.concat([X, X ** 2, X0 * X1, tf.ones(shape=(X.shape[0], 1))], axis=1)
return X_
def classify(X, w):
Given... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Your task starts here
Step4: The loss you should try to minimize is the Hinge Loss
Step5: Training
Step6: Implement gradient descent with mom... |
8,895 | <ASSISTANT_TASK:>
Python Code:
# pandas 모듈에서 DataFrame 함수와 read_csv 함수 임포트
from pandas import DataFrame, read_csv
# matplolib.pyplot 모듈과 pandas 모듈을 각각 plt와 pd라는 별칭으로 임포트
import matplotlib.pyplot as plt
import pandas as pd
# 쥬피터 노트북에서 그래프를 직접 나타내기 위해 사용하는 코드
# 파이썬 전문 에디터에서는 사용하지 않음
%matplotlib inline
# 아이 이름과 출생신고 숫자 리... | <SYSTEM_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: 두 개의 리스트를 합하여 이름과 숫자를 쌍으로 묶기 위해서 zip 함수를 이용한다.
Step3: zip 객체를 리스트 자료형으로 형변환을 하면 쌍들의 리스트로 활용할 수 있으며, 여기서는
Step4: 주의
Step5: df에 ... |
8,896 | <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: Recurrent Neural Networks (RNN) with Keras
Step2: Built-in RNN layers
Step3: Built-in RNNs support a number of useful features
Step4: In addi... |
8,897 | <ASSISTANT_TASK:>
Python Code:
from google.cloud import bigquery
compute_alpha =
#standardSQL
SELECT
SAFE_DIVIDE(
SUM(arrival_delay * departure_delay),
SUM(departure_delay * departure_delay)) AS alpha
FROM
(
SELECT
RAND() AS splitfield,
arrival_delay,
departure_delay
FROM
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: <h3> Create a simple machine learning model </h3>
Step4: <h3> What is wrong with calculating RMSE on the training and test data as follows? </h... |
8,898 | <ASSISTANT_TASK:>
Python Code:
birds = pd.read_csv('../../data/bird_tracking.csv')
birds.head()
# TODO
# TODO
import cartopy.crs as ccrs
plt.figure(figsize=(10,10))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
# TODO 1: comment in/out and see, what happens
# ax.set_extent((-25,20,52,10))
# TODO 2: d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercise 1
Step2: Exercise 2
Step3: Exercise 3
Step4: Exercise 3.1
Step5: Exercise 3.2
|
8,899 | <ASSISTANT_TASK:>
Python Code:
import graphlab
tmp = graphlab.SArray([1., 2., 3.])
tmp_cubed = tmp.apply(lambda x: x**3)
print tmp
print tmp_cubed
ex_sframe = graphlab.SFrame()
ex_sframe['power_1'] = tmp
print ex_sframe
def polynomial_sframe(feature, degree):
# assume that degree >= 1
# initialize the 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: Next we're going to write a polynomial function that takes an SArray and a maximal degree and returns an SFrame with columns containing the SArr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.