Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
5,600 | <ASSISTANT_TASK:>
Python Code:
import warnings
import numpy as np
import pandas as pd
from scipy.sparse import hstack
from sklearn.cross_validation import cross_val_predict
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data Cleaning
Step2: Subsample
Step3: Clustering
Step4: Models
Step5: Log Odds Ratio features
Step6: NMF features
Step8: Cross-Validated E... |
5,601 | <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: Use Membership Inference and Secret Sharer to Test Word Embedding Models
Step2: Membership Inference Attacks
Step3: We now define our loss fun... |
5,602 | <ASSISTANT_TASK:>
Python Code:
sample_points_filepath = ""
DEM_filepath = ""
elevation_filepath = ""
import rasterio
import fiona
import pandas
import numpy
from pyproj import Proj, transform
from fiona.crs import from_epsg
with fiona.open(sample_points_filepath, 'r') as source_points:
points = [f['geometry']['coo... | <SYSTEM_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 statements
Step2: Transform points
|
5,603 | <ASSISTANT_TASK:>
Python Code:
def timestamps(packets):
epoch = np.datetime64('2000-01-01T12:00:00')
t = np.array([struct.unpack('>I', p[ccsds.SpacePacketPrimaryHeader.sizeof():][:4])[0]
for p in packets], 'uint32')
return epoch + t * np.timedelta64(1, 's')
def load_frames(path):
frame... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: AOS frames
Step2: Virtual Channel 63 (Only Idle Data)
Step3: Virtual channel 0
Step4: APID 5
|
5,604 | <ASSISTANT_TASK:>
Python Code:
primes = []
i = 2
while len(primes) < 25:
for p in primes:
if i % p == 0:
break
else:
primes.append(i)
i += 1
print(primes)
def square(val):
print(val)
return val ** 2
squared_numbers = [square(i) for i in range(5)]
print('Squared from list... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Functional
Step4: Object oriented
Step7: There is a lot happening above.
Step11: There are many more special methods.
Step14: Both of our ob... |
5,605 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from selenium import webdriver
import time,re,json,numpy as np
import pandas as pd
from collections import defaultdict,Counter
import matplotlib.pyplot as plt
url = "http://www.imdb.com/list/ls061683439/"
with open('./img/filmfare.json',encoding="utf-8") as f:
dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initial Setup and Launch the browser to open the URL
Step2: Beautiful Soup
Step3: Getting Data
Step4: Let's extract all the required data lik... |
5,606 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import salib as sl
sl.import_notebooks()
from Tables import Table
from Nodes import Node
from Members import Member
from LoadSets import LoadSet, LoadCombination
from NodeLoads import makeNodeLoad
from MemberLoads import makeMemberLoad
from collection... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test Frame
Step2: Supports
Step3: Members
Step4: Releases
Step5: Properties
Step6: Node Loads
Step7: Member Loads
Step8: Load Combination... |
5,607 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image classification with TensorFlow Lite Model Maker
Step2: Import the required packages.
Step3: Simple End-to-End Example
Step4: You could ... |
5,608 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset 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: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
5,609 | <ASSISTANT_TASK:>
Python Code:
from nltk.featstruct import FeatStruct
f1 = FeatStruct(
'[Vorname=Max, Nachname=Mustermann,' +
'Privat=[Strasse=Hauptstrasse, Ort=[Muenchen]]]'
)
f2 = FeatStruct(
'[Arbeit=[Strasse="Oettingenstrasse", Ort=(1)["Muenchen"]],' +
'Privat=[Ort->(1)]]')
f3 = FeatStruct(
'[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Gegeben seien folgende Merkmalstrukturen
Step2: Unifizieren Sie
Step3: f2 mit f4
Step5: Aufgabe 2 Typhierarchie im NLTK
St... |
5,610 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
from tensorflow.contrib import rnn
class SeriesPredictor:
def __init__(self, input_dim, seq_size, hidden_dim=10):
# Hyperparameters
self.input_dim = input_dim
self.seq_size = seq_size
self.hidden_dim = hidden_... | <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: Define the RNN model
Step3: Now, we'll train a series predictor. Let's say we have a sequence of numbers [a, b, c, d] that we want to transform... |
5,611 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from qutip import *
from qutip import rcsolve
Del = 1.0 # The number of qubits in the system.
wq = 0.5 # Energy of the 2-level system.
Hsys = 0.5 * wq * sigmaz() + 0.5 * Del * sigmax()
Q = sigmaz()
wc = 0.05 # Cutoff frequency.
alpha = 2.5/pi ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Defining the 2-level system
Step2: Defining the coupling Q such that
Step3: Plotting the TLS state occupation
Step4: Plotting the photon dist... |
5,612 | <ASSISTANT_TASK:>
Python Code:
# import data from url
from py2cytoscape.data.cyrest_client import CyRestClient
# Create REST client for Cytoscape
cy = CyRestClient()
# Reset current session for fresh start
cy.session.delete()
# Load a sample network
network = cy.network.create_from('http://chianti.ucsd.edu/~kono/data/g... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Save image as png
Step2: Save image as svg
Step3: Save image as pdf
|
5,613 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from pandas import Series,DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
%matplotlib inline
from sklearn.datasets import load_boston
# Load the housing dataset
boston = load_boston()
print(boston.DESCR)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Imports for plotting
Step2: Now import dataset from scikit learn as well as the linear_model module. Note
Step3: Next we'll download the data ... |
5,614 | <ASSISTANT_TASK:>
Python Code:
#here we define sympy symbols to be used in the analytic calculations
g,mu,b,D,k=sympy.symbols('gamma mu B Delta k',real=True)
# onsite and hopping terms
U=sympy.Matrix([[-mu+b,g,0,D],
[g,-mu-b,-D,0],
[0,-D,mu-b,-g],
[D,0,-g,mu+b]])
T=sy... | <SYSTEM_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 us define a simple real, and hence time reversal invariant lattice model that can serve as a good description to a 1D chiral edge channel. W... |
5,615 | <ASSISTANT_TASK:>
Python Code:
from datasets import *
from qiskit_aqua.utils import split_dataset_to_data_and_labels
from qiskit_aqua.input import get_input_instance
from qiskit_aqua import run_algorithm
import numpy as np
n = 2 # dimension of each data point
sample_Total, training_input, test_input, class_labels = W... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here we choose the Wine dataset which has 3 classes.
Step2: Now we setup an Aqua configuration dictionary to use the quantum QSVM.Kernel algori... |
5,616 | <ASSISTANT_TASK:>
Python Code:
# Author: Denis A. Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import os
import os.path as op
import numpy as np
from scipy.misc import imread
import matplotlib.pyplot as plt
import mne
from mne import io
from mne.datasets import spm_face
from mne.minimum_norm import 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: Get data
Step2: Estimate covariances
Step4: Show the resulting source estimates
|
5,617 | <ASSISTANT_TASK:>
Python Code:
import pyautogui
# let us first change directory to the `files` subdirectory, to store these values
import os
os.chdir('files')
os.getcwd()
pyautogui.screenshot()
pyautogui.screenshot('screenshot_example.png')
pyautogui.locateOnScreen('calc7key.png')
pyautogui.locateCenterOnScreen('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: We can use the screenshot() function to take a screenshot of the current screen.
Step2: This creates an immediate screenshot file, stored in me... |
5,618 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy import optimize
sns.set()
from collections import Counter
from ICGC_data_parser import SSM_Reader
mutations_per_gene = Counter()
mutations = SSM_Reader(filename='/home/ad115/Downloads/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: We first map genes to the number of mutations they harbor (read from a random sample of 100,000 mutations)
Step2: Now we want to group by numbe... |
5,619 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import h5py
import matplotlib.pyplot as plt
from testCases_v2 import *
from dnn_utils_v2 import sigmoid, sigmoid_backward, relu, relu_backward
%matplotlib inline
plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots
plt.rcParams['image.interpolation'] ... | <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: 2 - Outline of the Assignment
Step4: Expected output
Step6: Expected output
Step8: Expected output
Step10: Expected output
Step12: <table s... |
5,620 | <ASSISTANT_TASK:>
Python Code:
import cantera
print cantera.__version__
from rmgpy.chemkin import *
from rmgpy.tools.canteraModel import *
from rmgpy.tools.plot import parseCSVData
from rmgpy.species import Species
from IPython.display import display, Image
speciesList, reactionList = loadChemkinFile('data/minimal_mod... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the species and reaction from the RMG-generated chemkin file chem_annotated.inp and species_dictionary.txt file found in your chemkin folde... |
5,621 | <ASSISTANT_TASK:>
Python Code:
from fretbursts import *
sns = init_notebook()
url = 'http://files.figshare.com/2182602/dsdna_d7_d17_50_50_1.hdf5'
download_file(url, save_dir='./data')
filename = './data/dsdna_d7_d17_50_50_1.hdf5'
filename
# filename = OpenFileDialog()
# filename
import os
if os.path.isfile(filename):... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Downloading the sample data file
Step2: Selecting a data file
Step3: Load the selected file
Step4: Execute the previous 2 cells until you get... |
5,622 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt, cm
from skimage import io
image = io.imread('../images/zebrafish-spinal-cord.png')
from scipy import ndimage as nd
top, bottom = image[[0, -1], :]
fig, (ax0, ax1) = plt.subplots(nrows=1, ncols=2, figsize=(8, 3))
top_smooth = nd.gau... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SciPy to estimate coordinates
Step2: With smooth curves, we can get the mode (the position of the center) and width of the signal.
Step3: scik... |
5,623 | <ASSISTANT_TASK:>
Python Code:
# pip install watermark
%reload_ext watermark
%watermark -v -m -p gensim,numpy,scipy,psutil,matplotlib
import os.path
if not os.path.isfile('text8'):
!wget -c http://mattmahoney.net/dc/text8.zip
!unzip text8.zip
LOGS = False
if LOGS:
import logging
logging.basicConfig(fo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Download Text8 Corpus
Step2: Import & Set up Logging
Step3: 2. Build Word2Vec Model
Step5: See the Word2Vec tutorial for how to initialize... |
5,624 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data_small.gl/kc_house_data_small.gl')
import numpy as np # note this allows us to refer to numpy as np instead
def get_numpy_data(data_sframe, features, output):
data_sframe['constant'] = 1 # this is how you add a constant column to... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in house sales data
Step2: Import useful functions from previous notebooks
Step3: We will also need the normalize_features() function fro... |
5,625 | <ASSISTANT_TASK:>
Python Code:
#Add all dependencies to PYTHON_PATH
import sys
sys.path.append("/usr/lib/spark/python")
sys.path.append("/usr/lib/spark/python/lib/py4j-0.10.4-src.zip")
sys.path.append("/usr/lib/python3/dist-packages")
#Define environment variables
import os
os.environ["HADOOP_CONF_DIR"] = "/etc/hadoop/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Connect to Spark
Step2: Read a GeoTiff file
Step3: Visualization
Step4: Interactive visualization
Step5: Histogram
|
5,626 | <ASSISTANT_TASK:>
Python Code:
import pymongo
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import json
import re
from pymongo import MongoClient
%matplotlib inline
client = MongoClient('mongodb')
db = client.dp
collection = db.divorce
data = db.divorce.find()[0]['data']
for entry in 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: 1. Connect to mongoDB
Step2: 2. Fetch & Transform
Step3: Transform to JSON for pandas import
Step4: Plot
|
5,627 | <ASSISTANT_TASK:>
Python Code:
from matplotlib.colors import ListedColormap
from sklearn import cross_validation, datasets, linear_model, metrics
import numpy as np
%pylab inline
blobs = datasets.make_blobs(centers = 2, cluster_std = 5.5, random_state=1)
colors = ListedColormap(['red', 'blue'])
pylab.figure(figsize(8,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Генерация данных
Step2: Линейная классификация
Step3: LogisticRegression
Step4: Оценка качества по cross-validation
Step5: cross_val_score с... |
5,628 | <ASSISTANT_TASK:>
Python Code:
!pip install google-cloud-bigquery
# Automatically restart kernel after installs
import IPython
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
PROJECT_ID = "your_project_id"
REGION = 'US'
from google.cloud import bigquery
import time
import pandas as pd
pd.set_optio... | <SYSTEM_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 your GCP project
Step2: Import libraries and define constants
Step3: Creating a BigQuery dataset
Step4: Raw data
Step5: Pre-process t... |
5,629 | <ASSISTANT_TASK:>
Python Code:
!ls
!ps x|grep python
%load_ext fortranmagic
%%fortran
subroutine f1(x, y, z)
real, intent(in) :: x,y
real, intent(out) :: z
z = sin(x+y)
end subroutine f1
f1(3,4)
?f1
%load_ext oct2py.ipython
%%octave
A=rand(10)
A
x = %octave [1 2; 3 4];
x
%%octave -f svg
p = [12 -2.5 -8 -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: Fortran
Step2: Octave
|
5,630 | <ASSISTANT_TASK:>
Python Code:
import os, numpy as np
import histogram.hdf as hh, histogram as H
from matplotlib import pyplot as plt
%matplotlib notebook
# %matplotlib inline
import mantid
from multiphonon.sqe import plot as plot_sqe
from multiphonon.ui.getdos import Context, NxsWizardStart, QEGridWizardStart, GetDOSW... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create a context for getdos. It stores the processing parameters.
Step2: Create a new working directory and change into it. All intermediate re... |
5,631 | <ASSISTANT_TASK:>
Python Code:
from collections import Counter
import pandas as pd
%matplotlib inline
from pylab import rcParams
from bs4 import BeautifulSoup
import textacy
rcParams['figure.figsize'] = 10, 4
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import spacy
nlp = spacy.load('en')
with open('pride.tx... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exploratory analysis of quoted speech
Step2: From the Penn Treebank table
Step9: Pride and Prejudice Highlights
|
5,632 | <ASSISTANT_TASK:>
Python Code:
a=[12586269025, 20365011074, 32951280099, 53316291173, 86267571272, 139583862445, 225851433717,365435296162, 591286729879,
956722026041, 1548008755920, 2504730781961, 4052739537881, 6557470319842, 10610209857723, 17167680177565, 27777890035288,
44945570212853, 72723460248141, 11766903... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 02-if
Step2: 03-Mértani sorozat
Step3: 04-Telefon központ
Step4: 05-Változó számú argumentumok-I
Step5: 07-kulcsszavas függvény változó szám... |
5,633 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline
from sklearn.datasets import make_regression
bias = 100
X0, y, coef = make_regression(n_samples=100, n_features=1, bias=bias, noise=10, coef=True, random_state=1)
X = np.hstack([np.ones_like(X0), X0]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: OLS (Ordinary Least Squares)
Step2: scikit-learn 패키지를 사용한 선형 회귀 분석
Step3: Boston Housing Price
Step4: statsmodels 를 사용한 선형 회귀 분석
Step5: Reg... |
5,634 | <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: Keras 中的遮盖和填充
Step2: 简介
Step3: 遮盖
Step4: 您可以在输出结果中看到,该掩码是一个形状为 (batch_size, sequence_length) 的二维布尔张量,其中每个 False 条目表示对应的时间步骤应在处理时忽略。
Step5: 对... |
5,635 | <ASSISTANT_TASK:>
Python Code:
import graphlab
products = graphlab.SFrame('amazon_baby_subset.gl/')
products['sentiment']
products.head(10)['name']
print '# of positive reviews =', len(products[products['sentiment']==1])
print '# of negative reviews =', len(products[products['sentiment']==-1])
import json
with open... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load review dataset
Step2: One column of this dataset is 'sentiment', corresponding to the class label with +1 indicating a review with positiv... |
5,636 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# from scipy.stats import norm
import scipy.stats as ss
import elfi
import logging
import matplotlib
import matplotlib.pyplot as plt
from scipy.stats import gaussian_kde
%matplotlib inline
# Set an arbitrary global seed to keep the randomly generated quantities the same... | <SYSTEM_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 reproduce the Example 1 from [1] as a test case for AdaptiveThresholdSMC.
Step2: Adaptive threshold selection ABC (elfi.AdaptiveThresholdSMC... |
5,637 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
from tensorprob import Model, Parameter, Normal, Exponential, Mix2, ScipyLBFGSBOptimizer
# We use the matplotlib_hep library to easily create high energy physics plots
from matplotlib_hep import histpoints
plt.rcPa... | <SYSTEM_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 model our distribution as a mixture of a normal distribution (parameters mu and sigma and mixture weight f) and an exponential distribution (... |
5,638 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
from IPython.display import display
assert True # leave this to grade the import statements
u = 'http://static1.squarespace.com/static/5201ab12e4b0ce82ad427ee2/53022aebe4b0649958de7de1/53022aeee4b0649958de7dec/1392650992037/tumblr_mz73s53TM11qf71bqo3_128... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic rich display
Step2: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi... |
5,639 | <ASSISTANT_TASK:>
Python Code:
#!pip install pint
#!pip install git+https://github.com/hgrecco/pint-pandas#egg=Pint-Pandas-0.1.dev0
import pint
units = pint.UnitRegistry()
pint.__version__
thickness = 68 * units.m
thickness
thickness.magnitude, thickness.units, thickness.dimensionality
f'{thickness**2}'
print(f'{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: To use it in its typical mode, we import the library then instantiate a UnitRegistry object. The registry contains lots of physical units.
Step2... |
5,640 | <ASSISTANT_TASK:>
Python Code:
from awips.dataaccess import DataAccessLayer
import matplotlib.tri as mtri
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from math import exp, log
import numpy as np
from metpy.calc import get_wind_components, lcl, dry_lapse, parcel_profile, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Available Locations
Step2: Model Sounding Parameters
Step3: Calculating Dewpoint from Specific Humidity
Step4: 2) metpy calculated assuming s... |
5,641 | <ASSISTANT_TASK:>
Python Code:
# Package imports
import matplotlib.pyplot as plt
import numpy as np
import sklearn
import sklearn.datasets
import sklearn.linear_model
import matplotlib
# Display plots inline and change default figure size
%matplotlib inline
matplotlib.rcParams['figure.figsize'] = (10.0, 8.0)
# Generat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generating a dataset
Step2: The dataset we generated has two classes, plotted as red and blue points. You can think of the blue dots as male pa... |
5,642 | <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: Post-training float16 quantization
Step2: Train and export the model
Step3: For the example, you trained the model for just a single epoch, so... |
5,643 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import sqlite3
import matplotlib
%matplotlib inline
matplotlib.style.use('ggplot')
cnx = sqlite3.connect('database.sqlite')
rank_vs_ncomps = pd.read_sql_query(
SELECT U.Ranking AS rank, COUNT(M.TeamId) as num_comps
FROM Users AS U
JOIN TeamMemberships AS M ON U.Id = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Is there any relationship between user ranking and the number of competitions entered?
Step4: We have used the log-log scale for both the x- an... |
5,644 | <ASSISTANT_TASK:>
Python Code:
def firstn(n):
num = 0
while num < n:
yield num
num += 1
print(sum(firstn(1000000)))
y = (x*2 for x in [1,2,3,4,5])
print y.next()
import random
class randomwalker_iter:
def __init__(self):
self.last = 1
self.rand = random.random()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: use build-in generator functions, such as xrange()
Step2: To implement a iterator, we have to define a class with two specific functions
|
5,645 | <ASSISTANT_TASK:>
Python Code:
# Execute this cell to load the notebook's style sheet, then ignore it
from IPython.core.display import HTML
css_file = '../style/custom.css'
HTML(open(css_file, "r").read())
# Import Libraries
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# Define parameters
vp0 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Computation of Green's functions and seismograms for the acoustic wave equation
Step2: 2D Green's function
Step3: 3D Green's function
Step4: ... |
5,646 | <ASSISTANT_TASK:>
Python Code:
# notebook to simulate a jupyter working environment
# the python module gets imported here...
from ipysig.core import IPySig
import networkx as nx
ctrl = IPySig('./app') # note this should point to the root folder of the express app
import pickle
import os
pkl_g = os.path.abspath(os.pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To start, we only need to import the IPySig object from the ipysig.core package. This is a singleton controller class that manages our sigma.js ... |
5,647 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
from math import log, sqrt
sales['sqft_living_sqrt'] = sales['sqft_living'].apply(sqrt)
sales['sqft_lot_sqrt'] = sales['sqft_lot'].apply(sqrt)
sales['bedrooms_square'] = sales['bedrooms']*sales['bedrooms']
# In the dataset, '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: Load in house sales data
Step2: Create new features
Step3: Squaring bedrooms will increase the separation between not many bedrooms (e.g. 1) a... |
5,648 | <ASSISTANT_TASK:>
Python Code:
type(True)
type(False)
True == True
True == False
False == False
5 == 5
5 == 7
5 != 7
5 > 3
-1 < 0
1 > 0
3.14 > 2.72
3.14 <= 2.72
'Hello!' != 'Hello!'
'Hi!' != 'Hello!'
[1, 2, 3] == [1, 2, 3]
[1, 2, 3] == [4, 5]
x = 5 == 7
y = 3 != 0
print(x, y)
z = x or y # Either x or y is True? Yes!... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Comparing things returns a bool
Step2: The result of a comparison can be stored in a variable and we can use it to do other things
Step3: Caut... |
5,649 | <ASSISTANT_TASK:>
Python Code:
!pip install --pre deepchem
import deepchem
deepchem.__version__
!pip install 'gym[atari]'
import deepchem as dc
import numpy as np
class PongEnv(dc.rl.GymEnvironment):
def __init__(self):
super(PongEnv, self).__init__('Pong-v0')
self._state_shape = (80, 80)
@property
de... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reinforcement Learning
Step2: Next we create a model to implement our policy. This model receives the current state of the environment (the pi... |
5,650 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
from tensorflow.python.framework import ops
from tf_func import *
from mnist import read_data_sets
mnist = read_data_sets('MNIST_data')
# Build Computational Graph
sess = tf.InteractiveSession()
# Initialize placeholders for data & labels
x = tf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Training
Step2: Save Weights
Step3: Simulate on CPU
|
5,651 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 's', 3, 'b'],
'B': ['green', 'red', 'blue', 'yellow', 'black']})
def g(df):
return df[pd.to_numeric(df.A, errors='coerce').notnull()]
result = 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:
|
5,652 | <ASSISTANT_TASK:>
Python Code:
from pygeocoder import Geocoder
apik='' #file-bol illeszd be
results = Geocoder(apik).geocode("FSEGA Cluj")
print(results[0].coordinates)
results[0].country
results[0].city
results[0].county
results[0].postal_code
results[0].formatted_address
results = Geocoder(apik).reverse_geocode(46.... | <SYSTEM_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 válaszban az összes Google Maps cím-tulajdonság benne van.
Step2: Fordított geokódolás
Step3: Alkalmazás
Step4: Geokódólás és hibakezelés
S... |
5,653 | <ASSISTANT_TASK:>
Python Code:
! pip install -q -U xarray matplotlib
! rm -rf data-driven-discretization-1d
! git clone https://github.com/google/data-driven-discretization-1d.git
! pip install -q -e data-driven-discretization-1d
# install the seaborn bug-fix from https://github.com/mwaskom/seaborn/pull/1602
! pip inst... | <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: Library code
Step3: model
Step4: one time step
Step5: visualize an example
Step6: Baseline performance
Step7: Untrained model
Step8: train... |
5,654 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
img = mnist.train.images[2]
plt.imshow(img.reshape((28, 28)), cmap='G... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Network Architecture
Step2: Training
Step3: Denoising
Step4: Checking out the performance
|
5,655 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import tensorflow as tf
import tflearn
from tflearn.data_utils import to_categorical
reviews = pd.read_csv('reviews.txt', header=None)
labels = pd.read_csv('labels.txt', header=None)
from collections import Counter
total_counts = Counter()
for idx,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preparing the data
Step2: Counting word frequency
Step3: Let's keep the first 10000 most frequent words. As Andrew noted, most of the words in... |
5,656 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import datetime
import open_cp
import open_cp.sources.sepp as source_sepp
rates = np.random.random(size=(10,10))
simulation = source_sepp.GridHawkesProcess(rates, 0.5, 10)
points = simulation.sample_to_randomised_grid(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simulate some test data
Step2: Train the model
Step3: Make predictions
|
5,657 | <ASSISTANT_TASK:>
Python Code:
# import the dataset
from quantopian.interactive.data.quandl import fred_gnp
# Since this data is public domain and provided by Quandl for free, there is no _free version of this
# data set, as found in the premium sets. This import gets you the entirety of this data set.
# import data op... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data goes all the way back to 1947 and is updated quarterly.
Step2: Let's go plot it for fun. This data set is definitely small enough to j... |
5,658 | <ASSISTANT_TASK:>
Python Code:
from __future__ import (absolute_import, division, print_function)
from functools import reduce, partial
from operator import mul
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
from pyneqsys.symbolic import SymbolicSys, TransformedSys, linear_exprs
sp.init_printing(... | <SYSTEM_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 consider
Step2: Let's define the stoichiometry and composition
Step3: and now a function for the system of equations
Step4: note how we... |
5,659 | <ASSISTANT_TASK:>
Python Code:
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.contrib.examples.bart import load_bart_od
from pyro.contrib.forecast import ForecastingModel, Forecaster, backtest, eval_crps
from pyro.infer.reparam import LocScaleReparam, StableReparam
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: Intro to Pyro's forecasting framework
Step2: Let's start with a simple log-linear regression model, with no trend or seasonality. Note that whi... |
5,660 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import logging
from conf import LisaLogging
LisaLogging.setup()#level=logging.WARNING)
import pandas as pd
from perf_analysis import PerfAnalysis
import trappy
from trappy import ILinePlot
from trappy.stats.grammar import Parser
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Run test workload
Step2: By default we'll run the EnergyModelWakeMigration test, which runs a workload alternating between high and low-intensi... |
5,661 | <ASSISTANT_TASK:>
Python Code:
# import numpy for SVD function
import numpy
# import matplotlib.pyplot for visualising arrays
import matplotlib.pyplot as plt
# create a really simple matrix
A = numpy.array([[-1,1], [1,1]])
# and show it
print("A = \n", A)
# plot the array
p = plt.subplot(111)
p.axis('scaled'); p.axis(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Start With A Simple Matrix
Step2: Now Take the SVD
Step3: Check U, S and V^T Do Actually Reconstruct A
|
5,662 | <ASSISTANT_TASK:>
Python Code:
# <!-- collapse=True -->
a = 1
b = 1.0
print(a, type(a), b, type(b))
# <!-- collapse=False -->
a = 'Mon texte'
b = "Mon deuxième texte"
print(a, type(a), b, type(b))
a = b'Mon texte'
print(a, type(a))
b = b'Mon deuxième texte'
b = b'Mon deuxi\xc3\xa8me texte'
print(b)
print(b.decode('... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mais il implémente aussi des nombres plus exotiques tels que les
Step2: Les bytes sont précédées de la lettre b, il s'agit de texte brut utilis... |
5,663 | <ASSISTANT_TASK:>
Python Code:
import logging
import os
from gensim import corpora, utils
from gensim.models.wrappers.dtmmodel import DtmModel
import numpy as np
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logging.debug("test")
documents = [[u'senior', u'studios', u'studios', u'studios', u'creators', ... | <SYSTEM_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 wil setup logging
Step2: Now lets load a set of documents
Step3: This corpus contains 10 documents. Now lets say we would like to mod... |
5,664 | <ASSISTANT_TASK:>
Python Code:
import ipyvolume as ipv
import numpy as np
s = 1/2**0.5
# 4 vertices for the tetrahedron
x = np.array([1., -1, 0, 0])
y = np.array([0, 0, 1., -1])
z = np.array([-s, -s, s, s])
# and 4 surfaces (triangles), where the number refer to the vertex index
triangles = [(0, 1, 2), (0, 1, 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: Triangle meshes
Step2: Surfaces
Step3: Colors
Step4: Texture mapping
Step5: We now make a small movie / animated gif of 30 frames.
Step6: A... |
5,665 | <ASSISTANT_TASK:>
Python Code:
# <!-- collapse=True -->
# Importando las librerías que vamos a utilizar
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import LabelEncoder
# graficos incrustados
%matplotlib inline
# parametros esteticos de seabo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Como podemos ver, utilizando simples expresiones de Python, podemos cargar la base de datos de la ONG en un Dataframe de Pandas; lo que nos va a... |
5,666 | <ASSISTANT_TASK:>
Python Code:
import os, sys
sys.path = [os.path.abspath("../../")] + sys.path
from deep_learning4e import *
from notebook4e import *
from learning4e import *
raw_net = [InputLayer(input_size), DenseLayer(input_size, output_size)]
iris = DataSet(name="iris")
classes = ["setosa", "versicolor", "virgin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Perceptron Learner
Step2: Where input_size and output_size are calculated from dataset examples. In the perceptron learner, the gradient descen... |
5,667 | <ASSISTANT_TASK:>
Python Code:
import sys
niftynet_path = '/Users/bar/Documents/Niftynet/'
sys.path.insert(0, niftynet_path)
from niftynet.io.image_reader import ImageReader
from niftynet.utilities.download import download
download('anisotropic_nets_brats_challenge_model_zoo')
from niftynet.io.image_reader import Ima... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For demonstration purpose we download some demo data to ~/niftynet/data/
Step2: Use case
Step3: The images are always read into a 5D-array, re... |
5,668 | <ASSISTANT_TASK:>
Python Code:
%%latex
\begin{align}
a = \frac{1}{2}\\
\end{align}
print 'hello world'
for i in range(10):
print i
# get a list of all the available magics
% lsmagic
% env
# to list your environment variables.
%prun
%time range(10)
%timeit range(100)
! cd /Users/chengjun/github/
% matplotlib inlin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 程序代码
Step2: !
|
5,669 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy import integrate
def integrand(x, a):
return 1.0/(x**2 + a**2)
def integral_approx(a):
# Use the args keyword argument to feed extra arguments to your integrand
I, e = integ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Indefinite integrals
Step2: Integral 1
Step3: Integral 2
Step4: Integral 3
Step5: Integral 4
Step6: Integral 5
|
5,670 | <ASSISTANT_TASK:>
Python Code:
def binarySearch(searchSpace , s , e , num ) :
while(s <= e ) :
mid =(s + e ) // 2
if searchSpace[mid ] >= num :
ans = mid
e = mid - 1
else :
s = mid + 1
return ans
def longestSubArr(arr , n ) :
searchSpace =[None ] * n
index =[None ] * n
j = 0
ans =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
5,671 | <ASSISTANT_TASK:>
Python Code:
%%bash
BUCKET=<your-bucket-here> # Change to your bucket name
JOB_NAME=dqn_on_gcp_$(date -u +%y%m%d_%H%M%S)
REGION='us-central1' # Change to your bucket region
IMAGE_URI=gcr.io/qwiklabs-resources/rl-qwikstart/dqn_on_gcp@sha256:326427527d07f30a0486ee05377d120cac1b9be8850b05f138fc9b53ac1dd2... | <SYSTEM_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 above command sends a hyperparameter tuning job to the Google Cloud AI Platform. It's a service that sets up scaling distributed training so... |
5,672 | <ASSISTANT_TASK:>
Python Code:
!ogr2ogr ../scratch/deelbekkens_wgs84 -t_srs "EPSG:4326" ../data/deelbekkens/Deelbekken.shp
!ogr2ogr --help
!ogr2ogr -f 'Geojson' ../scratch/provinces.geojson WFS:"https://geoservices.informatievlaanderen.be/overdrachtdiensten/VRBG/wfs" Refprv
provinces = gpd.read_file("../scratch/prov... | <SYSTEM_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 is this combination of commands?
Step2: but there are great online resources with good examples you can easily copy paste for your own app... |
5,673 | <ASSISTANT_TASK:>
Python Code:
!conda install pytest pytest-cov
!mkdir #complete
!touch #complete
%%file <yourpackage>/tests/test_something.py
def test_something_func():
assert #complete
from <yourpackage>.tests import test_something
test_something.test_something_func()
!py.test
!py.test
!py.test --cov=<yourpr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1b
Step2: 1d
Step3: 1e
Step4: 1f
Step5: 1g
Step6: This should yield a report, which you can use to decide if you need to add more tests to ... |
5,674 | <ASSISTANT_TASK:>
Python Code:
# the output of plotting commands is displayed inline within frontends,
# directly below the code cell that produced it
%matplotlib inline
from time import time
# this python library provides generic shallow (copy) and deep copy (deepcopy) operations
from copy import deepcopy
# import ... | <SYSTEM_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 beam distribution from CSRtrack format
Step2: create BC2 lattice
Step3: Initialization tracking method and MagneticLattice object
Step4: ... |
5,675 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import sklearn
df = load_data()
from sklearn.preprocessing import MultiLabelBinarizer
mlb = MultiLabelBinarizer()
df_out = df.join(
pd.DataFrame(
mlb.fit_transform(df.pop('Col4')),
index=df.index,
columns=mlb.classes_))
<E... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
5,676 | <ASSISTANT_TASK:>
Python Code:
import os
# The Google Cloud Notebook product has specific requirements
IS_GOOGLE_CLOUD_NOTEBOOK = os.path.exists("/opt/deeplearning/metadata/env_version")
# Google Cloud Notebook requires dependencies to be installed with '--user'
USER_FLAG = ""
if IS_GOOGLE_CLOUD_NOTEBOOK:
USER_FLAG... | <SYSTEM_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: Otherwise, set your project ID here.
Step4: Timestamp
Step5: Authenticate your Google Clou... |
5,677 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import cv2
from geospatial_learn import raster
from geospatial_learn.utilities import do_phasecong, houghseg
from math import ceil
import matplotlib.pyplot as plt
from skimage.color import rgb2gray, label2rgb
from skimage.feature import canny
from skimage.exposure 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: Read in a test image subset. Replace with your own if required parameters will need to be adjusted, needless to say complete segmentation is not... |
5,678 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from keras.layers import LSTM
from keras.layers import RNN
from keras.utils import np_utils
sample_poem = open('sample_sonnets.txt').read().lower()
sa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Method 1 - Character Based Poem Generation
Step2: Observation...
|
5,679 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd #数据分析
import numpy as np #科学计算
from pandas import Series,DataFrame
data_train = pd.read_csv("./Titanic/train.csv")
data_train.tail() #pandas是常用的python数据处理包,把csv文件读入成dataframe各式,我们在ipython notebook中,看到data_train如下所示:
data_train.info()
data_train.describe()
import matpl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 就把它想象成Excel里面的列好了。
Step2: 这个时候我们可能会有一些想法了:
|
5,680 | <ASSISTANT_TASK:>
Python Code:
path = Config().data_path()/'giga-fren'
#! wget https://s3.amazonaws.com/fast-ai-nlp/giga-fren.tgz -P {path}
#! tar xf {path}/giga-fren.tgz -C {path}
# with open(path/'giga-fren.release2.fixed.fr') as f:
# fr = f.read().split('\n')
# with open(path/'giga-fren.release2.fixed.en') as f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You only need to execute the setup cells once, uncomment to run. The dataset can be downloaded here.
Step2: Put them in a DataBunch
Step3: To ... |
5,681 | <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
|
5,682 | <ASSISTANT_TASK:>
Python Code:
# import everything from skyofstars
from skyofstars.examples import *
example = create_test_catalog()
example.coordinates = example.coordinates.transform_to('icrs')
print (example.coordinates.icrs.ra.rad)
# we can also access all the functions we defined *inside* the Catalog
example.plot... | <SYSTEM_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 defined a new kind of Python variable, by writing a class definition for a Catalog. We can create a new one of these objects as follows.
|
5,683 | <ASSISTANT_TASK:>
Python Code:
# change directory
%cd ../../../Projects/starspot/starspot/
from color import bolcor as bc
bc.utils.log_init('table_limits.log') # initialize bolometric correction log file
FeH = 0.0 # dex; atmospheric [Fe/H]
aFe = 0.0 # dex; atmospheric [alpha/Fe]
brand = 'marcs' # use theoretical ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Before requesting bolometric corrections, we need to first initialize the package, which loads the appropriate bolometric corrections tables int... |
5,684 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import graphviz
import lingam
from lingam.utils import print_causal_directions, print_dagc, make_dot
import warnings
warnings.filterwarnings('ignore')
print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])
np.set_printoptio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test data
Step2: Causal Discovery
Step3: Using the ancestors_list_ properties, we can see the list of ancestors sets as a result of the causal... |
5,685 | <ASSISTANT_TASK:>
Python Code:
from copy import deepcopy
import math
import scipy.sparse.linalg as spsl
import projectq
from projectq.backends import Simulator
from projectq.meta import Compute, Control, Dagger, Uncompute
from projectq.ops import All, H, Measure, Ph, QubitOperator, R, StatePreparation, X, Z
num_qubits... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's use a simple Hamiltonian acting on 3 qubits for which we want to know the eigenvalues
Step2: For this quantum algorithm, we need to norma... |
5,686 | <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 = ['season... | <SYSTEM_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: Splitting the data into training, testing, and validation sets
Step4: We'll spl... |
5,687 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image,Latex
from numpy import array, cross,dot, sqrt
AB = array([4.0,2.,0.]) - array([1., 0.,0.])
AC = array([0.,0.,3.]) - array([1., 0.,0.])
print 'AB=', AB, ',', 'AC=', AC
Nor = cross(AB,AC)
MNor = sqrt(dot(Nor,Nor))
n = Nor / MNor
print 'Normal=',Nor, ',... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Si el tensor de esfuerzos en un punto $P$, en el sistema de referencia $X,Y,Z$ está definidido por
Step2: El vector unitarion $\hat{n}$ es ento... |
5,688 | <ASSISTANT_TASK:>
Python Code:
import os
os.getcwd()
%matplotlib inline
%pylab inline
import pandas as pd
import numpy as np
from collections import Counter, OrderedDict
import json
import matplotlib
import matplotlib.pyplot as plt
import re
from scipy.misc import imread
from sklearn.linear_model import LogisticRegres... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 0. Create a kaggle account! https
Step2: Processing the data
Step3: 1.2
Step4: 2.2
Step5: 2.3
Step6: 2.4
Step7: 3. Predictive modeling
Ste... |
5,689 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy as sp
import pandas as pd
import mlutils
import matplotlib.pyplot as plt
%pylab inline
from sklearn.svm import SVC
seven_X = np.array([[2,1], [2,3], [1,2], [3,2], [5,2], [5,4], [6,3]])
seven_y = np.array([1, 1, 1, 1, -1, -1, -1])
fit = SVC(gamma = 'scale',... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Klasifikator stroja potpornih vektora (SVM)
Step2: Q
Step3: (c)
Step4: Q
Step5: 3. Optimizacija hiperparametara SVM-a
Step6: (b)
Step7: ... |
5,690 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('..')
import socnet as sn
sn.node_size = 10
sn.edge_width = 1
sn.edge_color = (192, 192, 192)
sn.node_label_position = 'top center'
g1 = sn.load_graph('renaissance.gml', has_pos=True)
g2 = sn.load_graph('../encontro02/1-introducao.gml', has_pos=True)
sn.show_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configurando a biblioteca
Step2: O objetivo desta atividade é realizar $24$ simulações de centralidade diferentes, para avaliar o desempenho de... |
5,691 | <ASSISTANT_TASK:>
Python Code:
from keras.models import Sequential
from keras.layers import Dense, Activation
model = Sequential([
Dense(32, input_shape=(784,)),
Activation('relu'),
Dense(10),
Activation('softmax'),
])
model = Sequential()
model.add(Dense(32, input_dim=784))
model.add(Activation('relu'... | <SYSTEM_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 simply add layers via the .add() method
Step2: Specifying the input shape
Step3: Compilation
Step4: Training
Step5: Examples
St... |
5,692 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import random
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
pd.set_option("display.max_rows", 8)
df = pd.read_csv('stress-ng/third/torpor-results/alltests.csv')
df.head()
df['machine'].unique()
machine_is_issdm_6 = df['... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First, we load all test data.
Step2: Let's have a look at the pattern of data.
Step3: Show all the test machines.
Step4: Define some predicat... |
5,693 | <ASSISTANT_TASK:>
Python Code:
predictors = subset[variables]
targets = subset['High BreastCancer']
#Split into training and testing sets
training_data, test_data, training_target, test_target = train_test_split(predictors, targets, test_size=.3)
model=LassoLarsCV(cv=10, precompute=False).fit(training_data, training... | <SYSTEM_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) Split into training and testing sets
Step2: (b) Building the LASSO Regression Model
Step3: Note
Step4: (b) Plot coefficient progression
S... |
5,694 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
# plotting options
font = {'size' : 20}
plt.rc('font', **font)
plt.rc('text', usetex=matplotlib.checkdep_usetex(True))
matplotlib.rc('figure', figsize=(18, 6) )
# capacity of the BSC
def C_BEC(epsilon):
retur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Binary Erasure Channel (BEC)
Step2: Random Coding Union Bound for the BEC
Step3: Singleton Bound for the BEC
|
5,695 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = 10, 8
BASE = '/home/brandon/Documents/seq2seq_projects/data/saved_train_data/'
path = BASE + 'cornell_03_11.csv'
df = 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: Analysis, Goals, and Predictions
Step3: Single Plots Distinguishing One Variable
Step4: Plots with Fixed Learning Rate
Step5: Hyperparam Sear... |
5,696 | <ASSISTANT_TASK:>
Python Code:
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=plt.figaspect(0.5))
ax1.plot([-10, -5, 0, 5, 10, 15], [-1.2, 2, 3.5, -0.3, -4, 1])
ax2.scatter([-10, -5, 0, 5, 10, 15], [-1.2, 2, 3.5, -0.3, -4, 1])
plt.show()
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=plt.figaspect(0.5))
ax1.pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ax.margins(...)
Step2: ax.axis(...)
Step3: Manually setting only one limit
Step4: Legends
Step5: Legends will go in the upper right corner b... |
5,697 | <ASSISTANT_TASK:>
Python Code:
# !pip install git+https://github.com/openai/baselines >/dev/null
# !pip install gym >/dev/null
import numpy
import gym
from gym.utils import seeding
from gym import spaces
def state_name_to_int(state):
state_name_map = {
'S': 0,
'A': 1,
'B': 2,
'C': 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: <a href="https
Step2: Try out Environment
Step3: Train model
Step4: Visualizing Results
Step5: Enjoy model
|
5,698 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
from xtoy import Toy
df = pd.read_csv(
"http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data",
header=None)
df.columns = [
"Age", "WorkClass"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model Performance
Step2: Which variable is most important?
Step3: The Above Analysis suggest that while Education Number is 13, Education has ... |
5,699 | <ASSISTANT_TASK:>
Python Code:
import pandas
# Load the data set.
df = pandas.read_csv('privacy/belgium_100k.csv')
df = df.where((pandas.notnull(df)), None)
df['birthday'] = df['birthday'].astype('datetime64[ns]')
df.head()
# Define function to evaluate uniqueness of the provided dataset.
def uniqueness(dataframe, pse... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1.2 Calculate uniqueness
Step2: The results indicate that about 20% of the individuals could potentially be identified using two features ("sex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.