Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
11,200 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from IPython.display import display, Latex
import seaborn as sb
sb.set_context('notebook')
sb.set_style('ticks')
from ldtk import LDPSetCreator, BoxcarFilter, TabulatedFilter
from ldtk.filters import sdss_g, sdss_r, sdss_i, sdss_z
sc = LDPSetCreator(teff=(5500,100), logg=(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initialisation
Step2: First, we initialise a LDPSetCreator with the stellar parameter estimates and our filter set. This may take some time, si... |
11,201 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
% matplotlib inline
from matplotlib import pyplot as plt
data = pd.read_csv('all_data.csv')
data.head(10)
duplicated_data = data.duplicated()
duplicated_data.head()
data[duplicated_data]
heights = data['height']
ages = data['age']
gender = 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: The data you'll be exloring
Step2: Duplicated data
Step3: So this is actually a mask. We can now ask for the data where the mask applies
Step4... |
11,202 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
pd.options.display.max_rows = 8
df = pd.read_csv("data/titanic.csv")
df.head()
df['Age'].hist()
df.groupby('Sex')[['Survived']].aggregate(lambda x: x.sum() / len(x))
df.groupby('Pclass')['Survive... | <SYSTEM_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. Let's start with a showcase
Step2: Starting from reading this dataset, to answering questions about this data in a few lines of code
Step3: ... |
11,203 | <ASSISTANT_TASK:>
Python Code:
DATA_FOLDER = 'Data' # Use the data folder provided in Tutorial 02 - Intro to Pandas.
path = "Data/ebola"
countries = [("Guinea","guinea_data"), ("Liberia","liberia_data"), ("Sierra Leone","sl_data")]
data = pd.DataFrame()
# for each country dataframe, concatenate all the sheets and add ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Task 1. Compiling Ebola Data
Step2: 2.
Step3: 3.
Step4: 4.
Step5: Comments
Step6: Task 3. Class War in Titanic
Step7: For each of the foll... |
11,204 | <ASSISTANT_TASK:>
Python Code:
import dnnSwift
# The layout is a list of dictionaries defining each layer of the DNN.
# For this example, the DNN will consist of two blocks of
# "convolution - convolution - maximum pooling", followed by a fully
# connected layer and finally a cross entropy cost function
dnn_layout =... | <SYSTEM_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 dnnSwift object writes its output into the 'weights_dir' directory. The output consists of weights and validation data. Validation data is c... |
11,205 | <ASSISTANT_TASK:>
Python Code:
# Source: Manuel Torres. Universidad de Almería.
import pymysql
# Establecemos la conexion con la base de datos
bd = pymysql.connect("localhost", "root", "gebd", "RRHH")
# Preparamos el cursor que nos va a ayudar a realizar las operaciones con la base de datos
cursor = bd.cursor()
# 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: Exercise 1
Step2: Exercise 2
Step3: Exercise 3
Step4: Exercise 4
Step5: Exercise 5
Step6: Exercise 6
|
11,206 | <ASSISTANT_TASK:>
Python Code:
import math
import pickle
from IPython.display import Image
import matplotlib.pyplot as plt
import numpy as np
import openmc
import openmc.mgxs
import openmoc
import openmoc.process
from openmoc.opencg_compatible import get_openmoc_geometry
from openmoc.materialize import load_openmc_mgxs... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First we need to define materials that will be used in the problem. Before defining a material, we must create nuclides that are used in the mat... |
11,207 | <ASSISTANT_TASK:>
Python Code:
# Setup
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# for auto-reloading external modules
# see http://sta... | <SYSTEM_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 sigmoid function "squashes" inputs to lie between 0 and 1. Unfortunately, this means that for inputs with sigmoid output close to 0 or 1, th... |
11,208 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import matplotlib as mpl
from pymc3 import Model, Normal, Slice
from pymc3 import sample
from pymc3 import traceplot
from pymc3.distributions import Interpolated
from theano import as_op
import theano.tensor as tt
import numpy as np
from scipy import stats
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generating data
Step2: Model specification
Step3: In order to update our beliefs about the parameters, we use the posterior distributions, whi... |
11,209 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
import numpy
perm = numpy.random.permutation(numpy.arange(20))
perm
def topk_sortall(ensemble, k):
# à vous
# ...
pass
topk_sortall(perm, 4)
def topk_idee1ou2(ensemble, k):
pass
from tim... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Enoncé
Step2: Exercice 1
Step3: Exercice 2
Step4: Vous avez aussi le droit de tricher pour une troisième idée Heap / Tas mais il faudra vou... |
11,210 | <ASSISTANT_TASK:>
Python Code:
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
sns.set(style="ticks", context='talk', font_scale=1.1)
%matplotlib inline
df = pd.read_csv('top10mountain-lions.csv')
sns.set_style("whitegrid")
sns.barplot(x="count", y="COUNTY", data=df, color="#2ecc71")
sns.des... | <SYSTEM_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 csv file into a panda
Step2: Chart 1 features a whitegrid style to help assign a number to each bar. Despine removes Tufte's chart jun... |
11,211 | <ASSISTANT_TASK:>
Python Code:
!pip install cufflinks
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
plt.style.use('ggplot')
import seaborn as sns # for making plots with seaborn
color = sns.color_palette()
sns.set(rc={'figure.figsize':(25,15)})
import plotly
plotly.offline.init_notebook_mo... | <SYSTEM_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 the dataset for the assignment
Step2: So, according to the description of the dataset as well as the descriptions of the columns we do ... |
11,212 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize = [15, 5])
plt.title('My plot')
plt.xlabel('X values')
plt.ylabel('Count of values')
plt.xlim([0, 10])
plt.ylim([0, 5])
data_dict = {
'x': [0, 1, 1, 2, 1, 0, 0, 1, 2, 1, 1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Chart Attributes
Step2: Axes - Set Range
Step3: Percentage of Each Label in Column of DataFrame
Step4: Count of (Continuous) Values in Column... |
11,213 | <ASSISTANT_TASK:>
Python Code:
import os
from google.cloud import bigquery
import pandas as pd
%load_ext google.cloud.bigquery
PROJECT = "cloud-training-demos" # Replace with your PROJECT
BUCKET = PROJECT
REGION = "us-central1"
os.environ['PROJECT'] = PROJECT
os.environ['BUCKET'] = BUCKET
os.environ['REGION'] = RE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Replace the variable values in the cell below
Step2: Create a Dataset from BigQuery
Step3: Let's do some regular expression parsing in BigQuer... |
11,214 | <ASSISTANT_TASK:>
Python Code:
import xlsxwriter
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello world')
workbook.close()
expenses = (
['Rent', 1000],
['Gas', 100],
['Food', 300],
['Gym', 50],
)
workbook = xlsxwriter.Workbook('Expense... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: tutorial 1
Step2: <img src="https
Step3: Tutorial 2
Step4: Tutorial 3
Step5: write() method
Step6: <img src="https
Step7: <img src="https... |
11,215 | <ASSISTANT_TASK:>
Python Code:
# Enter the specs of the detector
nep = 2.34e-12 # in Watts per root hz
BW = 10e6 # Bandwidth in Hz
gain = 0.75e4 # gain in V/A
responsivity = 0.5 # Amps per Watt (assume 800 nm)
pmin = nep * np.sqrt(BW)
volts_min = pmin * responsivity * gain
print("voltage generated by p_min:",volts_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note that we need at least 10mV to even resolve a signal on the scope. So the NEP is only part of the story
Step2: This setting (20dB) leaves p... |
11,216 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('..')
import collections
import mido
from commons import dgxdump
from commons.dumpdata import messages, songdata, regdata, regvalues
old_syx_messages = mido.read_syx_file('../data/syxout5.syx')
clear_syx_messages = mido.read_syx_file('../data/clear_bulk.txt')
o_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The mystery section remains the same.
Step2: All the blocks are empty.
Step3: The 'PresetStyle' settings are empty, too.
Step4: Each of the r... |
11,217 | <ASSISTANT_TASK:>
Python Code:
BATCH_SIZE = 16
PROJECT_DIR = os.path.expanduser("~/nta/nupic.research/projects/gsc")
EXPERIMENT_NAME = "default_sparse_cnn"
CHECKPOINT_FILE = "/home/ec2-user/nta/results/experiments/gsc/default_sparse_cnn/RemoteProcessTrainable_0_2021-01-07_15-54-473wnu2slv/checkpoint_30/checkpoint"
USE_... | <SYSTEM_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 the model from a checkpoint.
Step6: Helper class and method.
Step7: Add forward hooks to all layers of the model
Step8: A Brief Overview ... |
11,218 | <ASSISTANT_TASK:>
Python Code:
heart = sm.datasets.heart.load_pandas().data
heart.head(n=6)
heart.sort_values('age', ascending=False, inplace=True)
heart.head()
sum(heart.censors == 0)
heart.loc[(heart.censors == 1) & (heart.age < 45), 'age'].mean()
heart.groupby(['censors']).agg(['mean', 'std'])
import seaborn as sns
... | <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: Q2 (10 points)
Step6: Q3 (10 points)
Step7: Q4 (10 points)
Step8: Q5 (10 points)
|
11,219 | <ASSISTANT_TASK:>
Python Code:
# from __future__ import unicode_literals, division
import time, datetime, requests, itchat
from itchat.content import *
import tagui as t
from time import localtime, strftime
# import pandas as pd
# Function
# input : Parcel ID, type: string
# Return: File name of screenshot png image 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: Function
Step2:
Step3: * Log in web WeChat using QR code image / 用微信App扫QR码图片来自动登录
Step4:
Step5: * Interactive Conversation
Step6: Try ... |
11,220 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification
# Generate features matrix and target vector
X, y = make_classification(n_samples = 10000,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate Features And Target Data
Step2: Create Logistic Regression
Step3: Cross-Validate Model Using Recall
|
11,221 | <ASSISTANT_TASK:>
Python Code:
def \
quicksort():
pass
class Meta(type):
pass
class MyClass(metaclass = Meta):
pass
class MySubclass(MyClass):
pass
<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: Everything is represented by objects in python or relation among objects. Every object has a value, type, identity. Identity can be thought of a... |
11,222 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import networkx as nx
import numpy as np
import scipy as sp
import itertools
import matplotlib.pyplot as plt
import statsmodels.api as sm
%matplotlib inline
G = nx.Graph()
G.add_nodes_from(['A','B','C','D','E','F','G'])
G.add_edges_from([('A','B'),('A','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: Toy Network
Step2: Centrality
Step3: Eigenvector Centrality
Step4: Betweenness Centrality
Step5: Centrality Measures Are Different
Step6: T... |
11,223 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inm', 'inm-cm5-0', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_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,224 | <ASSISTANT_TASK:>
Python Code:
def minimum_sum(n , k ) :
if(k % n == 0 ) :
return 0 ;
return 1
n = 3
k = 56
print(minimum_sum(n , k ) )
<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,225 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
import matplotlib.image as mpimg
from IPython.display import Image
from astropy.io import fits
import aplpy
#Disable astropy/aplpy loggin... | <SYSTEM_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 section specific modules
Step2: 6.1 Sky Models<a id='deconv
Step3: Left
Step4: Left
Step6: Left
|
11,226 | <ASSISTANT_TASK:>
Python Code:
def nonPremCost(maxY, unitCostPrev, rPrev, prevDeduct, costBase, rBase, baseDeduct):
paidPrev = 0
paidBase = 0
# first, calculate the preventive services, suppose that 2 units per year
totalCostPrev = unitCostPrev * 2
coveredPrev = min(maxY, max(0, totalCostPrev -... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here, we consider different dental insurance options which are available online for individual and group member plans.
|
11,227 | <ASSISTANT_TASK:>
Python Code:
import os
import time
import sys
import requests
POP20_CC = ('CN IN US ID BR PK NG BD RU JP '
'MX PH VN ET EG DE IR TR CD FR').split()
BASE_URL = 'http://flupy.org/data/flags'
DEST_DIR = 'downloads/'
def save_flag(img, filename):
path = os.path.join(DEST_DIR, filename)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 注意上面代码细节,导入标准库 os time 和 sys 之后,使用一个空格分开了非标准库 requests
Step2: 这里为了方便引用了第一个代码块的一些函数,注意,上面的 download_one 函数其实是第一个例子的 for 循环结构体,编写并发代码经常这样重构,把依次执行... |
11,228 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# This is how we'll access astropy's units module:
import astropy.units as u
# astropy stores fundamental physical constants like
# the mass of the sun M_sun
from astropy.constants import M_sun
masses = u.Quantity([4.31e6*M_sun, 1*M_sun, 1.4*M_sun])
masses
# Newton'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: b) Retrieve constants from astropy's constants module
Step2: c) Compute $r_s$, convert to cm
Step3: d) $r_s$ in units of solar radii
Step4: e... |
11,229 | <ASSISTANT_TASK:>
Python Code:
%matplotlib auto
import matplotlib.pyplot as plt
from ipywidgets import interact
from bmi_live.bmi_diffusion import BmiDiffusion
def run_model(n_steps=10):
model = BmiDiffusion()
model.initialize('../data/diffusion.yaml')
grid_shape = model.get_grid_shape(0)
initial_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Define a function that runs the Diffusion model through its BMI for a fixed number of time steps. Store the temperture field from each time step... |
11,230 | <ASSISTANT_TASK:>
Python Code:
from rl import *
%psource PassiveTDAgent
from mdp import sequential_decision_environment
# Action Directions
north = (0, 1)
south = (0,-1)
west = (-1, 0)
east = (1, 0)
policy = {
(0, 2): east, (1, 2): east, (2, 2): east, (3, 2): None,
(0, 1): north, (2, 1): 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: CONTENTS
Step2: The Agent Program can be obtained by creating the instance of the class by passing the appropriate parameters. Because of the ... |
11,231 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
data = pd.DataFrame(data={'fruit': ["banana", "apple", "banana", "apple", "banana","apple", "banana",
"apple", "apple", "apple", "banana", "banana", "apple", "banana",],
'tasty': ["yes", "no", "yes", "yes"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We know that the variables relate as follows
Step2: Parameter learning is the task to estimate the values of the conditional probability distri... |
11,232 | <ASSISTANT_TASK:>
Python Code:
# Use this cell to test the output
!curl http://localhost:5000/datetime/v1/echo -vk
# Here's the `limit` parameter definition, including
# - it's a `query` parameter
# - its name
# - its schema
print(show_component('https://teamdigitale.github.io/openapi/0.0.5/definitions.yaml#/parameter... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Request parameters
Step2: Exercise
Step3: Implement get_echo
Step4: Now run the spec in a terminal using
|
11,233 | <ASSISTANT_TASK:>
Python Code:
reference_sf = graphlab.SFrame('data/sf_processed.sframe/')
pretrained_model = graphlab.load_model('data/imagenet_model')
nn_model = graphlab.load_model('data/nearest_dress_model')
reference_sf
def dress_similar(url):
img = graphlab.Image(url)
image_sf = graphlab.SFrame()
imag... | <SYSTEM_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. Create a Predictive Service (One time) <a id='create'></a>
Step2: Load an already created service
Step3: Query the model <a id='query'></a>... |
11,234 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def basisNone(x, dmy1=None, dmy2=None, dmy3=None):
return x
def basisPoly(x, j, dmy1=None, dmy2=None):
return x ** j
def basisGauss(x, j, mu, s):
return np.exp(- (x-mu[j]) ** 2 / (2 * s ** 2))
def basisSigm... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 基底関数
Step2: 例題
Step3: ${\bf w}$ のベイズ推定
|
11,235 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
train_data,test_data = sales.random_split(.8,seed=0)
# Let's compute the mean of the House Prices in King County in 2 different ways.
prices = sales['price'] # extract the price column of the sales SFrame -- this is now an SA... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load house sales data
Step2: Split data into training and testing
Step3: Useful SFrame summary functions
Step4: As we see we get the same ans... |
11,236 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
%pip install google-cloud-bigquery==1.25.0
# Importing necessary tensorflow library and printing the TF version.
import tensorflow as tf
print("Tensorflow version: ",tf.__version__)
import os
from google.cloud import bigq... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Please ignore any incompatibility warnings and errors.
Step2: Change the following cell as necessary
Step3: Create BigQuery tables
Step4: Let... |
11,237 | <ASSISTANT_TASK:>
Python Code:
# Create a SQLite database
# log in to your terminal, change to the folder where you want to keep the database file.
# type the following code and change xxxx to a name you want to give the database. Mine is called datarepo:
sqlite3 xxxx.db
.databases
# press control D to exit th... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Organize and manage datasets
Step2: Write the datasets into the SQLite file
Step3: List and view all the datasets in the database file
Step4: ... |
11,238 | <ASSISTANT_TASK:>
Python Code:
## Functions
import sys
sys.path.append("../dev")
import bib_mri as FW
import numpy as np
import scipy as scipy
import scipy.misc as misc
import matplotlib as mpl
import matplotlib.pyplot as plt
from numpy import genfromtxt
import platform
%matplotlib inline
def sign_extract(seg, resols)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introduction
Step2: Shape signature for comparison
Step3: In order to get a representative correct signature, mean signature per-resolution wa... |
11,239 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
DF = pd.read_csv('../data/alternative.tsv', sep='\t')
DF
DF['Berri1'].plot() # plot easier
<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: Qué Entidades (tablas) puede definir?
|
11,240 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate
def trapz(f, a, b, N):
h = (b - a)/N
i = np.arange(1,N)
c = h*(0.5*f(a)+f(b)*0.5+f(a+i*h).sum())
return c
f = lambda x: x**2
g = lambda x: np.sin(x)
I = trapz(f, 0, 1, 1000)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Trapezoidal rule
Step2: Now use scipy.integrate.quad to integrate the f and g functions and see how the result compares with your trapz functio... |
11,241 | <ASSISTANT_TASK:>
Python Code:
from menpowidgets.tools import (LogoWidget, ListWidget, SlicingCommandWidget, ColourSelectionWidget,
IndexButtonsWidget, IndexSliderWidget, ZoomOneScaleWidget, ZoomTwoScalesWidget,
ImageOptionsWidget, LineOptionsWidget, Mar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let us also define a generic print function that will be the callback trigger when the selected_values trait of all the widgets changes.
Step2: ... |
11,242 | <ASSISTANT_TASK:>
Python Code:
# important stuff:
import os
import pandas as pd
import numpy as np
import statsmodels.tools.numdiff as smnd
import scipy
# Graphics
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import rc
rc('text', usetex=True)
rc('text.latex', preamble=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: Generating synthetic data
Step2: Line fitting using Bayes' theorem
Step3: Specificity is necessary for credibility. Let's show that by optimiz... |
11,243 | <ASSISTANT_TASK:>
Python Code:
!pip install google-cloud-bigquery
!pip install google-cloud-bigquery-storage
!pip install pandas-gbq
# Reservation package needed to setup flex slots for flat-rate pricing
!pip install google-cloud-bigquery-reservation
# Automatically restart kernel after installs
import IPython
app = IP... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set up your Google Cloud Platform project
Step2: Import libraries and define constants
Step3: Data exploration and preparation
Step4: Build a... |
11,244 | <ASSISTANT_TASK:>
Python Code:
from xml.etree import ElementTree
with open('podcasts.opml', 'rt') as f:
tree = ElementTree.parse(f)
print(tree)
from xml.etree import ElementTree
import pprint
with open('podcasts.opml', 'rt') as f:
tree = ElementTree.parse(f)
for node in tree.iter():
print(node.ta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Traversing the parsed tree
Step2: To print only the groups of names and feed URL for the podcasts, leaving out all of the data in the header se... |
11,245 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import IFrame
IFrame(
'https://www.sunfrog.com/Geek-Tech/First-solve-the-problem-Then-write-the-code.html',
width=800,
height=350,
)
from IPython.display import IFrame
IFrame(
'https://docs.mongodb.com/manual/reference/geojson/',
width=800,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introduction
Step2: Tasks
Step3: Verify that the database is running and responding to the pymongo driver.
|
11,246 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import seaborn as sns
import os
import sys
sys.path.append(os.path.join(os.getcwd(), "src"))
import util.io as mio
import util.plotting as mplot
from model.conversationDataframe import ConversationDataframe
from stats.wordsCountStats import WordsCoun... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Word Count by Sender
Step2: Top N Words
Step3: Top Words by Sender
Step4: Top Unbalanced Words
Step5: Words Used Just By
Step6: Word Count ... |
11,247 | <ASSISTANT_TASK:>
Python Code:
import bitstring
from_hex = bitstring.BitArray('0x0001b3')
from_bin = bitstring.BitArray('0b001100')
from_oct = bitstring.BitArray('0o34100')
from_int = bitstring.BitArray(uint=45, length=8)
from_int_bigendian = bitstring.BitArray(intbe=-32768, length=16)
from_float = bitstring.BitArray(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basics
Step2: Converting to a different format
Step3: Lengths, slicing and joining
Step4: Non-byte aligned binary data
Step5: Packing and un... |
11,248 | <ASSISTANT_TASK:>
Python Code:
# Perform standard imports
import spacy
nlp = spacy.load('en_core_web_sm')
# Import the displaCy library
from spacy import displacy
doc = nlp(u'Over the last quarter Apple sold nearly 20 thousand iPods for a profit of $6 million. '
u'By contrast, Sony sold only 7 thousand Walkman... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Viewing Sentences Line by Line
Step2: <div class="alert alert-info"><font color=black>**NOTE**
Step3: <div class="alert alert-info"><font colo... |
11,249 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import scanpy.api as sc
sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.settings.set_figure_params(dpi=70) # dots (pixels) per inch determine size of inline figures
sc.logging.print_versions()
adata = sc.read... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Run standard preprocessing steps, see here.
Step2: Now compare this with the reference clustering of PAGA preprint, Suppl. Fig. 12, available f... |
11,250 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
deg = np.arange(0.0, 90.01, 0.01)
def deg2dist(deg): return 10.29 * np.cos(np.pi / 180 * deg)
dist = deg2dist(deg)
# Note that using plt.subplots below is equivalent to using
# fig = plt.figure and then ax = fig.add_su... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: So how should we query points?
Step2: Solving for theta and finding the equivelent slope of the angle...
Step3: It's actually pretty bad lol
... |
11,251 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import tensorflow as tf
import tflearn
from tflearn.data_utils import to_categorical
reviews = pd.read_csv('reviews.txt', header=None)
labels = pd.read_csv('labels.txt', header=None)
from collections import Counter
total_counts = Counter()
for _, 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: Preparing the data
Step2: Counting word frequency
Step3: Let's keep the first 10000 most frequent words. As Andrew noted, most of the words in... |
11,252 | <ASSISTANT_TASK:>
Python Code:
pairs = [(4, 4), (3, 4), (7, 16), (6, 8)]
time_signatures = [abjad.TimeSignature(_) for _ in pairs]
durations = [_.duration for _ in time_signatures]
time_signature_total = sum(durations)
counts = [1, 2, -3, 4]
denominator = 16
talea = rmakers.Talea(counts, denominator)
talea_index = 0
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: We can ask our talea for as many durations as we want. (Taleas output nonreduced fractions instead of durations. This is to allow talea output t... |
11,253 | <ASSISTANT_TASK:>
Python Code:
a = 99
if a % 9 == 0:
if a % 11 == 0:
print '!!!'
elif a % 10 ==0:
print '???'
else:
print 'hahaha'
x = 7
if (5 > x) and (x < 10):
print 'oh!'
a = []
if a:
print 'right'
else:
print "empty"
5 == 6
5 != 6
a = 0
if not a == 0:
print 'haha'
count = 1
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: for
Step2: if & for 연습문제
Step3: comprehension
Step4: practice
|
11,254 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
# RMS Titanic data visualization code
from titanic_visualizations import survival_stats
from IPython.display import display
%matplotlib inline
# Load the dataset
in_file = 'titanic_data.csv'
full_data = pd.read_csv(in_file)
# Print the first few ent... | <SYSTEM_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 a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship
Step3: The very same sample of th... |
11,255 | <ASSISTANT_TASK:>
Python Code:
import wget
import pandas as pd
import numpy as np
from sklearn.cross_validation import train_test_split
# Import the dataset
data_url = 'https://raw.githubusercontent.com/nslatysheva/data_science_blogging/master/datasets/spam/spam_dataset.csv'
dataset = wget.download(data_url)
dataset = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introducing randomized search
Step2: We then run the random search
Step3: Either grid search or randomized search is probably fine for tuning ... |
11,256 | <ASSISTANT_TASK:>
Python Code:
import sys
import pandas as pd
import matplotlib.pyplot as plt
import datetime as dt
import seaborn as sns
import numpy as np
%matplotlib inline
print('Python version:', sys.version)
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: 1 | Background
Step2: 3.1 | Slicing the Organizational Data
Step3: 3.2 | Joining the Organizational Data
Step4: 4 | Network Summary Data
Step... |
11,257 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
node1 = tf.constant(3.0, dtype=tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)
sess = tf.Session()
print(sess.run([node1, node2]))
node3 = tf.add(node1, node2)
print(node3)
print(sess.run(node3))
a = tf.placeholder(tf.float... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Computational Graph
Step2: Session
Step3: More complicated computations can be performed by combining Tensor nodes with Operation nodes. Use t... |
11,258 | <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: 深度卷积生成对抗网络
Step2: 加载和准备数据集
Step3: 创建模型
Step4: 使用(尚未训练的)生成器创建一张图片。
Step5: 判别器
Step6: 使用(尚未训练的)判别器对所生成的图像进行真伪分类。模型将被训练为对真实图像输出正值,对伪造图像输出负值。
S... |
11,259 | <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: TF Lattice 预制模型
Step2: 导入所需的软件包:
Step3: 下载 UCI Statlog (Heart) 数据集:
Step4: 提取特征和标签并将它们转换为张量:
Step5: 设置用于在本指南中进行训练的默认值:
Step6: 特征配置
Step7: ... |
11,260 | <ASSISTANT_TASK:>
Python Code:
set([1,2,3,4])
# Translate here. Add as many new cells as you like.
sum(range(5))
# One liner here :)
sum(map(lambda x: x * x, range(5)))
# Config environment for code examples.
%matplotlib inline
import networkx as nx
import matplotlib as plt
plt.rcParams['figure.figsize'] = 17, 12
g... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Some common symbols we will see in this class
Step2: Everyone knows how to do a summation in Python right?
Step3: What if we need to apply an ... |
11,261 | <ASSISTANT_TASK:>
Python Code:
# Author: Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import mne
import matplotlib.pyplot as plt
import numpy as np
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'... | <SYSTEM_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 DataFrame
Step2: Explore Pandas MultiIndex
|
11,262 | <ASSISTANT_TASK:>
Python Code:
print(type(12))
print(type('python'))
class A:
pass
print(type(A))
print(type.__doc__)
class A:
pass
# 实际上等于
B = type('A', (), {})
print(A.__name__ == B.__name__)
class Enum:
def __new__(cls, value):
print(cls, value)
return value
def __init__(self):
... | <SYSTEM_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 是由type() 产生的,也就是说 type 也可以用来产生新的对象,而且产生的是类对象,因此它是所有类对象的类:
Step2: class 定义类的语法实际上转化为 type(name, bases, dict),其中 name 参数为类的名字,ba... |
11,263 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-1', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
11,264 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
from phoebe import u # units
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('lc')
print(b.get_dataset(kind='lc', check_visible=False))
print(b.get_parameter(qualifier='times'))
print(b.get_parameter(qualifier='fluxe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new Bundle.
Step2: Dataset Parameters
Step3: times
Step4: fluxes
Step5: sigmas
Ste... |
11,265 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
rc('figure', figsize=(13,6))
def plot_lc(time, flux, c=None, ylim=(0.9865, 1.0025), ax=None, alpha=1):
if ax is None:
fig, ax = subplots()
else:
fig, ax = None, ax
ax.plot(time, flux, c=c, alpha=alpha)
ax.autoscale(axis='x', tight=True)
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: Import the model
Step2: Example 1
Step3: and given to the RoadRunnnerModel as any other limb darkening model.
Step4: after which the transit ... |
11,266 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# To check the data in the Terminal/Konsole
% ls data/bike_data/
data_path = 'data/bike_data/hour.csv'
rides = pd.read_csv(data_path)
# # The new histo... | <SYSTEM_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, explore, and prepare the dataset
Step2: Downloading/ checking out the bike sharing dataset
Step3: Dummy variables
Step4: Batch normaliz... |
11,267 | <ASSISTANT_TASK:>
Python Code:
labVersion = 'cs190_week5_v_1_2'
import matplotlib.pyplot as plt
import numpy as np
def preparePlot(xticks, yticks, figsize=(10.5, 6), hideLabels=False, gridColor='#999999',
gridWidth=1.0):
Template for generating the plot layout.
plt.close()
fig, ax = plt.sub... | <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: Part 1
Step4: (1a) Interpreting PCA
Step5: (1b) Sample covariance matrix
Step7: (1c) Covariance Function
Step8: (1d) Eigendecomposition
Step... |
11,268 | <ASSISTANT_TASK:>
Python Code:
import surprise
data = surprise.Dataset.load_builtin('ml-100k')
df = pd.DataFrame(data.raw_ratings, columns=["user", "item", "rate", "id"])
del df["id"]
df.head(10)
df_table = df.set_index(["user", "item"]).unstack()
df_table.fillna("").ix[212:222, 808:817]
plt.imshow(df_table)
plt.g... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 평점 데이터
Step2: 이 데이터는 다음과 같이 데이터프레임으로 변환할 수 있다.
Step3: 여기에서 user 열은 사용자 아이디, item 열은 상품 아이디, rate 열은 평점이다. 즉, 196번 사용자는 242번 영화에 대해 평점 3점을 주었음을... |
11,269 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import sys
from IPython.display import display, clear_output
sys.path.insert(0, 'helpers')
from efunctions import * # load my helper function(s) to save pdf figures, etc.
from hc3 import load_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: Load data
Step2: Find most appropriate number of states using cross validation
Step3: Remarks
Step4: Remarks
Step5: Remarks
Step6: Remarks
... |
11,270 | <ASSISTANT_TASK:>
Python Code:
# import libraries
# linear algebra
import numpy as np
# data processing
import pandas as pd
# data visualization
from matplotlib import pyplot as plt
# load the data with pandas
dataset = pd.read_csv('dataset.csv', header=None)
dataset = np.array(dataset)
plt.scatter(dataset[:,0], dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: 1. Implementar o algoritmo K-means
Step3: Teste a função criada e visualize os centróides que foram calculados.
Step5: 1.2 Definir os Clusters... |
11,271 | <ASSISTANT_TASK:>
Python Code:
version = '2020-08-25'
import logging
import os
import posixpath
import urllib.parse
import urllib.request
import re
import zipfile
import pickle
import urllib
import shutil
import datetime
import numpy as np
import pandas as pd
import utm # for transforming geoinformation in the utm fo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Script setup
Step2: Settings
Step3: Update the download links
Step4: Note that, as of August 25, 2020, the following sources are available on... |
11,272 | <ASSISTANT_TASK:>
Python Code:
# @title Install
!pip install --upgrade --no-cache-dir recsim
#@title Generic imports
import numpy as np
from gym import spaces
import matplotlib.pyplot as plt
from scipy import stats
#@title RecSim imports
from recsim import document
from recsim import user
from recsim.choice_model impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The main imports we use from RecSim are user and document -- they provide the abstract classes needed to instantiate all components of the envir... |
11,273 | <ASSISTANT_TASK:>
Python Code:
#a = 2
#b = 1
a, b, c = 2, 3, "Hello World!"
#print a # works in python2 but not python3
print( a )
print ("Hello World!")
print (3*3)
print (3**2)
print (2+2)
myint = 7
myfloat1 = 7.0; myfloat2 = float(7)
print (myint/2); print (myfloat1/2); print (myfloat2*2); print (myfloat2**2)
mys... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You can find more examples at LearnPython & PythonTutorial.
Step2: You may separate commands using ";"
Step3: print myfloat1
Step4: This is a... |
11,274 | <ASSISTANT_TASK:>
Python Code:
# Authors: Chris Holdgraf <choldgraf@gmail.com>
# Eric Larson <larson.eric.d@gmail.com>
# Nicolas Barascud <nicolas.barascud@ens.fr>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import loadmat
from os.path import join
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: Load the data from the publication
Step2: Create and fit a receptive field model
Step3: Investigate model coefficients
Step4: Create and fit ... |
11,275 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display, HTML
from nxpd import draw
import networkx as nx
def draw_graph(
graph, labels=None
):
# create networkx graph
G = nx.DiGraph()
G.graph['dpi'] = 120
G.add_nodes_from(set([
graph[k1][k2]
for k1 in range(len(graph))
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Flip coin
Step2: "Rain-Sprinkler-Grass" bayesian network
Step3: Happiness Test
Step4: $P(of='H', given=['S', 'R'], value=1)$
Step5: Alarm te... |
11,276 | <ASSISTANT_TASK:>
Python Code:
layers = [0.23, 0.34, 0.45, 0.25, 0.23, 0.35]
uppers = layers[:-1]
lowers = layers[1:]
rcs = []
for pair in zip(lowers, uppers):
rc = (pair[1] - pair[0]) / (pair[1] + pair[0])
rcs.append(rc)
rcs
# Exercise
def compute_rc(layers):
Computes reflection coefficients given
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Functions
Step3: Put in a file and import into a new notebook
Step4: Note that the log has to be fairly big for the benchmarking to work prope... |
11,277 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings('ignore')
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from scipy import stats
import seaborn as sns
sns.set(rc={"axes.labelsize": 15});
# Some nice default configuration for plots
plt.rcParams['figure.fi... | <SYSTEM_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. Import dataset
Step2: Our first collection of feature vectors will come from the Restaurant_Name column. We are still trying to predict whet... |
11,278 | <ASSISTANT_TASK:>
Python Code:
from datetime import date
from openfisca_france import init_country
from openfisca_france.model.base import *
import functools
from openfisca_core.formulas import make_reference_formula_decorator
from openfisca_france.entities import entity_class_by_symbol
reference_formula = make_refere... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Adaptation pour faciliter l'usage de ce notebook
Step2: Variable avec formule
Step3: Simulation
Step4: Réforme
|
11,279 | <ASSISTANT_TASK:>
Python Code:
import re
lines = ['4008','4008a','4009','1','9']
sorted(lines)
sorted(lines,key=int) # this raises an error
linenoRegex = re.compile('(\d+)(.*)')
def splitId(id):
Splits @id value like 4008a into parts, for sorting
results = linenoRegex.match(id).groups()
return (int(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: We initialize a lines list of strings and demonstrate how the default alphabetic sort gives the wrong results
Step2: In Python 3, the key param... |
11,280 | <ASSISTANT_TASK:>
Python Code:
# defining lists
sport_list = [ 'cycling', 'football', 'fitness' ]
first_prime_numbers = [ 2, 3, 5, 7, 11, 13, 17, 19 ]
# getting contents
sport = sport_list[ 2 ]
third_prime = first_prime_numbers[ 2 ]
# printing
print( 'All sports:', sport_list )
print( 'Sport to be done:', sport )
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: Tuples
Step2: Dictionaries
Step3: Sets
Step4: Flow Control
Step5: While Loops
Step6: Functions
|
11,281 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import structcol as sc
import structcol.refractive_index as ri
from structcol import montecarlo as mc
from structcol import detector as det
from structcol import phase_func_sphere as pfs
import matplotlib.pyplot as plt
import seaborn as sns
import os
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Start by running Monte Carlo code for a single sphere
Step2: Run Monte Carlo for sphere geometry
Step3: Plot results
Step4: The first plot sh... |
11,282 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
client_info = pd.read_csv('data/client_info.csv')
demographic_info = pd.read_csv('data/demographic_data.csv')
transaction_info = pd.read_csv('data/transction_info.csv')
order_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: Load data.
Step2: Creata a unique bank account (bank + account)
Step3: Build the graph.
Step4: Add non-empty edges.
Step5: Look at the large... |
11,283 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
%matplotlib inline
# Load data returns dari sektor2
ind = pd.read_csv("ind30_m_vw_rets.csv", header=0, index_col=0)/100
# Ubah index jadi perioda bulanan
ind.index = pd.to_datetime(ind.index, format="%Y%m").to_period('M')
# Hilangkan spasi pada kolom... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Kita buat covariance matrix-nya.
Step2: Agar lebih sederhana, kita pilih 4 industri saja dalam portfolio kita.
Step3: Expected returns dan cov... |
11,284 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import mne
from mne.preprocessing import ICA, create_ecg_epochs
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read and preprocess the data. Preprocessing consists of
Step2: Fit ICA model using the FastICA algorithm, detect and plot components
Step3: Pl... |
11,285 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import cv2
import numpy as np
%matplotlib inline
# Read in the image
image = mpimg.imread(fname='images/curved_lane.jpg')
plt.imshow(X=image)
# Convert to grayscale for filtering
gray = cv2.cvtColor(src=image,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convert the image to grayscale
Step2: TODO
Step3: Test out other filters!
|
11,286 | <ASSISTANT_TASK:>
Python Code:
# IMPORT STATEMENTS.
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import seaborn as sns # data visualisation
import matplotlib.pyplot as plt # data visualisation
import random # Used to sample survival.
# DEFINE GLOBALS.
NUM_OF... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As you should be able to see, there are a few different parameters we can consider in our models
Step2: From this visualisation you can see tha... |
11,287 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import scipy as sp
xgrid = np.linspace(-3,3,50)
f1 = np.exp(-xgrid**2)
f2 = np.tanh(xgrid)
plt.figure(figsize=(8,6))
plt.plot(xgrid, f1, 'bo-')
plt.plot(xgrid, f2, 'ro-')
plt.title('Just a demo plot')
plt.grid()
plt.sh... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Table of Contents
Step2: IPython also comes with a sophisticated display system that lets us insert rich web elements in the notebook. Here you... |
11,288 | <ASSISTANT_TASK:>
Python Code:
MODEL_NAME = 'auto-encoder-01'
TRAIN_DATA_FILES_PATTERN = 'data/data-*.csv'
RESUME_TRAINING = False
MULTI_THREADING = True
FEATURE_COUNT = 64
HEADER = ['key']
HEADER_DEFAULTS = [[0]]
UNUSED_FEATURE_NAMES = ['key']
CLASS_FEATURE_NAME = 'CLASS'
FEATURE_NAMES = []
for i in range(FEATURE_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: 1. Define Dataset Metadata
Step2: 2. Define CSV Data Input Function
Step3: 3. Define Feature Columns
Step4: b. Create normalized feature colu... |
11,289 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'png'
import matplotlib
matplotlib.rcParams['figure.figsize'] = (8, 8)
import astropy.io.fits as fits
import numpy
spot50=fits.open('fits_data/electron_flux_fits/spot50.fits')
matplotlib.pyplot.imshow(numpy.log10(spot50[0].data),cl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bringing in a FITS File
Step2: Here, we've got a 50 x 200 image. HTTM will assume this is four slices of 50 x 50 by default. We have 1000000 el... |
11,290 | <ASSISTANT_TASK:>
Python Code:
import os
os.chdir("/home/archimedeas/wrkspc/anaconda/major_1/datasets/1_the_senate_datasets")
import pandas as pd
import numpy as np
from bokeh._legacy_charts import output_notebook, show
import bokeh
df = pd.read_csv("1_age_group_5yr_span.csv", index_col = 0)
df
df.shape
%matplotlib in... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Style sheet for Matplotlib
Step2: Sample Bar Plot
Step3: Sample Pie Plot
Step4: Average age of Men and Women
Step5: Now we have read the dat... |
11,291 | <ASSISTANT_TASK:>
Python Code:
import qspectra as qs
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
electronic_fmo = np.array(np.mat(
12400 -87.7 5.5 -5.9 6.7 -13.7 -9.9;
-87.7 12520 30.8 8.2 0.7 11.8 4.3;
5.5 30.8 12200 -53.5 -2.2 -9.6 6.;
-5.9 8.2 -53.5 12310 -70.7 -17. -63.3;
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: FMO dynamics simulated with ZOFE master equation
Step2: Excited state dynamics
Step3: Gaussian pump pulse
Step4: Absorption spectra
|
11,292 | <ASSISTANT_TASK:>
Python Code:
form_uid = 'HQnDRM'
#form_uid = 'iSEGWq'
typeform_api_key = '_API_KEY_'
url = 'https://api.typeform.com/v1/form/' + form_uid + '?key=' + typeform_api_key
import requests
response = requests.get(url)
results = response.json()
results
questions = results.get('questions')
questions
responses... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: เปลี่ยน rating ให้กลายเป็น integer เนื่องจากตอนที่ดึงข้อมูลจาก API ข้อมูลส่วนของ rating จะมาเป็น string
Step2: แสดงคำตอบของแต่ละคนเพื่อเช็คว่าค... |
11,293 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import platform
import numpy as np
import matplotlib.pyplot as plt
import flopy.modflow as mf
import flopy.utils as fu
import flopy.plot as fp
modelname = 'swiex1'
#Set name of MODFLOW exe
# assumes executable is in users path statement
exe_name = 'mf2005'
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: Define model name of your model and the location of MODFLOW executable. All MODFLOW files and output will be stored in the subdirectory defined ... |
11,294 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.interpolate import interp1d
trajectory = np.load('trajectory.npz')
x = trajectory['x']
y = trajectory['y']
t = trajectory['t']
assert isinstance(x, np.ndarray) and len(x)==40
assert isi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2D trajectory interpolation
Step2: Use these arrays to create interpolated functions $x(t)$ and $y(t)$. Then use those functions to create the ... |
11,295 | <ASSISTANT_TASK:>
Python Code:
from pattern.en import parsetree
s = parsetree('The cat sat on the mat.')
for sentence in s:
for chunk in sentence.chunks:
print chunk.type, [(w.string, w.type) for w in chunk.words]
import cPickle as pickle
author1 = pickle.load( open( "author1.p", "rb" ) )
author1[0]
for ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's see an example
Step2: Loading the data
Step3: Parsing the data
Step4: Let's see what the numeric attributes for headlines written by th... |
11,296 | <ASSISTANT_TASK:>
Python Code::
import pandas as pd
import boto3
from io import StringIO
# Set your AWS credentials and region
aws_access_key_id = 'access_key_id'
aws_secret_access_key = 'secret_access_key'
aws_region = 'aws_region'
# Set the S3 bucket and file path
s3_bucket = 's3_bucket_name'
s3_file_path = 'data.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:
|
11,297 | <ASSISTANT_TASK:>
Python Code:
%%writefile hello.py
#!/usr/bin/env python
def printHello():
print "Hello World"
print "File Loaded"
cat mystuff.ipynb
2+4
%timeit range(1000)
%%timeit x = range(10000)
max(x)
%lsmagic
ls
%matplotlib inline
%%capture capt
from __future__ import print_function
import sys
pr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: ipython shell
Step2: Ok, backup, how do I interact with the notebook and what is it?
Step3: So, you exectued this by hitting the 'play' button... |
11,298 | <ASSISTANT_TASK:>
Python Code:
import json
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
g = nx.karate_club_graph()
plt.figure(figsize=(6,4));
nx.draw(g)
from networkx.readwrite import json_graph
data = json_graph.node_link_data(g)
with open('graph.json', 'w') as f:
j... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We load a famous social graph published in 1977, called Zachary's Karate club graph. This graph represents the friendships between members of a ... |
11,299 | <ASSISTANT_TASK:>
Python Code:
from IPython.parallel import Client
rc = Client()
print "Using cluster with %d engines." % len(rc.ids)
%%px --local
import os
import os.path
from PIL import Image
src_dir = "/kaggle/retina/sample" # source directory of images to resize
trg_dir = "/kaggle/retina/resized" # target directo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let us set up imports and parameters in one place for the cluster and the local engine
Step2: Load an image
Step3: Resize the image with defau... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.