Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
3,700
<ASSISTANT_TASK:> Python Code: import numpy as np import os.path import pdb import pandas as pd from pprint import pprint #DATA_DIR = '/home/brandon/terabyte/Datasets/ubuntu_dialogue_corpus/' DATA_DIR = '/home/brandon/ubuntu_dialogue_corpus/src/' # sample/' TRAIN_PATH = DATA_DIR + 'train.csv' VALID_PATH = DATA_DIR + '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: Step2: Reformatting Ubuntu Dialogue Corpus for Chatbot Model Step5: Functions for Visualization and Reformatting Step6: Training Data Step7: Turn-Ba...
3,701
<ASSISTANT_TASK:> Python Code: import os import numpy as np import matplotlib.pyplot as plt import speclite from desisim.io import read_basis_templates import matplotlib import seaborn as sns %matplotlib inline sns.set(style='white', font_scale=1.8, font='sans-serif') colors = sns.color_palette('Set2', n_colors=8, desa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Read the old (v2.2) and new (v3.0) templates here for convenience. Step2: Compare the coverage of physical parameter space. Step7: Directly co...
3,702
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy import optimize # training data x_train = np.array(([3,5],[5,1],[10,2],[6,1.5]), dtype=float) y_train = np.array(([75],[82],[93],[70]), dtype=float) # testing data x_test = np.array(([4, 5.5],[4.5, 1],[9,2.5],[6,2]), dtype=float) y_test = np.array(([70],[89],...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <p>The importance in separating testing data from training data is to always make sure the model is according to the real world by comparing to ...
3,703
<ASSISTANT_TASK:> Python Code: import rebound sim = rebound.Simulation() sim.add(m=1., x=1., vz = 2.) sim.add(m=1., a=1.) sim.status() sim.add(m=1.e-3, a=100.) sim.add(primary=sim.particles[1], a=0.01) print(sim.particles[1].a) orbits = sim.calculate_orbits() for orbit in orbits: print(orbit) print(sim.particl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Any components not passed automatically default to 0. REBOUND can also accept orbital elements. Step2: We always have to pass a semimajor ax...
3,704
<ASSISTANT_TASK:> Python Code: # point to our previously-saved data reference_catalog = '../data/PTF_Refims_Files/PTF_d022683_f02_c06_u000114210_p12_sexcat.ctlg' outfile = reference_catalog.split('/')[-1].replace('ctlg','shlv') ra_fav, dec_fav = (312.503802, -0.706603) mjds, mags, magerrs = source_lightcurve('../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: We'll start by loading the data from our favorite star, which has coordinates $\alpha_\mathrm{J2000}, \delta_\mathrm{J2000} = (312.503802, -0.70...
3,705
<ASSISTANT_TASK:> Python Code: import hashlib import os import pickle from urllib.request import urlretrieve import numpy as np from PIL import Image from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer from sklearn.utils import resample from tqdm import tqdm from zipfil...
<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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this...
3,706
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import openpnm as op %config InlineBackend.figure_formats = ['svg'] import openpnm.models.physics as pmods import matplotlib.pyplot as plt pn = op.network.Cubic(shape=[15,15,15], spacing=6e-5) geom = op.geometry.SpheresAndCylinders(network=pn, pores=...
<SYSTEM_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 only other argument that needs to be passed to the metrics relative permeability is the invasion sequence (We made it as a user defined sequ...
3,707
<ASSISTANT_TASK:> Python Code: import os from urllib.request import urlretrieve import pybel import logging logging.getLogger('pybel').setLevel(logging.DEBUG) logging.basicConfig(level=logging.DEBUG) logging.getLogger('urllib3').setLevel(logging.WARNING) print(pybel.get_version()) DESKTOP_PATH = os.path.join(os.path.ex...
<SYSTEM_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 download and parse a BEL document from the Human Brain Pharmacome project describing the 2018 paper from Boland et al., "Promoting ...
3,708
<ASSISTANT_TASK:> Python Code: from IPython.display import SVG SVG('oneport_tiered_calibration/images/boxDiagram.svg') SVG('oneport_tiered_calibration/images/probe.svg') ls oneport_tiered_calibration/ ls oneport_tiered_calibration/tier1/ ls oneport_tiered_calibration/tier1/measured/ from skrf.calibration import On...
<SYSTEM_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 notebook will demonstrate how to use skrf to do a two-tiered one-port calibration. We'll use data that was taken to characterize a wavegu...
3,709
<ASSISTANT_TASK:> Python Code: def f(x): return np.sin(x) # Функция def dfdx(x): return np.cos(x) # и ее производная. x0 = 1 # Точка, в которой производится дифференциирование. dx = np.logspace(-16, 0, 100) # Приращения аргумента. # Найдем приращения функции df = f(x0+dx)-f(x0) # и оценим производные. approx_dfdx = df...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step5: Как мы видим, погрешность не стремиться к нулю, а достигает своего минимума при шагах около $10^{-8}$, затем снова растет. Step8: Задание Step...
3,710
<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 classification with TensorFlow Lite Model Maker Step2: Import the required packages. Step3: Download the sample training data. Step4: Th...
3,711
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst # Ensure the right version of Tensorflow is installed. !pip freeze | grep tensorflow==2.5 import math import shutil import numpy as np import pandas as pd import tensorflow as tf print(tf.__version__) tf.compat.v1.logging....
<SYSTEM_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, we'll load our data set. Step2: Examine and split the data Step3: Now, split the data into two parts -- training and evaluation. Step4: ...
3,712
<ASSISTANT_TASK:> Python Code: import time import timeit currentTime = time.gmtime() print(currentTime) time.strftime("%a, %d %b %Y %H:%M:%S +0000", currentTime) type(currentTime) currentTime.tm_hour def parseTime(timeObj): '''parseTime: takes time.struct_time instances :return time displayed as strin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: UTC and local time Step2: As you can see, the returned values are not very interesting or useful themselves. Lets parse structure into more use...
3,713
<ASSISTANT_TASK:> Python Code: # Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Multilingual Universal Sentence Encoder Q&amp;A 检索 Step2: 运行以下代码块,下载并将 SQuAD 数据集提取为: Step3: 以下代码块使用 <a>Univeral Encoder Multilingual Q&amp;A 模...
3,714
<ASSISTANT_TASK:> Python Code: # Loading metadata from trainning database con = sqlite3.connect("F:/FMR/data.sqlite") db_documents = pd.read_sql_query("SELECT * from documents", con) db_authors = pd.read_sql_query("SELECT * from authors", con) data = db_documents # just a handy alias data.head() tokenised = load_json(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading Tokenised Full Text Step2: Preprocessing Data for Gensim and Finetuning Step3: Although we tried to handle these hyphenations in the p...
3,715
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import load_iris iris = load_iris() # create X(features) and y(response) X = iris.data y = iris.target from sklearn.linear_model import LogisticRegression logreg = LogisticRegression() logreg.fit(X, y) y_pred = logreg.predict(X) print "predicted response:\n",y_pred ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Logistic regression Step2: 分类准确率 Step3: 以上说明对于训练的数据,我们有96%的数据预测正确。这里我们使用相同的数据来训练和预测,使用的度量称其为训练准确度。 Step4: KNN(K=1) Step5: 上面我们得到了训练准确度为100%的...
3,716
<ASSISTANT_TASK:> Python Code: from __future__ import division import tweepy import datetime import json import os from pysqlite2 import dbapi2 as sqlite3 APP_KEY = "" APP_SECRET = "" OAUTH_TOKEN = "" OAUTH_TOKEN_SECRET = "" auth = tweepy.OAuthHandler(APP_KEY, APP_SECRET) auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Twitter authentication (fill this!) Step2: Using Tweepy instead of Twython (because it's more readily available via apt-get or zypper). Step3: ...
3,717
<ASSISTANT_TASK:> Python Code: # Import Node and Function module from nipype import Node, Function # Create a small example function def add_two(x_input): return x_input + 2 # Create Node addtwo = Node(Function(input_names=["x_input"], output_names=["val_output"], funct...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Trap 1 Step2: Now, let's see what happens if we move the import of random outside the scope of get_random_array
3,718
<ASSISTANT_TASK:> Python Code: s_pattern = 4000 # number of data points in the pattern t = np.arange(s_pattern)*0.001 # time points for the elements in the pattern D = 2 pattern1 = np.vstack([np.sin(t*np.pi), np.cos(t*np.pi)]).T pattern2 = np.vstack([np.sin(t*np.pi), -np.sin(t*np.pi)]).T plt.subplot(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: Now let's create a network that represents a rolling window in time (Aaron's "delay network"). The process determines what sort of pattern the ...
3,719
<ASSISTANT_TASK:> Python Code: my_variable = 10 print(my_variable) a = 10 b = 15 print(a + b) import this print('Entering the for loop:\n') for count in range(10): print(count) print('Still in the for loop.') print("\nNow I'm done with the for loop.") thing_1 = 47 # define an int object print(thing_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: ... and then access that variable in a later cell Step2: We'll be using Jupyter notebooks extensively in this class. I'll give a more detailed ...
3,720
<ASSISTANT_TASK:> Python Code: import torch import matplotlib.pyplot as plt import torch.nn as nn import torch.nn.functional as F import numpy as np from matplotlib.colors import ListedColormap def plot_decision_regions_3class(data_set,model=None): cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA','#00AAFF']) ...
<SYSTEM_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 this function only for plotting Step2: Use this function to calculate accuracy Step3: <a id="ref0"></a> Step4: Create a dataset object St...
3,721
<ASSISTANT_TASK:> Python Code: import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import numpy as np %matplotlib inline df = pd.read_json('../data/raw/train.json') df['created'] = df['created'].apply(lambda row: pd.to_datetime(row)) def relative_count(df, column): # Calculate counts per bedr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Bedrooms Step2: We can see that the interest level rises slightly for apartments with more than 1 bedrooms, but for 5 bedrooms and more it fall...
3,722
<ASSISTANT_TASK:> Python Code: %run "../Functions/2. Google form analysis.ipynb" # Localplayerguids of users who answered the questionnaire (see below). # French #localplayerguid = 'a4d4b030-9117-4331-ba48-90dc05a7e65a' #localplayerguid = 'd6826fd9-a6fc-4046-b974-68e50576183f' #localplayerguid = 'deb089c0-9be3-4b75-9b2...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 'Google form analysis' functions checks Step2: hasAnswered Step3: getAnswers Step4: getCorrections Step5: getScore Step6: code to explore s...
3,723
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() from cvxopt import solvers, matrix m = matrix( [ [2.0, 1.1] ] ) # mettre des réels (float) et non des entiers # cvxopt ne fait pas de conversion implicite t = m.T # la tra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Le langage Python propose des modules qui permettent de résoudre des problèmes d'optimisation sous contraintes et il n'est pas forcément nécessa...
3,724
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import tables import matplotlib.pyplot as plt import seaborn as sns import pybromo as pbm print('Numpy version:', np.__version__) print('PyTables version:', tables.__version__) print('PyBroMo version:', pbm.__version__) S = pbm.ParticlesSimulation.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: Timestamps simulation Step2: Simulation of the series of emission rates Step3: Simulate timestamps for background = 1kcps Step4: Simulate tim...
3,725
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from scipy.special import erfc def newfig(title='?', xlabel='?', ylabel='?', xlim=None, ylim=None, xscale='linear', yscale='linear', size_inches=(14, 8)): '''Setup a new axis for plotting''' fig, ax = plt.subpl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Convenience function for setting up a graph Step2: Super position with $\mathtt{erfc}()$ subtracted from initial head $a$ Step3: Same, thing, ...
3,726
<ASSISTANT_TASK:> Python Code: import os.path as op import mne from mne.datasets.sample import data_path fname = op.join(data_path(), 'MEG', 'sample', 'sample_audvis_raw.fif') raw = mne.io.read_raw_fif(fname).crop(0, 10) original_level = mne.get_config('MNE_LOGGING_LEVEL', 'INFO') print(mne.get_config_path()) print(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: MNE-python stores configurations to a folder called .mne in the user's Step2: These configurations include information like sample data paths a...
3,727
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline rnd = np.random.RandomState(seed=42) n_data = 16 # number of data points a_true = 1.255 # randomly chosen truth b_true = 4.507 # Fill in your solution here # evaluate the true model at the given x values y = a_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: Intro and choice of objective function Step2: Exercise 1 Step3: Execute the code below and verify that it executes Step4: Now let's forget th...
3,728
<ASSISTANT_TASK:> Python Code: #@title Default title text # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Goal Step2: Generalize the loss above to
3,729
<ASSISTANT_TASK:> Python Code: from collections import namedtuple from copy import deepcopy import random import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from sklearn.manifold import TSNE from sklearn.metrics.pairwise import cosine_similarity from sqlalchemy import create_en...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Abstract Step2: Next, let's get an idea of the sparsity of our data and how many songs each country has streamed. Step3: Construct training, v...
3,730
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import pandas as pd import statsmodels.api as sm from statsmodels import regression from scipy import poly1d x = np.arange(10) y = 2*np.random.randn(10) + x**2 xs = np.linspace(-0.25, 9.25, 200) lin = np.polyfit(x, y, 1) quad = np.polyfit...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: When working with real data, there is unlikely to ever be a situation where a ninth-degree polynomial is appropriate Step2: However, when we us...
3,731
<ASSISTANT_TASK:> Python Code: from keras.models import Sequential from keras.layers import Conv2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers import Dense classifier = Sequential() classifier.add(Conv2D(32, (3, 3), input_shape = (64, 64, 3), activation = 'relu')) classif...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Initialising the CNN Step2: Step 1 - Convolution Step3: Step 2 - Pooling Step4: Adding a second convolutional layer Step5: Step 3 - Flatteni...
3,732
<ASSISTANT_TASK:> Python Code: rst(O.to_iterable) s = marble_stream("a--b-c|") l, ts = [], time.time() def on_next(listed): print('got', listed, time.time()-ts) for i in (1, 2): d = s.subscribe(on_next) # second run: only one value, the list. s = s.to_list() # both are started around same 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: I want an operator to operate on a particular Scheduler Step2: ...when it notifies observers observe_on Step3: I want an Observable to invoke ...
3,733
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd %matplotlib inline import matplotlib.pyplot as plt plt.style.use('ggplot') from numpy.linalg import inv, norm def objective(P, q, r, x): Return the value of the Standard form QP using the current value of x. return 0.5 * np.dot(x, np.dot(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: Step2: Pure-Python ADMM Implementation Step3: QP Solver using CVXPY Step4: Generate Optimal Portfolio Holdings Step5: Set up the Portfolio Optimizat...
3,734
<ASSISTANT_TASK:> Python Code: !pip -q install rdkit-pypi==2021.9.4 import ast import pandas as pd import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers import matplotlib.pyplot as plt from rdkit import Chem, RDLogger from rdkit.Chem import BondType from rdkit.Chem....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Dataset Step2: Hyperparameters Step3: Generate training set Step4: Build the Encoder and Decoder Step5: Build the Sampling layer Step6: Bui...
3,735
<ASSISTANT_TASK:> Python Code: # Import required libraries from tpot import TPOTClassifier from sklearn.model_selection import train_test_split import pandas as pd import numpy as np # Load the data titanic = pd.read_csv('data/titanic_train.csv') titanic.head(5) titanic.groupby('Sex').Survived.value_counts() titanic....
<SYSTEM_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 Exploration Step2: Data Munging Step3: At present, TPOT requires all the data to be in numerical format. As we can see below, our data se...
3,736
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame(dict(col1=[[1, 2, 3],[4,5]])) def g(df): for i in df.index: df.loc[i, 'col1'] = df.loc[i, 'col1'][::-1] L = df.col1.sum() L = map(lambda x:str(x), L) return ','.join(L) result = g(df.copy()) <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:
3,737
<ASSISTANT_TASK:> Python Code: ## Can build up a dict by starting with the the empty dict {} ## and storing key/value pairs into the dict like this: ## dict[key] = value-for-that-key dict = {} dict['a'] = 'alpha' dict['g'] = 'gamma' dict['o'] = 'omega' print dict print dict['a'] dict['a'] = 6 print dict['a'] 'a' in dic...
<SYSTEM_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 for loop on a dictionary iterates over its keys by default. The keys will appear in an arbitrary order. The methods dict.keys() and dict.value...
3,738
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) img = mnist.train.images[2] plt.imshow(img.reshape((28, 28)), cmap='G...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Network Architecture Step2: Training Step3: Denoising Step4: Checking out the performance
3,739
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from bokeh.embed import file_html from bokeh.io import output_notebook, show from bokeh.layouts import layout from bokeh.models import ( ColumnDataSource, Plot, Circle, Range1d, LinearAxis, HoverTool, Text, SingleIntervalTicker, Slider, Cust...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setting up the data Step2: sources looks like this Step3: Build the plot Step4: Build the axes Step5: Add the background year text Step6...
3,740
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from IPython.display import HTML # intégration notebook %matplotlib inline def plot_cmap(cmap, ncolor=6): A convenient function to plot colors of a matplotlib cmap Args: ncolor (int): 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: Step3: Functions Step4: Color models Step5: Sequential palettes Step6: Reverse order Step7: Divergent palettes Step8: Build a custum color palette...
3,741
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np X = np.array([ [0, 0], [0, 1], [1, 0], [1, 1]]) y = np.array([0, 1, 1, 0]) pd.DataFrame(np.hstack((X, y.reshape(-1, 1))), columns=['x1', 'x2', 'y']) %matplotlib inline import matplotlib.pyplot as plt plt.scatter(X[y==0...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The problem with this function is that there is no linear function that correctly can classify the data. It is non-separable. Step2: Types of d...
3,742
<ASSISTANT_TASK:> Python Code: import tensorflow as tf tf.enable_eager_execution() tfe = tf.contrib.eager # Creating variables v = tfe.Variable(1.0) v v.assign_add(1.0) v # In the tf.keras.layers package, layers are objects. To construct a layer, # simply construct the object. Most layers take as a first argument the...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Variables Step2: Layers Step3: The full list of pre-existing layers can be seen in the documentation. It includes Dense (a fully-connected lay...
3,743
<ASSISTANT_TASK:> Python Code: !pip install thinc syntok "ml_datasets>=0.2.0" tqdm from syntok.tokenizer import Tokenizer def tokenize_texts(texts): tok = Tokenizer() return [[token.value for token in tok.tokenize(text)] for text in texts] import ml_datasets import numpy def load_data(): train_data, dev_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: For simple and standalone tokenization, we'll use the syntok package and the following function Step2: Setting up the data Step3: Defining the...
3,744
<ASSISTANT_TASK:> Python Code: from IPython.core.display import display, HTML display(HTML('My first ipython HTML <b>bold</b> tag')) display(HTML('My first ipython HTML <em>italics</em> tag')) display(HTML('My first ipython HTML <em>italics tag')) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 2 Step2: Debug 1
3,745
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns import networkx as nx K_5=nx.complete_graph(5) nx.draw(K_5) def complete_deg(n): np.zeros((n,n), dtype = np.int) np.diag(np.diag(n-1)) print complete_deg() D = complete_deg() #I dont get...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Complete graph Laplacian Step2: The Laplacian Matrix is a matrix that is extremely important in graph theory and numerical analysis. It is defi...
3,746
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from matplotlib import rc, patches # Increase font size, set CM as default text, and use LaTeX rc('font', **{'size': 16, 'family': 'serif', 'serif': ['Computer Modern Roman']}) rc('text', usetex=True) # Define colours (taken from http://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: Step2: Load the circle-function Step3: Linear example Step4: Semilog and loglog example
3,747
<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: 我们使用带自定义训练循环的 mini-batch 梯度对其进行训练。 Step4: 下面是我们的训练循环: Step5: 指标的低级处理 Step6: 下面是我们的训练和评估循环: Step7: 使用 tf.function...
3,748
<ASSISTANT_TASK:> Python Code: def fun(x): return np.exp(-x**2) integr.quad(fun,0.,1.) integr.quad(lambda x:np.exp(-x**2),0.,1.) def fun(x,a): return x**a [integr.quad(fun,0.,1.,args=(m,))[0] for m in range(0,5)] res1 = integr.quad(lambda y:integr.quad(lambda x,y:np.exp(-x**2-y**2)/np.pi,-1,1, args=(y,))[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: En ocasiones, conviene definir la función a integrar como dependiente de parámetros. Por ejemplo Step2: Integrales impropias Step3: Integració...
3,749
<ASSISTANT_TASK:> Python Code: pip install --user apache-beam[gcp] import apache_beam as beam print(beam.__version__) # change these to try this notebook out BUCKET = 'cloud-training-demos-ml' PROJECT = 'cloud-training-demos' REGION = 'us-central1' import os os.environ['BUCKET'] = BUCKET os.environ['PROJECT'] = PROJE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Run the command again if you are getting oauth2client error. Step2: You may receive a UserWarning about the Apache Beam SDK for Python 3 as not...
3,750
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline plt.style.use('fivethirtyeight') plt.rcParams['figure.figsize'] = (10, 6) pop = pd.read_csv('data/cars_small.csv') pop.head() class_mapping = {'Hatchback': 0, 'Sedan': 1} pop['types'] = pop['type']....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lets say we want to classify the vehicles by 'Hatchback' and 'Sedan' Step2: Why Linear Function does not work Step3: However, there are two pr...
3,751
<ASSISTANT_TASK:> Python Code: # # this function has 3 optional arguments # def optional_args(a=None, b='one', c=3): print('a={}, b={}, c={}'.format(a,b,c)) optional_args() #prints #a=None, b=one, c=3 # # we can also pass the arguments via a dictionary # so we can save them/modify them # arg_dict=dict(a=4,b=[1,2,3]...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Writing a function to take unknown optional arguments Step2: Required arguments Step3: Writing a function to take an unknown number of requir...
3,752
<ASSISTANT_TASK:> Python Code: import iris fname = iris.sample_data_path('air_temp.pp') cubes = iris.load(fname) print(type(cubes)) print(cubes) cube = iris.load_cube(fname) print(type(cube)) print(cube) cubes[0] == cube # # edit space for user code ... # fname = iris.sample_data_path('uk_hires.pp') cubes = iris....
<SYSTEM_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.1 Iris Load Functions<a id='iris_load_functions'></a> Step2: If we give this filepath to load, we see that Iris returns a cubelist. Step3: A...
3,753
<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: TFLite용 Jax 모델 변환 Step3: 데이터 준비 Step4: Jax로 MNIST 모델 빌드 Step5: 모델 학습 및 평가 Step6: TFLite 모델로 변환합니다. Step7: 변환된 TFLite 모델 확인 Step8: 모델 최적화 S...
3,754
<ASSISTANT_TASK:> Python Code: %%tikz --scale 2 --size 800,300 -f svg \tikzset{node distance=2cm, block/.style={rectangle, draw, minimum height=15mm, minimum width=20mm}, sumnode/.style={circle, draw, inner sep=2pt} } \node[coordinate] (input) {}; \node[block, right of=input] (TR) {$F_f(s)=K\frac{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: Model Step2: Finding the controller parameters Step3: Bodeplot of the loop gain
3,755
<ASSISTANT_TASK:> Python Code: import numpy as np C = np.complex(3,4) print('C=', C) print(type(C)) c = np.array([3+4j]) #c = 3+4j print('c=', c) print(type(c)) print('Parte real:', c.real) print('Parte imaginária:', c.imag) print(c.shape) cc = np.conjugate(c) print('c=', c) print('Complexo conjugado:', cc) print('Pa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Porém, como iremos trabalhar com números complexos em imagens, utilizaremos não apenas um Step2: O conjugado deste mesmo número complexo $c$ é ...
3,756
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-1', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
3,757
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import matplotlib.pyplot as plt try: import seaborn as sns except ImportError: print("Seaborn not installed. Oh well.") import numpy as np import astropy.io.fits as fits import sherpa.astro.ui as ui from clarsach.respond import RMF, ARF datadir = "../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: Let's load some data Step2: Let's load the data using Clàrsach Step3: Let's also load the ARF and RMF Step4: Let's make an empty model to div...
3,758
<ASSISTANT_TASK:> Python Code: from horsetailmatching import HorsetailMatching, UniformParameter from horsetailmatching.demoproblems import TP2 from horsetailmatching.surrogates import PolySurrogate import numpy as np uparams = [UniformParameter(), UniformParameter()] thePoly = PolySurrogate(dimensions=len(uparams), o...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lets start with the built in in polynomial chaos surrogate. This finds the coefficients of a polynomial expansion by evaluating the inner produc...
3,759
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd start_col, end_col = 'starttime', 'stoptime' # Loading just first 10,000 rows df = pd.read_csv('201501-citibike-tripdata.csv', parse_dates=[start_col, end_col], nrows=10000) @np.vectorize def minutes(time): Convert time to minutes since 00:00 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load Data Step3: Parts of Day Step4: Sample Output
3,760
<ASSISTANT_TASK:> Python Code: data = pd.read_csv('data/driving_log.csv', header=None, names=['center', 'left', 'right', 'angle', 'throttle', 'break', 'speed']) print(data.ix[0].center) data.sample() def img_id(path): return path.split('/IMG/')[1] image_paths = data.center.apply(img_id).values.t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reading and Preprocessing the Images with OpenCV Step2: Building a Convnet in Keras
3,761
<ASSISTANT_TASK:> Python Code: '8 = %d , 8.5 = %.1f, name = %s, 3 = %04d' % (8, 8.5, 'Ravi', 3) '8 = {}, 8.5 = {}, name = {}, 3 = {:04}'.format(8, 8.5, 'Ravi', 3) '8 = {a}, 8.5 = {b}, name = {c}, 3 = {d:04}'.format(a = 8, c = 'Ravi', d = 3, b = 8.5) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: There is one more way to format, without the hassle of remembering the format specifiers. You can use format() method of the current string. Sam...
3,762
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import cartopy.crs as ccrs ax = plt.axes(projection=ccrs.PlateCarree()) ax.coastlines() plt.show() # # EDIT for user code ... # # %load solutions/cartopy_exercise_1 # Make sure the figure is a decent size when plotted. fig = plt.figure(figsize=(14, 7)) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Cartopy's matplotlib interface is set up via the projection keyword when constructing a matplotlib Axes / SubAxes instance. The resulting axes i...
3,763
<ASSISTANT_TASK:> Python Code: import requests import json #Every request begins with the server's URL SERVER = 'http://data.neonscience.org/api/v0/' #Site Code for Lower Teakettle SITECODE = 'TEAK' #Make request, using the sites/ endpoint site_request = requests.get(SERVER+'sites/'+SITECODE) #Convert to Python JSON ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Site Querying Step2: We first use the requests module to send the API request using the 'get' function; this returns a 'request' object. Step3:...
3,764
<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: 加载和准备数据 Step2: 数据简介 Step3: 虚拟变量(哑变量) Step4: 调整目标变量 Step5: 将数据拆分为训练、测试和验证数据集 Step6: 我们将数据拆分为两个数据集,一个用作训练,一个在网络训练完后用来验证网络。因为数据是有时间序列特性的,所以我们用...
3,765
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'sandbox-3', 'toplevel') # 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...
3,766
<ASSISTANT_TASK:> Python Code: import pandas as pd test_data = pd.read_csv("../data/relex-sparse-multiple-choice.csv") test_data.head() import crowdtruth from crowdtruth.configuration import DefaultConfig class TestConfig(DefaultConfig): inputColumns = ["sent_id", "term1", "b1", "e1", "term2", "b2", "e2", "senten...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Declaring a pre-processing configuration Step2: Our test class inherits the default configuration DefaultConfig, while also declaring some addi...
3,767
<ASSISTANT_TASK:> Python Code: import os import numpy as np import cv2 %matplotlib inline from matplotlib import pyplot as plt REALSQUARE = 23.500 # Size of a square BOARDDIM = (6,8) # Dimensions of the given board NUMIMG = 9 # Number of images to open imagesList = list() # Opens each image and adds to the image list 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: Detect the corners on the real images and compute A matrix Step2: Now we must compute the parameters of the rotation matrix R and translation v...
3,768
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import sys print("Python Version:",sys.version.split(" ")[0]) print("TensorFlow Version:",tf.VERSION) sess = tf.InteractiveSession() a = tf.zeros(()) a a.eval() a.shape a.shape.ndims a.name tf.zeros(()) b = tf.zeros((3), name="b") b type(b.eval()) sess.r...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Graph Execution Step2: Generating new Tensors Step3: We create a tensor and assigned it to a local variable named a. When we check the value o...
3,769
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy import scipy.stats import matplotlib.pyplot as plt 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) weight = scipy.stats.lognorm(0.23, 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: 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...
3,770
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-2', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "ema...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
3,771
<ASSISTANT_TASK:> Python Code: !pip install -U -q PyDrive from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive from google.colab import auth from oauth2client.client import GoogleCredentials # 1. Authenticate and create the PyDrive client. auth.authenticate_user() gauth = GoogleAuth() gauth.credent...
<SYSTEM_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. 케라스 모델파일 읽기/쓰기 Step2: 4. root 경로에 저장된 모델파일을 드라이브의 원하는 폴더에 저장
3,772
<ASSISTANT_TASK:> Python Code: import time from collections import namedtuple import numpy as np import tensorflow as tf with open('anna.txt', 'r') as f: text=f.read() vocab = set(text) vocab_to_int = {c: i for i, c in enumerate(vocab)} int_to_vocab = dict(enumerate(vocab)) chars = np.array([vocab_to_int[c] for 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: First we'll load the text file and convert it into integers for our network to use. Here I'm creating a couple dictionaries to convert the chara...
3,773
<ASSISTANT_TASK:> Python Code: import os pgconfig = { 'host': os.environ['PGHOST'], 'port': os.environ['PGPORT'], 'database': os.environ['PGDATABASE'], 'user': os.environ['PGUSER'], 'password': os.environ['PGPASSWORD'], } %load_ext sql dsl = 'postgres://{user}:{password}@{host}:{port}/{database}'.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: 拡張を読み込み、データベースに接続します。 Step2: SQL を実行してその結果を確認 Step3: 実行結果を pandas のデータフレームに変換します。 Step4: 少し複雑な SQL を実行するため、店舗ごとの所在地、従業員数、顧客数を集計します。 Step5: 結...
3,774
<ASSISTANT_TASK:> Python Code: import heapq # Create a priority queue abstract base class class priority_queue: # Initialize the instance def __init__(self): # Create a list to use as the queue self._queue = [] # Create an index to use as ordering self._index = 0 # Create 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: Create A Priority Queue Object Step2: Add Items To Queue Step3: Retrieve Items From Queue By Priority
3,775
<ASSISTANT_TASK:> Python Code: n = 100 x = np.random.normal(1, 0.5, n) noise = np.random.normal(0, 0.25, n) y = 0.75*x + 1 + noise fig, ax = plt.subplots(1, 1, figsize=(6,4)) ax.scatter(x, y) ax.set_xlim([0,2]) ax.set_ylim([0,3.1]) def fit(x,y, with_constant=True): beta = np.cov(x,y)[0][1] / np.var(x) if with_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Simple linear regression considers the model function Step2: Expected value Step3: We can fit a linear regression model on the training data S...
3,776
<ASSISTANT_TASK:> Python Code: %cd -q ~/neurokernel/examples/olfaction/data %run gen_olf_input.py %run create_olf_gexf.py import re import networkx as nx import neurokernel.tools.graph g = nx.read_gexf('antennallobe.gexf.gz') df_node, df_edge = neurokernel.tools.graph.graph_to_df(g) glom_name = 'DA1' osn_ind = sorted(...
<SYSTEM_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, we identify the indices of the olfactory sensory neurons (OSNs) and projection neurons (PNs) associated with a specific glomerulus; in thi...
3,777
<ASSISTANT_TASK:> Python Code: NAME = "dchud" COLLABORATORS = "" !wget --quiet -O boating.csv "https://data.ct.gov/api/views/mrb6-7ee5/rows.csv?accessType=DOWNLOAD" !head boating.csv | csvlook !wc -l boating.csv !csvstat boating.csv !mv boating.csv boating-orig.csv !echo "year,tx_type,num" > boating.csv !tail -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: Exercise 03 - Due Friday, September 30 at 12pm Step2: Verify that it's what we think it is on the commandline Step3: Looks right. How many re...
3,778
<ASSISTANT_TASK:> Python Code: import pprint document = "Human machine interface for lab abc computer applications" text_corpus = [ "Human machine interface for lab abc computer applications", "A survey of user opinion of computer system response time", "The EPS user interface management system", "Sys...
<SYSTEM_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 core concepts of gensim are Step2: Corpus Step3: .. Important Step4: Before proceeding, we want to associate each word in the corpus with...
3,779
<ASSISTANT_TASK:> Python Code: from notebook_preamble import D, J, V, define J('[0 2 7 0] dup max') from joy.library import SimpleFunctionWrapper from joy.utils.stack import list_to_stack @SimpleFunctionWrapper def index_of(stack): '''Given a sequence and a item, return the index of the item, or -1 if not 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: Starting at index distribute count "blocks" to the "banks" in the sequence. Step2: Recalling "Generator Programs" Step3: A function to drive a...
3,780
<ASSISTANT_TASK:> Python Code: import numpy as np import warnings from scipy.optimize import minimize from scipy.integrate import quad from scipy.interpolate import interp1d from scipy import stats from importlib import reload from src import sim_cts, sim_discrete from scipy.stats import poisson, geom import tensorflow...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: basic use Step2: Interactive style session Step3: placeholders, variables, scope Step4: So that worked beautifully with TF's own built-in opt...
3,781
<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 = (5025, 5036) DON'T MODI...
<SYSTEM_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...
3,782
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import os from time import time from ipyparallel import Client os.environ['RTDATAPATH'] = '/Users/mate/g/rt/data/refdata/' import atmosphere as atm from atmosphere.rt import pydisort atm.refdata.setup_directory() def create_atmosphere_model(**kw): ...
<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: Define methods for generating an atmospheric model of Titan and performing RT calculation Step4: Parallel (multi-core) execution Step5: Compar...
3,783
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import numpy as np import pandas as pd import matplotlib.pyplot as plt import calendar import datetime import matplotlib.dates as mdates from API_client.python.datahub import datahub_main from API_client.python.lib.dataset import dataset from API_client.python.lib.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: Step1: The API needs a file APIKEY with your API key in the work folder. We initialize a datahub and dataset objects. Step2: At the moment we are goin...
3,784
<ASSISTANT_TASK:> Python Code: #Import libraries import os import glob import random import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy.misc import imread, imresize from random import shuffle from sklearn.model_selection import train_test_split from sklearn import preprocessing #Initial 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: Showing Training and Test Samples Step2: Training Images Step3: Storing Processed Files On Disk Step4: Since here, the images are processed a...
3,785
<ASSISTANT_TASK:> Python Code: # Import required modules import pandas as pd import numpy as np data = {'name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 'age': [42, 52, 36, 24, 73], 'preTestScore': [4, 24, 31, 2, 3], 'postTestScore': [25, 94, 57, 62, 70]} df = pd.DataFrame(data, columns = [...
<SYSTEM_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 a dataframe Step2: Add a new column for elderly
3,786
<ASSISTANT_TASK:> Python Code: from cobra.io import load_model model = load_model("textbook") model.medium medium = model.medium medium["EX_o2_e"] = 0.0 model.medium = medium model.medium model.slim_optimize() model.medium["EX_co2_e"] = 0.0 model.medium medium = model.medium medium["EX_co2_e"] = 0.0 model.medium = ...
<SYSTEM_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 will return a dictionary that contains the upper flux bounds for all active exchange fluxes (the ones having non-zero flux bounds). Right n...
3,787
<ASSISTANT_TASK:> Python Code: import random random.seed(1) a = [7, 1, 2, 8, 1, 3] rnd_lst = random.sample(range(0, 10000000), 1000) import sys def max_pairprod_1(ary): n = len(ary) max_prod = -sys.float_info.max for i in range(0, n): for j in range(i + 1, n): prod = ary[i] * ary[j...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The probably simplest implementation may be to compute the product of each pair in this list while keeping track of the largest product as we tr...
3,788
<ASSISTANT_TASK:> Python Code: data.head() from IPython.display import display, HTML display(HTML("<h1>Okay, you want not to do this on your own.. then now: How to do this (scroll down)</h1>")) for i in range(20): display(HTML("<br />")) numerical_cols = [col for col in data.columns if data[col].dtype == 'int64']...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Okay, please try to create the following images Step2: Okay, let's go! Step3: Okay, nice. Step4: Nice, we need to choose ground & fire poke...
3,789
<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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wri...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Environment Preparation Step2: Install Analytics Zoo Step3: You can install the latest pre-release version using pip install --pre --upgrade a...
3,790
<ASSISTANT_TASK:> Python Code: # import thr random numbers module. More on modules in a future notebook import random # empty list a = list() # or a = [] # define a list a = [1,2,3,4,2,2] print a # list of numbers from 0 to 9 a = range(10) a # Python is zer-bases indexing a[0] # Get the last element a[-1] # Get the ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Define a list Step2: Accesing elements of a list
3,791
<ASSISTANT_TASK:> Python Code: import sys import os import inspect import datetime as dt from opengrid.library import solarmodel as sm import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = 16,8 SI = sm.SolarInsolation('Brussel') print(SI.location.latlng, SI.elevation) date = dt.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: Solar Insolation object Step2: It uses this location to calculate the position of the sun and the mass of the air the sun has to penetrate for ...
3,792
<ASSISTANT_TASK:> Python Code: %matplotlib inline import cf import netCDF4 import matplotlib.pyplot as plt dataurl = "http://thredds.socib.es/thredds/dodsC/mooring/conductivity_and_temperature_recorder/buoy_canaldeibiza-scb_sbe37006/L1/dep0003_buoy-canaldeibiza_scb-sbe37006_L1_latest.nc" f = cf.read(dataurl) print 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: The data file is the same. Step2: Read the file Step3: We see that the file contains 4 variables Step4: The number of variables which have a ...
3,793
<ASSISTANT_TASK:> Python Code: # Author: Denis A. Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne import io from mne.datasets import spm_face from mne.minimum_norm import apply_inverse, make_inverse_operator from mne.cov import compu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get data Step2: Estimate covariances Step3: Show the resulting source estimates
3,794
<ASSISTANT_TASK:> Python Code: weather = pd.read_table("daily_weather.tsv") usage = pd.read_table("usage_2012.tsv") station = pd.read_table("stations.tsv") weather.loc[weather['season_code'] == 1, 'season_desc'] = 'winter' weather.loc[weather['season_code'] == 2, 'season_desc'] = 'spring' weather.loc[weather['season_co...
<SYSTEM_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.Use a scatterplot to show how the daily rental volume varies with temperature. Use a different series (with different colors) for each season....
3,795
<ASSISTANT_TASK:> Python Code: import numpy as np num_examples, num_features = (1000, 2) # dataset size num_classes = 2 # binary classification task X = np.random.random((num_examples, num_features)) y = np.int_(X[:, 0] * X[:, 0] + X[:, 1] >= 1).reshape(-1, 1) print("Features (X): {shape[0]}x{shape[1]}".format(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: Step2: Visualize Data Step3: Prepare Data for Training and Testing Step4: Build Computation Graph Step6: Define helper functions Step10: Define lay...
3,796
<ASSISTANT_TASK:> Python Code: import numpy import matplotlib.pyplot as plt from matplotlib import rc from scipy import linalg from scipy.integrate import simps %matplotlib inline def f(x): return x * numpy.sin(3 * numpy.pi * x / 2) + (9/4) * (numpy.pi ** 2) * numpy.sin(3 * numpy.pi * x /2) def expected_solution_ca...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Матрица $K_j = \frac{2}{h} \int \limits_{-1}^{1} \frac{d}{d\xi} Step2: Аналогично Step3: Вектор нагрузки также можно записать в виде скалярног...
3,797
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import numpy as np from scipy import signal import matplotlib.pyplot as plt import mne from mne.time_frequency import fit_iir_model_raw from mne.datasets import sample print(__doc__) data_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: Plot the different time series and PSDs
3,798
<ASSISTANT_TASK:> Python Code: from IPython.display import Image from IPython.core.display import HTML from __future__ import print_function, division import numpy as np import tensorflow as tf import matplotlib.pyplot as plt Image(url= "https://cdn-images-1.medium.com/max/1600/1*UkI9za9zTR-HL8uM15Wmzw.png") #hyperpar...
<SYSTEM_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 figure below shows the input data-matrix, and the current batch batchX_placeholder Step2: As you can see in the picture below that is done...
3,799
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'sandbox-1', 'ocnbgchem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("nam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...