Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
3,100 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
# pandas is a software library for data manipulation and analysis
# We commonly use shorter nicknames for certain packages. Pandas is often abbreviated to pd.
# hit shift + enter to run this cell or block of code
path = r'chopstick-effectiveness.csv'
# Change the path ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's do a basic statistical calculation on the data using code! Run the block of code below to calculate the average "Food Pinching Efficiency"... |
3,101 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sympy
import fipy as fp
import numpy as np
A, c, c_m, B, c_alpha, c_beta = sympy.symbols("A c_var c_m B c_alpha c_beta")
f_0 = - A / 2 * (c - c_m)**2 + B / 4 * (c - c_m)**4 + c_alpha / 4 * (c - c_alpha)**4 + c_beta / 4 * (c - c_beta)**4
print f_0
sympy.diff(f_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: The first step in implementing any problem in FiPy is to define the mesh. For Problem 1a the solution domain is just a square domain, but the bo... |
3,102 | <ASSISTANT_TASK:>
Python Code:
import re # Regular Expressions
import pandas as pd # DataFrames & Manipulation
from gensim.models.word2vec import Word2Vec
train_input = "../data/recipes.tsv.bz2"
# preserve empty strings (http://pandas-docs.github.io/pandas-doc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Input Normalization
Step2: Word2Vec Model
Step3: Training CBOW model
Step4: Model Details
Step5: Word Similarity
Step6: Training skip-gram ... |
3,103 | <ASSISTANT_TASK:>
Python Code:
# Magic command to insert the graph directly in the notebook
%matplotlib inline
# Load a useful Python libraries for handling data
import pandas as pd
import numpy as np
import statsmodels.formula.api as smf
import scipy.stats as stats
import seaborn as sns
import matplotlib.pyplot as plt... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: General information on the Gapminder data
Step2: Variables distribution
Step3: Income per person
Step4: From the distribution graph, we can s... |
3,104 | <ASSISTANT_TASK:>
Python Code:
def isBalanced(s ) :
st = list()
n = len(s )
for i in range(n ) :
if s[i ] == '(' :
st . append(s[i ] )
else :
if len(st ) == 0 :
return False
else :
st . pop()
if len(st ) > 0 :
return False
return True
def isBalancedSeq(s1 , s2 ) :
if(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
3,105 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from sklearn.linear_model import LogisticRegression
from gensim.corpora import Dictionary
from gensim.sklearn_api.tfidf import TfIdfTransformer
from gensim.matutils import corpus2csc
import numpy as np
import matplotlib.pyplot as py
import gensim.downloader as api
# Thi... | <SYSTEM_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 TFIDF scores for corpus without pivoted document length normalisation
Step2: Get TFIDF scores for corpus with pivoted document length norma... |
3,106 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
with open('../sentiment-network/reviews.txt', 'r') as f:
reviews = f.read()
with open('../sentiment-network/labels.txt', 'r') as f:
labels = f.read()
reviews[:2000]
from string import punctuation
all_text = ''.join([c for c in reviews if... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data preprocessing
Step2: Encoding the words
Step3: Encoding the labels
Step4: If you built labels correctly, you should see the next output.... |
3,107 | <ASSISTANT_TASK:>
Python Code:
# read the iris data into a DataFrame
import pandas as pd
url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
col_names = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species']
iris = pd.read_csv(url, header=None, names=col_names)
iris.head()... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Terminology
Step2: Import the Good Stuff
Step3: Feature Exploration with RadViz
Step4: Setosas tend to have the largest septal-width. This ca... |
3,108 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
x = range(0,10)
x
def cube(num):
return num ** 3
for item in x:
print(cube(item))
new_list = []
for item in x:
new_list.append(cube(item))
print(new_list)
map_list = map(cube, x)
print(list(map_list))
fx = map(float, range(10))
print(li... | <SYSTEM_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’ll have a list of things and we’ll want to repeat a transformation over and over again to each item in the list.
Step2: For example you may ... |
3,109 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import math
import numpy as np
import matplotlib.pyplot as plt
in_circle = 0
outside_circle = 0
n = 10 ** 4
# Draw many random points
X = np.random.rand(n)
Y = np.random.rand(n)
for i in range(n):
if X[i]**2 + Y[i]**2 > 1:
outside_circle += 1
else:
... | <SYSTEM_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 visualize the process to see how it works.
Step2: Finally, let's see how our estimate gets better as we increase $n$. We'll do this by c... |
3,110 | <ASSISTANT_TASK:>
Python Code:
import cobra.test
model = cobra.test.create_test_model("salmonella")
# remove some reactions and add them to the universal reactions
Universal = cobra.Model("Universal_Reactions")
for i in [i.id for i in model.metabolites.f6p_c.reactions]:
reaction = model.reactions.get_by_id(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: In this model D-Fructose-6-phosphate is an essential metabolite. We will remove all the reactions using it, and at them to a separate model.
Ste... |
3,111 | <ASSISTANT_TASK:>
Python Code:
import json
from utils import load_items
with open('parameters.json', 'r') as infile:
params = json.load(infile)
RESIZE_X = params['resize']['x']
RESIZE_Y = params['resize']['y']
ITEM_FOLDER = params['item_folder']
items = load_items(ITEM_FOLDER)
import cv2, glob
from utils import 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: Compute and Save<a id="compute"></a>
Step2: Statistics???<a id="statistics"></a>
Step3: Plot File<a id="plot"></a>
Step4: Plot All Items
Step... |
3,112 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import mne
from mne.datasets import sample
from mne.preprocessing import compute_proj_ecg, compute_proj_eog
# getting some data ready
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
raw = mne.io.read_raw_fif(raw_fname... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Compute SSP projections
Step2: Now let's do EOG. Here we compute an EEG projector, and need to pass
Step3: Apply SSP projections
Step4: Yes t... |
3,113 | <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: 변수는 텐서처럼 보이고 작동하며, 실제로 tf.Tensor에서 지원되는 데이터 구조입니다. 텐서와 마찬가지로, dtype과 형상을 가지며 NumPy로 내보낼 수 있습니다.
Step4: 변수를 재구성할 수는... |
3,114 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -v -m -p numpy,matplotlib
import random
import numpy as np
import matplotlib.pyplot as plt
def rn2(x):
return random.randint(0, x-1)
np.asarray([rn2(10) for _ in range(100)])
from collections import Counter
Counter([rn2(10) == 0 for _ in range(100)])
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: Rn2 distribution
Step2: Testing for rn2(x) == 0 gives a $1/x$ probability
Step3: Rne distribution
Step4: In the NetHack game, the player's e... |
3,115 | <ASSISTANT_TASK:>
Python Code:
# create a Jupyter image that will be our display surface
# format can be 'jpeg' or 'png'; specify width and height to set viewer size
# PNG will be a little clearer, especially with overlaid graphics, but
# JPEG is faster to update
import ipywidgets as widgets
jup_img = widgets.Image(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: You can now do nearly everything that can be done with a regular "pg" type ginga web widget.
Step2: Now press and release space bar in the view... |
3,116 | <ASSISTANT_TASK:>
Python Code:
%load preamble_directives.py
from source_code_analysis.models import CodeLexiconInfo
from lexical_analysis import LINSENnormalizer
from lexical_analysis import LexicalAnalyzer
from source_code_analysis.models import SoftwareProject
target_sw_project = SoftwareProject.objects.get(name__... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import Django Model for Code Lexicon Information
Step2: DATA FETCHING CODE
Step3: Lexical Analyzer
Step4: <a name="data_analysis"></a>
Step5:... |
3,117 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-2', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributo... | <SYSTEM_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... |
3,118 | <ASSISTANT_TASK:>
Python Code:
def __init__(self,lmbd,D):
self.lmbd = lmbd
self.D = D + 1
self.w = [0.] * self.D
def sign(self, x):
return -1. if x <= 0 else 1.
def hinge_loss(self,target,y):
return max(0, 1 - target*y)
def train(self,x,y,alpha):
if y*self.predict(x) < 1:
for i in xra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dataset
Step3: With data splited we should start building our model!
Step4: Last epoch results
Step5: Weight vector
Step6: Code Description
... |
3,119 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
def plot_sine1(a, b):
f = plt.figure(figsize=(16,2))
x = np.linspace(0, 4*np.pi, 1000)
plt.plot(x, np.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: Plotting with parameters
Step2: Then use interact to create a user interface for exploring your function
Step3: In matplotlib, the line style ... |
3,120 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
from sklearn.ensemble import RandomForestRegressor
from sklearn.tree import DecisionTreeRegressor
from sklearn.metrics import mean_absolute_error
from sklearn.model_selection import GridSearchCV, KFold, cross_val_predict
url = 'https://archive.ics.u... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, let's load the data. This week, we're going to load the Auto MPG data set, which is available online at the UC Irvine Machine Learning Rep... |
3,121 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('lc', times=np.linspace(0,1,101), dataset='lc01')
b['atm']
b['atm@primary']
b['atm@primar... | <SYSTEM_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: And we'll add a single light curve dataset to expose all the passb... |
3,122 | <ASSISTANT_TASK:>
Python Code:
# code for loading the format for the notebook
import os
# path : store the current path to convert back to it later
path = os.getcwd()
os.chdir(os.path.join('..', 'notebook_format'))
from formats import load_style
load_style(plot_style = False)
os.chdir(path)
import numpy as np
import 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: Chi-Square Feature Selection
Step2: One common feature selection method that is used with text data is the Chi-Square feature selection. The $\... |
3,123 | <ASSISTANT_TASK:>
Python Code:
@title License text
# 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 agree... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initialize Tensor Flow and GPU devices, import modules
Step2: Download raw images and annotation locally
Step11: Create a TensorFlow Datasets ... |
3,124 | <ASSISTANT_TASK:>
Python Code:
#dsfdskjfbskjdfbdkjbfkjdbf
#asdasd
#Mit einem Hashtag vor einer Zeile können wir Code kommentieren, auch das ist sehr wichtig.
#Immer, wirklich, immer den eigenen Code zu kommentieren. Vor allem am Anfang.
print("hello world")
#Der Printbefehl druckt einfach alles aus. Nicht wirklich w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: sad
Step2: Datentypen
Step3: Aktionen
Step4: Variablen, Vergleiche und Zuordnungen von Variablen
Step5: if - else - (elif)
Step6: Lists
Ste... |
3,125 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from sklearn.model_selection import train_test_split
import sklearn.metrics as metrics
# Set up code checking
from learntools.core import binder
binder.bind(globals())
from learntools.machine_learning.ex8 import *
print("Setup complete")
pulsar_data = pd.read_csv('../... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in the data and check out the first few rows to get acquainted with the features.
Step2: As normal, split the data into training and test ... |
3,126 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import time
plt.style.use('ggplot')
np.random.seed(1)
# Variável Aleatória X1
S_X1 = np.array([0., 1., 3., 4., 8., 11.]) # Espaço amostral de X1
fr_X1 = np.array([15., 28., 48., 14., 3., 7.]) # Frequências absolutas de X1
P_X1 = 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: Um exemplo com duas VADs
Step2: Para calcular a função de probabilidade conjunta $F\left(\mathbf{W}\right)$ da VAD bidimensional $\mathbf{W}=(X... |
3,127 | <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: Networks
Step2: Defining Networks
Step3: Let's create a RandomPyEnvironment to generate structured observations and validate our implementatio... |
3,128 | <ASSISTANT_TASK:>
Python Code:
from pomegranate import *
import math
c_table = [[0, 0, 0, 0.6],
[0, 0, 1, 0.4],
[0, 1, 0, 0.7],
[0, 1, 1, 0.3],
[1, 0, 0, 0.2],
[1, 0, 1, 0.8],
[1, 1, 0, 0.9],
[1, 1, 1, 0.1]]
d_table = [[ 0, 0, 0.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:
Step1: First let's define some conditional probability tables.
Step2: Then let's convert them into distribution objects.
Step3: Next we can convert t... |
3,129 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data')
def model_inputs(real_dim, z_dim):
inputs_real = tf.placeholde... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Model Inputs
Step2: Generator network
Step3: Discriminator
Step4: Hyperparameters
Step5: Build network
Step6: Discriminator and Generator L... |
3,130 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
pickle_file = 'notMNIST.pickle... | <SYSTEM_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 reload the data we generated in 1_notmnist.ipynb.
Step2: Reformat into a shape that's more adapted to the models we're going to train
Ste... |
3,131 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import os
import sys
import simpledbf
%pylab inline
import matplotlib.pyplot as plt
import statsmodels.api as sm
from sklearn.model_selection import train_test_split
from sklearn import linear_model
def runModel(dataset, income, varForModel):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Functions
Step2: Get Data
Step3: Modifiacion en variables
Step4: Para CABA
Step5: Modelo 1 b (educHeadYjobs)
Step6: Modelo 1 c (educHeadYjo... |
3,132 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy import integrate
def X(x):
return x**2
I,e=integrate.quad(X,0,3)
I
def integrand(x, a):
return 1.0/(x**2 + a**2)
def integral_approx(a):
# Use the args keyword argument to 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: Indefinite integrals
Step2: Integral 1
Step3: Integral 2
Step4: Integral 3
Step5: Integral 4
Step6: Integral 5
|
3,133 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.signal as sig
import matplotlib.pyplot as plt
%pylab inline
import test_signals as tst
def make_signals(nsamp,delay ):
ref = np.random.rand(nsamp+abs(delay))*2-1
wav = sig.ricker(80,5)
filtered = np.convolve(ref, wav,'same')
if delay < 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: Local Normalised Cross-correlation
Step2: Can we get a faster result using Numba?
|
3,134 | <ASSISTANT_TASK:>
Python Code:
mockDataFile = os.path.join(isotropy.example_data_dir, 'snFits.p.gz')
sampleData, totalSN = isotropy.read_mockDataPickle(mockDataFile)
sampleData.head()
# Total number of SN in the simulation (before we threw away bad points)
totalSN
sampleData['mu_err'] = sampleData.mu_var.apply(np.sqrt)... | <SYSTEM_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 statistics of binned quantities
Step2: Create a sample of sn with z, mu, mu_err
Step3: These show
|
3,135 | <ASSISTANT_TASK:>
Python Code:
filein = open('../data/protein.pdb', 'r')
fileout = open('../data/protein_hie.pdb', 'w')
#Finish...
filein.close()
fileout.close()
negative = set(['ARG', 'LYS']) #We consider histidines (HIS) neutral and epsilon protonated (thus the HIE name)
positive = #Finish
charged = #Finish... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Charge calculations
Step2: Now we need to count the number of residues. The problem is that if we count the number of GLU, ASP,... occurrences,... |
3,136 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import os
#if using Theano with GPU
#os.environ["KERAS_BACKEND"] = "tensorflow"
import random
import numpy as np
import keras
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from keras.preprocessing import image
from keras.applica... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting a dataset
Step2: This function is useful for pre-processing the data into an image and input vector.
Step3: Load all the images from r... |
3,137 | <ASSISTANT_TASK:>
Python Code:
from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_learn import KerasClassifier
from sklearn.model_selection import StratifiedKFold, cross_val_score
from sklearn.preprocessing import StandardScaler
import numpy as np
import pandas as pd
import ti... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Live ploting with Bokeh
Step2: Parameter tuning with grid search
|
3,138 | <ASSISTANT_TASK:>
Python Code:
# Authors: Mainak Jas <mainak.jas@telecom-paristech.fr>
# Eric Larson <larson.eric.d@gmail.com>
# Jaakko Leppakangas <jaeilepp@student.jyu.fi>
#
# License: BSD (3-clause)
import os.path as op
import pandas as pd
import numpy as np
import mne
from mne import combine_evoke... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To reduce memory consumption and running time, some of the steps are
Step2: The data was collected with a CTF 275 system at 2400 Hz and low-pas... |
3,139 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn.datasets import load_digits
digits = load_digits()
from IPython.html.widgets import interact
%matplotlib inline
import matplotlib.pyplot as plt
import NNpix as npx
def interact_fun(i):
plt.matshow(digits.images[i])
plt.show()
print("True Numbe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Visualizing our Data
Step4: Useful Functions
Step5: Neural Networks 1D Input
Step6: Here, the input is now 1D. Because it has 64 elements per... |
3,140 | <ASSISTANT_TASK:>
Python Code:
import os
com_port = 'COM12'
# com_port = 'COM13'
com_port = 'COM15'
# com_port = 'COM16'
# 現存檔案
files = !ampy --port {com_port} ls
files
# 清空
for file in files:
print('Deleting {0}'.format(file))
!ampy --port {com_port} rm {file}
def copy_one_file(folder, file):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 設定COM port (set current COM port)
Step2: 列出檔案 (list files)
Step3: 刪除檔案 (delete all files)
Step4: Functions for copying files
Step5: Copy 檔案到... |
3,141 | <ASSISTANT_TASK:>
Python Code:
from jax import lax
from jax._src import api
def multiply_add_lax(x, y, z):
Implementation of multiply-add using the jax.lax primitives.
return lax.add(lax.mul(x, y), z)
def square_add_lax(a, b):
A square-add function using the newly defined multiply-add.
return multiply_add_lax(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:
Step2: How JAX primitives work
Step9: In order to understand how JAX is internally using the primitives,
Step10: Instead of using jax.lax primitives ... |
3,142 | <ASSISTANT_TASK:>
Python Code:
!pip install fairness-indicators \
"absl-py==0.8.0" \
"pyarrow==0.15.1" \
"apache-beam==2.17.0" \
"avro-python3==1.9.1" \
"tfx-bsl==0.21.4" \
"tensorflow-data-validation==0.21.5"
%tensorflow_version 2.x
import os
import tempfile
import apache_beam as beam
import numpy as np
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: Next, import all the dependencies we'll use in this exercise, which include Fairness Indicators, TensorFlow Model Analysis (tfma), and the What-... |
3,143 | <ASSISTANT_TASK:>
Python Code:
def pricingSamples(T, number_of_samples,S0=25, SIGMA=1,
R=0.01, K=25):
'''
Produces samples of the selling price of an asset at time t=T,
given the parameters above.
'''
z = randn(number_of_samples)
s_T = S0*np.exp((R-0.5*SIGMA**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: Now that we have this function, we can use the samples to compute the expected price at time $T$.
Step2: Instead of computing the expected pric... |
3,144 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy
import pylab
import random
import time
import steps.model as smodel
import steps.solver as solvmod
import steps.geom as stetmesh
import steps.rng as srng
# The number of iterations to run
NITER = 10
# The data collection time increment (s)
DT = 0.001
# The simula... | <SYSTEM_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 set some parameters for our simulation. By keeping these variables grouped
Step2: At what stage these constants will be used will become... |
3,145 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data as input_data
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
print ("Packages imported")
mnist = input_data.read_data_sets("data/", one_hot=True)
trainimgs, trainlabels, testimgs, testlab... | <SYSTEM_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 will treat the MNIST image $\in \mathcal{R}^{28 \times 28}$ as $28$ sequences of a vector $\mathbf{x} \in \mathcal{R}^{28}$.
Step2: Out Netw... |
3,146 | <ASSISTANT_TASK:>
Python Code:
import nltk
g1 =
S -> NP VP
NP -> Det N | Det N PP | 'I'
VP -> V NP | VP PP
PP -> P NP
Det -> 'an' | 'my'
N -> 'elephant' | 'pajamas'
V -> 'shot'
P -> 'in'
grammar1 = nltk.CFG.fromstring(g1)
analyzer = nltk.ChartParser(grammar1)
oracion = "I shot an elephant in my pajamas".split()
# ... | <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: Gramáticas Independientes del Contexto (CFG)
Step3: Fíjate cómo hemos definido nuestra gramática
Step4: Con el objeto grammar1 ya creado, crea... |
3,147 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
#Customize default plotting style
%matplotlib inline
import seaborn as sns
sns.set_context('talk')
plt.rcParams["figure.figsize"] = (10, 8)
import os
from ase.build import bulk
from gpaw import GPAW, restart
if not os.path.exists('si-vac... | <SYSTEM_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: Wrapping Castep with f90wrap - CasPyTep
Step3: Single point calculation
Step4: Interactive introspection
Step5: Postproc... |
3,148 | <ASSISTANT_TASK:>
Python Code:
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.subplots(figsize=figsize, facecolor='... | <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: Principal Component Analysis
Step3: (1a) Interpretando o PCA
Step4: (1b) Matriz de Covariância
Step6: (1c) Função de Covariância
Step7: (1d)... |
3,149 | <ASSISTANT_TASK:>
Python Code:
import sys
print(sys.version)
print(2 / 3)
print(2 // 3)
print(2 - 3)
print(2 * 3)
print(2 ** 3)
print(12 % 5)
print("Welcome" + " to the " + "BornAgain" + " School")
print([1, 2, 3, 4] + [5, 6, 7, 8])
print((1, 2, 3, 4) + (5, 6, 7, 8))
print(5 < 6)
print(5 >= 6)
print(5 <= 6)
print(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:
Step1: At this point anything above python 3.5 should be ok.
Step2: Notes
Step3: Notes
Step4: Notes
Step5: Notes
Step6: Notes
Step7: Notes
Step8:... |
3,150 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format = "retina"
from matplotlib import rcParams
rcParams["savefig.dpi"] = 100
rcParams["figure.dpi"] = 100
rcParams["font.size"] = 20
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(123)
# Choose the "true" parameters.
m_true = -0.9594
b_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: The generative probabilistic model
Step2: The true model is shown as the thick grey line and the effect of the
Step3: This figure shows the le... |
3,151 | <ASSISTANT_TASK:>
Python Code:
# Please install this package using following command.
# $ pip install pandas-validator
import pandas_validator as pv
import pandas as pd
import numpy as np
# Create validator's instance
validator = pv.IntegerSeriesValidator(min_value=0, max_value=10)
series = pd.Series([0, 3, 6, 9]) # ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Series Validator
Step2: DataFrame Validator
|
3,152 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import c, pi
a = 0.192 # m
dx = 1e-4
x = np.arange(0, a+dx, step=dx, )
E = np.zeros_like(x)
# weights of the modes (example)
Ems = np.r_[0.2, 0, 1, 0.3, 0.1]
# total electric field is the sum of 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: Spatial signal
Step2: Fourier transform
|
3,153 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'sandbox-3', '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... |
3,154 | <ASSISTANT_TASK:>
Python Code:
import re
batRegex = re.compile(r'Bat(wo)?man') # The ()? says this group can appear 0 or 1 times to match; it is optional
mo = batRegex.search('The Adventures of Batman')
print(mo.group())
mo = batRegex.search('The Adventures of Batwoman')
print(mo.group())
mo = batRegex.search('The Adv... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: However, it cannot match multiple repititions
Step2: We can use this to find strings that may or may not include elements, like phone numbers w... |
3,155 | <ASSISTANT_TASK:>
Python Code:
from test import LisaTest
print LisaTest.__doc__
from energy_model import EnergyModel
print EnergyModel.__doc__
# juno_energy provides an instance of EnergyModel for ARM Juno platforms
from platforms.juno_energy import juno_energy
import pandas as pd
import matplotlib.pyplot as plt
%matp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Energy Model Related APIs
Step2: The above example shows how the EnergyModel class can be used to find optimal task placements. Here it is show... |
3,156 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
from google.cloud import bigquery
PROJECT = !(gcloud config get-value core/project)
PROJECT = PROJECT[0]
BUCKET = PROJECT # defaults to PROJECT
REGION = "us-central1" # Replace with your REGION
os.environ["PROJECT"] = PROJECT
os.environ["BUCKET"] = BUCKET
... | <SYSTEM_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... |
3,157 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
from google.cloud import bigquery
PROJECT = !gcloud config list --format 'value(core.project)'
PROJECT = PROJECT[0]
BUCKET = PROJECT
REGION = "us-central1"
os.environ["BUCKET"] = BUCKET
os.environ["REGION"] = REGION
bq = bigquery.Client(project=PROJECT)
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: Set environment variables so that we can use them throughout the entire lab. We will be using our project ID for our bucket, so you only need to... |
3,158 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import os
from pathlib import Path
from pprint import pprint
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import cellpy
from cellpy import prms
from cellpy import prmreader
from cellpy import cellreader
from cellpy.utils 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: Some functions
Step2: Checking
Step3: Initial exploration
Step4: Holomap (with selector)
Step5: Curve and HoloMap
Step6: Processing a cycle... |
3,159 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import zip
from builtins import range
from builtins import object
from past.utils import old_div
import pickle as pickle
import numpy ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepare the dataset. Download all works of Shakespeare concatenated. Other plain text files can also be used.
Step2: Conduct SGD
Step3: Check... |
3,160 | <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: 케라스를 사용한 다중 워커(Multi-worker) 훈련
Step2: 데이터셋 준비하기
Step3: 케라스 모델 만들기
Step4: 먼저 단일 워커를 이용하여 적은 수의 에포크만큼만 훈련을 해보고 잘 동작하는지 확인해봅시다. 에포크가 넘어감에 따라 손실... |
3,161 | <ASSISTANT_TASK:>
Python Code:
import time, os, re, zipfile
import numpy as np, pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import sklearn as sk, xgboost as xg
# from sklearn.model_selection import train_test_split
from sklearn.cross_validation import train_test_split
random_state = np.random.Rand... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now import some ML stuff
Step2: Mind the seed!!
Step3: Let's begin this introduction with usage examples.
Step4: As usual do the train-test s... |
3,162 | <ASSISTANT_TASK:>
Python Code:
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
from gensim import corpora
documents = ["Human machine interface for lab abc computer applications",
"A survey of user opinion of computer system response 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: if you want to see logging events.
Step2: This is a tiny corpus of nine documents, each consisting of only a single sentence.
Step3: Your way ... |
3,163 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
pickle_file = 'notMNIST.pickle... | <SYSTEM_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 reload the data we generated in 1_notmnist.ipynb.
Step2: Reformat into a shape that's more adapted to the models we're going to train
Ste... |
3,164 | <ASSISTANT_TASK:>
Python Code:
workDir = '/home/nick/notebook/SIPSim/dev/bac_genome1210/'
sourceDir = os.path.join(workDir, 'atomIncorp_evenness')
buildDir = os.path.join(workDir, 'atomIncorp_evenness_abund')
R_dir = '/home/nick/notebook/SIPSim/lib/R/'
import glob
from os.path import abspath
import nestly
from IPython... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Init
Step2: Nestly
Step3: Adding DESeq results table of 'NA' if file is not present
Step4: aggregating confusion matrix data
Step5: Plotting... |
3,165 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from w2v_utils import *
words, word_to_vec_map = read_glove_vecs('data/glove.6B.50d.txt')
word_to_vec_map
# GRADED FUNCTION: cosine_similarity
def cosine_similarity(u, v):
Cosine similarity reflects the degree of similariy between u and v
Argumen... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, lets load the word vectors. For this assignment, we will use 50-dimensional GloVe vectors to represent words. Run the following cell to lo... |
3,166 | <ASSISTANT_TASK:>
Python Code:
#Imort modules
from __future__ import print_function, division, absolute_import
import numpy as np
#Import citlalatonac from pyaneti_extras, note that pyaneti has to be compiled in your machine
#and pyaneti has to be in your PYTHONPATH, e.g., you have to add in your bashrc file
#export PY... | <SYSTEM_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 summon citlalatonac powers and create synthetic stellar data for K2-100
Step2: We can see that the behavior of the signal is similar to ... |
3,167 | <ASSISTANT_TASK:>
Python Code:
try:
import pycandela
except ImportError:
# Import hack for when in the pycandela source tree.
import sys
sys.path.append('..')
import pycandela
import requests
data = requests.get('https://raw.githubusercontent.com/vega/vega-datasets/gh-pages/data/iris.json').json()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Scatterplot matrix of JSON data
Step2: Scatterplot of a DataFrame
|
3,168 | <ASSISTANT_TASK:>
Python Code:
ht = hl.utils.range_table(10)
ht = ht.annotate(squared = ht.idx**2)
fig = ggplot(ht, aes(x=ht.idx, y=ht.squared)) + geom_line()
fig.show()
fig = ggplot(ht, aes(x=ht.idx, y=ht.squared)) + geom_col()
fig.show()
fig = ggplot(ht, aes(x=ht.idx, y=ht.squared)) + geom_point()
fig.show()
fig ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Every plot starts with a call to ggplot, and then requires adding a geom to specify what kind of plot you'd like to create.
Step2: aes creates ... |
3,169 | <ASSISTANT_TASK:>
Python Code:
import math
import pandas as pd
import scipy.stats as st
from IPython.display import Latex
from IPython.display import Math
from IPython.display import display
%matplotlib inline
path = r'./stroopdata.csv'
df_stroop = pd.read_csv(path)
df_stroop
mu_congruent = round(df_stroop['Congruent']... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Stroop Task
Step3: 5. Now, perform the statistical test and report your results. What is your confidence level and your critical statistic valu... |
3,170 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import matplotlib.pyplot as plt
%matplotlib inline
import cellpy.parameters.prms as prms
from cellpy import cellreader
from cellpy import log
log.setup_logging(default_level="DEBUG")
# print settings
prm_dicts = [d for d in dir(prms) if not d.startswith("_")]
for d 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: Some digging into the cellpy structure
Step2: Defining filenames etc
Step3: Loading and looking at what we got
Step4: dfsummary_made is wrong... |
3,171 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# 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 l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TensorFlow Probability on JAX
Step2: We can install TFP on JAX with the latest nightly builds of TFP.
Step3: Let's import some useful Python l... |
3,172 | <ASSISTANT_TASK:>
Python Code:
# import the dataset
from quantopian.interactive.data.quandl import fred_gdp
# Since this data is public domain and provided by Quandl for free, there is no _free version of this
# data set, as found in the premium sets. This import gets you the entirety of this data set.
# import data op... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data goes all the way back to 1947 and is updated quarterly.
Step2: Let's go plot for fun. 275 rows are definitely small enough to just put... |
3,173 | <ASSISTANT_TASK:>
Python Code:
import random
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# se have:
n_h = 140
n_t = 110
observations = (n_h, n_t)
n_observations = n_h + n_t
print observations, n_observations,
# We define the null hypothesis and the test statistic
def run_null_hypothesis(n_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:
Step3: USE-CASE
Step4: In the example above, like most of what will follow, we used the MC way to evaluate the p-value.
Step7: Is dice crooked ?
Step... |
3,174 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import h5py
import matplotlib.pyplot as plt
from testCases_v2 import *
from dnn_utils_v2 import sigmoid, sigmoid_backward, relu, relu_backward
%matplotlib inline
plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots
plt.rcParams['image.interpolation'] ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: 2 - Outline of the Assignment
Step4: Expected output
Step6: Expected output
Step8: Expected output
Step10: Expected output
Step12: <table s... |
3,175 | <ASSISTANT_TASK:>
Python Code:
import os
# The Google Cloud Notebook product has specific requirements
IS_GOOGLE_CLOUD_NOTEBOOK = os.path.exists("/opt/deeplearning/metadata/env_version")
# Google Cloud Notebook requires dependencies to be installed with '--user'
USER_FLAG = ""
if IS_GOOGLE_CLOUD_NOTEBOOK:
USER_FLAG... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Restart the kernel
Step2: Set up your Google Cloud project
Step3: Otherwise, set your project ID here.
Step4: Set project ID
Step5: Timestam... |
3,176 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
from itertools import compress
import mne
fnirs_data_folder = mne.datasets.fnirs_motor.data_path()
fnirs_cw_amplitude_dir = op.join(fnirs_data_folder, 'Participant-1')
raw_intensity = mne.io.read_raw_nirx(fnirs_cw_amp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Providing more meaningful annotation information
Step2: Viewing location of sensors over brain surface
Step3: Selecting channels appropriate f... |
3,177 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import cPickle as pickle
from copy import deepcopy
from sklearn.utils import shuffle
%matplotlib inline
plt.style.use("fivethirtyeight")
sns.set()
all_graphs = pickle.load(op... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: In addition to needing a train/test split, we need to ensure reasonable class balance. A simple approach to this is simply to shuffle both list... |
3,178 | <ASSISTANT_TASK:>
Python Code:
import math
import torch
import gpytorch
from matplotlib import pyplot as plt
%matplotlib inline
%load_ext autoreload
%autoreload 2
import urllib.request
import os.path
from scipy.io import loadmat
from math import floor
if not os.path.isfile('../3droad.mat'):
print('Downloading \'3d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Downloading Data
Step2: Using KeOps with a GPyTorch Model
Step3: Compute RMSE
|
3,179 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from IPython.display import Image
from IPython.display import HTML
display(Image(filename='images/portalpage.png'))
display(Image(filename='images/ipaddress.png'))
display(Image(filename='images/sophos01.png'))
display(Image(filename='images/sophos0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lorena Barba's tutorial, see this notebook for more detail on the Jupyter notebook.
Step2: IPython works by starting a web server on your PC an... |
3,180 | <ASSISTANT_TASK:>
Python Code:
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
from torchvision import datasets, transforms, models # add models to the list
from torchvision.utils import make_grid
import os
import numpy as np
import pandas as pd
import matplotl... | <SYSTEM_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 transforms
Step2: Prepare train and test sets, loaders
Step3: Display a batch of images
Step4: Define the model
Step5: <div class="al... |
3,181 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
print("Hello, world!")
string = "Hello, world!"
print(string)
import ee
ee.Initialize()
Image('http://www.google.com/earth/outreach/images/tutorials_eeintro_05_data_catalog.png')
srtm = ee.Image("CGIAR/SRTM90_V4")
info = srtm.getInfo()
print(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: Hello, World
Step2: That works, but we can also first store the content in a variable, and then print out the variable.
Step3: Hello, Images
S... |
3,182 | <ASSISTANT_TASK:>
Python Code:
# From the docstring
#x = sdr.capture(Tc, fo=88700000.0, fs=2400000.0, gain=40, device_index=0)
x = sdr.capture(Tc=5,fo=162.4e6,fs=2.4e6,gain=40,device_index=0)
sdr.complex2wav('capture_162475.wav',2400000,x)
fs, x = sdr.wav2complex('capture_162475.wav')
psd(x,2**10,2400);
def NBFM_demod... | <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: Narrowband FM Demodulator
|
3,183 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.interpolate import interp1d
traj = np.load('trajectory.npz')
x = traj['x']
y = traj['y']
t = traj['t']
assert isinstance(x, np.ndarray) and len(x)==40
assert isinstance(y, np.ndarray) 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: 2D trajectory interpolation
Step2: Use these arrays to create interpolated functions $x(t)$ and $y(t)$. Then use those functions to create the ... |
3,184 | <ASSISTANT_TASK:>
Python Code:
from salamanca.currency import Translator
xltr = Translator()
xltr.exchange(20, iso='AUT', yr=2010)
xltr.exchange(20, fromiso='AUT', toiso='USA', yr=2010) # equivalent to the above defaults
xltr.exchange(20, fromiso='AUT', toiso='USA',
fromyr=2010, toyr=2015)
xltr.excha... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Translating between currencies requires a number of different choices
Step2: Every translation is based on countries and years. By default, the... |
3,185 | <ASSISTANT_TASK:>
Python Code:
from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
IPythonConsole.ipython_useSVG=True
from rdkit.Chem import rdRGroupDecomposition
from IPython.display import HTML
from rdkit import rdBase
rdBase.DisableLog("rdApp.debug")
import pandas as pd
from rdkit.Chem import PandasToo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Perhaps we should file a bug that smarts doesn't show stereochem here.
Step2: Make some example stereochemistries
Step3: Make RGroup decomposi... |
3,186 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import holoviews as hv
hv.notebook_extension(bokeh=True, width=90)
%%output backend='matplotlib'
%%opts NdOverlay [aspect=1.5 figure_size=200 legend_position='top_left']
x = np.linspace(-1, 1, 1000)
curves = hv.NdOverlay(key_dimensions=['$\\beta$'])
for beta in [0.1, 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:
Step2: This gives us a nice way to move from our preference $x_i$ to a probability of switching styles. Here $\beta$ is inversely related to noise. For... |
3,187 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
%pylab inline
pylab.style.use('ggplot')
import seaborn as sns
data_df = pd.read_csv('diagnosis.csv', sep='\t', decimal=',', header=None)
data_df.head()
data_df.columns = ['temp', 'nausea', 'lumber_pain', 'urine_pushing', 'micturiation_pain',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Attribute Information
Step2: Bivariate Analysis - Inflammation
Step3: The Logistic Regression Model for Inflammation
Step4: Bivariate Analysi... |
3,188 | <ASSISTANT_TASK:>
Python Code:
# import required dependencies
from neo4j.v1 import GraphDatabase, basic_auth
from pandas import DataFrame
import graphistry
# To specify Graphistry account & server, use:
# graphistry.register(api=3, username='...', password='...', protocol='https', server='hub.graphistry.com')
# For mor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Connect To Neo4j
Step2: Once we've instantiated our Driver, we can use Session objects to execute queries against Neo4j. Here we'll use session... |
3,189 | <ASSISTANT_TASK:>
Python Code:
#$HIDE_INPUT$
import pandas as pd
reviews = pd.read_csv("../input/wine-reviews/winemag-data-130k-v2.csv", index_col=0)
pd.set_option('max_rows', 5)
reviews.price.dtype
reviews.dtypes
reviews.points.astype('float64')
reviews.index.dtype
reviews[pd.isnull(reviews.country)]
reviews.regi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Alternatively, the dtypes property returns the dtype of every column in the DataFrame
Step2: Data types tell us something about how pandas is s... |
3,190 | <ASSISTANT_TASK:>
Python Code:
import os
os.environ['THEANO_FLAGS']='mode=FAST_COMPILE,optimizer=None,device=cpu,floatX=float32'
import numpy as np
import sklearn.cross_validation as skcv
#x = np.linspace(0, 5*np.pi, num=10000, dtype=np.float32)
x = np.linspace(0, 4*np.pi, num=10000, dtype=np.float32)
y = np.cos(x)
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: Playing with the number of hidden units
Step2: With random forest
|
3,191 | <ASSISTANT_TASK:>
Python Code:
# Code to generate the toy example (let us not worry how this code works)
nums = np.arange(1000, 6000, 1000) \
+ np.round(np.random.RandomState(0).normal(0., 200., size=5,)).astype(np.int)
df = pd.DataFrame(dict(Numbers=nums, meanX=np.power(nums, 0.5)/5.,
stdX=... | <SYSTEM_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: Step 2
Step3: We can check (as it obviously must) that this matches our numbers if Nobj equals the total number of objects in ou... |
3,192 | <ASSISTANT_TASK:>
Python Code:
# imports
from importlib import reload
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline as IUS
from astropy import units as u
from frb.halos.models import ModifiedNFW
from frb.halos import models as frb_halos
from frb.halos import hmf as frb_hmf
from frb.dm 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: $\langle \rho_{diffuse, cosmic}\rangle$
Step2: $\langle n_{e,cosmic}\rangle$
Step3: $\langle DM_{cosmic}\rangle$
Step4: $\langle DM_{halos}\r... |
3,193 | <ASSISTANT_TASK:>
Python Code:
#1.1
import math
print('{:.4}'.format(math.pi))
#1.2 - no for loop
print('{:5.4}'.format(math.sqrt(1)))
print('{:5.4}'.format(math.sqrt(2)))
print('{:5.4}'.format(math.sqrt(3)))
print('{:5.4}'.format(math.sqrt(4)))
print('{:5.4}'.format(math.sqrt(5)))
#1.2 - for loop
for i in range(1, 6):... | <SYSTEM_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. Representing Numbers (5 Points)
Step2: 4. Lists and Slicing (11 Points)
Step3: 5. Numpy (12 Points)
Step4: 6. Plotting (16 Points)
|
3,194 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from astropy import units as u
class SpaceRock(object):
def __init__(self, name=None, ab_mag=None, albedo=None):
self.name = name
self.ab_mag = ab_mag
self.albedo = albedo
# Create some fake data:
my_name = "Geralt of Rivia"
my_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: We can see what values are stored in each attribute like this
Step2: Methods
Step3: To use a method you need to add () to the end of the metho... |
3,195 | <ASSISTANT_TASK:>
Python Code:
import pickle,glob
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
%pylab inline
def placeStartpoint(npts,fixedpts):
#Start Point
#start = (0.5,0.5)
start = (np.random.random(),np.random.random())
if fixedpts == []: #generates a set of random vertic... | <SYSTEM_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 Fractal From Random Points - The Chaos Game
Step2: Make A Fractal
Step3: Regular Polygons
Step4: Exploring Further
Step5: Randomn... |
3,196 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
from korg import korg
from korg.pattern import PatternRepo
import tarfile
from loganalyser import plot
pr = PatternRepo(['./korg_patterns/'], False)
lg = korg.LineGrokker('%{AOGAERU_LOAD}', pr)
df = pd.DataFrame()
# now grok the aogaeru load log
wit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Aogaeru load
Step2: LINUX_VMSTAT
Step3: convert the dataframe data into Json format
Step4: TODO
Step5: Access logs
|
3,197 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from matplotlib import animation
from IPython.display import HTML
font = {'size' : 15}
matplotlib.rc('font', **font)
def F_matrix(m):
F = np.zeros((m,m),dtype=complex)
for j in range(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: Pseudospectral collocation methods
Step2: Notice that $F$ is symmetric; this is true for any value of $m$. Also, $F$ is essentially unitary --... |
3,198 | <ASSISTANT_TASK:>
Python Code:
a=3.765
import numpy as np
import elephant
import neo
import quantities as pq
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from IPython.display import HTML
import matplotlib.animation as animation
# Load block from ANDA dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Print the value of the variable in markdown using
Step2: Matplotlib notebook<a id='matnb'></a>
Step3: Animated plots with HTML<a id='ani'></a... |
3,199 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import entrofy
import matplotlib.pyplot as plt
%matplotlib nbagg
df = pd.read_csv('/home/bmcfee/data/vggish-likelihoods-a226b3-maxagg10.csv.gz', index_col=0)
df.head(5)
(df >= 0.5).describe().T.sort_values('freq')
df.median()
N_OUT = 23 * 100
mapper... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Binary thresholding
Step2:
Step3: Multi-valued thresholds
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.