Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
7,000 | <ASSISTANT_TASK:>
Python Code:
import six
import json
import numpy as np
import pandas as pd
import tensorflow as tf
import annoy
from verta import Client
from verta.utils import ModelAPI, TFSavedModel
REPRESENTATION_LENGTH = 25
MAX_INPUT_LENGTH = 50
HOST = 'app.verta.ai'
DATA_DIR = ''
DATA_FILE = DATA_DIR + 'imdb_mast... | <SYSTEM_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 Glove embeddings
Step2: Build Simple TF model
Step3: Build Index
Step4: Instantiate Client
Step5: Log Artifacts
Step6: Build a Nea... |
7,001 | <ASSISTANT_TASK:>
Python Code:
name = "YOUR NAME HERE"
print("Hello {0}!".format(name))
%matplotlib inline
from matplotlib import rcParams
rcParams["savefig.dpi"] = 100 # This makes all the plots a little bigger.
import numpy as np
import matplotlib.pyplot as plt
# Load the data from the CSV file.
x, y, yerr = np.lo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If this works, the output should greet you without throwing any errors. If so, that's pretty much all we need so let's get started with some MCM... |
7,002 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
iris = load_iris()
print(type(iris.data))
print(type(iris.target))
import pandas as pd
import numpy as np
%matplotlib inline
import pandas as pd
from sklearn import datasets
iris = datasets.load_iris()
pd.DataFrame({'feature name': iris.feature_nam... | <SYSTEM_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 Dive In!
Step2: Features (aka columns in data)
Step3: Targets (aka labels)
Step4: sklearn TIP
Step5: <b>Sneak a peek at data (a remind... |
7,003 | <ASSISTANT_TASK:>
Python Code:
import sys
from docplex.cp.model import *
mdl0 = CpoModel()
masonry = mdl0.interval_var(size=35)
carpentry = mdl0.interval_var(size=15)
plumbing = mdl0.interval_var(size=40)
ceiling = mdl0.interval_var(size=15)
roofing = mdl0.interval_var(size=5)
painting = mdl0.interval_var(size=10)
win... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This code creates a CP model container that allows the use of constraints that are specific to constraint programming or to
Step2: Adding the c... |
7,004 | <ASSISTANT_TASK:>
Python Code:
# Figure 1
Image(url= "http://3.bp.blogspot.com/_UpN7DfJA0j4/TJtUBWPk0SI/AAAAAAAAABY/oWPMtmqJn3k/s1600/mnist_originals.png", width=200, height=200)
from __future__ import print_function # Use a function definition from future version (say 3.x from 2.7 interpreter)
import matplotlib.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: Goal
Step2: In the block below, we check if we are running this notebook in the CNTK internal test machines by looking for environment variable... |
7,005 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
%load neon_aop_refl_hdf5_functions.py
#Define inputs
filename = '../data/SERC/hyperspectral/NEON_D02_SERC_DP1_20160807_160559_reflectance.h5'
sercRefl, sercRefl_md, wavelengths = h5refl2array(filename)
clipExtDict = {}
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read in SERC Flightline & Subset
Step2: Stack NIR and VIS bands
Step3: Calculate NDVI & Plot
Step4: Extract Spectra Using Masks
Step5: Funct... |
7,006 | <ASSISTANT_TASK:>
Python Code:
from fretbursts import *
sns = init_notebook(apionly=True)
# Tweak here matplotlib style
import matplotlib as mpl
mpl.rcParams['font.sans-serif'].insert(0, 'Arial')
mpl.rcParams['font.size'] = 12
%config InlineBackend.figure_format = 'retina'
url = 'http://files.figshare.com/2182601/0023... | <SYSTEM_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
Step3: Burst Variance Analysis
Step4: Next we prepare the data for BVA
Step5: and call the bva_sigma_E function
Step6: Finally, we... |
7,007 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'sandbox-2', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
7,008 | <ASSISTANT_TASK:>
Python Code:
numero_entero = 5 # Asigno el número 5 a la variable numero_entero
print numero_entero # Imprimo el valor que tiene la variable numero_entero
print type(numero_entero) # Imprimo el tipo de la variable numero_entero
numero_muy_grande = 9223372036854775807
print numero_muy... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ahora, ¿qué pasa cuando ese número entero crece mucho?, por ejemplo, si le asignamos 9223372036854775807
Step2: ¿Y si ahora le sumamos 1?
Step3... |
7,009 | <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: TensorFlow Hub による転移学習
Step2: ImageNet の分類器
Step3: 1 枚の画像で実行する
Step4: バッチの次元を追加し、画像をモデルに入力します。
Step5: 結果は、1001 要素のベクトルのロジットで、画像の各クラスの確率を評価しま... |
7,010 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_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-Hub CORD-19 Swivel 임베딩 살펴보기
Step2: 임베딩 분석하기
Step3: 임베딩이 여러 용어의 의미를 성공적으로 포착했음을 알 수 있습니다. 각 단어는 해당 클러스터의 다른 단어와 유사하지만(즉, "coronavirus"는 "SAR... |
7,011 | <ASSISTANT_TASK:>
Python Code:
#python dom extension functions to get class and other attributes
def getAttr(dom,cl,attr='class',el='div'):
toreturn=[]
divs=dom.getElementsByTagName(el)
for div in divs:
clarray=div.getAttribute(attr).split(' ')
for cli in clarray:
if cli==cl: tor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get number of pages for publications
Step2: Extract links to publications, from all pages
Step3: Keyword extraction, for each publication
Step... |
7,012 | <ASSISTANT_TASK:>
Python Code:
import requests
response = requests.get("https://api.forecast.io/forecast/5afc9217d7eea82824254c951b1b57f4/-12.0561,-77.0268")
weather_Lima = response.json()
weather_Lima.keys()
print(weather_Lima['timezone'])
print("Longitude:", weather_Lima['longitude'], "Latitude:", weather_Lima['lati... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I have chosen Lima-Peru, the city I was born.
Step2: 2) What's the current wind speed? How much warmer does it feel than it actually is?
Step3:... |
7,013 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
% matplotlib inline
import warnings
warnings.filterwarnings('ignore')
import numpy as np
from thinkbayes2 import Hist, Pmf, Cdf, Suite, Beta
import thinkplot
prior = Beta(2, 3)
thinkplot.Pdf(prior.MakePmf())
prior.Mean()
posterior = Beta(3... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Part One
Step2: In its first test, the new Alien Blaster 9000 takes 10 shots and hits 2 targets. Taking into account this data, what is the po... |
7,014 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
from __future__ import absolute_import, division, print_function
import time
import numpy as np
import matplotlib.pyplot as plt
import seaborn
from cs231n.classifiers.fc_net import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check 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: Fully-Connected Neural Nets
Step4: Affine layer
Step5: Affine layer
Step6: ReLU layer
Step7: ReLU layer
Step8: "Sandwich" layers
Step9: Lo... |
7,015 | <ASSISTANT_TASK:>
Python Code:
!pip install --upgrade google-api-python-client
from httplib2 import Http
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
http = Http()
credentials.authorize(http)
from apiclient.discovery import build
genomics = build('genomic... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create an Authenticated Client
Step2: And then we create a client for the Genomics API.
Step3: Send a request to the Genomics API
Step4: Next... |
7,016 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn import datasets
N = 1000
X, color = datasets.samples_generator.make_s_curve(N, random_state=0)
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, project... | <SYSTEM_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 take a look at the data set with the following plot
Step2: The Geometry Class
Step3: Geometry is the main class that will Cache things ... |
7,017 | <ASSISTANT_TASK:>
Python Code:
#importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
%matplotlib inline
#reading in an image
image = mpimg.imread('test_images/solidWhiteRight.jpg')
#printing out some stats and plotting
print('This image is:', typ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read in an Image
Step10: Ideas for Lane Detection Pipeline
Step11: Test Images
Step12: Build a Lane Finding Pipeline
Step13: Test on Videos
... |
7,018 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
n_segurados = 1000
prob = 0.35
# Lista que salva a quantidade de aposentados para cada cenário
lista_nap = []
# Lista de seeds -> 50 cenários
seeds = range(0,50)
# Executa 50 cenários (seeds) diferentes
for seed in seeds:
# Define o seed para geração de números alea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Observem que diferente do método simples, para cada cenário (seed) ocorre uma situação diferente, ou seja, o número de segurados que se aposenta... |
7,019 | <ASSISTANT_TASK:>
Python Code:
### imports
from IPython.core.debugger import Tracer
#Tracer()()
import os, sys, time
### prevent the dying jupyter notebook
stdout = sys.stdout
#sys.stdout = sys.__stdout__ # did not work to restoure print -> console
#sys.stdout = open('keras_output.txt', 'a+')
#sys.stdout = stdout
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: Load the Models
Step2: Create the Mapping and Tranfer the Weights
Step3: Update the CSV file in Excel
|
7,020 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
data = pd.read_csv('https://github.com/albahnsen/PracticalMachineLearningClass/raw/master/datasets/dataTrain_carListings.zip')
data.head()
data.shape
data.Price.describe()
data.plot(kind='scatter', y='Price', x='Year')
data.plot(kind='scatter', y='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: Exercise P1.1 (50%)
Step2: Submission example
|
7,021 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
lst = list(range(1000))
arr = np.arange(1000)
arr[:10]
arr[10:20]
arr[10:20:2]
type(arr)
%timeit [i ** 2 for i in lst]
%timeit arr ** 2
arr[5:10]
arr[-1]
['a', 2, (1, 3)]
lst[0] = 'some other type'
lst[:3]
arr[0] = 'some other type'
arr.dtype
arr[0] = 1.234
arr[:... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NumPy Arrays and Indexing
Step2: Here's what the array looks like
Step3: We can index arrays in the same ways as lists
Step4: Arrays vs Lists... |
7,022 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import skfuzzy as fuzz
import matplotlib.pyplot as plt
%matplotlib inline
x = np.arange(30, 100, 0.1)
## LINEAR
# Create the membership functions
x_cold_lin = fuzz.trimf(x, [30, 30, 50])
x_mild_lin = fuzz.trimf(x, [30, 50, 70])
x_warm_lin = fuzz.trimf(x, [50, 70, 100])
... | <SYSTEM_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 can be seen in the figure above, each state ("cold", "mild", "warm", and "hot") has a membership value defined at all temperatures between 30... |
7,023 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import numpy as np
import matplotlib.pyplot as plt
import math
from sklearn.metrics import accuracy_score
import pickle
import sys
# Load data
with open('./data/pickled/xtrain.pickle', 'rb') as f:
xtrain = pickle.load(f)
with open('./data/pickled/ytrain.pickle', '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: First, we load the data. For details, please see the accompanying notebook MNIST-loader.ipynb for details.
Step2: Now let's define some useful ... |
7,024 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import seaborn as sns
import matplotlib.pyplot as plt
from thunder import Colorize
image = Colorize.image
tile = Colorize.tile
sns.set_style('darkgrid')
sns.set_context('notebook')
data = tsc.loadExample('mouse-images')
data
from numpy import random
from scipy.ndimage... | <SYSTEM_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: There are 500 images (corresponding to 500 time points), and the data are two-dimensional, so we'll want to generate 500... |
7,025 | <ASSISTANT_TASK:>
Python Code:
from scipy import stats
import pandas as pd
import numpy as np
LETTERS = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
df = pd.DataFrame({'NUM1': np.random.randn(50)*100,
'NUM2': np.random.uniform(0,1,50),
'NUM3': np.random.randint(100, size=5... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
7,026 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
xls = pd.ExcelFile(r'C:\Users\jenng\Documents\texaspse-blog\media\f16-scientific-python\week2\myExcelData.xls')
temp_table = xls.parse('Temperature')
liquid_flow_table = xls.parse('Liquid Flow')
temp_table
temp_table.head()
temp_table.head(7)
list(liquid_flow_tabl... | <SYSTEM_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 read in some data. Our file is an .xls file and it has 2 sheets. I don't know how to do that, so I will google "pandas read in excel file ... |
7,027 | <ASSISTANT_TASK:>
Python Code:
import os, re, math, json, shutil, pprint, datetime
import PIL.Image, PIL.ImageFont, PIL.ImageDraw
import numpy as np
import tensorflow as tf
from matplotlib import pyplot as plt
from tensorflow.python.platform import tf_logging
print("Tensorflow version " + tf.__version__)
BATCH_SIZE = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parameters
Step3: Colab-only auth
Step4: tf.data.Dataset
Step5: Let's have a look at the data
Step6: Estimator model [WORK REQUIRED]
Step7: ... |
7,028 | <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: Using the SavedModel format
Step2: You'll use an image of Grace Hopper as a running example, and a Keras pre-trained image classification model... |
7,029 | <ASSISTANT_TASK:>
Python Code:
from thermostate import State, Q_, units
from thermostate.plotting import IdealGas
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
substance = 'air'
p_1 = Q_(1.0, 'bar')
T_1 = Q_(300.0, 'K')
T_3 = Q_(1700.0, 'K')
p2_p1 = Q_(8.0, 'dimensionless')
p_low = Q_(2.0, 'dim... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Definitions
Step2: Problem Statement
Step3: Summarizing the states,
Step4: Then, the net work is calculated by
Step5: <div class="alert aler... |
7,030 | <ASSISTANT_TASK:>
Python Code:
DIM = 100 # Number of bits in the bit strings (i.e. the "models").
NOISE_STDEV = 0.01 # Standard deviation of the simulated training noise.
EARLY_SIGNAL_NOISE = 0.005 # Standard deviation of the noise added to earlier
# observations.
REDUCTION_FACTOR = 100.0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step6: Copyright 2019 Google LLC
Step9: Search Algorithms
Step10: Experiments
Step11: Plain Evolution
Step12: Plain Evolution
Step13: Progressive ... |
7,031 | <ASSISTANT_TASK:>
Python Code:
from pyechonest import config, artist, song
import pandas as pd
config.ECHO_NEST_API_KEY = 'XXXXXXXX' #retrieved from https://developer.echonest.com/account/profile
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
songs = song.search(title='Elas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Query a single song, get its audio features and make a dataframe
Step2: Grab and compare the hottest tracks, available in Spotify, for 2 artist... |
7,032 | <ASSISTANT_TASK:>
Python Code:
from tessfpe.dhu.fpe import FPE
from tessfpe.dhu.unit_tests import check_house_keeping_voltages
fpe1 = FPE(1, debug=False, preload=True, FPE_Wrapper_version='6.1.1')
print fpe1.version
fpe1.cmd_start_frames()
fpe1.cmd_stop_frames()
if check_house_keeping_voltages(fpe1):
print "Wrapper... | <SYSTEM_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 all the operating parameters to the default values
Step3: Start the frames
Step6: Run the variance test
|
7,033 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Eric Larson <larson.eric.d@gmail.com>
# License: BSD (3-clause)
import os.path as op
import numpy as np
from scipy import stats as stats
import mne
from mne import spatial_src_connectivity
from mne.stats im... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: Compute statistic
Step3: Visualize the clusters
|
7,034 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License")
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The AS... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Keys
Step2: Example
|
7,035 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd #The data package
import sys #The code below wont work for any versions before Python 3. This just ensures that (allegedly).
assert sys.version_info >= (3,5)
import requests
import io
import zipfile #Three packages we'll need to unzip the data
The next... | <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: Survey Data
Step4: We'll also be looking at prior-year surveys, so I'll condense the unzipping processes above into a function out of laziness
... |
7,036 | <ASSISTANT_TASK:>
Python Code:
import json
import requests
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
import datetime
import time
import calendar
import pytz
#from matplotlib.dates import date2num, num2date
utc_tz = pytz.utc
def epochsec_to_dt(epochsec):
Return the... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: DRB Vizer json services
Step2: Service end point
Step3: Meta info (metadata) requests
Step4: Examine all stations (siso assets) by first impo... |
7,037 | <ASSISTANT_TASK:>
Python Code:
# Authors: Christian Brodbeck <christianbrodbeck@nyu.edu>
# Tal Linzen <linzen@nyu.edu>
# Denis A. Engeman <denis.engemann@gmail.com>
# Mikołaj Magnuski <mmagnuski@swps.edu.pl>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
from m... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic plot_topomap options
Step2: If times is set to None at most 10 regularly spaced topographies will be
Step3: Instead of showing topograph... |
7,038 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
from sklearn.linear_model import LogisticRegression
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
# Load data
iris = datasets.load_iris()
X = iris.data
y = iris.target
# Standarize features
scaler = StandardScaler()
X_std = scaler.fit_tra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Iris Flower Data
Step2: Standardize Features
Step3: Train Logistic Regression Using SAG solver
|
7,039 | <ASSISTANT_TASK:>
Python Code:
from aesop import DirectedMutagenesis, plotScan_interactive, plotNetwork_interactive
path_apbs = 'path\to\executable\apbs'
path_coulomb = 'path\to\executable\coulomb'
path_pdb2pqr = 'path\to\executable\pdb2pqr'
jobname = 'directedscan'
pdbfile = 'barnase_barstar.pdb'
selstr = ['chain A... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Once DirectedMutagenesis is instantiated and finished running, we can plot the results. The plotScan_interactive function by default, outputs th... |
7,040 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from astropy.table import QTable
from astropy import units as u
from astropy import constants as const
from astropy.units import imperial
imperial.enable()
u.m # The unit of meters
u.s # The unit of seconds
u.m / u.s # combine them into a composite unit
u.m.f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note
Step2: For any unit you can find all of the built-in units that are equivalent
Step3: The units package is much more useful when you comb... |
7,041 | <ASSISTANT_TASK:>
Python Code:
# Author: Jussi Nurminen (jnu@iki.fi)
#
# License: BSD (3-clause)
import mne
import os
from mne.datasets import multimodal
fname_raw = os.path.join(multimodal.data_path(), 'multimodal_raw.fif')
print(__doc__)
raw = mne.io.read_raw_fif(fname_raw)
print(raw.acqparser)
cond = raw.acqparse... | <SYSTEM_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 raw file
Step2: Check DACQ defined averaging categories and other info
Step3: Extract epochs corresponding to a category
Step4: Get epoc... |
7,042 | <ASSISTANT_TASK:>
Python Code:
X = np.array([[11, 12], [21, 22], [31, 32]])
X
X = np.array([[1,1,1,1], [1,2,4,8], [1,3,5,7], [1,4,16,32], [1,5,9,13]])
X
X[1::2, 1:]
X = np.array([[1,1,1,1], [1,2,4,8], [1,3,5,7],[1,4,16,32],[1,5,9,13]])
X
X[X%4==0]
X = np.ones((5,4))
Y = np.zeros((5,4))
np.hstack([X, Y])
np.arange(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: 문제2.
Step2: 문제3.
Step3: 문제4.
Step4: 문제 5.
Step5: 문제6.
Step6: 문제7.
Step7: 문제10
Step8: 선형대수
|
7,043 | <ASSISTANT_TASK:>
Python Code:
def lempel_ziv_complexity(sequence):
Lempel-Ziv complexity for a binary sequence, in simple Python code.
sub_strings = set()
n = len(sequence)
ind = 0
inc = 1
# this while loop runs at most n times
while True:
if ind + inc > len(sequence):
b... | <SYSTEM_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: Tests (1/2)
Step4: We can start to see that the time complexity of this function seems to grow linearly as the size g... |
7,044 | <ASSISTANT_TASK:>
Python Code:
from kubernetes import client, config
from kubernetes.client.rest import ApiException
config.load_kube_config()
api_instance = client.CoreV1Api()
cmap = client.V1ConfigMap()
cmap.metadata = client.V1ObjectMeta(name="special-config")
cmap.data = {}
cmap.data["special.how"] = "very"
cmap... | <SYSTEM_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 config from default location
Step2: Create API endpoint instance and API resource instances
Step3: Create key value pair data for the Con... |
7,045 | <ASSISTANT_TASK:>
Python Code:
from keras.applications import VGG16
from keras.applications.imagenet_utils import preprocess_input, decode_predictions
import os
# -- Jupyter/IPython way to see documentation
# please focus on parameters (e.g. include top)
VGG16??
vgg16 = VGG16(include_top=True, weights='imagenet')
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: If you're wondering where this HDF5 files with weights is stored, please take a look at ~/.keras/models/
Step2: <img src="imgs/imagenet/strawbe... |
7,046 | <ASSISTANT_TASK:>
Python Code:
from fig_utils import *
import matplotlib.pyplot as plt
import time
%matplotlib inline
# Plot parameters
country = 'nigeria'
country_path = '../data/LSMS/nigeria/'
dimension = None
k = 5
k_inner = 5
points = 10
alpha_low = 1
alpha_high = 5
margin = 0.25
# Plot single panel
t0 = time.time... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Predicting consumption expeditures
Step2: Panel B
Step3: Panel C
Step4: Panel D
|
7,047 | <ASSISTANT_TASK:>
Python Code:
%run Regexp-2-NFA.ipynb
%run NFA-2-DFA.ipynb
def cartesian_product(A, B):
return { (x, y) for x in A
for y in B
}
cartesian_product({1, 2}, {'a', 'b'})
def fsm_complement(F1, F2):
States1, Σ, 𝛿1, q1, A1 = F1
States2, _, 𝛿2, q2, A2 = F2
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: NFA-2-DFA.ipynb contains the function nfa2dfa that converts a non-deterministic
Step2: Given two sets A and B, the function cartesian_product(... |
7,048 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model_name = type(model).__name__
<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:
|
7,049 | <ASSISTANT_TASK:>
Python Code:
# Load pickled data
import pickle
import cv2 # for grayscale and normalize
# TODO: Fill this in based on where you saved the training and testing data
training_file ='traffic-signs-data/train.p'
validation_file='traffic-signs-data/valid.p'
testing_file = 'traffic-signs-data/test.p'
with 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: Step 1
Step2: Include an exploratory visualization of the dataset
Step3: Step 2
Step4: Model Architecture
Step5: Train, Validate and Test th... |
7,050 | <ASSISTANT_TASK:>
Python Code:
import sklearn.model_selection, numpy, astropy.io.ascii as asc
table = asc.read('/Users/alger/data/Crowdastro/one-table-to-rule-them-all.tbl')
# clean = numpy.array(asc.read('clean-atlas.tbl')['Clean']).astype(bool)
# clean.shape
primary_component_to_norris_swire = {}
primary_component_to... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate training/testing subsets
Step2: Associate SWIRE objects with each set
Step3: Generate Features for Each SWIRE Object
Step4: Generate... |
7,051 | <ASSISTANT_TASK:>
Python Code:
# Initial imports and notebook setup, click arrow to show
from copy import copy
import matplotlib.pyplot as plt
import numpy as np
from HARK.ConsumptionSaving.ConsIndShockModel import PerfForesightConsumerType
from HARK.utilities import plot_funcs
mystr = lambda number: "{:.4f}".format(nu... | <SYSTEM_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 module HARK.ConsumptionSaving.ConsIndShockModel concerns consumption-saving models with idiosyncratic shocks to (non-capital) income. All o... |
7,052 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy as sp
import scipy.signal as signal
import matplotlib
import matplotlib.pyplot as pl
%matplotlib inline
import seaborn as sn
sn.set(style="ticks")
# extra dependencies of this notebook, for data loading and fitting of kernels
import pandas as pd
from lmfit... | <SYSTEM_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: Let's plot the raw pupil timeseries
Step3: The periods where the timeseries drop to 0 correspond to blinks. Let's linearly in... |
7,053 | <ASSISTANT_TASK:>
Python Code:
import sys
#sys.path.append('/Users/esumitra/workspaces/mc/mcpipy')
# Start typing below
# once you are done typing, press (Ctrl+Enter) to run the code
import mcpi.minecraft as minecraft
import time
mc = minecraft.Minecraft.create()
mc.postToChat("Hello kids")
time.sleep(5)
# Program 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: Send a chat message
Step2: If everthing went well, you saw a chat message in Minecraft. You have now written your first program for Minecraft. ... |
7,054 | <ASSISTANT_TASK:>
Python Code:
#I don't think this is the code golf winner. Try to beat me.
for i in range(100):
print('FizzBuzz'*(not (i+1)%5)*(not (i+1)%3) or 'Fizz'*(not (i+1)%5) or 'Buzz'*(not (i+1)%3) or str(i+1))
def sum_digits(number):
'''
Function that takes a number as an input and sums its digits... | <SYSTEM_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) Write a function called sum_digits that returns the sum of the digits of an integer argument; that is, sum_digits(123) should return 6. Use ... |
7,055 | <ASSISTANT_TASK:>
Python Code:
data_df = pd.read_excel("RESSALES-mf.xlsx", sheetname='data')
data_df.head()
categories_df = pd.read_excel("RESSALES-mf.xlsx", sheetname='categories')
data_types_df = pd.read_excel("RESSALES-mf.xlsx", sheetname='data_types')
error_types_df = pd.read_excel("RESSALES-mf.xlsx", sheetname='er... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Changing the index to the datetime
Step2: It's the column on the far left - 0, 1, 2, 3, 4... boring and useless! If we replace the index with t... |
7,056 | <ASSISTANT_TASK:>
Python Code:
# iterating over a list by object
x = ['bob', 'sue', 'mary']
for name in x:
print(name.upper() + ' WAS HERE')
# alternatively, you could iterate over position
for i in range(len(x)):
print(x[i].upper() + ' WAS HERE')
dir(x) # ignore the __ methods for now
y = (x*x for x in [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: generators return their contents 'lazily'. This leaves a minimal memory footprint, at the cost of making the generator nonreusable.
Step2: 'ran... |
7,057 | <ASSISTANT_TASK:>
Python Code:
! pip uninstall -y kfp
! pip install --no-cache-dir kfp torch captum
import kfp
import json
import os
from kfp.onprem import use_k8s_secret
from kfp import components
from kfp.components import load_component_from_file, load_component_from_url, InputPath
from kfp import dsl
from kfp 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: Enter your gateway and the cookie
Step2: Set Log bucket and Tensorboard Image
Step4: Define pipeline
Step5: Wait for inference service below ... |
7,058 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Instala a versão exata do pacote matplotlib
!pip install -q -U matplotlib==3.2.1
import matplotlib as mat
mat.__version__
import sqlite3
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Gráficos
|
7,059 | <ASSISTANT_TASK:>
Python Code:
exam_scores = [67,78,94,45,55,66]
print("scores: " ,exam_scores)
exam_scores = [67,78,94,45,55]
print("score 2: " ,exam_scores[1])
print("score 3: " ,exam_scores[2])
print("score 2 & 3: " ,exam_scores[1:3])
exam_scores = [67,78,94,45,55]
exam_scores[2] = 90
print("score: " ,exam_scores[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lists can be accessed by numerical position (aka index)
Step2: Slicing can also be used with strings in the same way. Just imagine that each ch... |
7,060 | <ASSISTANT_TASK:>
Python Code:
import tohu
from tohu import *
from utils import print_generated_sequence
print(f"Tohu version: {tohu.__version__}")
class FoobarGenerator(CustomGenerator):
a = Integer(low=1000, high=3000)
b = Sequential(prefix="Foo_", digits=2)
c = Float(low=1.0, high=4.0)
g1 = FoobarGenera... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Resetting one generator should not reset others of the same type
Step2: The random generators which produce the attributes of items generated b... |
7,061 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import time
%matplotlib inline
### function for shuffling the data and labels
def shuffle_in_unison(features, labels):
rng_state = np.random.get_state()
np.random.shuffle(feat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Again we need functions for shuffling the data and calculating classification errrors.
Step2: 0.1 Load the dataset of paintings
Step3: We wan... |
7,062 | <ASSISTANT_TASK:>
Python Code:
!python3 -c "import kfp; print('KFP SDK version: {}'.format(kfp.__version__))"
import os
import json
from functools import partial
import kfp
import pprint
import yaml
from jinja2 import Template
from kfp.v2 import dsl
from kfp.v2.compiler import compiler
from kfp.v2.dsl import Dataset
fr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then define the pipeline using the following function
Step2: Compile and run the end-to-end ML pipeline
Step3: Next, instantiate an API client... |
7,063 | <ASSISTANT_TASK:>
Python Code:
# If we're running on Colab, install empiricaldist
# https://pypi.org/project/empiricaldist/
import sys
IN_COLAB = 'google.colab' in sys.modules
if IN_COLAB:
!pip install empiricaldist
# Get utils.py
from os.path import basename, exists
def download(url):
filename = basename(url)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This chapter introduces "survival analysis", which is a set of statistical methods used to answer questions about the time until an event.
Step2... |
7,064 | <ASSISTANT_TASK:>
Python Code:
# Create a function that
def function(names):
# For each name in a list of names
for name in names:
# Returns the name
return name
# Create a variable of that function
students = function(['Abe', 'Bob', 'Christina', 'Derek', 'Eleanor'])
# Run the function
students
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we have a problem, we were only returned the name of the first student. Why? Because the function only ran the for name in names iteration o... |
7,065 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import bruges as bg
w, top, base, ref = bg.models.wedge()
plt.imshow(w, interpolation='none')
plt.axvline(ref, color='k', ls='--')
plt.plot(top, 'r-', lw=4)
plt.plot(base, 'r-', lw=4)
plt.show()
import numpy as np
vps = np.array([2320, 2350, 2350])
rhos = ... | <SYSTEM_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 function returns the following
Step2: And look at the result
Step3: Now the wedge contains rock properties, not integer labels.
Step4: No... |
7,066 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -v -d -u -p pandas,scikit-learn,numpy,matplotlib
feature_dict = {i:label for i,label in zip(
range(4),
('sepal length in cm',
'sepal width in cm',
'petal length in cm',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font size="1.5em">More information about the watermark magic command extension.</font>
Step 1
Step2: <a name="sample_data"></a>
Step3: $\pmb ... |
7,067 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
# Temperatures at stations
T1 = 150
T4 = 10 # celcius
# define values for thermal conductivity
k = [0.07, 0.7, 0.07]
# Length of layers
L = [0.03, 0.1, 0.03]
AR = [] # initialize empty array
for i in range(0,len(k)):
AR.append(L[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: 1. Conduction
Step2: These values can be used to calculate $\dot{Q}$ the rate of heat transfer. This can be related to a more physically releva... |
7,068 | <ASSISTANT_TASK:>
Python Code:
weightDict = {
'C':12,
'H':1,
'O':16,
'Cl':35
#add more if needed.
}
ethanol = {'C':2, 'H':6, 'O':1}
water = {'H':2, 'O':1}
HCl = {'H':1, 'Cl':1}
#Finish...
ethanol2 = [('C',1), ('H',3), ('C',1), ('H',2), ('O',1), ('H',1)]
acetic2 = [('C',1), ('H',3), ('C',1), ('O',1), ('O',1), ('H',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: Parsing the molecular formula is not a trivial task that we will do later. We start by assuming that the formula has been parsed.
Step2: From t... |
7,069 | <ASSISTANT_TASK:>
Python Code:
totalDomainsOccurrences = 0
for num in domains[1]:
totalDomainsOccurrences += num
length = 10
width = 0.8
fig = plt.figure()
plt.barh(range(length), np.asarray(domains[1][0:length] * 100 / totalDomainsOccurrences), width, align='center', color='b')
plt.grid(which='both')
plt.xlabel(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: Top used domains in Wikidata.
Step2: Top used domains in Wikipedia.
Step3: Matching domains across both Wikipedia and Wikidata.
Step4: Scatte... |
7,070 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import os
import pathlib
curr_dir = pathlib.Path("./")
rsfmri_basedir = str((curr_dir / "raw_data/autism/").resolve())
def parse_dataset():
_target_column_name = 'asd'
_prediction_label_names = [0, 1]
subject_id = pd.read_csv(os.pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fetch the dataset
Step2: The following code is heavily based on the code provided by the competition's organizers.
Step3: Dump arrays
|
7,071 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pylab as pl
%matplotlib inline
filename = './titanic-data.csv'
titanic_df = pd.read_csv(filename)
titanic_df.describe()
titanic_df = titanic_df.fillna(method='pad')#用前一个数值填充
titanic_df.describe()
sort_pclass =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 首先,我们观察一下几个比较重要的数值,初步得出一些结论,比如只有‘Age’这一列存在缺失值,整体的存活率只有0.383838。所以首先应该对年龄的缺失值进行填充。
Step2: 可以看出年龄这一列数据的总数正常了,为891,接下来可以进一步分析生存率了。
Step3: 根据以上不同舱... |
7,072 | <ASSISTANT_TASK:>
Python Code:
import hail as hl
hl.init()
from hail.plot import show
from pprint import pprint
hl.plot.output_notebook()
hl.utils.get_1kg('data/')
hl.import_vcf('data/1kg.vcf.bgz').write('data/1kg.mt', overwrite=True)
mt = hl.read_matrix_table('data/1kg.mt')
mt.rows().select().show(5)
mt.row_key.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If the above cell ran without error, we're ready to go!
Step2: Download public 1000 Genomes data
Step3: Importing data from VCF
Step4: Next ... |
7,073 | <ASSISTANT_TASK:>
Python Code:
# Authors: Sheraz Khan <sheraz@khansheraz.com>
#
# License: BSD (3-clause)
import numpy as np
import mne
from mne.datasets import sample
from mne.datasets.brainstorm import bst_raw
from mne import read_evokeds
from mne.viz import plot_arrowmap
print(__doc__)
path = sample.data_path()
fnam... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plot magnetometer data as an arrowmap along with the topoplot at the time
Step2: Plot gradiometer data as an arrowmap along with the topoplot a... |
7,074 | <ASSISTANT_TASK:>
Python Code:
# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Daniel Strohmeier <daniel.strohmeier@tu-ilmenau.de>
#
# License: BSD (3-clause)
import numpy as np
import mne
from mne.datasets import sample
from mne.inverse_sparse import mixed_norm, make_stc_from_dipoles
from mne.mini... | <SYSTEM_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 solver
Step2: Plot dipole activations
Step3: Plot residual
Step4: Generate stc from dipoles
Step5: View in 2D and 3D ("glass" brain like... |
7,075 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import pandas as pd
import sys
sys.path.append("../../../bayespy")
import bayespy
from bayespy.network import Builder as builder
import logging
import os
import matplotlib.pyplot as plt
from IPython.display import display
logger = logging.getLogger()
logger.addHandler... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Rather than using a template to build the network, it's fairly easy to define it by hand. The network looks something like the following
Step2: ... |
7,076 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
from sklearn.cross_validation import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn import metrics
# read in the iris data
iris = load_iris()
# create X (features) and y (response)
X = iris.data
y = iris.target
# 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: Question 1
Step2: From this example, we could see that if we just split training and testing data for just once, sometimes we could get a very ... |
7,077 | <ASSISTANT_TASK:>
Python Code:
import theano
import theano.tensor as T
x = T.scalar()
x
y = 3*(x**2) + x
type(y)
print(y)
theano.pprint(y)
theano.printing.debugprint(y)
from IPython.display import SVG
SVG(theano.printing.pydotprint(y, return_image=True, format='svg'))
y.eval({x: 2})
f = theano.function([x], y)
f(2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Symbolic variables
Step2: Variables can be used in expressions, but (IMPORTANT!) the result is symbolic as well
Step3: Investigating expressi... |
7,078 | <ASSISTANT_TASK:>
Python Code:
import arviz as az
import bambi as bmb
import numpy as np
import pandas as pd
az.style.use("arviz-darkgrid")
# Read in a tab-delimited file containing our data
data = pd.read_table("data/my_data.txt", sep="\t")
# Initialize the model
model = bmb.Model("y ~ x + z", data)
# Inspect model 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: Creating a model
Step2: Typically, we will initialize a Bambi Model by passing it a model formula and a pandas DataFrame. Other arguments such ... |
7,079 | <ASSISTANT_TASK:>
Python Code:
import sciunit
from sciunit.models import ConstModel # One of many dummy models included for illustration.
const_model_37 = ConstModel(37, name="Constant Model 37")
from sciunit.capabilities import ProducesNumber
from sciunit.scores import ZScore # One of many SciUnit score types.
f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In this chapter we will use the same toy model in Chapter 1 but write a more interesting test with additional features included in SciUnit.
Step... |
7,080 | <ASSISTANT_TASK:>
Python Code:
import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_filt-0-40_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
print(raw.info)
info ... | <SYSTEM_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 seen in the introductory tutorial <tut-overview>, when a
Step2: However, it is not strictly necessary to load the
Step3: As you can ... |
7,081 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'sandbox-2', 'land')
# 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... |
7,082 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import mne
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
subjects_dir = op.join(data_path, 'subjects')
raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif')
tr_fname = op.join(data_path, 'MEG', 'sample', 'sample_audv... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2:
Step3: It is quite clear that things are not well aligned for estimating the
Step4: The previous is possible if you ha... |
7,083 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
%matplotlib inline
#读取数据集
auto_df = pd.read_csv('data/Auto.csv', na_values = "?")
auto_df.dropna(inplace = True)
auto_df.head()
fig, ax = plt.subplots()
ax.scatter(x=auto_df['horsepower'],y=auto_df['... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Leave One Out Cross Validation(LOOCV)
Step2: $$CV_{(n)} = \frac {1} {n} \sum_{i =1}^n (\frac{y_i - \hat y_i}{1- h_i})^2$$
Step3: K-Fold Cross ... |
7,084 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function # only needed on py2
%matplotlib inline
import numpy as np
import tables
import matplotlib.pyplot as plt
def print_children(group):
Print all the sub-groups in `group` and leaf-nodes children of `group`.
Parameters:
group (... | <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. Utility functions
Step3: 2. Open the data file
Step4: We can open the file, as a normal HDF5 file
Step5: The object h5file is a pytables f... |
7,085 | <ASSISTANT_TASK:>
Python Code:
def metropolis_hastings(f, q, initial_state, num_iters):
Generate a Markov Chain Monte Carlo using
the Metropolis-Hastings algorithm.
Parameters
----------
f : function
the [relative] likelood function for
the distribution we would like to
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: $$\text{???} = (MC)^2$$
Step2: Estimation
Step3: Another Aspect
Step4:
|
7,086 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -u -v -d -p matplotlib,numpy
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
# Generating a Gaussion dataset:
# creating random vectors from the multivariate normal distribution
# given mean and covariance
mu_vec1 = np.array([0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font size="1.5em">More info about the %watermark extension</font>
Step2: Scatter plots in matplotlib
Step3: <br>
Step5: <br>
Step6: <br>
|
7,087 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cmcc', 'cmcc-cm2-sr5', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
7,088 | <ASSISTANT_TASK:>
Python Code:
## Setup the path for our codebase
import sys
sys.path.append( '../code/' )
%matplotlib inline
import matplotlib.pyplot as plt
import neural_network.simple as simple
data = simple.generate_hill_data(100)
xs = map(lambda z: z[0], data)
ys = map(lambda z: z[1], data)
plt.plot( xs, ys )
nn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example Data (centered Quadratic)
Step2: Simple Feed-Foward 1-Layer Neural Networks
Step3: Let's visualize the inputs to the final layer
Step4... |
7,089 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import scipy.stats as stats
from sklearn import covariance
# Generate random values of x
X = np.random.normal(size = 1000)
epsilon = np.random.normal(0, 3, size = len(X))
Y = 5*X + epsilon
produ... | <SYSTEM_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 take the covariance of two closely related variables, $X$ and $Y$. Say that $X$ is some randomly drawn set and that $Y = 5X + \epsilon$, ... |
7,090 | <ASSISTANT_TASK:>
Python Code:
from SPARQLWrapper import SPARQLWrapper, JSON
# Specify the DBPedia endpoint
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
# Query for the description of "Capsaicin", filtered by language
sparql.setQuery(
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?comment
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SPARQL from Python
Step4: Querying Wikidata
Step5: Let's use pandas to review the results as a dataframe
|
7,091 | <ASSISTANT_TASK:>
Python Code:
from atmPy.instruments.DMA import smps
from atmPy.instruments.DMA import dma
from matplotlib import colors
import matplotlib.pyplot as plt
from numpy import meshgrid
import numpy as np
import pandas as pd
from matplotlib.dates import date2num
from matplotlib import dates
from atmPy import... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The first thing we do in the analysis is we create a new SMPS object with the DMA instance we wish to use. Here, we also set the initial direct... |
7,092 | <ASSISTANT_TASK:>
Python Code:
import sqlite3
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import CGATPipelines.Pipeline as P
import os
import statistics
import collections
#load R and the R packages required
# use these functions to dis... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This is where and when the notebook was run
Step2: First lets set the output path for where we want our plots to be saved and the database path... |
7,093 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
import random
def enumerate_row(nb=10000, n=10):
for i in range(nb):
# on retourne un tuple, les données sont
# plus souvent recopiées car le type est immuable
yield tuple(random.random() for k 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: Création d'un dataframe à partir d'un itérateur
Step2: On compare plusieurs constructions
Step3: On décompose
Step4: D'après ces temps, pan... |
7,094 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
# load MNIST data
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
train_images = np.reshape(mnist.train.images, [-1, 28, 28, 1])
train_labels = mnist.train.labels
test_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: Define Network Architectures
Step2: Setup
Step3: Training
Step4: Evaluation
Step5: If PartialFlow works correctly, the losses should be very... |
7,095 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Criando uma classe chamada Circulo
class Circulo():
# O valor de pi é constante
pi = 3.14
# Quando um objeto desta class... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Métodos
|
7,096 | <ASSISTANT_TASK:>
Python Code:
from timeit import default_timer as timer
from bokeh.plotting import figure, show, output_notebook
from bokeh.models import GlyphRenderer, LinearColorMapper
from bokeh.io import push_notebook
from numba import jit, njit
from ipywidgets import interact
import numpy as np
import scipy.misc
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Gaussian Blur
Step2: 3x3 Image Kernels
Step4: Wavelet Decomposition
|
7,097 | <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... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Acquiring Data
Step2: You should see a DataFrame containing information about iris flowers.
Step3: Downloading With Pandas
Step4: Kaggle Data... |
7,098 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import statsmodels.api as sm
from statsmodels.formula.api import logit, probit, poisson, ols
print(sm.datasets.fair.SOURCE)
print( sm.datasets.fair.NOTE)
dta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How well are we predicting?
Step2: The coefficients of the discrete choice model do not tell us much. What we're after is marginal effects.
Ste... |
7,099 | <ASSISTANT_TASK:>
Python Code:
from pathlib import Path
import requests
data_path = Path('data')
path = data_path/'mnist'
path.mkdir(parents=True, exist_ok=True)
url = 'http://deeplearning.net/data/mnist/'
filename = 'mnist.pkl.gz'
(path/filename)
if not (path/filename).exists():
content = requests.get(url+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: the torch.Tensor.sum(dim) call takes an integer argument as the axis along which to sum. This applies to NumPy arrays as well.
Step2: torch.uns... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.