Unnamed: 0
int64
0
16k
text_prompt
stringlengths
149
45.7k
code_prompt
stringlengths
67
140k
700
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: CIFAR 10 Wayne Nixalo 2018/2/20-21 A redo of the Fast.ai DL1L7 cifar10 notebook for some PyTorch practice. Data Step1: Something changed, or I forgot ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline %reload_ext autoreload %autoreload 2 from fastai.conv_learner import * PATH = 'data/cifar10/' os.makedirs(PATH, exist_ok=True) classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck') stats = (np.array([ 0.4914 , 0.48216, 0.44653]), n...
701
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: This is the second part in a series of notes on my exploration of the recently released Google QuickDraw dataset, using the concurrently released Sketc...
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'svg' %load_ext autoreload %autoreload 2 import matplotlib.pyplot as plt import matplotlib.patches as patches import numpy as np import tensorflow as tf from matplotlib.animation import FuncAnimation from matplotlib.path import Path...
702
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Generative Adversarial Networks Generative Adversarial Networks are invented by Ian Goodfellow (https Step1: MNIST database The MNIST database (Modifi...
<ASSISTANT_TASK:> Python Code: import numpy as np from keras.datasets import mnist import keras from keras.layers import Input, UpSampling2D, Conv2DTranspose, Conv2D, LeakyReLU from keras.layers.core import Reshape,Dense,Dropout,Activation,Flatten from keras.models import Sequential from keras.optimizers import RMSprop...
703
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Atmoschem MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contribu...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'bcc', 'sandbox-3', 'atmoschem') Explanation: ES-DOC CMIP6 Model Properties - Atmoschem MIP Era: CMIP6 Institute: BCC Source ID: SANDBOX-3 Topic: Atmoschem Sub-Topics...
704
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Generalized Watts-Strogatz Graph Experiments Output Visualization Step1: Parse results Step2: PageRank Seeds Percentage How many times the "Top X" no...
<ASSISTANT_TASK:> Python Code: #!/usr/bin/python %matplotlib inline import numpy as np import matplotlib.pyplot as plt from stats import parse_results, get_percentage, get_avg_per_seed, draw_pie, draw_bars, draw_bars_comparison, draw_avgs Explanation: Generalized Watts-Strogatz Graph Experiments Output Visualization En...
705
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fully-Connected Neural Nets In the previous homework you implemented a fully-connected two-layer neural network on CIFAR-10. The implementation ...
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup import time import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.fc_net import * from cs231n.data_utils import get_CIFAR10_data from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array from cs231n.solver impo...
706
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Automated ML for time series predicion We used one of the dataset in Numenta Anomaly Benchmark (NAB) for demo, i.e. NYC taxi passengers dataset, which ...
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 Explanation: Automated ML for time series predicion We used one of the dataset in Numenta Anomaly Benchmark (NAB) for demo, i.e. NYC taxi passengers dataset, which contains 10320 records, each indicating the total number of taxi passengers in NYC at a co...
707
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: This notebook was created by Sergey Tomin for Workshop Step1: Change RF parameters for the comparison with ASTRA Step2: Initializing SpaceCharge Step...
<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 ...
708
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Lecture 2 - Logic, Loops, and Arrays This iPython notebook covers some of the most important aspects of the Python language that is used daily by real ...
<ASSISTANT_TASK:> Python Code: #Example conditional statements x = 1 y = 2 x<y #x is less than y #x is greater than y x>y #x is less-than or equal to y x<=y #x is greater-than or equal to y x>=y Explanation: Lecture 2 - Logic, Loops, and Arrays This iPython notebook covers some of the most important aspects of the Pyth...
709
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: The simplest native coroutine demo (that I could imagine) Step1: The driving code starts here Step2: A slightly more interesting demo Now the generat...
<ASSISTANT_TASK:> Python Code: import types @types.coroutine def gen(): yield 42 async def delegating(): await gen() Explanation: The simplest native coroutine demo (that I could imagine) End of explanation coro = delegating() coro coro.send(None) # coro.send(None) # --> StopIteration Explanation: The driving ...
710
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2019 The TensorFlow Authors. Step1: 深度卷积生成对抗网络 <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https S...
<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...
711
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: EventVestor Step1: Let's go over the columns Step2: <a id='pipeline'></a> Pipeline Overview Accessing the data in your algorithms & research The only...
<ASSISTANT_TASK:> Python Code: # import the dataset from quantopian.interactive.data.eventvestor import mergers_and_acquisitions_free as dataset # or if you want to import the free dataset, use: #from quantopian.data.eventvestor import buyback_auth_free # import data operations from odo import odo # import other librar...
712
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: hot-CNO and breakout Step1: This collection of rates has the main CNO rates plus a breakout rate into the hot CNO cycle Step2: To evaluate the rates,...
<ASSISTANT_TASK:> Python Code: import pynucastro as pyrl Explanation: hot-CNO and breakout End of explanation files = ["c12-pg-n13-ls09", "c13-pg-n14-nacr", "n13--c13-wc12", "n13-pg-o14-lg06", "n14-pg-o15-im05", "n15-pa-c12-nacr", "o14--n14-wc12", "o15--n1...
713
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Calculating Annotation Coverage This section shows how to calculate annotation coverage as described here Step1: 2. Read associations 2a. You can read...
<ASSISTANT_TASK:> Python Code: # Get ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene2go.gz from goatools.base import download_ncbi_associations gene2go = download_ncbi_associations() Explanation: Calculating Annotation Coverage This section shows how to calculate annotation coverage as described here: Annotation coverage...
714
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: kochbar (7M) Results Analysis - MCMC - 100 iter-5Fold Step1: User Rating Average and Standard Deviation Histograms Step2: Item Rating Average and Sta...
<ASSISTANT_TASK:> Python Code: Analyse('kochbar\\Output', ['kochbar_ds.','kochbar_ds2.','kochbar_ds3.','kochbar_ds4.','kochbar_ds5.','kochbar_ds6.','kochbar_ds7.'], 100) print 'kochbar_ds - Rating + Users + Item\nkochbar_ds2 - Rating + Users + Item + AvgRatUser\nkochbar_ds3 - Rating + Users + Item + AvgRatUser + StdDev...
715
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Statistics Step1: Provide one or two visualizations that show the distribution of the sample data. Write one or two sentences noting what you observe ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (16.0, 8.0) df = pandas.read_csv('./stroopdata.csv') df.describe() Explanation: Statistics: The Science of Decisions Project Instructions Background Information In a Stroop task, participants...
716
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Interpolation Exercise 1 Step1: 2D trajectory interpolation The file trajectory.npz contains 3 Numpy arrays that describe a 2d trajectory of a particl...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns import numpy as np from scipy.interpolate import interp1d Explanation: Interpolation Exercise 1 End of explanation # YOUR CODE HERE with np.load('trajectory.npz') as data: x = data['x'] t=data['t'] y=data...
717
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Global Ocean Waves Analysis As a part of the continuous Marine Data support, this time Planet OS Team releases a Meteo France Global Ocean Waves Analys...
<ASSISTANT_TASK:> Python Code: import os from dh_py_access import package_api import dh_py_access.lib.datahub as datahub import xarray as xr from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np import imageio import shutil import datetime import matplotlib as mpl mpl.rcParams['fon...
718
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Enron POI Classifier general imports and mods Step1: sklearn imports Step2: load data Step3: original classifier Step4: data-record snapshot Step5:...
<ASSISTANT_TASK:> Python Code: import sys import os from time import time import re import pickle sys.path.append("ud120-projects/tools/") sys.path.append("ud120-projects/final_project/") #sys.path.append("ud120-projects/maildir/") import numpy as np import pandas as pd #from matplotlib import pyplot as plt #import sea...
719
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Classification and Regression There are two major types of supervised machine learning problems, called classification and regression. In classificatio...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline Explanation: Classification and Regression There are two major types of supervised machine learning problems, called classification and regression. In classification, the goal is to predict a class l...
720
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Handwritten Digit Recognition This tutorial guides you through a classic computer vision application Step1: We plot the first 10 images and print thei...
<ASSISTANT_TASK:> Python Code: import numpy as np import os import urllib import gzip import struct def download_data(url, force_download=True): fname = url.split("/")[-1] if force_download or not os.path.exists(fname): urllib.urlretrieve(url, fname) return fname def read_data(label_url, image_url)...
721
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: AdaptiveMD Example 1 - Setup 0. Imports Step1: We want to stop RP from reporting all sorts of stuff for this example so we set a specific environment ...
<ASSISTANT_TASK:> Python Code: import sys, os Explanation: AdaptiveMD Example 1 - Setup 0. Imports End of explanation # verbose = os.environ.get('RADICAL_PILOT_VERBOSE', 'REPORT') os.environ['RADICAL_PILOT_VERBOSE'] = 'ERROR' Explanation: We want to stop RP from reporting all sorts of stuff for this example so we set a...
722
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2019 The TensorFlow Authors. Step1: 사전 제작 Estimator <table class="tfo-notebook-buttons" align="left"> <td><a target="_blank" href="https S...
<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...
723
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <small> <i> This notebook was prepared by Marco Guajardo. For license visit github </i> </small> . Challenge Notebook Problem Step1: Unit Test <b> The...
<ASSISTANT_TASK:> Python Code: def reverse_words (S): #TODO: implement me pass Explanation: <small> <i> This notebook was prepared by Marco Guajardo. For license visit github </i> </small> . Challenge Notebook Problem: Given a string of words, return a string with the words in reverse Constraits Test Cases Alg...
724
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Análisis de los datos obtenidos Uso de ipython para el análsis y muestra de los datos obtenidos durante la producción. Los datos analizados son del fil...
<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...
725
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: The Inference Button Step1: Generating data Create some toy data to play around with and scatter-plot it. Essentially we are creating a regression li...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from pymc3 import * import numpy as np import matplotlib.pyplot as plt Explanation: The Inference Button: Bayesian GLMs made easy with PyMC3 Author: Thomas Wiecki This tutorial appeared as a post in a small series on Bayesian GLMs on my blog: The Inference Button: Baye...
726
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: The goal here is to make a model where you put something into working memory, then leave it there for a while, and then clear the working memory. When...
<ASSISTANT_TASK:> Python Code: dimensions = 10 input_scale = 1 n_neurons_per_dim = 50 intercept_low = -0.5 intercept_high = 1.0 tau_input = 0.01 tau_recurrent = 0.1 tau_reset = 0.2 max_rate_high = 200 max_rate_low = 150 sensory_delay = 0.05 reset_scale = 0.3 model = nengo.Network() with model: vocab = spa.Vocabular...
727
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Matplotlib Exercise 2 Imports Step1: Exoplanet properties Over the past few decades, astronomers have discovered thousands of extrasolar planets. The ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np Explanation: Matplotlib Exercise 2 Imports End of explanation !head -n 30 open_exoplanet_catalogue.txt Explanation: Exoplanet properties Over the past few decades, astronomers have discovered thousands of extrasolar pla...
728
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Electric Machinery Fundamentals 5th edition Chapter 6 (Code examples) Example 6-6 Step1: First, initialize the values needed in this program. Step2: ...
<ASSISTANT_TASK:> Python Code: %pylab notebook Explanation: Electric Machinery Fundamentals 5th edition Chapter 6 (Code examples) Example 6-6: Creates and plot of the torque-speed curve of an induction motor with a double-cage rotor design as depicted in Figure 6-29. Note: You should first click on "Cell &rarr; Run All...
729
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Character level language model - Dinosaurus land Welcome to Dinosaurus Island! 65 million years ago, dinosaurs existed, and in this assignment they are...
<ASSISTANT_TASK:> Python Code: import numpy as np from utils import * import random from random import shuffle Explanation: Character level language model - Dinosaurus land Welcome to Dinosaurus Island! 65 million years ago, dinosaurs existed, and in this assignment they are back. You are in charge of a special task. L...
730
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: WAve Models (WAM) Usage Example WAM wave models are most widely used wave models in the world. This notebook illustrates ways of using WAM models data...
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import urllib.request import numpy as np import simplejson as json import pandas as pd from netCDF4 import Dataset, date2num, num2date import ipywidgets as widgets from IPython.display import display, clear_output import dateutil.parser import matplotlib.pyplot as plt...
731
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Creating an advanced interactive map with Bokeh This page demonstrates, how it is possible to visualize any kind of geometries (normal geometries + Mul...
<ASSISTANT_TASK:> Python Code: from bokeh.palettes import YlOrRd as palette #Spectral6 as palette from bokeh.plotting import figure, save from bokeh.models import ColumnDataSource, HoverTool, LogColorMapper from bokeh.palettes import RdYlGn10 as palette import geopandas as gpd import pysal as ps import numpy as np # ...
732
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Byte 4 Step1: Custom functions and global variables Step2: Dataset Step3: Next, read the two documents describing the dataset (data/ACS2015_PUMS_REA...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns import pickle import os from IPython.display import Image from IPython.display import display from sklearn.preprocessing import LabelEncoder from sklearn.preprocessing imp...
733
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Gaussian Process Regression in Pytorch Thomas Viehmann, &#116;&#118;&#64;&#108;&#101;&#114;&#110;&#97;&#112;&#112;&#97;&#114;&#97;&#116;&#46;&#100;&#10...
<ASSISTANT_TASK:> Python Code: from matplotlib import pyplot %matplotlib inline import IPython import torch from torch import nn from torch.autograd import Variable import numpy Explanation: Gaussian Process Regression in Pytorch Thomas Viehmann, &#116;&#118;&#64;&#108;&#101;&#114;&#110;&#97;&#112;&#112;&#97;&#114;&#97...
734
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Training Ensemble on MNIST Dataset On the function points branch of nengo On the vision branch of nengo_extras Step1: Represent each number using a on...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt %matplotlib inline import nengo import numpy as np import scipy.ndimage import matplotlib.animation as animation from matplotlib import pylab from PIL import Image import nengo.spa as spa import cPickle import random from nengo_extras.data import load_mnist...
735
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Project Euler Step2: Now write a set of assert tests for your number_to_words function that verifies that it is working as expected. Step4: No...
<ASSISTANT_TASK:> Python Code: import numpy as np numbers = {0: "", 1:"one", 2:"two", 3:"three", 4:"four", 5:"five", 6:"six", 7:"seven", 8:"eight", 9:"nine", 10:"ten", 11:"eleven", 12:"twelve", 13:"thirteen", 14:"fourteen", 15:"fifteen", 16:"sixteen", 17:"seventeen", 18:"eighteen", 19:"nineteen", 20...
736
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Introduction This notebook demonstrates how to perform phase and electrochemical assessments starting from a VASP calculation using Python Materials Ge...
<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...
737
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Today Step1: Q. Is the following call sequence acceptable? Step2: No! The following are all OK! Step3: Keyword arguments Step4: The first two argum...
<ASSISTANT_TASK:> Python Code: from math import exp # Could avoid this by using our constants.py module! h = 6.626e-34 # MKS k = 1.38e-23 c = 3.00e8 def intensity(wave, temp, mydefault=0): wavelength = wave / 1e10 B = 2 * h * c**2 / (wavelength**5 * (exp(h * c / (wavelength * k * temp)) - 1)) return B Expl...
738
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Styling New in version 0.17.1 <span style="color Step1: Here's a boring example of rendering a DataFrame, without any (visible) styles Step2: Note St...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot # We have this here to trigger matplotlib's font cache stuff. # This cell is hidden from the output import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame({'A': np.linspace(1, 10, 10)}) df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), ...
739
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: &larr; Back to Index Spectral Features For classification, we're going to be using new features in our arsenal Step1: librosa.feature.spectral_bandwid...
<ASSISTANT_TASK:> Python Code: x, fs = librosa.load('simple_loop.wav') IPython.display.Audio(x, rate=fs) spectral_centroids = librosa.feature.spectral_centroid(x, sr=fs) plt.plot(spectral_centroids[0]) Explanation: &larr; Back to Index Spectral Features For classification, we're going to be using new features in our ar...
740
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Python API to EasyForm Step1: You can access the values from the form by treating it as an array indexed on the field names Step2: The array works bo...
<ASSISTANT_TASK:> Python Code: from beakerx import * f = EasyForm("Form and Run") f.addTextField("first") f['first'] = "First" f.addTextField("last") f['last'] = "Last" f.addButton("Go!", tag="run") f Explanation: Python API to EasyForm End of explanation "Good morning " + f["first"] + " " + f["last"] f['last'][::-1] +...
741
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Algorithms Exercise 1 Imports Step3: Word counting Write a function tokenize that takes a string of English text returns a list of words. It should al...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np Explanation: Algorithms Exercise 1 Imports End of explanation s = "this is a test\n here it is" print(s.splitlines()) s.split(" ") def tokenize(s, stop_words=None, punctuation='`~!@#$%^&*()_-+={[}]|\:;"<,>.?/}\t\n'...
742
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: How HDBSCAN Works HDBSCAN is a clustering algorithm developed by Campello, Moulavi, and Sander. It extends DBSCAN by converting it into a hierarchical ...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import seaborn as sns import sklearn.datasets as data %matplotlib inline sns.set_context('poster') sns.set_style('white') sns.set_color_codes() plot_kwds = {'alpha' : 0.5, 's' : 80, 'linewidths':0} Explanation: How HDBSCAN Works HDBSCAN i...
743
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Predicting Student Admissions with Neural Networks In this notebook, we predict student admissions to graduate school at UCLA based on three pieces of ...
<ASSISTANT_TASK:> Python Code: # Importing pandas and numpy import pandas as pd import numpy as np # Reading the csv file into a pandas DataFrame data = pd.read_csv('student_data.csv') # Printing out the first 10 rows of our data data[:10] Explanation: Predicting Student Admissions with Neural Networks In this notebook...
744
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <small><i>This notebook was prepared by Thunder Shiviah. Source and license info is on GitHub.</i></small> Challenge Notebook Problem Step1: Unit Test...
<ASSISTANT_TASK:> Python Code: def list_primes(n): # TODO: Implement me pass Explanation: <small><i>This notebook was prepared by Thunder Shiviah. Source and license info is on GitHub.</i></small> Challenge Notebook Problem: Implement list_primes(n), which returns a list of primes up to n (inclusive). Constrain...
745
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 练习 1:写程序,可由键盘读入用户姓名例如Mr. right,让用户输入出生的月份与日期,判断用户星座,假设用户是金牛座,则输出,Mr. right,你是非常有性格的金牛座!。 Step1: 练习 2:写程序,可由键盘读入两个整数m与n(n不等于0),询问用户意图,如果要求和则计算从m到n的和输出,...
<ASSISTANT_TASK:> Python Code: name=input('请输入你的姓名,回车结束:') print(name,'你好!') month=int(input('请输入你的出生月份,回车结束:')) date=int(input('请输入你的出生日期,回车结束:')) print('你的生日是:',month,'月',date,'日') if month == 3: if date >= 21: print(name,',你是白羊座。') else: print(name,',你是双鱼座。') if month == 4: if date >= 20:...
746
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Machine Learning Engineer Nanodegree Capstone Project Step1: Load the Dataset Keras provides api to download and load the mnist dataset in a single li...
<ASSISTANT_TASK:> Python Code: from __future__ import print_function from numpy import random from keras.datasets import mnist # helps in loading the MNIST dataset from keras.models import Sequential from keras.layers import Input, Dense, Dropout, Activation, Flatten from keras.layers import Convolution2D, MaxPooling2D...
747
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Bins Mark This Mark is essentially the same as the Hist Mark from a user point of view, but is actually a Bars instance that bins sample data. The diff...
<ASSISTANT_TASK:> Python Code: # Create a sample of Gaussian draws np.random.seed(0) x_data = np.random.randn(1000) Explanation: Bins Mark This Mark is essentially the same as the Hist Mark from a user point of view, but is actually a Bars instance that bins sample data. The difference with Hist is that the binning is ...
748
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Getting started in scikit-learn with the famous iris dataset From the video series Step1: Machine learning on the iris dataset Framed as a supervised ...
<ASSISTANT_TASK:> Python Code: from IPython.display import IFrame IFrame('http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data', width=300, height=200) Explanation: Getting started in scikit-learn with the famous iris dataset From the video series: Introduction to machine learning with scikit-learn A...
749
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Two coins refresher Given a world that consist of bunch random events (2 coins for simplicity) we are interested in quantifying the probability of diff...
<ASSISTANT_TASK:> Python Code: #Your code here Explanation: Two coins refresher Given a world that consist of bunch random events (2 coins for simplicity) we are interested in quantifying the probability of different combinations of the world state. The state space The combination of all possible outcomes is called the...
750
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Comparing the output of pip in the magical venv that can run the alexnet_based and a fresh install that can't. Have saved both of these to different te...
<ASSISTANT_TASK:> Python Code: cd .. !cat magical.freeze !cat fresh.freeze Explanation: Comparing the output of pip in the magical venv that can run the alexnet_based and a fresh install that can't. Have saved both of these to different text files: End of explanation magical = [] with open("magical.freeze") as f: f...
751
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Process an observation Setup the processing Step1: Fetch all the image documents from the metadata store. We then filter based off image status and me...
<ASSISTANT_TASK:> Python Code: # Default input parameters (replaced in next cell) sequence_id = '' # e.g. PAN012_358d0f_20191005T112325 # Unused option for now. See below. # vmag_min = 6 # vmag_max = 14 position_column_x = 'catalog_wcs_x' position_column_y = 'catalog_wcs_y' input_bucket = 'panoptes-images-processed' #...
752
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Layer Gradient Checks Here, we use numerical gradient checking to verify the backpropagation correctness of all layers in the Layers folder. We should...
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import numpy as np import LearnyMcLearnface as lml Explanation: Layer Gradient Checks Here, we use numerical gradient checking to verify the backpropagation correctness of all layers in the Layers folder. We should expect to see very small nonzero value...
753
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: English Wikipedia page views, 2008 - 2017 For this assignment, your job is to analyze traffic on English Wikipedia over time, and then document your pr...
<ASSISTANT_TASK:> Python Code: import requests import pandas endpoint = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/aggregate/{project}/{access}/{agent}/{granularity}/{start}/{end}' headers={'User-Agent' : 'https://github.com/r1rajiv92', 'From' : 'rajiv92@uw.edu'} yearMonthCombinations = { '2015' : [ 7, 8, 9, ...
754
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2017 Google LLC. Step1: # Pandas 간단 소개 학습 목표 Step2: Pandas의 기본 데이터 구조는 두 가지 클래스로 구현됩니다. DataFrame은 행 및 이름 지정된 열이 포함된 관계형 데이터 테이블이라고 생각할 수 있...
<ASSISTANT_TASK:> Python Code: # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, sof...
755
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Module 5- Other Forms of Visualization author Step1: The following module creates a pi chart that illustrates the breakdown of which isotope is measur...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import csv import io import urllib.request import matplotlib.pyplot as plt from datetime import datetime import numpy as np url = 'https://radwatch.berkeley.edu/sites/default/files/pictures/rooftop_tmp/weather.csv' response = urllib.request.urlopen(url) r...
756
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting HYCOM Global Ocean Forecast Data Note Step2: Let's choose a location near Oahu, Hawaii... Step3: Important! You'll need to replace ap...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import dateutil.parser import datetime from urllib.request import urlopen, Request import simplejson as json def extract_reference_time(API_data_loc): Find reference time that corresponds to most complete forecast. ...
757
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: An Attractive Representation of Count Data I like to play with ways to visualise data, in particular with how to represent data in the most meaningful,...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline before = np.loadtxt('Data/questionnaire_before.txt',delimiter=',') after = np.loadtxt('Data/questionnaire_after.txt',delimiter=',') form = np.loadtxt('Data/questionnaire_form.txt',delimiter=',') questions = np.array(ran...
758
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <h1><span style="color Step1: Simulate example data Step2: Input data file Step3: Population assignments Step4: Filter missing data and convert to ...
<ASSISTANT_TASK:> Python Code: # conda install ipyrad ipcoal -c conda-forge -c bioconda import ipyrad.analysis as ipa import toytree import ipcoal print('ipyrad', ipa.__version__) print('toytree', toytree.__version__) print('ipcoal', ipcoal.__version__) Explanation: <h1><span style="color:gray">ipyrad-analysis toolkit:...
759
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Consuming API Instead of using web scraping, using an API, application programming interface, is the preferred method. Usually, you need to register in...
<ASSISTANT_TASK:> Python Code: !pip install omdb Explanation: Consuming API Instead of using web scraping, using an API, application programming interface, is the preferred method. Usually, you need to register in order to use an API. But we will use a freely available API called Open Movie Database API. 1. Install Pyt...
760
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 1. Install Dependencies First install the libraries needed to execute recipes, this only needs to be done once, then click play. Step1: 2. Get Cloud P...
<ASSISTANT_TASK:> Python Code: !pip install git+https://github.com/google/starthinker Explanation: 1. Install Dependencies First install the libraries needed to execute recipes, this only needs to be done once, then click play. End of explanation CLOUD_PROJECT = 'PASTE PROJECT ID HERE' print("Cloud Project Set To: %s" ...
761
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: WEB_API Scrapper Step1: I would like to get the Best Seller list for the Month of October 2015. First I signed up to the New York Times API, and after...
<ASSISTANT_TASK:> Python Code: import urllib2 import json import pandas as pd Explanation: WEB_API Scrapper End of explanation url = urllib2.urlopen('http://api.nytimes.com/svc/books/v3/lists/2015-10-01/hardcover-fiction.json?callback=books&sort-by=rank&sort-order=DESC&api-key=efb1f6ff386ce33c0b913d44bce40fd8%3A10%3A73...
762
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Network Analysis--Using Null Models Adapted from Professor Clauset's lectures and homeworks for Network Analysis and Modeling // Course page Step1: Gr...
<ASSISTANT_TASK:> Python Code: #relatively fast networks package (pip install python-igraph) that I used for these homeworks import igraph # slow-and-steady networks package. fewer bugs, easier drawing import networkx as nx # plots! import matplotlib.pyplot as plt from matplotlib import style %matplotlib inline # othe...
763
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: False positive and false negatives This notebook explores the two sources of systematic error that we identify and trim in our datasets. Step1: False ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import pandas as pd import numpy as np Explanation: False positive and false negatives This notebook explores the two sources of systematic error that we identify and trim in our datasets. End of explanation stats2 = pd.read_csv("los...
764
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Matplot lib - All your plotting functions under one roof (almost!) Matplotlib is a simple (most of the time) plotting library. So let's have a try! St...
<ASSISTANT_TASK:> Python Code: # This will plot a simple scatter graph of points. # The points will have all different sizes just for visual appearance, as well as varied colours %matplotlib inline # Import the required libraries import numpy as np import matplotlib.pyplot as plt # Lets say we want to plot 50 points N...
765
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Silicon Forest Math Series<br/>Oregon Curriculum Network Introduction to Public Key Cryptography Here in the Silicon Forest, we do not expect ev...
<ASSISTANT_TASK:> Python Code: import pprint def primes(): generate successive prime numbers (trial by division) candidate = 1 _primes_so_far = [2] # first prime, only even prime yield _primes_so_far[0] # share it! while True: candidate += 2 # check odds only from now on for ...
766
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Frequentism and Bayesianism II Step1: In other words, we'd give Bob the following odds of winning Step2: So we've estimated using frequentist ideas t...
<ASSISTANT_TASK:> Python Code: p_hat = 5. / 8. freq_prob = (1 - p_hat) ** 3 print("Naïve Frequentist Probability of Bob Winning: {0:.2f}".format(freq_prob)) Explanation: Frequentism and Bayesianism II: When Results Differ Mario Juric & Jake VanderPlas, University of Washington e-mail: &#109;&#106;&#117;&#114;&#105;&#99...
767
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step4: Where Am I? Startup.ML Conference - San Francisco - Jan 20, 2017 Who Am I? Chris Fregly Research Scientist @ PipelineIO Video Series Author "Hig...
<ASSISTANT_TASK:> Python Code: import numpy as np import os import tensorflow as tf from tensorflow.contrib.session_bundle import exporter import time # make things wide from IPython.core.display import display, HTML display(HTML("<style>.container { width:100% !important; }</style>")) from IPython.display import clear...
768
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Regression This section follows the section 7.10 of Modern Statistical Methods in Astronomy by Feigelson and Babu ordinary least squares The statsmodel...
<ASSISTANT_TASK:> Python Code: import statsmodels statsmodels.__version__ import pandas as pd import numpy as np import statsmodels.api as sm import statsmodels.formula.api as smf from statsmodels.sandbox.regression.predstd import wls_prediction_std import matplotlib.pyplot as plt Explanation: Regression This section f...
769
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Formulas & Automata generators The spot.gen package contains the functions used to generate the patterns produced by genltl and genaut. Step1: LTL pat...
<ASSISTANT_TASK:> Python Code: import spot import spot.gen as sg spot.setup() from IPython.display import display Explanation: Formulas & Automata generators The spot.gen package contains the functions used to generate the patterns produced by genltl and genaut. End of explanation sg.ltl_pattern(sg.LTL_AND_GF, 3) sg.lt...
770
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Synthetic Seismogram Widget Using the Notebook This is the <a href="https Step1: 1 Normal Incidence Seismogram Backgrounds Step2: 1.2 Depth to Time c...
<ASSISTANT_TASK:> Python Code: # Import the necessary packages %matplotlib inline from SimPEG.utils import download from geoscilabs.seismic.syntheticSeismogram import InteractLogs, InteractDtoT, InteractWconvR, InteractSeismogram from geoscilabs.seismic.NMOwidget import ViewWiggle, InteractClean, InteractNosiy, NMOs...
771
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Plot Gaze Timeline with Kinematic Events (shooting study) Input Step1: Coding errors shotFired not always accurate. So create new var Step2: Find gaz...
<ASSISTANT_TASK:> Python Code: ## set to full width if not using theme #from IPython.core.display import display, HTML #display(HTML("<style>.container { width:100% !important; }</style>")) import pandas as pd import numpy as np import matplotlib.pyplot as plt import string import matplotlib.patches as mpatches import ...
772
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Using and Creating Labels Labels are a way to 'bookmark' certain pores for easier lookup later, such as specifying boundary conditions. When networks ...
<ASSISTANT_TASK:> Python Code: import openpnm as op %config InlineBackend.figure_formats = ['svg'] import numpy as np Explanation: Using and Creating Labels Labels are a way to 'bookmark' certain pores for easier lookup later, such as specifying boundary conditions. When networks are generated they include a set of re...
773
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Functions Functions are blocks of code identified by a name, which can receive ""predetermined"" parameters or not ;). In Python, functions Step...
<ASSISTANT_TASK:> Python Code: def caps(val): caps returns double the value of the provided value return val*2 a = caps("TEST ") print(a) print(caps.__doc__) Explanation: Functions Functions are blocks of code identified by a name, which can receive ""predetermined"" parameters or not ;). In Python, f...
774
<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: OLS Analysis Using Full PSU dataset Step3: Partitioning a dataset in training and test sets Step4: Determine Feature Importances Test Predicti...
<ASSISTANT_TASK:> Python Code: #Import required packages import pandas as pd import numpy as np import datetime import matplotlib.pyplot as plt def format_date(df_date): Splits Meeting Times and Dates into datetime objects where applicable using regex. df_date['Days'] = df_date['Meeting_Times'].str.ex...
775
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: OrderExtend example with boat image This note shows how the OrderExtend algorithm performs the matrix completion task on a partially observed image dat...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from scipy import ndimage import matplotlib.pyplot as plt import matplotlib.cm as cm from model import OrderExtend img = ndimage.imread('images/boat.jpeg', flatten=True) img /= np.max(img) #normalize image [0,1] plt.imshow(img, cmap = cm.Greys_r) Expl...
776
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: textblob Step1: Vamos a crear nuestro primer ejemplo de textblob a través del objeto TextBlob. Piensa en estos textblobs como una especie de cadenas d...
<ASSISTANT_TASK:> Python Code: from textblob import TextBlob Explanation: textblob: otro módulo para tareas de PLN (NLTK + pattern) textblob es una librería de procesamiento del texto para Python que permite realizar tareas de Procesamiento del Lenguaje Natural como análisis morfológico, extracción de entidades, anális...
777
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <table> <tr align=left><td><img align=left src="./images/CC-BY.png"> <td>Text provided under a Creative Commons Attribution license, CC-BY. All code ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint from mpl_toolkits.mplot3d import Axes3D from numpy.linalg import eigvals Explanation: <table> <tr align=left><td><img align=left src="./images/CC-BY.png"> <td>Text provided under a C...
778
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Intro to MongoDB Makes sense for data science applications widely used in big data document database or associative array python dictionary Resources M...
<ASSISTANT_TASK:> Python Code: import pprint def get_client(): from pymongo import MongoClient return MongoClient('mongodb://localhost:27017/') def get_db(): # 'examples' here is the database name. It will be created if it does not exist. db = get_client().examples return db def add_city(db...
779
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Introduction to Python part VI (And a discussion of random vectors) Activity 1 Step1: We can access elements of a list using indices – numbered positi...
<ASSISTANT_TASK:> Python Code: odds = [1, 3, 5, 7] print('odds are:', odds) Explanation: Introduction to Python part VI (And a discussion of random vectors) Activity 1: Discussion of multiple random variables How is the notion of the expected value extended into multiple variables? What does this represent? What is a ...
780
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Sentiment Classification & How To "Frame Problems" for a Neural Network by Andrew Trask Twitter Step1: Note Step2: Lesson Step3: Project 1 Step4: W...
<ASSISTANT_TASK:> Python Code: def pretty_print_review_and_label(i): print(labels[i] + "\t:\t" + reviews[i][:80] + "...") g = open('reviews.txt','r') # What we know! reviews = list(map(lambda x:x[:-1],g.readlines())) g.close() g = open('labels.txt','r') # What we WANT to know! labels = list(map(lambda x:x[:-1].uppe...
781
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Dependencies Step1: Loading Data First, we want to create our word vectors. For simplicity, we're going to be using a pretrained model. As one of the...
<ASSISTANT_TASK:> Python Code: # Tensorflow import tensorflow as tf print('Tested with TensorFlow 1.2.0') print('Your TensorFlow version:', tf.__version__) # Feeding function for enqueue data from tensorflow.python.estimator.inputs.queues import feeding_functions as ff # Rnn common functions from tensorflow.contrib.le...
782
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Introduction This notebook gives examples for processing spins monitor data. Logging data is stored in monitors that are defined within the optimizatio...
<ASSISTANT_TASK:> Python Code: ## Import libraries necessary for monitor data processing. ## from matplotlib import pyplot as plt import numpy as np import os import pandas as pd import pickle from spins.invdes.problem_graph import log_tools ## Define filenames. ## # `save_folder` is the full path to the directory cont...
783
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: FD_1D_DX8_DT2 1-D acoustic Finite-Difference modelling GNU General Public License v3.0 Author Step1: Input Parameter Step2: Preparation Step3: Creat...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import time as tm import matplotlib.pyplot as plt Explanation: FD_1D_DX8_DT2 1-D acoustic Finite-Difference modelling GNU General Public License v3.0 Author: Florian Wittkamp Finite-Difference acoustic seismic wave simulation Discretization of the fir...
784
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <a href="https Step1: De esta manera, Python estandariza el aspecto del código desde la definición del lenguaje. Nota Step2: Los operadores para vari...
<ASSISTANT_TASK:> Python Code: if 2 + 3 == 5: x = 5 + 3 mensaje = "Verdadero!" else: x = 5 - 3 mensaje = "Falso!" print(x) print(mensaje) Explanation: <a href="https://www.python.org/"><img src="./Imagenes/python-logo.png" alt="Python Logo" style="width: 200px; display:inline;"/></a> Python es un l...
785
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Benchmark concepts This notebook goes through all concepts and runs the query using EXPLAIN ANALYZE. This is useful for informing how long the queries ...
<ASSISTANT_TASK:> Python Code: import os import re import psycopg2 import getpass from collections import OrderedDict # database config sqluser=getpass.getuser() # keep sqlpass blank if using peer authentication sqlpass='' # database sqldb='mimic' sqlschema='public,mimiciii' query_schema = 'set search_path to ' + sqlsc...
786
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Contents Introduction Removing Features Introduction This IPython notebook illustrates how to remove features from feature table. First, we need to imp...
<ASSISTANT_TASK:> Python Code: # Import py_entitymatching package import py_entitymatching as em import os import pandas as pd Explanation: Contents Introduction Removing Features Introduction This IPython notebook illustrates how to remove features from feature table. First, we need to import py_entitymatching package...
787
<SYSTEM_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 In this project, you’re going to take a peek into the realm of neural network machine translation. You’ll be training a se...
<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) Explanation: Language Translation In this proj...
788
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 迷你项目:蒙特卡洛方法 在此 notebook 中,你将自己编写很多蒙特卡洛 (MC) 算法的实现。 虽然我们提供了一些起始代码,但是你可以删掉这些提示并从头编写代码。 第 0 部分:探索 BlackjackEnv 请使用以下代码单元格创建 Blackjack 环境的实例。 Step1: 每个状态都...
<ASSISTANT_TASK:> Python Code: import gym env = gym.make('Blackjack-v0') Explanation: 迷你项目:蒙特卡洛方法 在此 notebook 中,你将自己编写很多蒙特卡洛 (MC) 算法的实现。 虽然我们提供了一些起始代码,但是你可以删掉这些提示并从头编写代码。 第 0 部分:探索 BlackjackEnv 请使用以下代码单元格创建 Blackjack 环境的实例。 End of explanation STICK = 0 HIT = 1 Explanation: 每个状态都是包含以下三个元素的 3 元组: - 玩家的当前点数之和 $\in...
789
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2019 The TensorFlow Authors. Step1: 乱数の生成 <table class="tfo-notebook-buttons" align="left"> <td><a target="_blank" href="https Step2: tf....
<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...
790
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tables to Networks, Networks to Tables Networks can be represented in a tabular form in two ways Step1: At this point, we have our stations and trips ...
<ASSISTANT_TASK:> Python Code: stations = pd.read_csv('datasets/divvy_2013/Divvy_Stations_2013.csv', parse_dates=['online date'], index_col='id') stations trips = pd.read_csv('datasets/divvy_2013/Divvy_Trips_2013.csv', parse_dates=['starttime', 'stoptime'], index_col=['trip_id']) trips = trips.sort() trips Explanation:...
791
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: When analyzing data, I usually use the following three modules. I use pandas for data management, filtering, grouping, and processing. I use numpy for ...
<ASSISTANT_TASK:> Python Code: import pandas import numpy import toyplot import toyplot.pdf import toyplot.png import toyplot.svg print('Pandas version: ', pandas.__version__) print('Numpy version: ', numpy.__version__) print('Toyplot version: ', toyplot.__version__) Explanation: When analyzing data, I usually use t...
792
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 1 - Design parameters <img src="https Step1: System Height From Geometry Expressions, we obtain Step2: Lens Hole Radius From Geometry Expressions, we...
<ASSISTANT_TASK:> Python Code: w, h, b, d, c1, c2, k1, k2, r_sys, r_ref = symbols("w, h, b, d, c_1, c_2, k_1, k_2, r_{sys}, r_{ref}", real=True) # Constraints for hyperboloids: k1_constraint = k1 > 2 k2_constraint = k2 > 2 c1_constraint = c1 > 0 c2_constraint = c2 > 0 xw, yw, zw = symbols("x_w, y_w, z_w", real=True) # ...
793
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Radial Wavefunctions and Quantum Defects In this tutorial we show how to access quantum defects and wavefunctions, which are used for the computation o...
<ASSISTANT_TASK:> Python Code: %matplotlib inline Explanation: Radial Wavefunctions and Quantum Defects In this tutorial we show how to access quantum defects and wavefunctions, which are used for the computation of matrix elements, using the Python API. Some aspects of this are discussed in Appendix A of the pairinte...
794
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Naive Bayes Male or Female Multivariate author Step1: Since we are simply using two Multivariate Gaussian Distributions, our Naive Bayes model is very...
<ASSISTANT_TASK:> Python Code: from pomegranate import * import numpy as np Explanation: Naive Bayes Male or Female Multivariate author: Nicholas Farn [<a href="sendto:nicholasfarn@gmail.com">nicholasfarn@gmail.com</a>] This example shows how to create a Multivariate Guassian Naive Bayes Classifier using pomegranate. I...
795
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Generate Region of Interests (ROI) labeled arrays for simple shapes This example notebook explain the use of analysis module "skxray/core/roi" https St...
<ASSISTANT_TASK:> Python Code: import skxray.core.roi as roi import skxray.core.correlation as corr import numpy as np import matplotlib.pyplot as plt %matplotlib inline from matplotlib.ticker import MaxNLocator from matplotlib.colors import LogNorm import xray_vision.mpl_plotting as mpl_plot Explanation: Generate Regi...
796
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <hr width=80%> <center> Data Cleaning & Bigrams</center> <hr width=80%> Data Cleaning Loading the data Removing missing data Adding 'yearmonth' Stemmin...
<ASSISTANT_TASK:> Python Code: all_data_list = [] for year in range(1990,2017): data = pd.read_csv('{}_Output.csv'.format(year), header=None) all_data_list.append(data) # list of dataframes data = pd.concat(all_data_list, axis=0) data.columns = ['id','date','headline', 'lead'] data.head() Explanation: <hr width...
797
<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 - Advanced Level Example - Modeling an Agriculture+PV (AGRIPV) Site This journal shows how to model an AgriPV site, calculating the irradiance not o...
<ASSISTANT_TASK:> Python Code: import os from pathlib import Path testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'Tutorial_11') if not os.path.exists(testfolder): os.makedirs(testfolder) print ("Your simulation will be stored in %s" % testfolder) from bifacial_radiance import...
798
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Modeling and Simulation in Python Case study. Copyright 2017 Allen Downey License Step1: Unrolling Let's simulate a kitten unrolling toilet paper. As...
<ASSISTANT_TASK:> Python Code: # Configure Jupyter so figures appear in the notebook %matplotlib inline # Configure Jupyter to display the assigned value after an assignment %config InteractiveShell.ast_node_interactivity='last_expr_or_assign' # import functions from the modsim.py module from modsim import * Explanatio...
799
<SYSTEM_TASK:> Given the following text problem statement, write Python code to implement the functionality described below in problem statement <END_TASK> <USER_TASK:> Problem: Given a pandas DataFrame, how does one convert several binary columns (where 1 denotes the value exists, 0 denotes it doesn't) into a single c...
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame({'A': [1, 0, 0, 0, 1, 0], 'B': [0, 1, 0, 0, 0, 1], 'C': [0, 0, 1, 0, 0, 0], 'D': [0, 0, 0, 1, 0, 0]}) df["category"] = df.idxmax(axis=1) <END_TASK>