Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
13,600 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from random import randint
from pandas import Series,DataFrame
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib
import math
%matplotlib inline
plt.rcParams['figure.figsize'] = (8, 6)
plt.rcParams['font.size'] = 14
from sklearn... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Make Random dataset.
Step2: Start with X0 split, then X1 split.
Step3: Now try out X1 first then X0.
|
13,601 | <ASSISTANT_TASK:>
Python Code:
from beampy import *
# Remove quiet=True to get beampy compilation outputs
doc = document(quiet=True)
with slide('Animation from svg files'):
animatesvg("./ressources/svg_anims/*.svg", width="600")
display_matplotlib(gcs())
import pylab as p
with slide('Animation from matplotlib figu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From matplotlib figure list
|
13,602 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import algos
import features
import parametric
import policy
import chicken
from agents import OffPolicyAgent, OnPolicyAgent
from rlbench import *
# define the experiment
num_states =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Assessing Learning Algorithms
Step2: What do the target values look like?
Step3: Actual Testing
Step4: These algorithms are given to OffPolic... |
13,603 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from math import radians, cos, sin, asin, sqrt
import itertools
from sklearn import neighbors
from sklearn import preprocessing
from sklearn import ensemble
from sklearn.model_selection import LeaveOneGroupOut, LeavePGroupsOut
import inversion
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: Load training data
Step2: Build features
Step3: Because solving the sum of squares equation involved the quadratic formula, in some cases imag... |
13,604 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
path = "data/dogscats/"
#path = "data/dogscats/sample/"
from __future__ import division,print_function
import os, json
from glob import glob
import numpy as np
np.set_printoptions(precision=4, linewidth=100)
from matplotlib import pyplot as plt
import utils; reload(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: Define path to data
Step2: A few basic libraries that we'll need for the initial exercises
Step3: We have created a file most imaginatively ca... |
13,605 | <ASSISTANT_TASK:>
Python Code:
import pp
gap = 0.2
wg_width = 0.5
length = 10
yaml = f
instances:
sl:
component: coupler_symmetric
settings:
gap: {gap}
wg_width: {wg_width}
sr:
component: coupler_symmetric
settings:
gap: {gap}
wg_width: {wg_width}
cs:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: YAML component connections
Step5: While this one has the sbend_left_coupler sl centered at (100, 0)
Step7: You can rotate and instance specify... |
13,606 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
survey_data = pd.read_csv("data/surveys.csv")
survey_data.head()
# %load _solutions/case2_observations_processing1.py
datasetname = "Ecological Archives E090-118-D1."
# %load _sol... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Scenario
Step2: <div class="alert alert-success">
Step3: Adding the data source information as static column
Step4: Adding this static value ... |
13,607 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import pandas as pd
pd.set_option('display.width', 500)
pd.set_option('display.max_columns', 100)
pd.set_option('display.notebook_repr_html', True)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Each of the datasheets downloaded from ELSI had download metadata on the top of them and total and key information on the bottom of them that we... |
13,608 | <ASSISTANT_TASK:>
Python Code:
from pprint import pprint
import numpy as np
import contextlib
@contextlib.contextmanager
def printoptions(*args, **kwargs):
original = np.get_printoptions()
np.set_printoptions(*args, **kwargs)
yield
np.set_printoptions(**original)
## compact print (numpy array)
def cpr... | <SYSTEM_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 construct the vocabulary and the doc-term matrix.
Step2: Now we transform raw tf to tf by $1 + \log(tf)$.
Step3: Adding idf
Step4: We ... |
13,609 | <ASSISTANT_TASK:>
Python Code:
from keras.datasets import imdb
(train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)
max([max(sequence) for sequence in train_data])
# word_index is a dictionary mapping words to an integer index
word_index = imdb.get_word_index()
# We reverse it, mappi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: num_words=10000 表示我們只採用前 10000 個常出現的字詞,此外在 label 中 0 表示負評 1 表示正評。
Step2: 也可以透過字典檔,將資料組合回評論文字。
Step3: 處理資料
Step4: 將結果標記進行正規化
Step5: 建立網路架構
St... |
13,610 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from IPython.display import display, HTML
CSS =
.output {
flex-direction: row;
}
patient_data = pd.read_csv("../data/Exercises_Summary_Statistics_Data.csv")
patient_data.head()
patients = # Subtet patient_data to include only patients
control =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Summary Statistics - Exercises
Step2: Exercise 1 - Lets get a quick look at the groups
Step3: Find out the Age means for each of the groups
St... |
13,611 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from owslib.csw import CatalogueServiceWeb
from owslib import fes
from pprint import pprint
fmt = '{:*^64}'.format
def fes_date_filter(start, stop, constraint='overlaps'):
Take datetime-like objects and returns a fes filter for date range
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: IOOS CSW queries
Step2: GeoPortal uuid's for NGDC IOOS Collections
Step3: Query 1
Step4: Run CSW query
Step5: Note that the COOPS SOS is not... |
13,612 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('olympics.csv', index_col=0, skiprows=1)
for col in df.columns:
if col[:2]=='01':
df.rename(columns={col:'Gold'+col[4:]}, inplace=True)
if col[:2]=='02':
df.rename(columns={col:'Silver'+col[4:]}, inplace=True)
if col[:2]=='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: Question 0 (Example)
Step2: Question 1
Step3: Question 2
Step4: Question 3
Step5: Question 4
Step6: Part 2
Step7: Question 6
Step8: Quest... |
13,613 | <ASSISTANT_TASK:>
Python Code:
# 1. Input model parameters and print
# 2. Compute the steady state of the model directly
# 3. Define a function that evaluates the equilibrium conditions
def equilibrium_equations(variables_forward,variables_current,parameters):
# Parameters
p = parameters
# Variab... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Add Output and Investment
Step2: Evaluation
|
13,614 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from scipy import ndimage
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from model import OrderExtend
img = ndimage.imread('images/boat.jpeg', flatten=True)
img /= np.max(img) #normalize image [0,1]
plt.imshow(img, cmap = cm.Greys_r)
nx,... | <SYSTEM_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 model.
Step2: Now we set the iteration number to 1000, and rerun the model.
Step3: The model cannot solve any dimension of $x$-axi... |
13,615 | <ASSISTANT_TASK:>
Python Code:
import copy
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import shap.benchmark as benchmark
import shap
import scipy as sp
import nlp
import torch
pd.set_option('display.max_columns', None... | <SYSTEM_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 and Model
Step2: Class Label Mapping
Step3: Define Score Function
Step4: Create Explainer Object
Step5: Run SHAP Explanation
Step6... |
13,616 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.random.seed(29384924)
data = np.random.randint(10, size = 100)
print(data)
print("Number of data points: {}".format(data.shape[0]))
print("Largest value: {}".format(data.max()))
print("Smallest value: {}".format(data.min()))
print(data.mean()) # Mean
outlier = np... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Some very straightforward statistics are the number of data points, the largest value, and the smallest value. These shouldn't be immediately ig... |
13,617 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from scipy import integrate
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.colors import cnames
from matplotlib import animation
import seaborn as sns
import butter_lowpass_filter as blf
def solve_lorenz(... | <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: Let's write a quick Lorenz solver
Step3: Let's plot this solution
Step5: Very pretty. If you are curious, you can even change the plot angle w... |
13,618 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
sns.set_context('talk')
import csv
import urllib2
import StringIO
%matplotlib inline
ceb = pd.read_csv('http://data.princeton.edu/wws509/datasets/ceb.dat', sep='\s+')
ceb.head()
ceb_int = pd.rea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Children Ever Born is a dataset of birthrates in Fiji from the World Fertility Survey with the following columns
Step2: With the these columns ... |
13,619 | <ASSISTANT_TASK:>
Python Code:
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
X, y = make_classification(n_features=1, n_informative=1, n_redundant=0, n_clusters_per_class=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: Con la función make_classification de scikit-learn, creamos un conjunto de datos para clasificar. Para empezar vamos a contar con sólo un atribu... |
13,620 | <ASSISTANT_TASK:>
Python Code:
import oommfc as oc
import discretisedfield as df
%matplotlib inline
print(df.__file__)
system = oc.System(name="first_notebook")
A = 1e-12 # exchange energy constant (J/m)
H = (5e6, 0, 0) # external magnetic field in x-direction (A/m)
system.hamiltonian = oc.Exchange(A=A) + oc.Demag(... | <SYSTEM_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 create a system object and provide
Step2: Our Hamiltonian should only contain exchange, demagnetisation, and Zeeman energy terms. We will ap... |
13,621 | <ASSISTANT_TASK:>
Python Code:
def load_data():
path = 'data/cifar-10-batches-py'
num_train_samples = 50000
x_train = np.zeros((num_train_samples, 3, 32, 32), dtype='uint8')
y_train = np.zeros((num_train_samples,), dtype='uint8')
for i in range(1, 6):
data, labels = load_batch(os.path.join(p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here's an example of CIFAR-10
Step2: We want to normalize pixel values (0-255) to unit interval.
Step3: Densenet
Step4: Convolutional layer
S... |
13,622 | <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: Training and evaluation with the built-in methods
Step2: 시작하기
Step3: 일반적인 엔드 투 엔드 워크 플로는 다음과 같이 구성되어 있습니다.
Step4: 훈련 구성(최적화 프로그램, 손실, 메트릭)을 지... |
13,623 | <ASSISTANT_TASK:>
Python Code:
%load_ext sql
%%sql mysql://admin:admin@172.20.101.81/pidata
DROP TABLE if exists temps3;
CREATE TABLE temps3 (
device varchar(20) DEFAULT NULL,
datetime datetime DEFAULT NULL,
temp float DEFAULT NULL,
hum float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
%sql ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <b>Connect to the MySQL database instance using and account that has admin access and run SQL to drop/create table
Step2: Check to see that the... |
13,624 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from IPython.display import HTML
# Import from local directory
# import sys
# sys.path.insert(0, '../pypdb')
# from pypdb import *
# Import from installed package
from pypdb import *
%load_ext autoreload
%autoreload 2
found_pdbs = Query("ribosome").search()
print(found_pdbs... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Search functions that return lists of PDB IDs
Step2: Search by PubMed ID Number
Step3: Search by source organism using NCBI TaxId
Step4: Sear... |
13,625 | <ASSISTANT_TASK:>
Python Code:
### START CODE HERE ### (≈ 1 line of code)
test = "Hello World"
### END CODE HERE ###
print ("test: " + test)
# GRADED FUNCTION: basic_sigmoid
import math
def basic_sigmoid(x):
Compute sigmoid of x.
Arguments:
x -- A scalar
Return:
s -- sigmoid(x)
#... | <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: Expected output
Step3: Expected Output
Step4: In fact, if $ x = (x_1, x_2, ..., x_n)$ is a row vector then $np.exp(x)$ will apply the exponent... |
13,626 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cas', '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... |
13,627 | <ASSISTANT_TASK:>
Python Code:
#@title Copyright 2020 The Earth Engine Community Authors { display-mode: "form" }
#
# 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/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: Detecting Changes in Sentinel-1 Imagery (Part 1)
Step2: Datasets and Python modules
Step3: And in order to make use of interactive maps, we im... |
13,628 | <ASSISTANT_TASK:>
Python Code:
import os
import requests
import gzip
from six.moves import cPickle as pkl
import time
import numpy
import theano
import theano.tensor as T
from theano.tensor.nnet import categorical_crossentropy
from theano import config
from fuel.datasets import TextFile
from fuel.streams import DataStr... | <SYSTEM_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 Model
Step2: The next block contains some code that computes cross-entropy for masked sequences and a stripped down version of the logistic... |
13,629 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import math
import random
import string
from scipy import optimize
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.html.widgets import interact
from sklearn.datasets import load_digits
digits = load_digits()
print(digits.data.shape)
Neron for for detrmi... | <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: Core Algorithms
Step3: Neuron Layer
Step4: Training Set
Step5: Visualizations
|
13,630 | <ASSISTANT_TASK:>
Python Code:
# Ensure that the github-issues-data volume is mounted in /mnt
!ls -la /mnt
# Set path for data dir
%env DATA_DIR=/mnt/github-issues-data
# Download the github-issues.zip training data to /mnt/github-issues-data
!wget --directory-prefix=${DATA_DIR} https://storage.googleapis.com/kubeflow-... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Process Data
Step2: Convert to lists in preparation for modeling
Step3: Pre-Process Data For Deep Learning
Step4: Look at one example of proc... |
13,631 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.insert(0, "..")
import sqlite3
import datetime
import os
import osmdigest.sqlite as sq
# Delete the database if it already exists.
try:
os.remove("demo.db")
except FileNotFoundError:
pass
import os
filename = os.path.join("//media", "disk", "OSM_Data", "isle-of... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Similarly for relations. It is worth noting something a little surprising about the input data here. The first relation returned is "Scotland"... |
13,632 | <ASSISTANT_TASK:>
Python Code:
%%capture
# Installing the required libraries:
!pip install matplotlib pandas scikit-learn tensorflow pyarrow tqdm
!pip install google-cloud-bigquery google-cloud-bigquery-storage
!pip install flake8 pycodestyle pycodestyle_magic
# Python Builtin Libraries
from datetime import datetime
# ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Authentication
Step3: Configurations
Step5: Data Preparation
Step6: Check the Dataframe
Step7: Process the Dataframe
|
13,633 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from medpy.io import load
import matplotlib.pyplot as plt
import matplotlib.cm as cm
i, h = load("flair.nii.gz")
plt.imshow(i, cmap = cm.Greys_r);
print(h)
from medpy.io import header
print header.get_pixel_spacing(h)
print header.get_offset(h)
header.set_pixel_spac... | <SYSTEM_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 let's take a look at the header.
Step2: That is quite a lot of information and the header appear to be of class 'nibabel.nifti1.Nifti1Image... |
13,634 | <ASSISTANT_TASK:>
Python Code:
# We need scipy for .wav file IO.
!pip install tensorflowjs==2.1.0 scipy==1.4.1
# TensorFlow 2.3.0 is required due to https://github.com/tensorflow/tensorflow/issues/38135
# TODO: Switch to 2.3.0 final release when it comes out.
!pip install tensorflow-cpu==2.3.0
!mkdir -p /tmp/tfjs-sc-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: Below we download the files of the original or transfer-learned TF.js Speech Commands model.
Step2: As a required step, we download the audio ... |
13,635 | <ASSISTANT_TASK:>
Python Code:
import cufflinks as cf
# The colors module includes a pre-defined set of commonly used colors
cf.colors.cnames
# HEX to RGB
cf.colors.hex_to_rgb('red')
# RGB to HEX
cf.colors.rgb_to_hex('rgb(219, 64, 82)')
# RGB or HEX to RGBA (transparency)
cf.colors.to_rgba('#3780bf',.5), cf.colors.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: Colors can be represented as strings
Step2: Normalization
Step3: Color Ranges
Step4: Color Tables
Step5: Color Generators
|
13,636 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import LakeModel
alpha = 0.012
lamb = 0.2486
b = 0.001808
d = 0.0008333
g = b-d
N0 = 100.
e0 = 0.92
u0 = 1-e0
T = 50
LM0 = LakeModel.LakeModel(lamb,alpha,b,d)
x0 = LM0.find_steady_state()# initial conditions
print "Initial Steady State: ", x0
LM1 = LakeModel.LakeModel(0.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 construct the class containing the initial conditions of the problem
Step2: New legislation changes $\lambda$ to $0.2$
Step3: Now plot sto... |
13,637 | <ASSISTANT_TASK:>
Python Code:
prglngth_cdf = st.Cdf(live.prglngth, label='Pregnancy length')
prglngth_cdf.plot()
firsts_cdf = st.Cdf(firsts.prglngth, label='first babies')
others_cdf = st.Cdf(others.prglngth, label='other babies')
fig = st.multiplot([firsts_cdf, others_cdf], title='CDF of Pregnancy Length')
import 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: Methods
Step2: The plot function for cdfs can take a complement argument, and a yscale argument
Step3: Testing if a distribution is Normal
Ste... |
13,638 | <ASSISTANT_TASK:>
Python Code:
tot_moves = 0
all_moves = []
num_runs = 10000
for i in range(num_runs):
game.run()
moves = SL.count_moves(game.records)
tot_moves += moves
all_moves.append(moves)
print(tot_moves/num_runs)
max(all_moves)
df = pd.DataFrame({'moves': all_moves})
df.describe()
type(df['moves'... | <SYSTEM_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 want as many bins as there are integers between the lowest and highest number of moves found in the data!
|
13,639 | <ASSISTANT_TASK:>
Python Code:
# for plotting purposes
%matplotlib inline
from matplotlib.pylab import plt
from matplotlib import rcParams
dark_colors = ["#A51C30", "#808080",
(0.8509803921568627, 0.37254901960784315, 0.00784313725490196),
(0.4588235294117647, 0.4392156862745098, 0.70196... | <SYSTEM_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 preparation
Step2: One contribution to this aggregated data is the cycles of the fridge plotted below.
Step3: Of course there are many ot... |
13,640 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from keras.layers import LSTM
from keras.callbacks import ModelCheckpoint
from keras.utils import np_utils
from time import gmtime, strftime
import os
import re
import pi... | <SYSTEM_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 need to do is generate our training data set. In this case we will use a recent article written by Barack Obama for The Econo... |
13,641 | <ASSISTANT_TASK:>
Python Code:
# Author: Marijn van Vliet <w.m.vanvliet@gmail.com>
# Roman Goj <roman.goj@gmail.com>
# Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import numpy as np
import mne
from mne.datasets import sample
from mne.time_frequency import csd_morlet
from mne.be... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading the raw data
Step2: Computing the cross-spectral density matrix at 4 evenly spaced frequencies
|
13,642 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
from google.cloud import bigquery
%load_ext google.cloud.bigquery
PROJECT = # Replace with your PROJECT
BUCKET = PROJECT
REGION = "us-east1"
os.environ['PROJECT'] = PROJECT
os.environ['BUCKET'] = BUCKET
os.environ['REGION'] = REGION
%%bigquery --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: Replace the variable values in the cell below
Step2: Create a Dataset from BigQuery
Step3: Let's do some regular expression parsing in BigQuer... |
13,643 | <ASSISTANT_TASK:>
Python Code:
publisher = IoT_mqtt_publisher("localhost", 1883)
sensor_1 = IoT_sensor("1", "temperature", "°C", 20, 26, 2)
sensor_2 = IoT_sensor("2", "umidade", "%", 50, 60, 3)
sensor_3 = IoT_sensor("3", "temperature", "°C", 28, 30, 4)
sensor_4 = IoT_sensor("4", "umidade", "%", 40, 55, 5)
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: Componente para simulação de um sensor
Step2: Conectando os Componentes
|
13,644 | <ASSISTANT_TASK:>
Python Code:
import warnings
import scipy as sp
import numpy as np
import openpnm as op
%config InlineBackend.figure_formats = ['svg']
np.set_printoptions(precision=4)
np.random.seed(10)
%matplotlib inline
from pathlib import Path
path = Path('../_fixtures/ICL-Sandstone(Berea)/')
project = op.io.Stat... | <SYSTEM_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 following assumes that the folder containing the 'dat' files is in a directory called 'fixtures' in the same directory as this script. You ... |
13,645 | <ASSISTANT_TASK:>
Python Code:
%%sh
pip install pandas
pip install scikit-learn
pip install keras
from __future__ import print_function
import numpy as np
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
from keras.preprocessing import sequence
from keras.models import Sequential
from keras.layers... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We load the training and testing data to preprocess it for further analysis.
Step2: We fill the missing data values in the PE field with zero a... |
13,646 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-2', 'ocnbgchem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
13,647 | <ASSISTANT_TASK:>
Python Code:
# Keep the original SGD
sgd_orig = sgd.copy()
# Find overlapping genes in park's data
loci=[]
for i in range(len(sgd)-10):
for j in range(1,10):
if sgd.ix[i,'max'] >= sgd.ix[i+j,'min_cassette'] and sgd.ix[i,'chromosome'] == sgd.ix[i+j,'chromosome']:
loci.append(sg... | <SYSTEM_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 wiggle objects of sequenced gcn4 Pol_II and Mediator data
Step2: I compare ChIP-seq and ChEC-seq
Step3: <font color=green>Interesting...<... |
13,648 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
iris = pd.read_csv('../datasets/iris.csv')
# Print some info and statistics about the dataset
iris.info()
iris.Class.unique()
iris.describe()
# Encode the classes to numeric values
class_encodings = {'Iris-setosa': 0, 'Iris-versicolor': 1, 'Iris-virginica': 2}
iris.Cla... | <SYSTEM_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 data
Step2: Classifying species
|
13,649 | <ASSISTANT_TASK:>
Python Code:
graph = {
"A": {"B": (12, 3), "C":(25, 6), },
"B": {"C": (11, 2), },
"C": {"A": (30, 6), "D": (16, 4), },
"D": {"A": (12, 2), },
}
# decompose graph into separate cost and time graphs
graph_c = {key: {key2: -val2[0] for (key2, val2) in value.items()}
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: I will encode the graph as a python dictionary. Each vertex is a key. The value for this key is another dictionary. This dictionary has keys f... |
13,650 | <ASSISTANT_TASK:>
Python Code:
from sklearn.cluster import KMeans
df = load_data()
kmeans = KMeans(n_clusters=2)
labels = kmeans.fit_predict(df[['mse']])
<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:
|
13,651 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import json
classfile_in = 'ap-aas229-test-classifications.csv'
classifications = pd.read_csv(classfile_in)
len(classifications)
classifications
subjectsfile_in = 'ap-aas229-test-subjects.csv'
subjects = pd.read_csv(subjectsfile_in)
workflowsfile_in = 'ap-aas229-test... | <SYSTEM_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 and examine content of "classifications" table.
Step2: Read-in and examine content of "subjects" and "workflows" table.
Step3: Expandi... |
13,652 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn.metrics import mean_squared_error
import datetime as dt
from math import sqrt
data = pd.read_csv('./all_stocks_5yr.csv')
data.shape
data.head()
data.dtypes
data['Date'] = pd.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: Explore the Kaggle dataset all_stocks_5yrs.csv
Step2: For each trading day we have the ticker symbol (Name) and the price at opening (Open), cl... |
13,653 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# setup Lambert Conformal basemap.
m = Basemap(width=12000000,height=9000000,projection='lcc',
resolution='c',lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
# draw coastlines.
m.drawcoastlin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Draw coastlines, filling ocean and land areas.
Step2: Draw a land-sea mask as an image.
Step3: Draw the NASA ‘Blue Marble’ image.
Step4: Draw... |
13,654 | <ASSISTANT_TASK:>
Python Code:
#instructor key info
n1 = 11 * 7
e1 = 37
d1 = 13
#student key info
n2 = 13 * 19
e2 = 41
d2 = 137
grade = 5
m = pow(grade, e2, n2)
signature = pow(m, d1, n1)
print(f'message|signature: {m}|{signature}')
if (pow(m, e1, n1) != signature):
print("Failed to verify")
# Choose big ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problem 2 (10 points)
Step2: 2.Implement functions that implement the encryption and decryption functions. (2 points)
Step3: 3.Test your funct... |
13,655 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
import PyFBA
model_functions_file = "data/citrobacter.assigned_functions"
close_genomes_functions_file = "data/close_genomes_functions"
org_name = "Citrobacter sedlakii"
org_id = "Citrobacter sedlakii"
model = PyFBA.model.roles_to_model(model_functions_file, org_id, ... | <SYSTEM_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 model
Step2: The model has been generated and is now ready to use for flux-balance analysis simulations. Running flux-balance analysis... |
13,656 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset 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: 图像分类
Step2: 探索数据
Step5: 实现预处理函数
Step8: One-hot 编码
Step10: 随机化数据
Step12: 检查点
Step17: 构建网络
Step20: 卷积和最大池化层
Step23: 扁平化层
Step26: 全连接层
Ste... |
13,657 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn import datasets
iris = datasets.load_iris()
X_train = iris.data[iris.target != 2, :2] # first two features and
y_train = iris.target[iris.target != 2] # first two labels only
fig = plt.figure(figsize=(8,8))
mycolors = {"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: We'll train a logistic regression model of the form
Step2: Q
Step3: Problem 2
Step4: Let's also store the documents in a list as follows
Ste... |
13,658 | <ASSISTANT_TASK:>
Python Code:
#This notebook also uses the `(some) LaTeX environments for Jupyter`
#https://github.com/ProfFan/latex_envs wich is part of the
#jupyter_contrib_nbextensions package
from myhdl import *
from myhdlpeek import Peeker
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%ma... | <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: IP ClockDivider
|
13,659 | <ASSISTANT_TASK:>
Python Code:
from vis_int import *
import vis_int
print(dir(vis_int))
def biseccion(funcion, a, b, tol_x = 1e-6, factor_ty = 1e2):
f0 = funcion(a)
f1 = funcion(b)
if abs(f0) < tol_x: # Se verifica que los extremos sean raices
return a
elif abs(f1) < tol_x:
return 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: Técnicas Numéricas
Step2: Se observa en la implementación del método de bisección, que se considera una revisión extra a los códigos tradiciona... |
13,660 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from six.moves import range
# Setup Pandas
pd.set_option('display.width', 500)
pd.set_option('display.max_... | <SYSTEM_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: Explore
Step3: <div class="span5 alert alert-info">
Step4: Naive Bayes
Step5: Picking Hyperparameters for Naive Bay... |
13,661 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
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('mesh', compute_times=[0.75], dataset='mesh01')
b['requiv@primary@component'] = 1.8
b.ru... | <SYSTEM_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: Adding Datasets
Step3: Running Compute
Step4: Now we'll compute ... |
13,662 | <ASSISTANT_TASK:>
Python Code:
fig, ax = plt.subplots(figsize=(8,6))
ax.scatter(data['X1'], data['X2'], s=50, c=data['y'], cmap='Reds')
ax.set_title('Raw data')
ax.set_xlabel('X1')
ax.set_ylabel('X2')
svc1 = sklearn.svm.LinearSVC(C=1, loss='hinge')
svc1.fit(data[['X1', 'X2']], data['y'])
svc1.score(data[['X1', 'X2']],... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: try $C=1$
Step2: try $C=100$
|
13,663 | <ASSISTANT_TASK:>
Python Code:
from collections import OrderedDict # For recording the model specification
import pandas as pd # For file input/output
import numpy as np # For vectorized math operations
import pylogit as pl # For MNL model estimation and
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load and filter the raw Swiss Metro data
Step2: Convert the Swissmetro data to "Long Format"
Step3: Perform desired variable creations and tra... |
13,664 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo(id='sdF0uJo2KdU', width="100%")
import networkx as nx
from datetime import datetime
import matplotlib.pyplot as plt
import numpy as np
import warnings
from nams import load_data as cf
warnings.filterwarnings('ignore')
G = cf.load_seve... | <SYSTEM_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 introduce you to the NetworkX API.
Step2: Understanding a graph's basic statistics
Step3: Because the graph is a DiGr... |
13,665 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import holoviews as hv
hv.notebook_extension()
np.random.seed(10)
def sine_curve(phase, freq, amp, power, samples=102):
xvals = [0.1* i for i in range(samples)]
return [(x, amp*np.sin(phase+freq*x)**power) for x in xvals]
phases = [0, np.pi/2, np.pi, 3*np.p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This code produces what looks like a relatively simple animation of two side-by-side figures, but is actually a deeply nested data structure
Ste... |
13,666 | <ASSISTANT_TASK:>
Python Code:
# Import the packages/libraries you typically use
import clr
import System
import numpy as np
import matplotlib.pyplot as plt
#This forces plots inline in the Spyder/Python Command Console
%matplotlib inline
#In the line below, make sure the path matches your installation!
LTCOM64Path="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: Sending a message to LightTools
Step2: Sending commands to LightTools
Step3: Send a command with Coord3() function
Step4: Setting and getting... |
13,667 | <ASSISTANT_TASK:>
Python Code:
try:
%matplotlib inline
except:
!pip3 install matplotlib
import matplotlib.pyplot as plt
try:
import numpy as np
except:
!pip3 install numpy
chess_board = np.zeros([8, 8], dtype=int)
chess_board[0::2, 1::2] = 1
chess_board[1::2, 0::2] = 1
plt.matshow(chess_board, cmap=pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Importing it
Step2: Drawing data structures (matrices)
Step3: Drawing 2D curves
Step4: Drawing 3D curves
|
13,668 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import gdsfactory as gf
import gdsfactory.simulation.sipann as gs
def pltAttr(x, y, title=None, legend="upper right", save=None):
if legend is not None:
plt.legend(loc=legend)
plt.xlabel(x)
plt.ylabel(y)
if title 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: Coupler ring
Step2: Coupler
Step3: Reproducing numbers from thesis page 88
|
13,669 | <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: Keras 前処理レイヤーを使って構造化データを分類する
Step2: データセットを読み込み、pandas DataFrame に読み込む
Step3: DataFrame の最初の 5 行をチェックして、データセットを確認します。
Step4: ターゲット変数を作成する
Ste... |
13,670 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
import numpy
import scipy.stats
import matplotlib.pyplot as pyplot
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
# seed the random number generator so we all get the same results
numpy.random.seed(18)
# som... | <SYSTEM_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: Here's what that distribution looks like
Step3: make_sample draws a random sample from this distribution. The result is a Num... |
13,671 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-hh', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
13,672 | <ASSISTANT_TASK:>
Python Code:
# Imports all libraries required
import os
import cv2
import csv
import time
import pickle
import numpy as np
import pandas as pd
import seaborn as sns
import tensorflow as tf
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from PIL import Image
from pylab import rcParams... | <SYSTEM_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 unexpected errors are present
Step2: executing the same codes again removes the errors, not sure why!!
Step3: Step 1
Step4: Visualize th... |
13,673 | <ASSISTANT_TASK:>
Python Code:
# in select mode, shift j/k (to select multiple cells at once)
# split cell with ctrl shift -
# merge with shift M
first = 1
second = 2
third = 3
import numpy as np
np.random.choice()
mylist = !ls
[x.split('_')[-1] for x in mylist]
%%bash
pwd
for i in *.ipynb
do
echo $i | awk -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: Different heading levels
Step2: SQL
Step4: Tab; shift-tab; shift-tab-tab; shift-tab-tab-tab-tab; and more!
Step5: Multicursor magic
|
13,674 | <ASSISTANT_TASK:>
Python Code:
class Employee:
emp_count = 0 # Class Variable
company = 'Google' # Class Variable
def __init__(self, fname, lname):
self.fname = fname
self.lname = lname
self.email = self.fname + '.' + self.lname + '@' + self.company + '.com'
Employee.emp_cou... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Class Methods
Step2: Class Methods can be used to create alternate constructors
Step3: Static Methods
Step4: Inheritance - Creating subclasse... |
13,675 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import numpy as np
import matplotlib.pyplot as plt
from cs231n.classifiers.cnn import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check import eval_numerical_gradient_array, eval_numerical_gradient
from cs231n.layers import *
from cs231... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convolutional Networks
Step2: Convolution
Step4: Aside
Step5: Convolution
Step6: Max pooling
Step7: Max pooling
Step8: Fast layers
Step9: ... |
13,676 | <ASSISTANT_TASK:>
Python Code:
from time import time
start_nb = time()
# Initialize logging.
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s')
sentence_obama = 'Obama speaks to the media in Illinois'
sentence_president = 'The president greets the press in Chicago'
sentence_obama = 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: These sentences have very similar content, and as such the WMD should be low. Before we compute the WMD, we want to remove stopwords ("the", "to... |
13,677 | <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: Text generation with an RNN
Step2: Download the Shakespeare dataset
Step3: Read the data
Step4: Process the text
Step5: The prediction task
... |
13,678 | <ASSISTANT_TASK:>
Python Code:
import itertools
import pprint
import re
from IPython.display import HTML, display
import ga4gh.client
import prettytable
import requests
print(ga4gh.__version__)
gc = ga4gh.client.HttpClient("http://localhost:8000")
region_constraints = dict(referenceName="1", start=0, end=int(1e10))
var... | <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: Search VariantAnnotations using SO term sets
Step3: SnpEff map
Step4: Region name map
Step5: Meta maps
Step6: Search for variants by each SO... |
13,679 | <ASSISTANT_TASK:>
Python Code:
#put matplotlib plots in the notebook, then import the package
%matplotlib inline
import kappa
amber = kappa.Amber()
print(kappa.lattices)
cnt = kappa.build(amber, "cnt")
kappa.plot.bonds(cnt)
graphene = kappa.build(amber, "graphene", radius=2)
kappa.plot.bonds(graphene, indices=Tru... | <SYSTEM_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 it stands users must define a forcefield before building molecules. We will establish an Amber forcefield. We can turn interactions in the ... |
13,680 | <ASSISTANT_TASK:>
Python Code:
hw_data_directory = '/Users/farr/Documents/Research/KepHackWeek/data'
occur_dir = '/Users/farr/Google Drive/Kepler ExoPop Hack 2015/end2end_occ_calc'
eff_dir = '/Volumes/KepHacWkWMF/Kepler_HW2015/Dp4_DetectionCountours/v0'
rbins = array([1.5**(i-1) for i in range(9)])
pbins = array([10*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: Planet Database
Step2: G Dwarfs
Step3: We want to know the average detection efficiency across the bin. (Actually, what we want to know is th... |
13,681 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import os
!cat talks.tsv
talks = pd.read_csv("talks.tsv", sep="\t", header=0)
talks
html_escape_table = {
"&": "&",
'"': """,
"'": "'"
}
def html_escape(text):
if type(text) is str:
return "".join(html_escape_table.get(c,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: Data format
Step2: Import TSV
Step3: Escape special characters
Step4: Creating the markdown files
Step5: These files are in the talks direct... |
13,682 | <ASSISTANT_TASK:>
Python Code:
%pylab notebook
fe = 60 # [Hz]
p = 2
n_nl = 3580 # [r/min]
n_fl = 3440 # [r/min]
n_sync = 120*fe / p
print('n_sync = {:.0f} r/min'.format(n_sync))
s_nl = (n_sync - n_nl) / n_sync
print('''
s_nl = {:.2f} %
============='''.format(s_nl*100))
f_rnl = s_nl * fe
print('''
f_rnl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Description
Step2: SOLUTION
Step3: The slip and electrical frequency at no-load conditions is
Step4: $$f_\text{r,nl} = sf_e$$
Step5: The sli... |
13,683 | <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: Embeddings de Palavras
Step2: Usando a camada Embedding
Step3: Quando você cria uma camada de embedding, os pesos para a incorporação são inic... |
13,684 | <ASSISTANT_TASK:>
Python Code:
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
autorizar = tweepy.OAuthHandler(consumer_key, consumer_secret)
autorizar.set_access_token(access_token, access_token_secret)
api = tweepy.API(autorizar)
print(api)
tweets = api.search(q='Pytho... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pesquisando
Step2: Recuperar 1000 tweets
|
13,685 | <ASSISTANT_TASK:>
Python Code:
import statsmodels
statsmodels.__version__
import pandas as pd
import numpy as np
import statsmodels.api as sm
import statsmodels.formula.api as smf
from statsmodels.sandbox.regression.predstd import wls_prediction_std
import matplotlib.pyplot as plt
df = pd.read_csv('data/SDSS_QSO.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: The file SDSS_QSO.dat is from Feigelson's Astrostatistics school, September 2014 at Caltech
Step2: Weighted least-squares
Step3: Exercise
Step... |
13,686 | <ASSISTANT_TASK:>
Python Code:
# Load data
X = np.concatenate((np.ones((pima.shape[0],1)),pima[:,0:8]), axis=1)
Y = pima[:,8]
Xs = (X - np.mean(X, axis=0))/np.concatenate((np.ones(1),np.std(X[:,1:], axis=0)))
n, p = X.shape
M = np.identity(p)
### HMC version
def logistic(x):
return 1/(1+np.exp(-x))
def U(theta, Y, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Correct coefficients
Step2: Our code - SGHMC
Step3: Our code - Gradient descent
Step5: Cliburn's code
|
13,687 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from sklearn.metrics import confusion_matrix
tf.__version__
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets("data/MNIST/", one_hot=True)
print("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: This was developed using Python 3.5.2 (Anaconda) and TensorFlow version
Step2: 2017-06-04
Step3: The MNIST data-set has now been loaded and co... |
13,688 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import matplotlib.pyplot as plt
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sam... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loading continuous data
Step2: As you can see above,
Step3: By default, the
Step4: Querying the Raw object
Step5: <div class="alert alert-... |
13,689 | <ASSISTANT_TASK:>
Python Code:
from pygoose import *
from gensim.models.wrappers.fasttext import FastText
kg.gpu.cuda_disable_gpus()
from keras.preprocessing.text import Tokenizer
from keras.preprocessing.sequence import pad_sequences
project = kg.Project.discover()
MAX_VOCAB_SIZE = 125000
MAX_SEQUENCE_LENGTH = 30
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Hide all GPUs from TensorFlow to not automatically occupy any GPU RAM.
Step2: Config
Step3: The maximum allowed size of the embedding matrix a... |
13,690 | <ASSISTANT_TASK:>
Python Code:
# Importar bibliotecas
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import linear_model
from sklearn.metrics import mean_squared_error, r2_score
pd.options.mode.chained_assignment = None # default='warn'
# Abrir banco de dados
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Algumas observações sobre a estrutura dos dados. Na linha '21136', Paquetá está como dúvida é teve pontuação de 0. Na linha abaixo ('21137'), el... |
13,691 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10, 10)
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# Only run this cell once in the active kernel or the files in later cells will not be found
... | <SYSTEM_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 LabelMap.
Step2: Load the net in the test phase for inference, and configure input preprocessing.
Step3: 2. SSD detection
Step4: Run the... |
13,692 | <ASSISTANT_TASK:>
Python Code:
#%load_ext rpy2.ipython
#%R install.packages("nycflights13", repos='http://cran.us.r-project.org')
#%R library(nycflights13)
#%R write.csv(flights, "flights.csv")
# Downloading and unzipg a file, without R method :
# source= http://stackoverflow.com/a/34863053/3140336
import io
from zipf... | <SYSTEM_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 an internet download to get flight.qcsv
Step2: Data
Step3: Single table verbs
Step4: We see the first big language difference between ... |
13,693 | <ASSISTANT_TASK:>
Python Code:
import os
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
! pip3 install $USER kfp --upgra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Install the latest GA version of google-cloud-storage library as well.
Step2: Install the latest GA version of KFP SDK library as well.
Step3: ... |
13,694 | <ASSISTANT_TASK:>
Python Code:
data_in_shape = (3, 6)
rnn = SimpleRNN(4, activation='tanh')
layer_0 = Input(shape=data_in_shape)
layer_1 = rnn(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
weights = []
for i, w in enumerate(model.get_weights()):
np.ra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: [recurrent.SimpleRNN.1] units=5, activation='sigmoid'
Step2: [recurrent.SimpleRNN.2] units=4, activation='tanh', return_sequences=True
Step3: ... |
13,695 | <ASSISTANT_TASK:>
Python Code:
e = Element("This is fancy text")
print(e._name, e._id)
print(e.get_name())
e.render()
e = Element("Hello {{kwargs['you']}}, my name is `{{this.get_name()}}`.")
e.render(you='World')
child = Element('This is the child.')
parent = Element('This is the parent.').add_child(child)
parent ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Each element has an attribute _name and a unique _id. You also have a method get_name to get a unique string representation of the element.
Step... |
13,696 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import scipy as sp
import json
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import pandas as pd
from pyquery import PyQuery as pq
import requests
pd.set_option('display.width', 500)
pd.set_option('display.max_col... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We intentionally ignore some of the data relative to body and surface waves as well as other source of estimations of the magnitude to take less... |
13,697 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
x = numpy.array([[0,0],[-1,0.1],[0.3,-0.05],[0.7,0.3],[-0.2,-0.6],[-0.15,-0.63],[-0.25,0.55],[-0.28,0.67]])
y = numpy.array([0,0,0,0,1,1,2,2])
def plot_data(features,labels,axis,alpha=1.0):
# separate features according to their class
X0,X1,X2 = features[labels==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: That is, there are eight feature vectors where each of them belongs to one out of three different classes (identified by either 0, 1, or 2). Let... |
13,698 | <ASSISTANT_TASK:>
Python Code:
import skbeam.core.correlation as corr
from skbeam.core.correlation import two_time_corr, two_time_state_to_results
import skbeam.core.roi as roi
import skbeam.core.utils as utils
from xray_vision.mpl_plotting.roi import show_label_array_on_image
import numpy as np
import time as ttime
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:
Step4: Brute force correlation
Step5: Using the NIPA gel data
Step6: Multi tau two time correlation
|
13,699 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(seed=1)
import math
import os
import random
try:
import torch
except ModuleNotFoundError:
%pip install -qq torch
import torch
from torch import nn
from torch.nn import functional as F
import requests
import zipf... | <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: Data
Step6: We make a vocabulary, replacing any word that occurs less than 10 times with unk.
Step8: Mikolov suggested keeping word $w$ with p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.