Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
11,600 | <ASSISTANT_TASK:>
Python Code:
from openhunt.mordorutils import *
spark = get_spark()
sd_file = "https://raw.githubusercontent.com/OTRF/Security-Datasets/master/datasets/atomic/windows/lateral_movement/host/covenant_dcom_iertutil_dll_hijack.zip"
registerMordorSQLTable(spark, sd_file, "sdTable")
df = spark.sql(
'''
SE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download & Process Security Dataset
Step2: Analytic I
Step3: Analytic II
Step4: Analytic III
Step5: Analytic IV
|
11,601 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis A. Engemann <denis.engemann@gmail.com>
# Mainak Jas <mainak.jas@telecom-paristech.fr>
#
# License: BSD (3-clause)
import mne
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
fname = data_path + '/MEG/sample/sample_audvis-ave.fif'
evok... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Compute interpolation (also works with Raw and Epochs objects)
Step2: You can also use minimum-norm for EEG as well as MEG
|
11,602 | <ASSISTANT_TASK:>
Python Code:
import h2o
import imp
from h2o.estimators.kmeans import H2OKMeansEstimator
# Start a local instance of the H2O engine.
h2o.init();
iris = h2o.import_file(path="https://github.com/h2oai/h2o-3/raw/master/h2o-r/h2o-package/inst/extdata/iris_wheader.csv")
iris.describe()
try:
imp.find_... | <SYSTEM_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 next step of using H2O is to parse and load data into H2O's in-memory columnar compressed storage. Today we will be using the Iris flower d... |
11,603 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib as plt
import matplotlib.pyplot as plt
% matplotlib inline
df = pd.read_csv("07-hw-animals.csv")
df
df.columns.values
df.head(3)
df.sort_values(by='length', ascending = False).head(3)
df['animal'].value_counts()
df['animal'] == 'dog'
df[df['ani... | <SYSTEM_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 all graphics from matplotlib to display inline
Step2: 3. Read the csv in (it should be UTF-8 already so you don't have to worry about en... |
11,604 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
DON'T MODIFY AN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
11,605 | <ASSISTANT_TASK:>
Python Code:
root_directory = 'D:/github/w_vattenstatus/ekostat_calculator'#"../" #os.getcwd()
workspace_directory = root_directory + '/workspaces'
resource_directory = root_directory + '/resources'
#alias = 'lena'
user_id = 'test_user' #kanske ska vara off_line user?
# workspace_alias = 'lena_indica... | <SYSTEM_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 subset filters
Step2: #####################################################################################################################... |
11,606 | <ASSISTANT_TASK:>
Python Code:
import os
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if os.environ["IS_TESTING"]:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
11,607 | <ASSISTANT_TASK:>
Python Code:
multi_language = app.loc[app['multiple languages'] == 'Y']
sin_language = app.loc[app['multiple languages'] == 'N']
multi_language['overall rating'].plot(kind = "density")
sin_language['overall rating'].plot(kind = "density")
plt.xlabel('Overall Rating')
plt.legend(labels = ['multiple lan... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <p>First, the data set is splitted into two parts, one is app with multiple languages and another is app with single language. Then the density ... |
11,608 | <ASSISTANT_TASK:>
Python Code:
print(__doc__)
import numpy as np
from skopt import Optimizer
from skopt.space import Real
from joblib import Parallel, delayed
# example objective taken from skopt
from skopt.benchmarks import branin
optimizer = Optimizer(
dimensions=[Real(-5.0, 10.0), Real(0.0, 15.0)],
random_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: Example
|
11,609 | <ASSISTANT_TASK:>
Python Code:
import re
import tables
import matplotlib.pyplot as plt
import numpy as np
from astropy.time import Time
from astropy.table import Table
import Ska.engarchive.fetch_eng as fetch
from Ska.engarchive import fetch_sci
from Chandra.Time import DateTime
from Ska.Numpy import interpolate
from k... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step5: Model for aimpoint drift (aka ACA alignment drift) 2018-11
Step6: Fit model coefficients for DY and plot results
Step7: Zoom in around the 201... |
11,610 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
%matplotlib inline
df = pd.read_csv('911.csv')
df.info()
df.head(3)
df['zip'].value_counts().head(5)
df['twp'].value_counts().head(5)
df['title'].nunique()
df['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: Import visualization libraries and set %matplotlib inline.
Step2: Read in the csv file as a dataframe called df
Step3: Check the info() of the... |
11,611 | <ASSISTANT_TASK:>
Python Code:
response = requests.get('https://api.spotify.com/v1/search?query=Lil&type=artist&limit=50&market=US')
Lil_data = response.json()
Lil_data.keys()
Lil_data['artists'].keys()
Lil_artists = Lil_data['artists']['items']
for artist in Lil_artists:
print(artist['name'], artist['popularity']... | <SYSTEM_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) With "Lil Wayne" and "Lil Kim" there are a lot of "Lil" musicians. Do a search and print a list of 50 that are playable in the USA (or the co... |
11,612 | <ASSISTANT_TASK:>
Python Code:
#Importamos las librerías utilizadas
import numpy as np
import pandas as pd
import seaborn as sns
#Mostramos las versiones usadas de cada librerías
print ("Numpy v{}".format(np.__version__))
print ("Pandas v{}".format(pd.__version__))
print ("Seaborn v{}".format(sns.__version__))
#Abrimos... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Representamos ambos diámetro y la velocidad de la tractora en la misma gráfica
Step2: Con esta segunda aproximación se ha conseguido estabiliza... |
11,613 | <ASSISTANT_TASK:>
Python Code:
get_ipython().magic('load_ext autoreload')
get_ipython().magic('autoreload 2')
from IPython.display import display, clear_output
import glob
import logging
import numpy as np
import os
import cv2
logging.basicConfig(format=
"%(relativeCreated)12d [%(filename)s:%(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First specify the data file(s) to be analyzed
Step2: Set up some parameters
Step3: Now run the Ring-CNN + CaImAn online algorithm (OnACID).
St... |
11,614 | <ASSISTANT_TASK:>
Python Code:
import psi4
import forte
import forte.utils
xyz =
0 1
C -1.9565506735 0.4146729724 0.0000000000
H -0.8865506735 0.4146729724 0.0000000000
H -2.3132134555 1.1088535618 -0.7319870007
H ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: We will start by generating SCF orbitals for methane via psi4 using the forte.util.psi4_scf function
Step3: Next we start forte, setup the MOSp... |
11,615 | <ASSISTANT_TASK:>
Python Code:
import base64
import datetime
import logging
import os
import json
import pandas as pd
import time
import sys
import grpc
import google.auth
import numpy as np
import tensorflow.io as tf_io
from google.cloud import bigquery
from typing import List, Optional, Text, Tuple
ANN_GRPC_ENDPOINT... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In the experimental release, the Online Querying API of the ANN service is exposed throught the GRPC interface. The ann_grpc folder contains the... |
11,616 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat
import tensorflow as tf
!mkdir data
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
data_dir = 'data/'
if not isdir(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: Getting the data
Step2: These SVHN files are .mat files typically used with Matlab. However, we can load them in with scipy.io.loadmat which we... |
11,617 | <ASSISTANT_TASK:>
Python Code:
from stingray.utils import create_window
from scipy.fftpack import fft, fftshift, fftfreq
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
N = 100
window = create_window(N)
plt.plot(window)
plt.title("Uniform window")
plt.ylabel("Amplitude")
plt.xlabel("Sample Number... | <SYSTEM_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_window function in stingray.utils takes two parameters.
Step2: Parzen Window
Step3: Hamming Window
Step4: Hanning Window
Step5: Trai... |
11,618 | <ASSISTANT_TASK:>
Python Code:
# importing code modules
import json
import ijson
from ijson import items
import pprint
from tabulate import tabulate
import matplotlib.pyplot as plt
import re
import csv
import sys
import codecs
import nltk
import nltk.collocations
import collections
import statistics
from nltk.metrics.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: Reading the File
Step2: A bit of error checking here to confirm the number of records in the file. We should have 14.
Step3: Changing the numb... |
11,619 | <ASSISTANT_TASK:>
Python Code:
machine = dict(
name="PM-4-130",
lfe=0.1,
poles=4,
outer_diam=0.13,
bore_diam=0.07,
inner_diam=0.015,
airgap=0.0015,
stator=dict(
num_slots=12,
rlength=1.0,
statorRotor3=dict(
slot_height=0.02,
slot_h1=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: Use a pm_sym_fast calculation at a rotor speed of 5000 1/min
Step2: Define the variation parameters with their ranges and number of steps
Step3... |
11,620 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import pandas as pd
import shutil
print(tf.__version__)
!gsutil cp gs://cloud-training-demos/taxifare/small/*.csv .
!ls -l *.csv
df_train = pd.read_csv(filepath_or_buffer = "./taxi-train.csv")
df_valid = pd.read_csv(filepath_or_buffer = "./taxi-valid.csv")
df_tes... | <SYSTEM_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 raw data
Step2: Because the files are small we can load them into in-memory Pandas dataframes.
Step3: Create feature columns
Step4: Defi... |
11,621 | <ASSISTANT_TASK:>
Python Code:
class Person:
# Constructor
def __init__(self, name, age):
self.name = name
self.age = age
def __str__(self):
return 'name = {}\nage = {}'.format(self.name,self.age)
# Inherited or Sub class
class Employee(Person):
def __init__(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: <div class="alert alert-info">
Step2: Note how pass statement is used to leave the class body empty. Otherwise it would have raised a Syntax Er... |
11,622 | <ASSISTANT_TASK:>
Python Code:
PATH = '/cellar/users/agross/TCGA_Code/Methlation/'
cd $PATH
import NotebookImport
from Setup.Imports import *
epic = pd.read_csv(PATH + 'data/EPIC_ITALY/detectionP.csv',
index_col=0)
pData = pd.read_csv(PATH + 'data/EPIC_ITALY/pData.csv',
dtype='st... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Epic Data
Step2: Hannum
Step3: UCSD
|
11,623 | <ASSISTANT_TASK:>
Python Code:
import bali
fileReader = bali.FileReader()
fileReader.taught
fileReader.transcribed
fp = bali.FileParser()
fp.taught
firstPattern = fp.taught[0]
print(firstPattern)
firstPattern.title
firstPattern.drumPattern
firstPattern.gongPattern
firstPattern.beatLength()
firstPattern.strokes
for 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: Now we make a FileReader
Step2: More useful Object
Step3: Now we have all the taught patterns! Yay!
Step4: How many strokes total are there i... |
11,624 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'sandbox-3', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
11,625 | <ASSISTANT_TASK:>
Python Code:
import json
import re
with open('../catalogs/json/ecoinvent_3.2_undefined_xlsx.json') as fp:
ei32 = json.load(fp)
def search_tags(entity, search):
This function searches through all the 'tags' (semantic content) of a data set
and returns 'true' if the search expression is... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The object of this exercise is to find the UUIDs for processes dealing with sugar beet production.
Step2: 11 beet-related flows
Step3: that di... |
11,626 | <ASSISTANT_TASK:>
Python Code:
from sklearn.decomposition import PCA
pca = PCA(n_components=2)
res = pca.fit_transform(df_norm)
res
# Singular values
pca.singular_values_.round(2)
# Eigenvalues
pca.explained_variance_.round(2)
# Eigenvalues/eigenvalues.sum()
pca.explained_variance_ratio_.round(2)
# Eigenvectors
pca.com... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From scratch with eigenvalues
Step2: Compute eigenvalues & eigenvectors
Step3: Sort eigenvectors by DESC eigenvalues
Step4: PC1 is a principa... |
11,627 | <ASSISTANT_TASK:>
Python Code:
import wishbone
# Plotting and miscellaneous imports
import os
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
# Load sample data
scdata = wishbone.wb.SCData.from_csv(os.path.expanduser('~/.wishbone/data/sample_scseq_data.csv'),
data_type='sc-seq', 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: A sample RNA-seq csv data is installed at ~/.wishbone/data/sample_scseq_data.csv. This sample data will be used to demonstrate the utilization a... |
11,628 | <ASSISTANT_TASK:>
Python Code:
# To support both python 2 and python 3
from __future__ import division, print_function, unicode_literals
# Common imports
import numpy as np
import os
# to make this notebook's output stable across runs
np.random.seed(42)
# To plot pretty figures
%matplotlib inline
import matplotlib as m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Voting classifiers
Step2: Warning
Step3: Bagging ensembles
Step4: Random Forests
Step5: Out-of-Bag evaluation
Step6: Feature importance
Ste... |
11,629 | <ASSISTANT_TASK:>
Python Code:
import sympy as sym
sym.init_printing()
t, l = sym.symbols('t lambda')
y = sym.Function('y')(t)
dydt = y.diff(t)
expr = sym.Eq(dydt, -l*y)
expr
sym.dsolve(expr)
import numpy as np
def euler_fw(rhs, y0, tout, params):
y0 = np.atleast_1d(np.asarray(y0, dtype=np.float64))
dydt = np.... | <SYSTEM_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, pretend for a while that this function lacked an analytic solution. We could then integrate this equation numerically from an initial state... |
11,630 | <ASSISTANT_TASK:>
Python Code:
# conventional way to import pandas
import pandas as pd
# read CSV file directly from a URL and save the results
data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Advertising.csv', index_col=0)
# display the first 5 rows
data.head()
# display the last 5 rows
data.tail()
# check the ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Primary object types
Step2: What are the features?
Step3: Linear regression
Step4: Splitting X and y into training and testing sets
Step5: L... |
11,631 | <ASSISTANT_TASK:>
Python Code:
import pints
import pints.toy as toy
import pints.plot
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats
x = np.linspace(-15, 15, 1000)
y_c = scipy.stats.t.pdf(x, 1, loc=0, scale=1)
y_t = scipy.stats.t.pdf(x, 3, loc=0, scale=1)
y_norm = scipy.stats.norm.pdf(x, 0, 3)
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: Compare a Cauchy error process with a normal error process for the logistic model.
Step2: Specify a model using a Cauchy error process and use ... |
11,632 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import holoviews as hv
%reload_ext holoviews.ipython
fractal = hv.Image(np.load('mandelbrot.npy'))
((fractal * hv.HLine(y=0)).hist() + fractal.sample(y=0))
%%opts Points [scaling_factor=50] Contours (color='w')
dots = np.linspace(-0.45, 0.45, 19)
hv.HoloMap({y: (fracta... | <SYSTEM_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 HoloViews, you first wrap your data in a HoloViews component along with optional metadata describing it. It will then display itself aut... |
11,633 | <ASSISTANT_TASK:>
Python Code:
# List all directories and sub-directories
!find ./Convolutional_Neural_Networks/dataset -type d -maxdepth 5
# Importing the Keras libraries and packages
from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Fla... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Building the CNN
Step2: Fitting the CNN to the images
Step3: Making new predictions
Step4: Challenge
|
11,634 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import hyperspy.api as hs
import pyxem as pxm
import numpy as np
rp = hs.load('./data/08/amorphousSiO2.hspy')
rp.set_signal_type('electron_diffraction')
rp = pxm.signals.ElectronDiffraction1D([[rp.data]])
calibration = 0.00167
rp.set_diffraction_calibration(calibrati... | <SYSTEM_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 id='loa'></a>
Step2: For now, the code requires navigation dimensions in the reduced intensity signal, two size 1 ones are created.
Step3: ... |
11,635 | <ASSISTANT_TASK:>
Python Code:
import bnn
print(bnn.available_params(bnn.NETWORK_CNVW1A1))
classifier = bnn.CnvClassifier(bnn.NETWORK_CNVW1A1,"streetview",bnn.RUNTIME_HW)
print(classifier.classes)
from PIL import Image
import numpy as np
img = Image.open('/home/xilinx/jupyter_notebooks/bnn/pictures/6.png')
img
resul... | <SYSTEM_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. Get classes of dataset
Step2: 3. Open image to be classified
Step3: 4. Launching BNN in hardware
Step4: 5. Launching BNN in software
Step5... |
11,636 | <ASSISTANT_TASK:>
Python Code:
import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False)
raw.crop(tmax=60).... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Background
Step2: If a scalp electrode was used as reference but was not saved alongside the
Step3: By default,
Step4: .. KEEP THESE BLOCKS ... |
11,637 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False)
DO NOT MODIFY THIS CELL
def fully_connected(prev_layer, num_units):
Create a fully connectd layer with the given layer... | <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: Batch Normalization using tf.layers.batch_normalization<a id="example_1"></a>
Step6: We'll use the following function to create convolutional l... |
11,638 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
%matplotlib inline
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import math
import os
import rand... | <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: Download the data from the source website if necessary.
Step4: Read the data into a string.
Step5: Build the dictionary and replace rare words... |
11,639 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from pymatgen.core import Composition, Element
from pymatgen.ext.matproj import MPRester
from pymatgen.io.vasp import Vasprun
from pymatgen.phasediagram.maker import PhaseDiagram, CompoundPhaseDiagram
from pymatgen.phasediagram.analyzer import PDAnalyzer
from pymatgen.p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preparation
Step2: To construct the phase diagram, we need all entries in the Li-P-S-Cl chemical space. We will use the MPRester class to obtai... |
11,640 | <ASSISTANT_TASK:>
Python Code:
# Import the IO module
import menpo.io as mio
# Import Matplotlib so we can plot subplots
import matplotlib.pyplot as plt
# Import a couple of interesting images that are landmarked!
takeo = mio.import_builtin_asset('takeo.ppm')
takeo = takeo.as_masked()
lenna = mio.import_builtin_asset('... | <SYSTEM_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, given a landmarked image, it is simple to create a reference template by constraining the images mask to lie within the boundary of the lan... |
11,641 | <ASSISTANT_TASK:>
Python Code:
# Authors: Christopher Holdgraf <choldgraf@berkeley.edu>
#
# License: BSD (3-clause)
from scipy.ndimage import imread
import numpy as np
from matplotlib import pyplot as plt
from os import path as op
import mne
from mne.viz import ClickableImage, add_background_image # noqa
from mne.chan... | <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: Load data and click
|
11,642 | <ASSISTANT_TASK:>
Python Code:
# sequence_to_sequence_implementation course assignment was used a lot to finish this hw
# A live help person highly suggested I worked through it again. --- 10000% correct. this was vital
### AKA the UDACITY seq2seq assignment, /deep-learning/seq2seq/sequence_to_sequence_implementation.i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
11,643 | <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
print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])
np.set_printoptions(precision=3, suppress=True)
np.random.seed(0)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test data
Step2: Bootstrapping
Step3: Causal Directions
Step4: We can check the result by utility function.
Step5: Directed Acyclic Graphs
S... |
11,644 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
h = np.array([[-1,0,1],
[-2,0,2],
[-1,0,1]])
r,c = np.nonzero(h)
print(r,c)
xx = np.transpose(np.nonzero(h))
print(xx)
import numpy as np
def ptrans(f,t):
H,W = f.shape
rr,cc = t
row,col = np.indices(f.shape)
g = f[(row-rr)%H, (col... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercícios para a próxima aula, dia 27 de abril
Step2: Converter para ipynb e melhorar (com bons exemplos e equações) as demonstrações feitas n... |
11,645 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%reload_ext autoreload
%autoreload 2
from fastai.structured import *
from fastai.column_data import *
np.set_printoptions(threshold=50, edgeitems=20)
PATH='data/rossmann/'
def concat_csvs(dirname):
path = f'{PATH}{dirname}'
filenames=glob.glob(f"{path}/*.csv")
... | <SYSTEM_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 datasets
Step2: Feature Space
Step3: We'll be using the popular data manipulation framework pandas. Among other things, pandas allows y... |
11,646 | <ASSISTANT_TASK:>
Python Code:
header1 = r\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[croatian]{babel}
\usepackage{minted}
\usepackage{amsmath,amsfonts}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage[hmargin=1.5cm,vmargin=1cm]{geometry}
\pagestyle{empt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step5: Skripta za generiranje kolokvija
Step6: Učitavanje potrebnih paketa & podataka
Step7: Kreiranje datoteke
|
11,647 | <ASSISTANT_TASK:>
Python Code:
import geopyspark as gps
from pyspark import SparkContext
conf=gps.geopyspark_conf(appName="BristleConePine")
conf.set('spark.ui.enabled', True)
sc = SparkContext(conf = conf)
elev_rdd = gps.geotiff.get(
layer_type='spatial',
uri='s3://geopyspark-demo/elevation/ca-elevation.tif... | <SYSTEM_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 will need to set up a spark context. To learn more about what that means take a look here
Step2: Retrieving an elevation .tif from AWS S3
S... |
11,648 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cmcc', 'cmcc-cm2-vhr4', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "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:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
11,649 | <ASSISTANT_TASK:>
Python Code:
from sklearn.pipeline import Pipeline
from skutil.preprocessing import BoxCoxTransformer, SelectiveScaler
from skutil.decomposition import SelectivePCA
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
# build a pipeline
pipe = Pipeline([
... | <SYSTEM_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 performance isn't bad. The training accuracy is phenomenal, but the validation accuracy is sub-par. Plus, there's quite of variance in the m... |
11,650 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.time_frequency import tfr_morlet
from mne.stats import permutation_cluster_1samp_test
from mne.datasets import sample
... | <SYSTEM_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: Compute statistic
Step3: View time-frequency plots
|
11,651 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
ioos_tools = os.path.join(os.path.pardir)
sys.path.append(ioos_tools)
from datetime import datetime, timedelta
import dateutil.parser
service_type = 'WMS'
min_lon, min_lat = -90.0, 30.0
max_lon, max_lat = -80.0, 40.0
bbox = [min_lon, min_lat, max_lon, max_lat]
crs ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's start by creating the search filters.
Step2: With these 3 elements it is possible to assemble a OGC Filter Encoding (FE) using the owslib... |
11,652 | <ASSISTANT_TASK:>
Python Code:
import functools
def myfunc(a, b=2):
"Docstring for myfunc()."
print(' called myfunc with:', (a, b))
def show_details(name, f, is_partial=False):
"Show details of a callable object."
print('{}:'.format(name))
print(' object:', f)
if not is_partial:
print(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Acquiring Function Properties
Step2: Other Callables
Step3: Methods and Functions
Step4: method1() can be called from an instance of MyClass,... |
11,653 | <ASSISTANT_TASK:>
Python Code:
dc = DrawControl(marker={'shapeOptions': {'color': '#0000FF'}},
rectangle={'shapeOptions': {'color': '#0000FF'}},
circle={'shapeOptions': {'color': '#0000FF'}},
circlemarker={},
)
def handle_draw(self, action, geo_json):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In addition, the DrawControl also has last_action and last_draw attributes that are created dynamicaly anytime a new drawn path arrives.
Step2: ... |
11,654 | <ASSISTANT_TASK:>
Python Code:
def htop(h,units='milibar'):
'''h in m
returns p in Pa'''
k=1
if units=='Pa':
k=1
if units=='mmhg':
k=7.50061683/1000.
if units=='milibar':
k=1./100.
return 101325*k* (1. - 2.25577E-5* h)**5.25588
def ptoh(p,units='milibar'):
'''p i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Altura sobre el nivel del mar
Step2: Altura del edificio
|
11,655 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from sequana import GenomeCov, sequana_data
rcParams['figure.figsize'] = (10,6)
gc = GenomeCov(sequana_data("virus.bed", "data"), low_threshold=-2.5, high_threshold=2.5)
chrom = gc[0]
N = 4001
chrom.running_median(N, circular=True)
chrom.compute_zscore()
chrom.plot_covera... | <SYSTEM_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 a Coverage file in BED format
Step2: Select one chromosome (there is only one in this case)
Step3: Compute the running median and plot th... |
11,656 | <ASSISTANT_TASK:>
Python Code:
s = pd.Series([4, 7, -5, 3])
s
s.values
type(s.values)
s.index
type(s.index)
s * 2
np.exp(s)
s2 = pd.Series([4, 7, -5, 3], index=["d", "b", "a", "c"])
s2
s2.index
s2['a']
s2['b':'c']
s2[["a", "b"]]
s2[2]
s2[1:4]
s2[[2, 1]]
s2[s2 > 0]
"a" in s2, "e" in s2
for i, j in s2.iteritems():
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Vectorized Operation
Step2: 명시적인 Index를 가지는 Series
Step3: Series Indexing 1
Step4: Series Indexing 2
Step5: dict 연산
Step6: dict 데이터를 이용한 Se... |
11,657 | <ASSISTANT_TASK:>
Python Code:
# this is a comment and will not run in the code
'''this is just a mulit line comment'''
pwd
#addition
2+1
# substraction
2-1
1-2
2*2
3/2
3.0/2
float(3)/2
3/float(2)
from __future__ import division
3/2
1/2
2/3
root(2)
sqrt(2)
4^2
4^.5
4**.5
a=5
a=6
a+a
a
0.1+0.2-0.3
'hello'
'this entire 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: strings yoiu can use the %s to format strings into your print statements
|
11,658 | <ASSISTANT_TASK:>
Python Code:
import sys
import scipy.io as sio
import glob
import numpy as np
import matplotlib.pyplot as plt
from skimage.filters import threshold_otsu
sys.path.append('../code/functions')
import qaLib as qLib
sys.path.append('../../pipeline_1/code/functions')
import connectLib as cLib
from IPython.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: Algorithm
Step2: Actual Code
Step3: Algorithm Conditions
Step4: Prediction on Good Data
Step5: Prediction on Challenging Data
Step6: The ea... |
11,659 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pysalvador as sal
demerec=sal.demerec_data
np.transpose(demerec)
sal.newtonLD(demerec)
sal.newtonLD(demerec, show_iter=True)
sal.confintLD(demerec,show_iter=True)
luria16=sal.luria_16_data
luria16
sal.newtonLD_plating(luria16,e=0.4,show_iter=True)
sal.confin... | <SYSTEM_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 basic model
Step2: To obtain a maximum likelihood estimate of the expected number of mutations per culture, m, you execute the following.
S... |
11,660 | <ASSISTANT_TASK:>
Python Code:
#obj = ["3C 454.3", 343.49062, 16.14821, 1.0]
obj = ["PKS J0006-0623", 1.55789, -6.39315, 1.0]
#obj = ["M87", 187.705930, 12.391123, 1.0]
#### name, ra, dec, radius of cone
obj_name = obj[0]
obj_ra = obj[1]
obj_dec = obj[2]
cone_radius = obj[3]
obj_coord = coordinates.SkyCoord(ra=obj_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Matching coordinates
Step2: Plot $W_1-J$ vs $W_1$
Step3: W1-J < -1.7 => galaxy
Step4: Collect relevant data
Step5: Analysis
Step6: DBSCAN
S... |
11,661 | <ASSISTANT_TASK:>
Python Code:
from pymatgen import MPRester, Composition
from pymatgen.analysis.phase_diagram import PhaseDiagram
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.apps.borg.hive import VaspToComputedEntryDrone
from pymatgen.entries.compatibility import MaterialsProjectCompatibi... | <SYSTEM_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 all H, P, V, O, C entries by MPRester
Step2: Remove CO, CO2, H2O, VPO5 entries from all_entries, use experimental data and our own calculat... |
11,662 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
sns.set_style("white")
import util
df = util.load_burritos()
N = df.shape[0]
df.head()
print('Number of burri... | <SYSTEM_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: Brief metadata
Step3: What types of burritos have been rated?
Step4: Progress in number of burritos rated
Step5: Burrito di... |
11,663 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# dask and distributed are extra installs
from dask.distributed import Client, LocalCluster
import matplotlib.pyplot as plt
import mdtraj as md
traj = md.load("5550217/kras.xtc", top="5550217/kras.pdb")
topology = traj.topology
from contact_map import DaskContactFreque... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Much of the core computational effort in Contact Map Explorer is performed by MDTraj, which uses OpenMP during the nearest-neighbors calculation... |
11,664 | <ASSISTANT_TASK:>
Python Code:
#Step 1 - Check spark version
#Type:
#sc.version
#Step 2 - Create RDD of Numbers 1-10
#Type:
#x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
#x_nbr_rdd = sc.parallelize(x)
#Step 2 - Extract first line
#Type:
#x_nbr_rdd.first()
#Step 2 - Extract first 5 lines
#Type:
#x_nbr_rdd.take(5)
#Step 2 - Cre... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step 1 - Working with Spark Context
Step1: Step 2 - Working with Resilient Distributed Datasets
Step2: Step 3 - Working with Strings
|
11,665 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import matplotlib.pyplot as plt
import fitsio
from astropy.table import Table
from corner import corner
plt.style.use('seaborn-talk')
%matplotlib inline
basicdir = os.path.join(os.getenv('IM_DATA_DIR'), 'upenn-photdec', 'basic-catalog', 'v2')
adddir = os.path.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read the parent CAST catalog.
Step4: Read the g-band model fitting results and select a "good" sample.
Step5: Identify the subset of galaxies ... |
11,666 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
import pyqg
from pyqg import diagnostic_tools as tools
year = 24*60*60*360.
m = pyqg.QGModel(tmax=10*year, twrite=10000, tavestart=5*year)
m.run()
m_ds = m.to_dataset().isel(time=-1)
m_ds
m_ds['q_upper'] = m_ds.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initialize and Run the Model
Step2: Convert Model Outpt to an xarray Dataset
Step3: Visualize Output
Step4: Plot Diagnostics
Step5: To look ... |
11,667 | <ASSISTANT_TASK:>
Python Code:
# Importing tensorflow lib
import tensorflow as tf
tf.__version__ #Checking if notebook is working in tensorflow
# Reading the dataset from Yann LeCun's Website: http://yann.lecun.com/exdb/mnist/
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: x is a placeholder, a value that we'll input when we ask TensorFlow to run a computation. We want to be able to input any number of MNIST images... |
11,668 | <ASSISTANT_TASK:>
Python Code:
import os
import shutil
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from tensorflow.keras import Sequential
from tensorflow.keras.callbacks import ModelCheckpoint, TensorBoard
from tensorflow.keras.layers import Dense, Flatten, Softmax
print(tf.__version__)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exploring the data
Step2: Each image is 28 x 28 pixels and represents a digit from 0 to 9. These images are black and white, so each pixel is a... |
11,669 | <ASSISTANT_TASK:>
Python Code:
def display_board(board):
for row in board:
print(row)
# Runing the tests...
test()
# Note if you recieve an error message saying test_board not found
# try hitting the run button on the test_board cell and try again.
def display_board(board):
print(*board, sep=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Alternate Solution
|
11,670 | <ASSISTANT_TASK:>
Python Code:
target = pd.read_csv('../data/train_target.csv')
target.describe()
target = target / 1000
sns.distplot(target);
plt.title('SalePrice')
import scipy as sp
sp.stats.skew(target)
sp.stats.skewtest(target)
logtarget = np.log1p(target)
print('skewness of logtarget = ', sp.stats.skew(logtarge... | <SYSTEM_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 sale price is in hte hundreds of thousands, so let's divide the price by 1000 to get more manageable numbers.
Step2: The distribution is sk... |
11,671 | <ASSISTANT_TASK:>
Python Code:
! pip uninstall -y tensorflow
! pip install -U tf-nightly
import tensorflow as tf
tf.enable_eager_execution()
! git clone --depth 1 https://github.com/tensorflow/models
import sys
import os
if sys.version_info.major >= 3:
import pathlib
else:
import pathlib2 as pathlib
# Add `mode... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Train and export the model
Step2: For the example, we only trained the model for a single epoch, so it only trains to ~96% accuracy.
Step3: Us... |
11,672 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import numpy
from matplotlib import pyplot
pyplot.style.use('ggplot')
def matmult1(A, x):
Entries of y are dot products of rows of A with x
y = numpy.zeros_like(A[:,0])
for i in range(len(A)):
row = A[i,:]
for j in range(len(row)):
... | <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: Jupyter notebooks
Step4: Some common terminology
Step5: Inner products and orthogonality
Step6: Gram-Schmidt Orthogonalization
Step7: Theore... |
11,673 | <ASSISTANT_TASK:>
Python Code:
# this is a python comment
# this cell contains python code
# executing the cell yields the results of the python command
2+2
# live code some graphics here
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot([3,1,4,1,5])
plt.style.use("fivethirtyeight")
plt.plot([3,1,4,1,5])
# y... | <SYSTEM_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 does it work so well for me?
Step2: We will use two "packages" for the hands-on portion of this tutorial
Step3: Scikit-Learn
|
11,674 | <ASSISTANT_TASK:>
Python Code:
# Create an object called "foo" and assign it the value 9.
foo = 9
# Try running this block!
foo + 5
# Evaluate the variable itself
foo
# Here, foo has the value of 9. Let's add 9 to it.
foo = foo + 9
foo
# Correct variable names
building_height = 100
water = 4
result = building_height... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Jupyter Notebooks are know to be REPL environments. This simply means that the notebooks serve as "interactive" programming environments, where ... |
11,675 | <ASSISTANT_TASK:>
Python Code:
from parcels import FieldSet, ParticleSet, JITParticle
from parcels import AdvectionRK4
import numpy as np
from datetime import timedelta as delta
fieldset = FieldSet.from_parcels("Peninsula_data/peninsula", allow_time_extrapolation=True)
npart = 10 # number of particles to be released
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: Exporting trajectory data in zarr format
Step2: Reading the output file
Step3: Using the xarray package
Step4: Note that opening the .zarr fi... |
11,676 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from jyquickhelper import add_notebook_menu
add_notebook_menu()
import matplotlib.pyplot as plt
poids = [ 0.2, 0.15, 0.15, 0.1, 0.4 ]
valeur = [ 0,1,2,3,4 ]
plt.figure(figsize=(8,4))
plt.bar(valeur,poids)
import numpy.random as rnd
draw = rnd.multinomial(1000, poids)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Une variable qui suit une loi multinomiale est une variable à valeurs entières qui prend ses valeurs dans un ensemble fini, et chacune de ces va... |
11,677 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.ndimage import label, find_objects
from scipy.ndimage.morphology import generate_binary_structure
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from nacoustik import Wave
from nacoustik.spectrum import psd
from nacoustik.noise impor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Variable definitions
Step2: Compute spectrogram
Step3: Remove background noise
Step4: Label regions of interest
Step5: Plot regions of inter... |
11,678 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import os
import re
# Defining hyperparameters
VOCAB_SIZE = 8192
MAX_SAMPLES = 50000
BUFFER_SIZE = 20000
MAX_LENGTH = 40
EMBED_DIM = 256
LATENT_DIM = 512
NUM_HEADS = 8
BATCH_SIZE = 64
path_to_zip = k... | <SYSTEM_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: Preprocessing and Tokenization
Step3: Tokenizing and padding sentences using TextVectorization
Step4: Creating the FNet E... |
11,679 | <ASSISTANT_TASK:>
Python Code::
from transformers import GPT2Tokenizer
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
<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:
|
11,680 | <ASSISTANT_TASK:>
Python Code:
%reload_ext autoreload
%autoreload 2
%matplotlib inline
import os
import io
import tarfile
import PIL
import boto3
from fastai.vision import *
path = untar_data(URLs.PETS); path
path_anno = path/'annotations'
path_img = path/'images'
fnames = get_image_files(path_img)
np.random.seed(2)
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: Export model and upload to S3
Step2: Now we need to export the model in the PyTorch TorchScript format so we can load into an AWS Lambda functi... |
11,681 | <ASSISTANT_TASK:>
Python Code:
345
339 + 6
345 - 6
2.7 / 12.1
345 - 12/6
# Importa tutte le procedure (funzioni) definite nel modulo "operator"
from operator import *
add(339, 6)
sub(345, truediv(12, 6))
mul(add(2,3), (sub(add(2,2), add(3,2))))
a = 13
3*a
add(a, add(a,a))
pi = 3.14159
raggio = 5
circonferenza = 2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Semplici espressioni numeriche possono essere combinate usando delle procedure primitive che rappresentano l'applicazione di procedure a quei nu... |
11,682 | <ASSISTANT_TASK:>
Python Code:
# 3 x 3 filter shape
filter1 = [
[.1, .1, .2],
[.1, .1, .2],
[.2, .2, .2],
]
# Each filter only has one input channel (grey scale)
# 3 x 3 x 1
channel_filters1 = [filter1]
# We want to output 2 channels which requires another set of 3 x 3 x 1
filter2 = [
[.9, .5, .9],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bias Shape
Step2: Convolutional Layers
Step3: Activation Shape
Step4: Activation2 Shape
Step5: Fully Connected Layer
|
11,683 | <ASSISTANT_TASK:>
Python Code:
print("Exemplo 3.3")
import numpy as np
from sympy import *
Vsource = 2
Csource1 = 2
Csource2 = 7
R1 = 2
R2 = 4
R3 = 10
#i1 = v1/R1 = v1/2
#i2 = v2/R2 = v2/4
#i1 + i2 + 7 = 2 => i1 + i2 = -5
#v2 - v1 = 2
#v1/2 + v2/4 = -5 => (v2 - 2)/2 + v2/4 = - 5
#3v2/4 = -4
v2 = -16/3
v1 = v2 - 2
print... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problema Prático 3.3
Step2: Exemplo 3.4
Step3: Problema Prático 3.4
|
11,684 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from models import linear_model, logistic_model, log_cost, log_cost_dev, gd_update
from models import binary_confusion_matrix, std_normalize, binary_accuracy, create_parameters, data_normalize
from sklearn.model_select... | <SYSTEM_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), prepare data
Step2: 2), train
Step3: 3). try test data
Step4: so, this is only for Setosa, we want generalize binary classification to mu... |
11,685 | <ASSISTANT_TASK:>
Python Code:
# try one example, figure is created by default
mlab.test_molecule()
# clear the figure then load another example
mlab.clf()
mlab.test_flow_anim()
# create a new figure
mlab.figure('mesh_example', bgcolor=(0,0,0,))
mlab.test_surf()
<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: Mayavi has some very useful interactive controls that can be accessed from the GUI. This includes the ability to record changing of parameters.
|
11,686 | <ASSISTANT_TASK:>
Python Code:
import json #for reading oauth info and save the results
import io
from googleplaces import GooglePlaces, types, lang
from pprint import pprint
with io.open('google_places_key.json') as cred:
creds = json.load(cred)
google_places = GooglePlaces(**creds)
query_result = googl... | <SYSTEM_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 from API
Step2: Then we check if we get any results from API and print some information to the screen.
Step3: The response from API a... |
11,687 | <ASSISTANT_TASK:>
Python Code:
st = 'Print only the words that start with s in this sentence'
for word in st.split():
if word[0] == 's':
print word
range(0,11,2)
[x for x in range(1,50) if x%3 == 0]
st = 'Print every word in this sentence that has an even number of letters'
for word in st.split():
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: Use range() to print all the even numbers from 0 to 10.
Step2: Use List comprehension to create a list of all numbers between 1 and 50 that are... |
11,688 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nuist', 'sandbox-3', 'ocean')
# 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... |
11,689 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
from sklearn.linear_model import LinearRegression
# Create artificial data
X = np.array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
Y = np.array([-1.1, 4, 1, 6, 4, 2, 8, 5, 12, 7])
# 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: Simple Linear Regression
Step2: The green dots represent our artificial data i.e. the observed data. The red vertical lines indicate the errors... |
11,690 | <ASSISTANT_TASK:>
Python Code:
# Import the necessary packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import LeaveOneOut
from sklearn import linear_model, neighbors
%matplotlib inline
plt.style.use('ggplot')
# Where to save the figures
PROJECT_ROOT_DIR = ".."... | <SYSTEM_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 data
Step2: Here's the full dataset, and there are other columns. I will subselect a few of them by hand.
Step5: I will defi... |
11,691 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import statsmodels.api as sm
data =
x y y_err
201 592 61
244 401 25
47 583 38
287 402 15
203 495 21
58 173 15
210 479 27
202 504 14
198 510 30
158 416 16
165 393 14
201 442 25
157 317 52
131 311 16
16... | <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: Linear models
Step3: To fit a straight line use the weighted least squares class WLS ... the parameters are called
Step4: Check against scipy.... |
11,692 | <ASSISTANT_TASK:>
Python Code:
%%capture
!pip install pandas sklearn auto-sklearn kubeflow-fairing grpcio kubeflow.metadata bentoml plotly fbprophet
import uuid
from importlib import reload
import grpc
from kubeflow import fairing
from kubeflow.fairing import constants
import os
import pandas as pd
import logging
loggi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Config
Step2: Minio
Step3: Start
Step4: Model Training
Step5: Prediction
Step6: Projected vs Reality
Step7: Define BentoML Service
Step8: ... |
11,693 | <ASSISTANT_TASK:>
Python Code:
len
max
print
import requests
requests.get
# And if we just wanted to use them, for some reason
n = -34
print(n, "in absolute value is", abs(n))
print("We can add after casting to int:", 55 + int("55"))
n = 4.4847
print(n, "can be rounded to", round(n))
print(n, "can also be rounded to 2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Almost everything useful is a function. Python has a ton of other built-in functions!
Step2: See? Functions make the world run.
Step3: Horrify... |
11,694 | <ASSISTANT_TASK:>
Python Code:
import bqplot.pyplot as plt
# first, let's create two vectors x and y to plot using a Lines mark
import numpy as np
x = np.linspace(-10, 10, 100)
y = np.sin(x)
# 1. Create the figure object
fig = plt.figure(title='Simple Line Chart')
# 2. By default axes are created with basic defaults. I... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Steps for building plots in pyplot
Step1: For creating other marks (like scatter, pie, bars, etc.), only step 2 needs to be changed. Lets look a simple... |
11,695 | <ASSISTANT_TASK:>
Python Code:
import random
import os
import numpy as np
from work.dataset.activitynet import ActivityNetDataset
dataset = ActivityNetDataset(
videos_path='../dataset/videos.json',
labels_path='../dataset/labels.txt'
)
videos = dataset.get_subset_videos('validation')
videos = random.sample(vide... | <SYSTEM_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 trained model with its weigths
Step2: Extract the predictions for each video and print the scoring
Step3: Print the global classifica... |
11,696 | <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: On-device Text-to-Image Search with TensorFlow Lite Searcher Library
Step2: Note you might need to restart the runtime after installation.
Step... |
11,697 | <ASSISTANT_TASK:>
Python Code:
#begin by importing flopy
import os
import sys
import numpy as np
#flopypath = '../..'
#if flopypath not in sys.path:
# sys.path.append(flopypath)
import flopy
workspace = os.path.join('data')
#make sure workspace directory exists
if not os.path.exists(workspace):
os.makedirs(works... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: List of Boundaries
Step2: If we look at the River Package created here, you see that the layer, row, and column numbers have been increased by ... |
11,698 | <ASSISTANT_TASK:>
Python Code:
# construct and simulate toy example: diffusive dynamics in a double-well potential
import numpy as np
import numpy.random as npr
import matplotlib.pyplot as plt
%matplotlib inline
offset = np.array([3,0])
def q(x):
''' unnormalized probability '''
return np.exp(-np.sum((x-offset)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Two candidate discretizations
Step2: Discretization_fast
Step3: Discretization_slow
Step4: Extract discrete trajectories
Step5: Cross-valida... |
11,699 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import seaborn
class Bandit:
def __init__(self):
self.arm_values = np.random.normal(0,1,10)
self.K = np.zeros(10)
self.est_values = np.zeros(10)
def get_reward(self,action):
noise = np.random.normal(0,1)
reward = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How are we estimating the value of an action?
Step2: Let's make three different experiments
Step3: Although ε-greedy action selection is an ef... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.