Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
2,900 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%matplotlib notebook
from astropy.time import Time
from threeML import *
get_available_plugins()
gbm_catalog = FermiGBMBurstCatalog()
gbm_catalog.cone_search(ra=0,dec=0,radius=10)
gbm_catalog.search_around_source('Crab',radius=5)
gbm_catalog.query("2<t90<10")
mjd =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: GBM catalog
Step2: Searching cones on the sky
Step3: Or perhaps we want to know the GRBs around the Crab nebula
Step4: Searching on T90 and t... |
2,901 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# Demonstrando propriedades de vetores
# Ideia: coloque mais dimensoes nos vetores e veja o que acontece!
x = np.array([4, 3])
y = np.array([3, 4])
print x
print y
print x + y # Soma de vetores
print 10 * x # Multiplica... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Estatística e vetores
Step2: Normalizando vetores
Step3: Análise estatística de descritores de áudio
Step4: Podemos, neste momento, detectar ... |
2,902 | <ASSISTANT_TASK:>
Python Code:
from myhdl import *
from myhdlpeek import Peeker
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from sympy import *
init_printing()
import random
#https://github.com/jrjohansson/version_information
%load_ext version_information
%version_informati... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: RTL and Implimentation Schamatics are from Xilinx Vivado 2016.1
Step2: And if we try writing to the tuple we will get an error
Step4: Random a... |
2,903 | <ASSISTANT_TASK:>
Python Code::
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25)
model.fit(X_train, y_train)
<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:
|
2,904 | <ASSISTANT_TASK:>
Python Code:
from google.colab import auth
auth.authenticate_user()
!pip install -U earthengine-api --no-deps
import ee
ee.Authenticate()
ee.Initialize()
import tensorflow as tf
print(tf.__version__)
import folium
print(folium.__version__)
# REPLACE WITH YOUR CLOUD PROJECT!
PROJECT = 'your-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: Upgrade Earth Engine and Authenticate
Step2: Test the TensorFlow installation
Step3: Test the Folium installation
Step4: Define variables
Ste... |
2,905 | <ASSISTANT_TASK:>
Python Code:
import os, tempfile
import logging
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from ionchannelABC import theoretical_population_size
from ionchannelABC import IonChannelDistance, EfficientMultivariateNormalTransition, IonChannelAccepto... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Initial set-up
Step2: Plot steady-state and tau functions of original model
Step3: Activation gate ($a$) calibration
Step4: Set up prior rang... |
2,906 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import sys
# In ../testing/ dir, we prepared a small script for generating the above matrix A
sys.path.append('../testing/')
import make_LosMatrix
# Import GPinv
import GPinv
n = 30
N = 40
# rad... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Synthetic signals
Step2: Prepare the synthetic signal.
Step3: Inference
Step4: Variational inference by StVGP
Step5: Check the initial estim... |
2,907 | <ASSISTANT_TASK:>
Python Code:
from molpher.core import MolpherMol
cymene_smiles = MolpherMol("CC1=CC=C(C(C)C)C=C1")
print(cymene_smiles.smiles)
cymene_sdf = MolpherMol("cymene.sdf") # if the string ends with '.sdf', the library interprets it as a path to a file
print(cymene_sdf.smiles)
# imports that will enable dire... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: For convenience, it is possible to readily convert the MolpherMol molecule to an RDKit Mol
Step2: We can also convert the RDKit molecule back t... |
2,908 | <ASSISTANT_TASK:>
Python Code:
from zdf import zdf_read_grid, zdf_read_particles
(data, info) = zdf_read_grid( "J3-000500.zdf" )
print(type(data))
print(info)
import numpy as np
from bokeh.io import push_notebook, show, output_notebook
output_notebook()
from bokeh.plotting import figure
from bokeh.models import Line... | <SYSTEM_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 you need to read the data. You should also read the metadata while you are at it.
Step2: data is a NumPy ndarray, info is a dictionary wit... |
2,909 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-mh', 'ocean')
# 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... |
2,910 | <ASSISTANT_TASK:>
Python Code:
ds['lon']
# multiple titles are stacked into a single 2D array
# just passinsg this will crash ESMPy
plt.scatter(ds['lon'], ds['lat'], s=0.2)
# Get a more well-defined 2D mesh (subset of the full grid)
plt.scatter(ds['lon'][:80,:], ds['lat'][:80,], s=0.2)
ds_subset = ds.isel(i=slice(0,8... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Correctly build the regridder
Step2: So the error could be fixed by breaking your full grid to several well-defined 2D tiles... or maybe it's e... |
2,911 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nerc', 'sandbox-1', '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... |
2,912 | <ASSISTANT_TASK:>
Python Code:
r = np.random.ranf(4)
def seed(n, size=4):
global r
np.random.seed(n)
r = np.random.ranf(size)
seed(0, 8)
y = [f1(x) for x in x]
plt.plot(x, y, 'bo')
v0 = 2
v1 = 5
plt.plot([0,1], [v0,v1])
def f1(x): return 3 * x + 2
x = np.linspace(0, 1, 10)
y = [f1(x) for x in x]
plt.plo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Actually, lets define a seed function that initializes this table with using a seed number and and sample size
Step2: And now we can define ${f... |
2,913 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.2,<2.3"
%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('lc', times=phoebe.linspace(0,1,101), dataset='lc01')
b.set_value('irrad_method', 'none')
b.set_value_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: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details.
Step2: And we'll add a single li... |
2,914 | <ASSISTANT_TASK:>
Python Code:
%run ../../shared_setup.ipynb
# load variation data
sample_exclusions = dup_samples.copy()
for cross in excessive_recomb_samples:
sample_exclusions[cross] += excessive_recomb_samples[cross]
callsets = load_callsets(COMBINED_CALLSET_FN_TEMPLATE,
sample_exclusi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: CO recombination events
Step2: Conversion tracts
Step3: Combine adjacent blocks into conversion tracts
Step4: Identify tracts with robust sup... |
2,915 | <ASSISTANT_TASK:>
Python Code:
##########################################
plt.rcParams["figure.figsize"] = (12,3.5)
fig, ax = plt.subplots(1, 3)
##########################################
# Observed points of the Lorenz curve and population parameters
p = [0.0, 0.4, 0.8, 1.0]
L = [0.0, 0.16, 0.64, 1.0]
mean = 10.0
po... | <SYSTEM_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 cyan curve is a valid Lorenz curve (increasing, convex) that interpolates the points, but so is the magenta - with a different resulting inc... |
2,916 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = 12, 10
plt.rcParams.update({'font.size': 15})
data = pd.read_csv('../data/train.csv')
data.describe()
# Create a quick function to allow reusing
def scatter_plot(ind... | <SYSTEM_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 shown above, I managed to collect data for 56 exams. It seems that the minimum mean mark was of 37, and the maximum was of 83.66. On average,... |
2,917 | <ASSISTANT_TASK:>
Python Code:
import espressomd
import espressomd.magnetostatics
import espressomd.magnetostatic_extensions
import espressomd.cluster_analysis
import espressomd.pair_criteria
espressomd.assert_features('DIPOLES', 'LENNARD_JONES')
import numpy as np
# Lennard-Jones parameters
LJ_SIGMA = 1
LJ_EPSILON = ... | <SYSTEM_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 up all simulation parameters.
Step2: Note that we declared a <tt>lj_cut</tt>. This will be used as the cut-off radius of the Lennard... |
2,918 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import sys
# Modify the path
sys.path.append("/Users/rebeccabilbro/Desktop/waves/stuff/yellowbrick")
import requests
import numpy as np
import pandas as pd
import yellowbrick as yb
import matplotlib.pyplot as plt
## The path to the test data sets
FIXTURES... | <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: Fetching the data
Step3: Ok now try with VisualPipeline
|
2,919 | <ASSISTANT_TASK:>
Python Code:
# Load image and libraries
%matplotlib inline
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
from scipy import misc
input_image = misc.imread('figure_processed.png')
# Convert input image from RGBA to binary
input_image = input_image - 255
input_image = np.me... | <SYSTEM_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 3. Project 2-D binary image to 1-D time series
Step2: Step 4. Rescale in x- and y- variables
Step3: Step 5. Resample at desired sampling ... |
2,920 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'bcc', 'sandbox-3', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
2,921 | <ASSISTANT_TASK:>
Python Code:
from biovida.images import OpeniInterface
opi = OpeniInterface()
opi.search(query='lung cancer')
pull_df1 = opi.pull()
from biovida.images import CancerImageInterface
cii = CancerImageInterface(api_key=YOUR_API_KEY_HERE)
cii.search(cancer_type='lung')
pull_df2 = cii.pull(collections_limi... | <SYSTEM_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 also get some data from the Cancer Imaging Archive.
Step3: Next, we can import the tool we will be using to unify the data
Step4: To clo... |
2,922 | <ASSISTANT_TASK:>
Python Code:
# data analysis and wrangling
import pandas as pd
import numpy as np
import random as rnd
# visualization
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
# machine learning
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC, LinearSVC
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Acquire data
Step2: Analyze by describing data
Step3: Which features are categorical?
Step4: Which features are mixed data types?
Step5: Whi... |
2,923 | <ASSISTANT_TASK:>
Python Code:
print('Hello World')
x = 5
print(x)
print(type(x))
x = 5.0
print(x)
print(type(x))
x = 1
y = 7.3
is_red = False
title = 'Just a string'
print(type(x), type(y), type(is_red), type(title))
names = ['Hugo', 'Charles','Janine']
ages = [72, 33, 16]
print(type(names), type(ages))
print(n... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This is the easiest way to use print. In order to produce a prettier output of the variable contents format specifications can be used. But we w... |
2,924 | <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... |
2,925 | <ASSISTANT_TASK:>
Python Code:
numbers = [1.5, 2.3, 0.7, -0.001, 4.4]
total = 0.0
for n in numbers:
assert n > 0.0, 'Data should only contain positve values'
total += n
print('total is: ', total)
def normalize_rectangle(rect):
'''Normalizes a rectangle so that it is at the origin and 1.0 units long on its ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Programs like firefox browser are full of assertions
Step2: now look at the post-conditions to help us catch bugs by telling us the calculation... |
2,926 | <ASSISTANT_TASK:>
Python Code:
from selenium import webdriver # powers the browser interaction
from selenium.webdriver.support.ui import Select # selects menu options
from pyvirtualdisplay import Display # for JHub environment
from bs4 import BeautifulSoup # to parse HTML
import csv # to write CSV
import pandas #... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Selenium actually uses our web browser, and since the JupyterHub doesn't come with Firefox, we'll download the binaries
Step2: We also need the... |
2,927 | <ASSISTANT_TASK:>
Python Code:
# Convention for import to get shortened namespace
import numpy as np
import xarray as xr
# Create some sample "temperature" data
data = 283 + 5 * np.random.randn(5, 3, 4)
data
temp = xr.DataArray(data)
temp
temp = xr.DataArray(data, dims=['time', 'lat', 'lon'])
temp
# Use pandas to cr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here we create a basic DataArray by passing it just a numpy array of random data. Note that XArray generates some basic dimension names for us.
... |
2,928 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'thu', 'sandbox-1', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
2,929 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import datetime
from astropy import coordinates as coord, units as u, time, constants as const
import logging
import sys
import os
from scipy import 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: First we'll start with the simple observing as often as we can when a field is up. We only need to consider one year in this case. Start with so... |
2,930 | <ASSISTANT_TASK:>
Python Code:
import json
import os
import pickle
import requests
import time
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.cross_validation import KFold, StratifiedKFold, train_test_spl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fetch the data
Step2: Our data, including the target, is categorical. We will need to change these values to numeric ones for machine learning.... |
2,931 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib
matplotlib.rcParams['figure.figsize'] = (12, 9)
# Import Jupyter's sound player widget
# See: https://ipython.org/ipython-doc/dev/api/generated/IPython.display.html#IPython.display.Audio
from IPython.display import Audio
from scipy.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Official documentation
Step2: Read wav file
Step3: Another example
|
2,932 | <ASSISTANT_TASK:>
Python Code:
# versions
import IPython
print("pyspark version:" + str(sc.version))
print("Ipython version:" + str(IPython.__version__))
# agg
x = sqlContext.createDataFrame([("Alice","Bob",0.1),("Bob","Carol",0.2),("Carol","Dave",0.3)], ['from','to','amt'])
y = x.agg({"amt":"avg"})
x.show()
y.show()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a href="http
Step2: <a href="http
Step3: <a href="http
Step4: <a href="http
Step5: <a href="http
Step6: <a href="http
Step7: <a href="htt... |
2,933 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import parallel
import itertools
import networkx as nx
import numpy as np
bhs = parallel.Parallel()
fig, ax = plt.subplots()
ax.bar([x+0.9 for x in range(5)], -1./bhs.evals[1:], width=0.2)
ax.set_xlabel(r'Eigenvalue', fontsize=16)
ax.set... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Again, the system exhibits a time scale separation between the first and second modes as we would expect.
Step2: Committors and reactive flux
S... |
2,934 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
%matplotlib notebook
import matplotlib
import matplotlib.pyplot as plt
from IPython.display import Image
def write_png(tensor, name):
casted_to_uint8 = tf.cast(tensor, tf.uint8)
converted_to_png = tf.image.encode_png(casted_to_uint8)
... | <SYSTEM_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 needed for Jupiter
Step2: A function to save a picture
Step4: A function to draw the cost function in Jupyter
Step5: Create some rando... |
2,935 | <ASSISTANT_TASK:>
Python Code:
import sncosmo
import analyzeSN as ans
import numpy as np
from analyzeSN import LightCurve
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
ex_data = sncosmo.load_example_data().to_pandas()
ex_data.head()
lc = LightCurve(ex_data)
lc.lightCurve.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: Instantiation
Step2: This was a SNCosmo example dataset, loaded into pandas.DataFrame. Note that the column representing temporal information i... |
2,936 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 归一化
Step2: 准备数据集
Step3: 组归一化教程
Step4: 实例归一化教程
Step5: 层归一化教程
|
2,937 | <ASSISTANT_TASK:>
Python Code:
# -*- coding: utf-8 -*-
from pylab import *
from pyspecdata import *
from numpy.random import random
import time
init_logging('debug')
a_nd = nddata(random(10*2048),[10,2048],['x','y']).setaxis('x','#').setaxis('y','#')
a = a_nd.data
a2_nd = nddata(random(10*2048),[2048,10],['y','z']).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: In this example, the assertions essentially tell the story of what's going on
Step2: in the next line, note how only the dimension that goes aw... |
2,938 | <ASSISTANT_TASK:>
Python Code:
data = [
('california', 1),
('california', 3),
('colorado', 0),
('colorado', 10),
('washington', 2),
('washington', 4)
]
# This won't work because I haven't initialized keys
summed = dict()
for row in data:
key, value = row # destructure the tuple
summed[k... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: With an ordinary dictionary, I would need to check if they key exists. If it doesn't I need to initialize it with a value. For instrutional purp... |
2,939 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def well2d(x, y, nx, ny, L=1.0):
Compute the 2d quantum well wave function.
# YOUR CODE HERE
psi=(2.0/L)*np.sin(nx*np.pi*x/L)*np.sin(ny*np.pi*y/L)
return psi
psi = well2d(np.linspace(0,1,10), np.linspac... | <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: Contour plots of 2d wavefunctions
Step3: The contour, contourf, pcolor and pcolormesh functions of Matplotlib can be used for effective visuali... |
2,940 | <ASSISTANT_TASK:>
Python Code:
# SBML model we want to import
sbml_file = 'model_presimulation.xml'
# Name of the model that will also be the name of the python module
model_name = 'model_presimulation'
# Directory to which the generated model code is written
model_output_dir = model_name
import libsbml
import amici
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: Model Loading
Step2: For this example we want specify the initial drug and kinase concentrations as experimental conditions. Accordingly we spe... |
2,941 | <ASSISTANT_TASK:>
Python Code:
red = tf.constant([255, 0, 0])
# The match_filenames_once will accept a regex but there is no need for this example.
image_filename = "./images/chapter-05-object-recognition-and-classification/working-with-images/test-input-image.jpg"
filename_queue = tf.train.string_input_producer(
... | <SYSTEM_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 scalar can be changed to make the pixel another color or a mix of colors. The rank 1 tensor of a pixel is in the format of [red, green, blu... |
2,942 | <ASSISTANT_TASK:>
Python Code:
from imdbpie import Imdb
imdb = Imdb()
imdb = Imdb(anonymize=True)
def title_search(title):
return pd.DataFrame(imdb.search_for_title(title),index=[x for x in range(len(pd.DataFrame(imdb.search_for_title(title))))])
titles_to_search=['Fast and Furious','Police Academy',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pull ratings and votes using the imdb id
|
2,943 | <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', times=np.linspace(0,1,11), dataset='mesh01')
print(b['requiv@component'])
print(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new Bundle.
Step2: Now let's add a mesh dataset at a few different times so that we c... |
2,944 | <ASSISTANT_TASK:>
Python Code:
#The following line fetches you two datasets: images, usable for autoencoder training and attributes.
#Those attributes will be required for the final part of the assignment (applying smiles), so please keep them in mind
from lfw_dataset import fetch_lfw_dataset
data,attrs = fetch_lfw_dat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: For simplicity we want all values of the data to lie in the interval $[0,1]$
Step3: Autoencoder
Step4: Sampling
Step5: Can you visualize how ... |
2,945 | <ASSISTANT_TASK:>
Python Code:
doc1="Electron acceleration in a post-flare decimetric continuum source Prasad Subramanian, S. M. White, M. Karlický, R. Sych, H. S. Sawant, S. Ananthakrishnan(Submitted on 23 Mar 2007)Aims: To calculate the power budget for electron acceleration and the efficiency of the plasma emission ... | <SYSTEM_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 test our small dictionary on a new abstract. It returns with a vector that represents [[word ID, frequency]]
Step2: Now use the arxiv API i... |
2,946 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from scipy.cluster import vq
# create 100 coordinate pairs (i.e. two values), then add 5 to all of them
year_1 = np.random.randn(100, 2) + 5
# create 30 coordinatee pairs (i.e. two values), then subtract 5 to all of th... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create coordinates for battles for each year of the war
Step2: View the first 3 entries of each year of battles
Step3: Pool all three years of... |
2,947 | <ASSISTANT_TASK:>
Python Code:
ifile = open("data/HOPG.txt", mode='r', encoding='utf-8')
text = ifile.read()
ifile.close()
print(text[:300], "...")
import nltk
text = text.lower()
print(text[:300], "...")
myFD = nltk.FreqDist(text)
print(myFD)
for x in ":,.-[];!'\"\t\n/ ?":
del myFD[x]
for x in myFD:
print... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The optional parameters in the open function above define the mode of operations on the file and the encoding of the content. For example, setti... |
2,948 | <ASSISTANT_TASK:>
Python Code:
import vaex
import vaex.jupyter.model as vjm
import numpy as np
import matplotlib.pyplot as plt
df = vaex.example()
df
E_axis = vjm.Axis(df=df, expression=df.E, shape=140)
Lz_axis = vjm.Axis(df=df, expression=df.Lz, shape=100)
Lz_axis
await vaex.jupyter.gather() # wait until Vaex is do... | <SYSTEM_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 to build a 2 dimensinoal grid with the number counts in each bin. To do this, we first define two axis objects
Step2: When we inspect t... |
2,949 | <ASSISTANT_TASK:>
Python Code:
import pixiedust
pixiedust.printAllPackages()
pixiedust.installPackage("graphframes:graphframes:0")
pixiedust.printAllPackages()
#import the Graphs example
from graphframes.examples import Graphs
#create the friends example graph
g=Graphs(sqlContext).friends()
#use the pixiedust displa... | <SYSTEM_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 a package from spark-packages.org
Step2: Restart your kernel
Step3: Display a GraphFrames data sample
Step4: Install from maven
Step5: I... |
2,950 | <ASSISTANT_TASK:>
Python Code:
#|export
class TerminateOnNaNCallback(Callback):
"A `Callback` that terminates training if loss is NaN."
order=-9
def after_batch(self):
"Test if `last_loss` is NaN and interrupts training."
if torch.isinf(self.loss) or torch.isnan(self.loss): raise CancelFitEx... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TrackerCallback -
Step2: When implementing a Callback that has behavior that depends on the best value of a metric or loss, subclass this Callb... |
2,951 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# Data ge... | <SYSTEM_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 initial variance is scaled by a factor of $\sqrt[]{\frac{2}{N}}$, where $N$ is the number of inputs to each neuron in the layer (as per http... |
2,952 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (10, 20)
DON'T MODIFY 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: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
2,953 | <ASSISTANT_TASK:>
Python Code:
%%capture
import sys
if not 'chempy' in sys.modules:
!pip install chempy
from chempy import ReactionSystem, Substance
from chempy.kinetics.ode import get_odesys
from collections import defaultdict
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 12... | <SYSTEM_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. Reaction conditions
Step17: 3. Construct the reaction system
Step18: Show the reaction equations and the initial concentrations of reagents... |
2,954 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('data/running_example.csv', sep=';')
df
# number of cases
len(df['case_id'].unique())
# number of events
len(df)
import pm4py
log = pm4py.format_dataframe(df, case_id='case_id',activity_key='activity',
timestamp_key='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: Let's inspect the small event log.
Step2: Formatting Data Frames
Step3: Observe that the column names are updated as expected.
Step4: The pm4... |
2,955 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('fivethirtyeight')
import tweepy
import numpy as np
import pandas as pd
from collections import Counter
from datetime import datetime
# Turn on retina mode for high-quality inline plot resolution
from 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: Tweet activity
Step2: Hmmm, what's this created_at attribute?
Step3: Hourly counts
Step4: Because there are hours of the day where there are ... |
2,956 | <ASSISTANT_TASK:>
Python Code:
import graphlab
loans = graphlab.SFrame('lending-club-data.gl/')
loans['safe_loans'] = loans['bad_loans'].apply(lambda x : +1 if x==0 else -1)
loans = loans.remove_column('bad_loans')
features = ['grade', # grade of the loan
'term', # the term 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: Load the lending club dataset
Step2: Like the previous assignment, we reassign the labels to have +1 for a safe loan, and -1 for a risky (bad) ... |
2,957 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
%matplotlib inline
import warnings
warnings.filterwarnings('ignore', category=FutureWarning)
import numpy as np
import pandas as pd
import random
import thinkstats2
import thinkplot
transactions = pd.read_csv('mj-clean.csv', parse_dates=[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: Time series analysis
Step3: The following function takes a DataFrame of transactions and compute daily averages.
Step5: The following function... |
2,958 | <ASSISTANT_TASK:>
Python Code:
l = [] # List
d = {} # Dict
t = () # tuples
s = '' # strings
# ...
fobj = open('test.dat', mode='w')
import numpy as np
ary = np.linspace(0, 2*np.pi, 200)
from matplotlib import pyplot as plt
import numpy as np
%matplotlib inline
fig = plt.figure(figsize=(20,5)) # Figure ob... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: File objects
Step2: Numpy arrays
Step3: Plots contain many objects
Step4: But what is Object-oriented programming ?
Step5: How to create obj... |
2,959 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 150
from skdaccess.framework.param_class import *
from skdaccess.finance.timeseries.stream import DataFetcher
stock_ap_list = AutoList(['SPY'])
stockdf = DataFetcher([stock_ap_list], 'daily', '2017-06-01')
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Select which symbol to retrieve
Step2: Create a data fetcher
Step3: Access the data
Step4: List the columns of the data
Step5: Plot the clos... |
2,960 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
import numpy as np
from sklearn.naive_bayes import BernoulliNB
# Create three binary features
X = np.random.randint(2, size=(100, 3))
# Create a binary target vector
y = np.random.randint(2, size=(100, 1)).ravel()
# View first ten observations
X[0:10]
# Create Bernoull... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create Binary Feature And Target Data
Step2: View Feature Data
Step3: Train Bernoulli Naive Bayes Classifier
|
2,961 | <ASSISTANT_TASK:>
Python Code:
import tsvopener
import pandas as pd
import numpy as np
from nltk import word_tokenize
from sklearn.feature_extraction.text import CountVectorizer
from scipy.sparse import csr_matrix, vstack
from sklearn.semi_supervised import LabelPropagation, LabelSpreading
regex_categorized = tsvopener... | <SYSTEM_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 Vectors
Step2: Use Scikit's semisupervised learning
Step3: Measuring effectiveness.
Step4: PCA
|
2,962 | <ASSISTANT_TASK:>
Python Code:
# for item in my_list:
# if item.flavor == 'banana':
# break
# else:
# raise ValueError('No banana flavor found!')
# try:
# dangerous_call()
# after_call()
# except OSError:
# log('OSError...')
# try:
# dangerous_call()
# except OSError:
# log('OSErro... | <SYSTEM_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/except 中使用 else 子句,毕竟下面代码中只有 dangerous_cal() 不抛出异常 after_call() 才会执行
Step2: 然而,after_call() 不应该放在 try 块中。为了清晰准确,try 块应该只抛出预期异常... |
2,963 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
a = np.arange(9).reshape(3, 3)
a
' '.join(str(i) for i in a.ravel(order='C'))
' '.join(str(i) for i in a.ravel(order='F'))
volume = np.load('data/F3_volume_3x3_16bit.npy')
volume.shape
idx = np.indices(volume.shape)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A tiny example
Step2: A seismic volume
Step3: Let's look at how the indices vary
Step4: We can't easily look at the indices for 190 × 1... |
2,964 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import numpy as np
%matplotlib notebook
import matplotlib.pyplot as plt
from visualize import drawCoefficient
from gridlod import interp, coef, util, fem, world, linalg
from gridlod.world import World
import femsolverCoarse
import pg_rand
import buildcoef2d
def resul... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plot function
Step2: Coefficient
Step3: Perturbations
Step4: Change in value to 50
Step5: Disappearance
Step6: Shift one step
Step7: Shift... |
2,965 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 150
from skdaccess.astro.tess.simulated.cache import DataFetcher as TESS_DF
from skdaccess.framework.param_class import *
import numpy as np
tess_fetcher = TESS_DF([AutoList([376664523])])
tess_dw = tess_fetc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TESS End-to-End 6 Simulated Light Curve Time Series<br>
Step2: Normalize flux
Step3: Plot Relative PDCSAP Flux vs time
|
2,966 | <ASSISTANT_TASK:>
Python Code:
# Import the pydna package functions
from pydna.all import *
# Give your email address to Genbank, so they can contact you.
# This is a requirement for using their services
gb=Genbank("bjornjobb@gmail.com")
# download the SAAT CDS from Genbank
# We know from inspecting the
saat = gb.nucl... | <SYSTEM_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 the cell below, primers relevant to the Yeast Pathway Kit are read into six sequence objects. These are similar to the ones created in cell [... |
2,967 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
from phoebe import u # units
logger = phoebe.logger(clevel='WARNING')
b = phoebe.default_binary()
b.set_value(qualifier='teff', component='primary', value=6500)
b.add_dataset('lc', compute_times=phoebe.linspace(0,1,101))
b.run_comput... | <SYSTEM_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 get started with some basic imports
Step2: If running in IPython notebooks, you may see a "ShimWarning" depending on the version of Jupyt... |
2,968 | <ASSISTANT_TASK:>
Python Code:
import faps as fp
import numpy as np
import pandas as pd
print("Created using FAPS version {}.".format(fp.__version__))
np.random.seed(867)
allele_freqs = np.random.uniform(0.3,0.5,50)
adults = fp.make_parents(100, allele_freqs, family_name='a')
progeny = fp.make_sibships(adults, 0, [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: FAPS uses information in a paternityArray to generate plausible full-sibship configurations. This information is stored as a sibshipCluster obje... |
2,969 | <ASSISTANT_TASK:>
Python Code:
import jax
import jax.numpy as jnp
x = jnp.arange(10)
print(x)
x
long_vector = jnp.arange(int(1e7))
%timeit jnp.dot(long_vector, long_vector).block_until_ready()
def sum_of_squares(x):
return jnp.sum(x**2)
sum_of_squares_dx = jax.grad(sum_of_squares)
x = jnp.asarray([1.0, 2.0, 3.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: So far, everything is just like NumPy. A big appeal of JAX is that you don't need to learn a new API. Many common NumPy programs would run just ... |
2,970 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import poisson, norm, chi2
from scipy.optimize import minimize, brentq
import warnings; warnings.simplefilter('ignore') # ignore some numerical errors
E = np.logspace(0,2,30+1)
E = (E[1:] + E[:-1]) / 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: We need something to place a limit on, and in our first example we are looking for a bump in an otherwise smooth background. This could be a gam... |
2,971 | <ASSISTANT_TASK:>
Python Code:
#@title Imports & Utils
# Imports
!pip install -q git+https://www.github.com/google/jax-md
import numpy as onp
from jax.config import config ; config.update('jax_enable_x64', True)
import jax.numpy as np
from jax import random
from jax import jit
from jax import vmap
from jax import lax
v... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a href="https
Step2: Warning
Step3: We can instantiate a collection of boids randomly in a box of side length $L$. We will use periodic bound... |
2,972 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from jyquickhelper import add_notebook_menu
add_notebook_menu()
url = "http://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing?file=data/"
file = "demo_mlifetable.tsv.gz"
import pyensae.datasource
local = pyensae.data... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Récupération des données
Step2: Puis on le charge sous forme de dataframe
Step3: La première colonne contient une aggrégation de champs. On s... |
2,973 | <ASSISTANT_TASK:>
Python Code:
%%bash
pip freeze | grep tensor
!pip3 install tensorflow-hub==0.7.0
!pip3 install --upgrade tensorflow==1.15.3
!pip3 install google-cloud-bigquery==1.10
import os
import tensorflow as tf
import numpy as np
import tensorflow_hub as hub
import shutil
PROJECT = 'cloud-training-demos' # REP... | <SYSTEM_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 make sure you install the necessary version of tensorflow-hub. After doing the pip install below, click "Restart the kernel" on the notebo... |
2,974 | <ASSISTANT_TASK:>
Python Code:
!pip install -q flax
from typing import Sequence
import matplotlib.pyplot as plt
import jax
import jax.numpy as jnp
try:
import flax.linen as nn
except ModuleNotFoundError:
%pip install -qq flax
import flax.linen as nn
from flax.training import train_state
try:
import opta... | <SYSTEM_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 Generation
Step2: Plotting
Step3: Models and Training
Step4: The loss function for the discriminator is
Step5: The loss function for th... |
2,975 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_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 prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
2,976 | <ASSISTANT_TASK:>
Python Code:
import time
import os
from package_api import download_data
import xarray as xr
from netCDF4 import Dataset, num2date
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
import datetime
import warnings
warnings.filterwarnings("igno... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font color='red'>Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly ... |
2,977 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-hh', '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... |
2,978 | <ASSISTANT_TASK:>
Python Code:
from functions import connect
connect() # Executeu, polsant Majúscules + Enter
from functions import forward, stop # cliqueu ací, i polseu Majúscules + Enter
from time import sleep # per a executar el bloc d'ordres
forward()
sleep(1)
stop()
from functions import disconnect... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Si apareix un missatge de confirmació, enhorabona, tot funciona. Si no, hi ha algun problema i haureu de cridar el professor de l'aula.
Step2: ... |
2,979 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import sklearn
import sklearn.datasets
from init_utils import sigmoid, relu, compute_loss, forward_propagation, backward_propagation
from init_utils import update_parameters, predict, load_dataset, plot_decision_boundary, predict_dec
%mat... | <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: You would like a classifier to separate the blue dots from the red dots.
Step4: 2 - Zero initialization
Step5: Expected Output
Step6: The per... |
2,980 | <ASSISTANT_TASK:>
Python Code:
t4 = [
[3],
[7, 4],
[2, 4, 6],
[8, 5, 9, 3],
]
t4
t15 = [
[75],
[95, 64],
[17, 47, 82],
[18, 35, 87, 10],
[20, 4, ... | <SYSTEM_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 try a somewhat functional approach.
Step2: Try tuples instead of lists.
Step3: Convert t4 and t15 to be tuples instead of lists.
|
2,981 | <ASSISTANT_TASK:>
Python Code:
# Initialize logging.
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
sentence_obama = 'Obama speaks to the media in Illinois'.lower().split()
sentence_president = 'The president greets the press in Chicago'.lower().split()
sente... | <SYSTEM_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 1
Step2: The first two sentences have very similar content, and as such the SCM should be large. Before we compute the SCM, we want to rem... |
2,982 | <ASSISTANT_TASK:>
Python Code:
# Basic imports
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
import scipy.optimize as spo
import sys
from time import time
from sklearn.metrics import r2_score, median_absolute_error
from multiprocessing import Pool
%matplotlib inl... | <SYSTEM_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 show the symbols data, to see how good the recommender has to be.
Step2: Let's run the trained agent, with the test set
Step3: And now a... |
2,983 | <ASSISTANT_TASK:>
Python Code:
def sumatoria_recursiva(n):
# Condición de termino
if n == 1:
return 1
# regla general
return n + sumatoria_recursiva(n-1)
sumatoria_recursiva(20)
20*21/2
def contar_texto(texto, st):
# Condición de termino
if len(texto) < len(st):
return 0
# D... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ahora implementaremos la funcion contar_texto, que busca cuantas veces se encuentra el texto "st", dentro de "texto".
Step2: Por ultimo, hace p... |
2,984 | <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
if os.environ["IS_TESTING"]:
... | <SYSTEM_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: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
2,985 | <ASSISTANT_TASK:>
Python Code:
data_train.info()
data_train.describe()
#每个/多个 属性和最后的Survived之间有着什么样的关系
#中文乱码:http://blog.csdn.net/heloowird/article/details/46343519
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
fig = plt.figur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 从整体数据信息来看,总共包含891个顾客信息,总共有714个顾客有年龄信息,船舱信息缺失比较严重。
Step2: 从上可以看出,头等舱顾客比较少,不到25%,平均年龄不到30,看起来都比较年轻啊,家里人平均数都不到1,
Step3: 这个时候我们可能会有一些想法了:
Step4: ... |
2,986 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
init_printing()
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x = Symbol('x', real=True)
A = Matrix(3,3, [x,x,0,0,x,x,0,0,x])
A
A.exp()
A = Matrix(4,4,[0,1,0,0,-1,0,1,0,0,0,0,1,1,0,-3, 0])
A
A.eigenvals()
%time Phi = (x*A).exp() # Fundamenta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Matrixexponentiale
Step2: Gekoppelte Pendel
Step3: Fundamentalsystem
Step4: Das Fundamentalsystem wird leider zu kompliziert
Step5: Numerisc... |
2,987 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
from sklearn.model_selection import train_test_split
my_color_map = ['green','aqua','pink','blue','red','black','yellow','teal','orange','grey']
tr_data = pd.read_csv('../input... | <SYSTEM_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 lets load our data set for this tutorial
Step2: pandas has lots of great features that can help us get insights to the data with very littl... |
2,988 | <ASSISTANT_TASK:>
Python Code:
def solve(n ) :
initial_array =[[ 0 for i in range(n - 1 ) ] for j in range(n - 1 ) ]
final_array =[[ 0 for i in range(n ) ] for j in range(n ) ]
for i in range(n - 1 ) :
initial_array[0 ][i ] = i + 1
for i in range(1 , n - 1 ) :
for j in range(n - 1 ) :
initial_array[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
2,989 | <ASSISTANT_TASK:>
Python Code:
# inline plots
%matplotlib inline
# import matplotlib as plt acronym
import matplotlib.pylab as plt
# import numpy as np acronym
import numpy as np
# synthetic data
x = np.linspace(-10, 10, 100)**3
# plotting
plt.plot(x)
plt.show()
# synthetic data
x = np.random.normal(0, 2, 20)
y = 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: Kreslení bodů a řad
Step2: Popisky, legenda, titulek, velikost, rozsah, mřížka
Step3: Styl značek, spojnic
Step4: Ostatní druhy grafů
Step5: ... |
2,990 | <ASSISTANT_TASK:>
Python Code:
dic = {'name': 'Dabar', 'name': 'Dabar New', 'band': 'Honey'}
print(dic)
print(len(dic))
print(dic.items())
for i, j in {"a": "test", "b": "test2"}.items():
print(i, j)
# Progs and their albums
progs = {'Yes': ['Close To The Edge', 'Fragile'],
'Genesis': ['Foxtrot', 'The Nursery ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NOTE
Step2: NOTE
Step3: Lets check below two examples and see what is happening
Step4: NOTE
|
2,991 | <ASSISTANT_TASK:>
Python Code:
# Ваш ответ здесь
import numpy as np
def bagging(sample, sample_answers, subsamples_count):
'''
Делаем subsamples_count выборок с повторениями из sample и соответствующих им sample_answers.
'''
subsamples = np.empty([subsamples_count, sample.shape[0], sample.shape[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: Задача 3 (10% баллов)
Step2: Тестирование (15%)
Step3: Покажите, как менялись значения критерия качества accuracy при увеличении параметра num... |
2,992 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import sys
import matplotlib.pyplot as plt
import sympy as sym
import pandas as pd
import magnitude as mag
from magnitude import mg
mag.new_mag('lbm', mag.Magnitude(0.45359237, kg=1))
mag.new_mag('lbf', mg(4.4482216152605, 'N'))
mag.new_mag('mph', mg(0.44704, 'm/s'))
fr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Diagram
Step2: physical quantities
Step3: ground station parameters
Step4: secondary parameters
Step5: Calculations
Step6: balance moments ... |
2,993 | <ASSISTANT_TASK:>
Python Code:
# Import modules
import time
import math
import numpy as np
import scipy
import matplotlib.pyplot as plt
def linear_congruential_generator(x, a, b, m):
x = (a * x + b) % m
u = x / m
return u, x, a, b, m
def stdrand(x):
return linear_congruential_generator(x, pow(7, 5), 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: Necesaary Function For Monte Carlo Simulation
Step2: Monte Carlo Simulation (with Minimal standard random number generator)
Step3: Monte Carlo... |
2,994 | <ASSISTANT_TASK:>
Python Code:
# Authors: Tal Linzen <linzen@nyu.edu>
# Denis A. Engemann <denis.engemann@gmail.com>
# Jona Sassenhagen <jona.sassenhagen@gmail.com>
#
# License: BSD (3-clause)
import pandas as pd
import mne
from mne.stats import linear_regression, fdr_correction
from mne.viz import 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: Psycholinguistically relevant word characteristics are continuous. I.e.,
Step2: We observe that there appears to be a monotonic dependence of E... |
2,995 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.2,<2.3"
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('orb', times=np.linspace(0,10,1000), dataset='orb01', component=['primary', 'secondary'])
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: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details.
Step2: And we'll attach some dum... |
2,996 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('../..')
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
import pandas as pd
from batchflow import NumpySampler as NS
# truncated normal and uniform
ns1 = NS('n', dim=2).truncate(2.0, 0.8, lambda m: np.sum(np.abs(m), axis=1)) + 4
ns2 = 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: Intro
Step2: Building Samplers
Step3: take a look at a sample generated by our sampler
Step4: The same goes for ScipySampler based on scipy.s... |
2,997 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-3', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("... | <SYSTEM_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... |
2,998 | <ASSISTANT_TASK:>
Python Code:
#df = pd.read_csv("small-311-2015.csv")
df = pd.read_csv("311-2014.csv", nrows=200000)
df.head(2)
df.info()
def parse_date (str_date):
return dateutil.parser.parse(str_date)
df['created_dt']= df['Created Date'].apply(parse_date)
df.head(3)
df.info()
df["Complaint Type"].value_counts(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: What was the most popular type of complaint, and how many times was it filed?
Step2: Make a horizontal bar graph of the top 5 most frequent com... |
2,999 | <ASSISTANT_TASK:>
Python Code:
import pip
REQUIRED_MINIMUM_PANDAS_VERSION = '0.17.1'
try:
import pandas as pd
assert pd.__version__ >= REQUIRED_MINIMUM_PANDAS_VERSION
except:
raise Exception("Version %s or above of Pandas is required to run this notebook" % REQUIRED_MINIMUM_PANDAS_VERSION)
import sys
try:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Use decision optimization
Step 1
Step2: If CPLEX is not installed, you can install CPLEX Community edition.
Step3: Step 2
Step4: Blend qualit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.