Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
7,600
<ASSISTANT_TASK:> Python Code: !pip install nnabla-ext-cuda100 !git clone https://github.com/sony/nnabla-examples.git %cd nnabla-examples import numpy as np import nnabla as nn import nnabla.logger as logger import nnabla.functions as F import nnabla.parametric_functions as PF import nnabla.solvers as S import nnabla....
<SYSTEM_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 start by importing dependencies. Step2: Now let's define a function to download and load MNIST. This function will pass image-label pairs...
7,601
<ASSISTANT_TASK:> Python Code: # populate namespace with pylab functions and stuff %pylab inline # import NEST & NEST rasterplot import nest import nest.raster_plot # simulation parameters simtime = 1000. # simulation time (ms) dt = 0.1 # simulation resolution (ms) # network parameters gam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Configure NEST Step3: Create neurons and devices Step4: Create connections Step5: Simulate and analyse
7,602
<ASSISTANT_TASK:> Python Code: data = dict( labels=['Bananas','Apples','Oranges','Watermelons','Grapes','Kiwis'], values=[4000,8000,3000,1600,1000,2500] ) out = StdCharts.HBar(data) HTML(out) StdCharts.save(out,'report_chart.png') data = dict( labels=['Bananas','Apples','Oranges','Watermelons','Grapes','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: You can also save your chart with the save method Step2: Example 2 Step3: Vertical Bar Charts Step4: Example 4
7,603
<ASSISTANT_TASK:> Python Code: def sumar(x, y): # Defino la función sumar return x + y x = 4 z = 5 print sumar(x, z) # Invoco a la función sumar con los parámetros x y z print sumar(1, 2) # Invoco a la función sumar con los parámetros 1 y 2 print sumar('hola ', 'mundo') def sumar(x, y): Suma dos elementos ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Aunque en ningún momento indicamos que lo que tiene que sumar son números, por lo que también puede sumar strings Step3: Además, a esta función...
7,604
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-ll', 'toplevel') # 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: 2...
7,605
<ASSISTANT_TASK:> Python Code: # Python 2 and 3 compatibility # pip install future from __future__ import (absolute_import, division, print_function, unicode_literals) # отключим предупреждения Anaconda import warnings warnings.simplefilter('ignore') import pandas as pd import numpy as np %matpl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Основными структурами данных в Pandas являются классы Series и DataFrame. Первый из них представляет собой одномерный индексированный массив дан...
7,606
<ASSISTANT_TASK:> Python Code: import numpy as np from sklearn.decomposition import PCA import pandas as pd df = pd.read_csv('Manhattan.txt', sep='\s+') df.drop('id', axis=1, inplace=True) df.tail() tdf = df.iloc[:, 0:-3] tdf.tail() pca = PCA(n_components=8) pca.fit(tdf) np.set_printoptions(precision=6, suppress=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: how to index a given part of a DataFrame have been a problem for me. Step2: 取一个主成分, 解释方差0.917864
7,607
<ASSISTANT_TASK:> Python Code: # TensorBoard Helper Functions and Constants # Directory to export TensorBoard summary statistics, graph data, etc. TB_DIR = '/tmp/tensorboard/tf_basics' def _start_tb(d): Private function that calls `tensorboard` shell command args: d: The desired directory to lau...
<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: TensorBoard Jupyter Notebook Helpers Step4: TensorFlow Fundamentals Step5: My First TensorFlow Graph Step 1 Step6: Step 2 Step7: Step 3ish S...
7,608
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'bcc', 'sandbox-1', 'landice') # 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: 1...
7,609
<ASSISTANT_TASK:> Python Code: !pip install --upgrade watson_developer_cloud import requests import json import os from os.path import join, dirname from watson_developer_cloud import SpeechToTextV1 # @hidden_cell url = "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize" username= "$USERNAME" password...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Authentication Handling and File Details Step2: Basic transcription with CURL Step3: Output Handling with Requests Step4: Pandas from Results...
7,610
<ASSISTANT_TASK:> Python Code: fname = io.download_occultation_times(outdir='../data/') print(fname) tlefile = io.download_tle(outdir='../data') print(tlefile) times, line1, line2 = io.read_tle_file(tlefile) tstart = '2018-09-27T12:00:00' tend = '2018-09-29T12:10:00' orbits = planning.sunlight_periods(fname, tstart, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Download the NuSTAR TLE archive. Step2: Here is where we define the observing window that we want to use. Step3: We want to know how to orient...
7,611
<ASSISTANT_TASK:> Python Code: import mne from mne.preprocessing import maxwell_filter data_path = mne.datasets.sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif' ctc_fname = data_path + '/SSS/ct_sparse_mgh.fif' fine_cal_fname = data_path + '/SSS/sss_cal_mgh.dat' raw = mne.io.read_raw_fif(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Preprocess with Maxwell filtering Step3: Select events to extract epochs from, pick M/EEG channels, and plot evoked
7,612
<ASSISTANT_TASK:> Python Code: # THINGS TO IMPORT # This is a baseline set of libraries I import by default if I'm rushed for time. %matplotlib inline import codecs # load UTF-8 Content import json # load JSON files import pandas as pd # Pandas handles dataframes ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exploring Within-Group Variation and Between-Group Variation Step2: Predicting Math Achievement from SES with Linear Models Step3: Fixed Effec...
7,613
<ASSISTANT_TASK:> Python Code: _MIN = - 2147483648 _MAX = 2147483648 class getnode : def __init__(self , data ) : self . data = data self . left = None self . right = None   def getlevel(root , data ) : q =[] level = 1 q . append(root ) q . append(None ) while(len(q ) ) : temp = q[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:
7,614
<ASSISTANT_TASK:> Python Code: import dataset as ds import numpy as np import matplotlib.pyplot as plt import tensorflow as tf # Download database ds.download('UCI HAR') # Paths and filenames DATASET_PATH = "../dataset/UCI HAR/UCI HAR Dataset" TEST_RELPATH = "/test" TRAIN_RELPATH = "/train" VARS_FILENAMES = [ 'bod...
<SYSTEM_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 Dataset Step2: Filtered plots Step3: RNN
7,615
<ASSISTANT_TASK:> Python Code: import pickle import numpy as np import pandas as pd from matplotlib import pyplot as plt from BranchedGP import VBHelperFunctions as bplot plt.style.use("ggplot") %matplotlib inline datafile = "syntheticdata/synthetic20.csv" data = pd.read_csv(datafile, index_col=[0]) G = data.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: Load the data Step2: Plot the data Step3: Run the BGP model Step4: We can also plot with the predictive uncertainty of the GP. Step5: Plot p...
7,616
<ASSISTANT_TASK:> Python Code: %load_ext watermark %watermark -a 'Sebastian Raschka' -u -d -v -p numpy,pandas,matplotlib,scipy,scikit-learn # to install watermark just uncomment the following line: #%install_ext https://raw.githubusercontent.com/rasbt/watermark/master/watermark.py from IPython.display import Image 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: <br> Step2: Grouping objects by similarity using k-means Step3: <br> Step4: <br> Step5: Comparison to "bad" clustering Step6: <br> Step7: ...
7,617
<ASSISTANT_TASK:> Python Code: %run dataFormating.ipynb import sklearn print (sklearn.__version__) from sklearn import preprocessing from sklearn.ensemble import RandomForestClassifier from sklearn.ensemble import ExtraTreesClassifier from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import 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: Questionnaire only Step2: Conclusion Step3: Conclusion Step4: Can the score of a player be predicted with their RedMetrics data? Step5: Pred...
7,618
<ASSISTANT_TASK:> Python Code: numbers_str = '496,258,332,550,506,699,7,985,171,581,436,804,736,528,65,855,68,279,721,120' numbers = [int(i) for i in numbers_str.split(",")] max(numbers) sorted(numbers)[-10:] sorted([number for number in numbers if number%3 == 0]) from math import sqrt [sqrt(number) for number in 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: In the following cell, complete the code with an expression that evaluates to a list of integers derived from the raw numbers in numbers_str, as...
7,619
<ASSISTANT_TASK:> Python Code: import datetime import numpy as np import scipy as sp from scipy import interpolate import matplotlib.pyplot as plt %matplotlib inline import cmocean import seawater as sw from netCDF4 import Dataset from llctools import llc_model from pyspec import spectrum as spec c1 = 'slateblue' c2 = ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: This notebook showcases the analysis applied to LLC outputs. Here the calculations are performed for a single snapshot. The full LLC model outpu...
7,620
<ASSISTANT_TASK:> Python Code: # Some examples (you do not have to remember this now): a_list = [1,2,3, "let's", "use", "containers"] a_tuple = (1, 2, 3, "let's", "use", "containers") a_set = {1, 2, 3, "let's", "use", "containers"} a_dict = {1:"let's", 2:"use", 3: "containers"} #print(a_list) #print(a_tuple) #print(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: 2. Understanding class methods Step2: In all of the examples above, a string method is called, e.g., upper or count. Step3: The method documen...
7,621
<ASSISTANT_TASK:> Python Code: import openpnm as op wrk = op.Workspace() wrk.logelevel=50 pn = op.network.Cubic(shape=[10, 10, 10], spacing=1) pn = op.network.Cubic(shape=[10, 10, 10], spacing=1, connectivity=26) import scipy as sp pn = op.network.Cubic(shape=[10, 10, 10], spacing=[1, 1, 1], connectivity=26) print(pn...
<SYSTEM_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 case pn will be a 10 x 10 x 10 cube with each pore spaced 1 unit away from it's neighbors in all directions. Each pore is connected to ...
7,622
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import seaborn as sns; sns.set_context('notebook') from pymc3 import exp, Normal, Binomial, sample, Model # Samples for each dose level n = 5 * np.ones(4, dtype=int) # Log-dose dose = np.array([-.86, -.3, -.05, .73]) deaths = np.array([0, 1, 3, 5]) de...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Informal Methods Step2: A similar approach involves Step3: An extension of this approach can be taken Step4: A principal reason that evidence...
7,623
<ASSISTANT_TASK:> Python Code: import io from omegaconf import OmegaConf import pp from pp.config import connections c0 = pp.c.mzi() pp.qp(c0) netlist = c0.get_netlist() import pp c1 = pp.component_from_yaml('mzi.yml') pp.show(c1) pp.plotgds(c1) len(c1.get_netlist().connections) connections.clear() # reset the conne...
<SYSTEM_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 what we did to store the netlist Step2: You can also reconstruct the circuit from the instances and placements but the you lose the mos...
7,624
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt def square(n): squares = [] for i in range(n): squares.append(i**2) return squares print(square(10)) sq = lambda n: [i**2 for i in range(n)] print(sq(10)) #actually this isn't really functional! pr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Programming "Paradigms" Step2: Functional Step3: Objects Step4: Instances Step5: Inheritance Step6: Objects in practice Step7: Example
7,625
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt # define colours used in plots dark_purple = '#8464c5' light_purple = '#ededfb' dark_green = '#336433' light_green = '#a0d9a0' white = '#FFFFFF' olive = '#aaa460' def get_data(t): Loads the hysteresis data for...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: We start by defining a few helper variables and functions which be used for creating the plots below. Step4: The plots are produced below.
7,626
<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: Decoding API Step2: Initialize Sampling Module in TF-NLP. Step3: In auto-regressive architectures like Transformer based Encoder-Decoder model...
7,627
<ASSISTANT_TASK:> Python Code: from IPython.display import HTML HTML('''<script> code_show=true; function code_toggle() { if (code_show){ $('div.input').hide(); } else { $('div.input').show(); } code_show = !code_show } $( document ).ready(code_toggle); </script> <form action="javascript:code_toggle()"><input 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: Run the Demo Step2: Video Step3: Audio Step4: Advanced options
7,628
<ASSISTANT_TASK:> Python Code: from problem_formulation import joint joint import chaospy polynomial_expansion = chaospy.generate_expansion(3, joint) polynomial_expansion[:4].round(10) alpha, beta = chaospy.variable(2) phi_phi = chaospy.outer( polynomial_expansion, polynomial_expansion) [polynomial_expansion.sha...
<SYSTEM_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 the parameters are positional defined as $\alpha$ and $\beta$ Step2: Note again, that the variables are here defined positional. $\alpha$ ...
7,629
<ASSISTANT_TASK:> Python Code: import gzip import pickle import numpy as np import matplotlib.pyplot as plt import random def vectorized_result(d): e = np.zeros((10, 1), dtype=np.float32) e[d] = 1.0 return e vectorized_result(2) def load_data(): with gzip.open('../mnist.pkl.gz', 'rb') as 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: As our data is stored as a tuple of numpy arrays, we have to import numpy. Step2: In order to be able to show the images of the handwritten dig...
7,630
<ASSISTANT_TASK:> Python Code: %pylab inline %matplotlib inline import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') import shogun as sg import numpy as np # use scipy for generating samples from scipy.stats import laplace, norm def sample_gaussian_vs_laplace(n=220, mu=0.0, sigma2=1, b=np.sqrt(0.5))...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Some Formal Basics (skip if you just want code examples) Step2: Now how to compare these two sets of samples? Clearly, a t-test would be a bad ...
7,631
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.signal import medfilt import matplotlib.pyplot as plt import kplr %matplotlib inline client = kplr.API() koi = client.koi(1274.01) lcs = koi.get_light_curves(short_cadence=True) p = 704.2 time, flux, ferr, med = [], [], [], [] for lc in lcs: with lc.open(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <hr> Step2: <hr> Step3: Se ejecuta batman como se explica en la documentación, entregando como parámetros los valores obtenidos a lo largo de ...
7,632
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from astropy.modeling import models, fitting from astroquery.vizier import Vizier import scipy.optimize # Make plots display in notebooks %matplotlib inline catalog = Vizier.get_catalogs('J/A+A/605/A100') period = np.array(catalog[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: 1) Fit a Linear model Step2: This catalog has a lot of information, but for this tutorial we are going to work only with periods and magnitudes...
7,633
<ASSISTANT_TASK:> Python Code: df['Count'].plot.box() df.groupby('Year')['Count'].sum().sort_values(ascending=False) df.groupby('Year')['Count'].sum().mean() fig, ax = plt.subplots(figsize=(9, 6)) df.groupby('Year')['Count'].sum().plot.barh() mean = df.groupby('Year')['Count'].sum().mean() ax.plot([mean, mean], [0, 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: 1. In what year new yorkers died the most? Step2: 2. Who is more likely to die, a male newyorker or a female new yorker? Step3: 3. Is Sex (in)...
7,634
<ASSISTANT_TASK:> Python Code: from floweaver import * dataset = Dataset.from_csv('us-energy-consumption.csv', dim_process_filename='us-energy-consumption-processes.csv') sources = ['Solar', 'Nuclear', 'Hydro', 'Wind', 'Geothermal', 'Natural_Gas', 'Coal', 'Biomass', 'Petroleum'] ...
<SYSTEM_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 dataset Step2: This defines the order the nodes appear in Step3: Now define the Sankey diagram definition. Step4: Define the colours...
7,635
<ASSISTANT_TASK:> Python Code: seconds_in_a_day = 24 * 60 * 60 seconds_in_a_day seconds_in_a_week = 7 * seconds_in_a_day seconds_in_a_week import numpy as np from matplotlib import pyplot as plt ys = 200 + np.random.randn(100) x = [x for x in range(len(ys))] plt.plot(x, ys, '-') plt.fill_between(x, ys, 195, where=(ys...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To execute the code in the above cell, select it with a click and then either press the play button to the left of the code, or use the keyboard...
7,636
<ASSISTANT_TASK:> Python Code: import pandas as pd from sklearn import tree X = [[0, 0], [1, 2]] y = [0, 1] clf = tree.DecisionTreeClassifier() clf = clf.fit(X, y) clf.predict([[2., 2.]]) clf.predict_proba([[2. , 2.]]) clf.predict([[0.4, 1.2]]) clf.predict_proba([[0.4, 1.2]]) clf.predict_proba([[0, 0.2]]) from sklearn...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: DecisionTreeClassifier is capable of both binary (where the labels are [-1, 1]) classification and multiclass (where the labels are [0, …, K-1])...
7,637
<ASSISTANT_TASK:> Python Code: def check_python_version(): print 'Python version:\n', sys.version assert sys.version_info < (3,0) check_python_version() def improved_check_python_version(): print 'Python version:\n', sys.version try: assert sys.version_info < (3,0) except: ra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Raising errors Step2: Raising warnings
7,638
<ASSISTANT_TASK:> Python Code: # Generate data import numpy as np import pandas as pd raw_data = np.array([0] * 30 + [1] * 70) # Representing heads by 0 and tails by 1 data = pd.DataFrame(raw_data, columns=['coin']) print(data) # Defining the Bayesian Model from pgmpy.models import BayesianModel from pgmpy.estimators 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: We can see that we get the results as expected. In the maximum likelihood case we got the probability just based on the data where as in the bay...
7,639
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline from keras.utils import np_utils from keras.datasets import mnist # for Multi-layer Perceptron (MLP) model from keras.models import Sequential from keras.layers import Dense # for Convolutional Neura...
<SYSTEM_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 Data Step2: Plotting images and their class values Step3: Viewing shape and content of data Step4: Flattening images Step5: Normaliz...
7,640
<ASSISTANT_TASK:> Python Code: def f(t, x): # Se importan funciones matematicas necesarias from numpy import matrix, sin, cos # Se desenvuelven las variables que componen al estado q1, q2, q̇1, q̇2 = x # Se definen constantes del sistema g = 9.81 m1, m2, J1, J2 = 0.3, 0.2, 0.0005, 0.0002 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Mandamos llamar al simulador
7,641
<ASSISTANT_TASK:> Python Code: import numpy import chaospy distribution = chaospy.Uniform(0, 15) samples = distribution.sample(10, rule="sobol") evaluations = samples*numpy.sin(samples) evaluations.round(4) from matplotlib import pyplot expansion = chaospy.generate_expansion(9, distribution, normed=True) t = numpy.lin...
<SYSTEM_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 goal is to create a so called "polynomial chaos kriging" model as defined in the paper with the same name. We are going to do this using the...
7,642
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-3', 'seaice') # 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: 2...
7,643
<ASSISTANT_TASK:> Python Code: #Version 1 def main(): name, age = input("Enter name") , int( input("Enter age")) for i in range( int(input("Enter a number"))): print("You will turn 100 in {}".format(2017-age+100)) main() from datetime import date today = str(date.today()).split("-") print(type(today)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Using datetime module to find current date and extracting year from the current date Step2: Use the above and modify our program
7,644
<ASSISTANT_TASK:> Python Code: def parse_fastq(fh): Parse reads from a FASTQ filehandle. For each read, we return a name, nucleotide-string, quality-string triple. reads = [] while True: first_line = fh.readline() if len(first_line) == 0: break # end of file 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: FASTQ Step6: The nucleotide string can sometimes contain the character "N". N essentially means "no confidence." The sequencer knows there's a...
7,645
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import pandas as pd import metpy.calc as mpcalc from metpy.cbook import get_test_data from metpy.plots import add_metpy_logo, SkewT from metpy.units import units col_names = ['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed'] df = pd.re...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Upper air data can be obtained using the siphon package, but for this example we will use Step2: We will pull the data out of the example datas...
7,646
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf import utils from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import zipfile dataset_folder_path = 'data' dataset_filename = 'text8.zip' dataset_name = 'Text8 Dataset' class DLProgress(tq...
<SYSTEM_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 text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ...
7,647
<ASSISTANT_TASK:> Python Code: import os import numpy as np import matplotlib.pyplot as plt import mne from mne.preprocessing import compute_proj_ecg from mne_connectivity import envelope_correlation sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: For this tutorial we'll crop and resample the raw data to a manageable size Step2: To create fixed length epochs, we simply call the function a...
7,648
<ASSISTANT_TASK:> Python Code: import pandas as pd import math import matplotlib.pyplot as plt %matplotlib inline from vega_datasets import data data.list_datasets() from vega_datasets import local_data local_data.list_datasets() local_data.anscombe.description df = local_data.anscombe() df.head() # TODO: put your...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Vega datasets Step2: or you can work with only smaller, local datasets. Step3: Ah, we have the anscombe data here! Let's see the description o...
7,649
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'thu', 'sandbox-1', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<SYSTEM_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...
7,650
<ASSISTANT_TASK:> Python Code: import chaospy uniform = chaospy.Uniform(0, 4) chaospy.E(uniform) samples = uniform.sample(1e7) numpy.mean(samples) q0 = chaospy.variable() chaospy.E(q0**3-1, uniform) q0, q1, q2 = chaospy.variable(3) joint3 = chaospy.J(chaospy.Normal(0, 1), chaospy.Uniform(0, 2), chaospy.Normal(2, 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: Its empirical counterpart is the mean function Step2: The operator can also be used on any polynomial, but would then require the distribution ...
7,651
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function, unicode_literals [10.5, 5.2, 3.25, 7.0] import numpy as np video = np.array([10.5, 5.2, 3.25, 7.0]) video video.size video[2] # 3rd element %matplotlib inline import matplotlib.pyplot as plt u = np.array([2, 5]) v = np.array([3, 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: Vectors Step2: Since we plan to do quite a lot of scientific calculations, it is much better to use NumPy's ndarray, which provides a lot of co...
7,652
<ASSISTANT_TASK:> Python Code: import numpy as np np.random.seed(42) import keras from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPooling2D from keras.layers.normalization import BatchNormalization from keras.callbacks import TensorBoard # for part 3.5 on TensorBoard 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: Load dependencies Step2: Load and preprocess data Step3: Design neural network architecture Step4: Configure model Step5: Configure TensorBo...
7,653
<ASSISTANT_TASK:> Python Code: # Author: Eric Larson <larson.eric.d@gmail.com> # Denis Engemann <denis.engemann@gmail.com> # # License: BSD-3-Clause import mne Brain = mne.viz.get_brain_class() subjects_dir = mne.datasets.sample.data_path() / 'subjects' mne.datasets.fetch_hcp_mmp_parcellation(subjects_dir=subje...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We can also plot a combined set of labels (23 per hemisphere). Step2: We can add another custom parcellation
7,654
<ASSISTANT_TASK:> Python Code: import pymatgen as pmg si = pmg.Element('Si') print('Si:') print(si.atomic_mass) print(si.common_oxidation_states) print(si.number) lattice = pmg.Lattice.cubic(4.2) cscl = pmg.Structure(lattice, ["Cs", "Cl"], [[0,0,0],[0.5,0.5,0.5]]) print('\nCsCl structure') print(cscl) print('\n') 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: 3. Create the following Structures from Lattices. Instead of using the convience class methods e.g. Lattice.cubic, create them from basis vector...
7,655
<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: int16 アクティベーションによるトレーニング後の整数量子化 Step2: 16x8 量子化モードが使用可能であることを確認します Step3: モデルをトレーニングしてエクスポートする Step4: この例では、モデルを 1 エポックでトレーニングしたので、トレーニングの精度は...
7,656
<ASSISTANT_TASK:> Python Code: str1 = '"Hola" is how we say "hello" in Spanish.' str2 = "Strings can also be defined with quotes; try to be sistematic." print str1 print type(str1) print type(3) print type(3.) print str1[0:5] print str1+str2 print str1.lower() print str1.upper() print len(str1) print str1.replace('h'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: It is easy to check the type of a variable with the type() command Step2: The following commands implement some common operations with strings ...
7,657
<ASSISTANT_TASK:> Python Code: from nilearn import plotting %matplotlib inline from os.path import join as opj import json from nipype.interfaces.spm import Level1Design, EstimateModel, EstimateContrast from nipype.algorithms.modelgen import SpecifySPMModel from nipype.interfaces.utility import Function, IdentityInterf...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Experiment parameters Step2: Specify Nodes Step3: Specify GLM contrasts Step4: Specify GLM Model Step5: We can also create a data frame usin...
7,658
<ASSISTANT_TASK:> Python Code: writefile("funwave-input.tpl", !INPUT FILE FOR FUNWAVE_TVD ! NOTE: all input parameter are capital sensitive ! --------------------TITLE------------------------------------- ! title only for log file TITLE = VESSEL ! -------------------HOT START--------------------------------- HO...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Adding dynamic inputs Step3: Smarter wrapper templates Step4: Using Agave commands, we make a directory on the storage server an deploy our wr...
7,659
<ASSISTANT_TASK:> Python Code: !pip install oauth2 !pip install unidecode %matplotlib inline from collections import defaultdict import json import numpy as np import scipy as sp import matplotlib.pyplot as plt import pandas as pd from matplotlib import rcParams import matplotlib.cm as cm import matplotlib as mpl #colo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lab 9 - Graphs & Networks Step2: 1. Get API key Step3: 2. Get Access Token Step4: 3. Get data, clean it and store to disk Step5: When you ha...
7,660
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cas', '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...
7,661
<ASSISTANT_TASK:> Python Code: from pycobra.cobra import Cobra from pycobra.diagnostics import Diagnostics import numpy as np %matplotlib inline # setting up our random data-set rng = np.random.RandomState(1) # D1 = train machines; D2 = create COBRA; D3 = calibrate epsilon, alpha; D4 = testing n_features = 20 D1, D2, ...
<SYSTEM_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 data set Step2: Setting up COBRA Step3: When we are fitting, we initialise COBRA with an epsilon value of $0.5$ - this is because w...
7,662
<ASSISTANT_TASK:> Python Code: pulses = otx.getall() len(pulses) json_normalize(pulses)[0:5] json_normalize(pulses[1]["indicators"]) indicator_types = [ { "name": "IPv4", "description": "An IPv4 address indicating the online location of a server or other computer." }, { "name": "IPv6"...
<SYSTEM_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 list a few pulses Step2: author_name Step3: _id Step4: Besides receiving the pulse information, there is another function that can retr...
7,663
<ASSISTANT_TASK:> Python Code: df = pd.read_csv('atlas-taggings.csv') df[2:5] articles = df[df.tagged_type == 'Article'] articles.tag_url = articles.tag_url.apply(get_tag_name) articles = get_dummies_and_join(articles,'tag_url') articles = articles.drop(['tag_id','tag_url','tagged_type','tagged_id'],axis=1) articles ...
<SYSTEM_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 only care about the content type "Article" Step2: But we need to get the tag name out of the url string for the tag Step3: Import the table...
7,664
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline sns.set_style('white') fpvals = 'schubert-sb-table.txt' fotu = 'data/cdi_schubert_results/RDP/cdi_schubert.otu_table.100.denovo.rdp_assigned' fmeta = 'data/cdi_schubert_results/...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: It looks like OTUs with an uncorrected pvalue of 0.9 get smushed down to 0.08 with qvalue - this seems fishy! Step2: So these are, for the most...
7,665
<ASSISTANT_TASK:> Python Code: # This is our distribution (we assume gaussian) data = np.random.normal(240, 25, 1000) # we want to calcluate the 95CI (alpha = 0.95) alpha = 0.95 # out data data = np.random.normal(240, 25, 1000) print "The sample mean is: ", data.mean() # now we get the least of mean values using boots...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: - using Bootstrap Step2: - using t-distribution table Step3: Use-Case Step4: Use-Case
7,666
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper data_dir = './data/simpsons/moes_tavern_lines.txt' text = helper.load_data(data_dir) # Ignore notice, since we don't use it for analysing the data text = text[81:] view_sentence_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL import num...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TV Script Generation Step3: Explore the Data Step6: Implement Preprocessing Functions Step9: Tokenize Punctuation Step11: Preprocess all the...
7,667
<ASSISTANT_TASK:> Python Code: df = pd.read_csv("311-2014.csv", nrows=200000, low_memory = False) df.head(3) df.columns type(df['Created Date'][0]) print(df['Created Date'][0]) dateutil.parser.parse(df['Created Date'][0]) def str_to_time(str_date): datetype_date = dateutil.parser.parse(str_date) return datetype...
<SYSTEM_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...
7,668
<ASSISTANT_TASK:> Python Code: g_dataset_name = "Notebook4Test" g_fastq_counts_run_prefix = "TestSet4" g_fastq_counts_dir = '~/dual_crispr/test_data/test_set_4' g_collapsed_counts_run_prefix = "" g_collapsed_counts_dir = '~/dual_crispr/test_outputs/test_set_4' g_combined_counts_dir = "" g_combined_counts_run_prefix = "...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step 4 Step1: Automated Set-Up Step2: Count Combination Functions Step3: Input Count Filenames Step4: Count Combination Execution
7,669
<ASSISTANT_TASK:> Python Code: import networkx as nx import numpy as np import matplotlib.pyplot as plt import random import copy from Bio.PDB import * from IPython.display import HTML, display import tabulate from __future__ import division from IPython.display import Image ## Initialization genes = 25 tfbs_pool = 10...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Question 1 Step2: Final Coexpression network (images exported from Cytoscape) Step3: Degree Distribution for cases <br> Step6: Analysis and c...
7,670
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division %matplotlib inline import numpy as np import nsfg import first import thinkstats2 import thinkplot preg = nsfg.ReadFemPreg() live = preg[preg.outcome == 1] hist = thinkstats2.Hist(live.birthwgt_lb, label='birthwgt_lb') thinkplot.Hist(hist)...
<SYSTEM_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, I'll load the NSFG pregnancy file and select live births Step2: Here's the histogram of birth weights Step3: To normalize the disrtibut...
7,671
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from scipy import stats # use seaborn plotting defaults import seaborn as sns; sns.set() from sklearn.datasets.samples_generator import make_blobs X, y = make_blobs(n_samples=50, centers=2, random_sta...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Motivating Support Vector Machines Step2: A linear discriminative classifier would attempt to draw a straight line separating the two sets of d...
7,672
<ASSISTANT_TASK:> Python Code: from sklearn import datasets digits = datasets.load_digits() X = digits.data n_classes = len(digits.target_names) from sklearn.ensemble import RandomForestClassifier clf = RandomForestClassifier(n_estimators=512, max_depth=7, min_samples_leaf=30, random_state = 1960) clf.fit(digits.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: Generate SQL Code from the Model Step2: Execute the SQL Code Step3: Scikit-learn Prediction Step4: Comparing the SQL and Scikit-learn Predict...
7,673
<ASSISTANT_TASK:> Python Code: %pylab inline import sys from corner import corner sys.path.append('.') from src.mocklc import MockLC, SimulationSetup from src.blendlpf import MockLPF import src.plotting as pl lc = MockLC(SimulationSetup('M', 0.1, 0.0, 0.15, 'short_transit', cteff=5500, know_orbit=False)) lc.create(wn...
<SYSTEM_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 mock light curve Step2: Initialize the log posterior function Step3: Optimize Step4: Estimate the posterior Step5: Analysis Step6: ...
7,674
<ASSISTANT_TASK:> Python Code: import numpy as np from opsimsummary import OpSimOutput %matplotlib inline import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt opsout = OpSimOutput.fromOpSimDB('/Users/rbiswas/data/LSST/OpSimData/minion_1016_sqlite.db', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Declination Boundaries for the WFD proposal Step2: Total area covered, should be ~ 0.5 sky Step3: Equations for the boundary values Step4: Pl...
7,675
<ASSISTANT_TASK:> Python Code: !pip install wikipedia import wikipedia bky = wikipedia.page("Berkeley, California") bky bk_split = bky.content.split() bk_split[:10] !pip install nltk import nltk fdist1 = nltk.FreqDist(bk_split) fdist1.most_common(10) print(bky.references[:10]) print(bky.links[:10]) user_config= fami...
<SYSTEM_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, we will get the page for Berkeley, California and count the most commonly used words in the article. I'm using nltk, which is a...
7,676
<ASSISTANT_TASK:> Python Code: !pip3 install 'tfx==0.15.0' --upgrade !python3 -m pip install 'kfp>=0.1.35' --quiet # Directory and data locations (uses Google Cloud Storage). import os _input_bucket = '<your gcs bucket>' _output_bucket = '<your gcs bucket>' _pipeline_root = os.path.join(_output_bucket, 'tfx') # Google...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Enable DataFlow API for your GKE cluster Step2: Configure the TFX pipeline example Step3: Submit pipeline for execution on the Kubeflow cluste...
7,677
<ASSISTANT_TASK:> Python Code: import numpy as np import os import urllib import gzip import struct def download_data(url, force_download=True): fname = url.split("/")[-1] if force_download or not os.path.exists(fname): urllib.urlretrieve(url, fname) return fname def read_data(label_url, image_url)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We plot the first 10 images and print their labels. Step2: Next we create data iterators for MXNet. The data iterator, which is similar the ite...
7,678
<ASSISTANT_TASK:> Python Code: !date import numpy as np import torch import math import matplotlib.mlab as mlab import torch.nn.functional as F import matplotlib.pyplot as plt from torch.autograd import Variable import scipy.stats as stats import scipy import gc from sklearn.utils import check_random_state seed = 133...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Complex computer simulators are increasingly used across fields of science as generative models tying parameters of an underlying theory to expe...
7,679
<ASSISTANT_TASK:> Python Code: print hex(1024) print round(5.23222,2) s = 'hello how are you Mary, are you feeling okay?' retVal = 1 for word in s.split(): print word for item in word: # print item if not item.islower(): # print item print 'The string has Uppercase cha...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problem 2 Step2: Advanced Strings Step3: Problem 4 Step4: Advanced Sets Step5: Problem 6 Step6: Advanced Dictionaries Step7: Advanced List...
7,680
<ASSISTANT_TASK:> Python Code: import graphlab as gl sf = gl.SFrame('data/people-example.csv') sf # we can view first few lines of the table sf.head() sf.tail() sf['Country'] sf['age'].mean() sf sf['Full Name'] = sf['First Name'] + ' ' + sf['Last Name'] sf sf['Country'] def transform_country(country): return '...
<SYSTEM_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 a tabular dataset Step2: SFrame basics Step3: Inspect Dataset Step4: Creating new columns Step5: Apply Function for Data transformation...
7,681
<ASSISTANT_TASK:> Python Code: def power(x , y , p ) : res = 1 x = x % p if(x == 0 ) : return 0  while(y > 0 ) : if(( y & 1 ) == 1 ) : res =(res * x ) % p  y = y >> 1 x =(x * x ) % p  return res  N = 3 if(( N == 1 ) or(N == 2 ) ) : print(62 )  else : m =(10 ** 9 ) + 7 if(N % 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:
7,682
<ASSISTANT_TASK:> Python Code: def pet_names(name1, name2): print("Pet 1: ", name1) print("Pet 2: ", name2) pet1 = "King" pet2 = "Reginald" pet_names(pet1, pet2) # pet1 variable, then pet2 variable pet_names(pet2, pet1) # notice we've switched the order in which they're passed to the function pet1 = "Rocco" ...
<SYSTEM_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, we switched the ordering of the arguments between the two function calls; consequently, the ordering of the arguments inside th...
7,683
<ASSISTANT_TASK:> Python Code: #We can import the obspy module, and give it a shorter name (PS as you can see, the # symbol starts a comment) import obspy as op #note we can start a comment after a line that has executable code on it. #matplotlib is a large plotting package, with a submodule pyplot that we can import 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: One of the key cornerstones of the scientific Python platform is Numpy, which is a highly optimized library for multidimensional arrays. It allo...
7,684
<ASSISTANT_TASK:> Python Code: import pylab as plt import numpy as np %matplotlib inline from __future__ import division from scipy.integrate import odeint,ode from numpy import zeros,ones,eye,tanh,dot,outer,sqrt,linspace,cos,pi,hstack,zeros_like,abs,repeat from numpy.random import uniform,normal,choice %config InlineB...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: FORCE Step2: The loss function Step3: FORCE does a pretty nice job learning how to be a sin wave. If you rerun this a few times, you'll see th...
7,685
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import theano # By convention, the tensor submodule is loaded as T import theano.tensor as T # The theano.tensor submodule has various primitive symbolic variable types. # Here, we're defining a scalar (0-d) variable. ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Basics Step2: Functions Step3: theano.tensor Step4: Shared variables Step5: updates Step6: Gradients Step7: Debugging Step8: The above er...
7,686
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np tf.reset_default_graph() # Define our Dataset X = np.array([[0,0],[0,1],[1,0],[1,1]]) Y = np.array([0,0,0,1]).reshape(-1,1) # Define the tensorflow tensors x = tf.placeholder(tf.float32, [None, 2], name='X') # inputs y = tf.placeholder(tf.float3...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To visualize the graph you just created, launch tensorbord. Step2: Print the weights of your model Step3: Build a CNN to predict the MNIST dig...
7,687
<ASSISTANT_TASK:> Python Code: # Author: Alexandre Gramfort <alexandre.gramfort@inria.fr> # # License: BSD (3-clause) from mne import read_evokeds from mne.datasets import sample print(__doc__) data_path = sample.data_path() fname = data_path + '/MEG/sample/sample_audvis-ave.fif' # Reading condition = 'Left Auditory' e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Show result as a butterfly plot
7,688
<ASSISTANT_TASK:> Python Code: # Tensorflow import tensorflow as tf print('Tested with TensorFLow 1.2.0') print('Your TensorFlow version:', tf.__version__) # Feeding function for enqueue data from tensorflow.python.estimator.inputs.queues import feeding_functions as ff # Rnn common functions from tensorflow.contrib.le...
<SYSTEM_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 Data Step2: We can also search our word list for a word like "baseball", and then access its corresponding vector through the embedding...
7,689
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib #matplotlib.use('nbagg') #%matplotlib inline import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize=(10,3)) ax.set_ylim([-0.1,1.1]) ax.set_xticklabels([]) ax.set_yticklabels([]) ax.set_title('Universe') ax.plot([-1,1],[0,0],c='k') plt.show() 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: To begin testing our powers, let's make something happen. An event in the center of the universe may be exciting. Step2: Actually, that wasn't ...
7,690
<ASSISTANT_TASK:> Python Code: # initialize environment %matplotlib inline import numpy as np import matplotlib.pyplot as plt import sympy as sy x = np.linspace(0.0,10.0,1000) dx = x[1]-x[0] def numDeriv( x, f ): return (x[1:]+x[:-1])*0.5, (f[1:]-f[:-1])/(x[1:]-x[:-1]) def func1(r): r2 = r**2 E = 1-r2 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: How to use $|\vec r|^2$ instead of $|\vec r|$ (get rid of sqrt()) Step2: Factorized Polynominals Step3: Approx exponential Step4: Approx Gaus...
7,691
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'messy-consortium', 'emac-2-53-aerchem', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_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: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
7,692
<ASSISTANT_TASK:> Python Code: import pylearn2.utils import pylearn2.config import theano import neukrill_net.dense_dataset import neukrill_net.utils import numpy as np %matplotlib inline import matplotlib.pyplot as plt import holoviews as hl %load_ext holoviews.ipython import sklearn.metrics cd .. m = pylearn2.utils.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: Now check the model specified in alexnet_extra_layer_dropouts2.json model, which has 0.9 dropout on all but last convolutional layers, and 0.5 d...
7,693
<ASSISTANT_TASK:> Python Code: !pip install --user --upgrade --no-deps pixiedust import sys reload(sys) sys.setdefaultencoding('utf-8') from pixiedust.packageManager import PackageManager pkg=PackageManager() pkg.installPackage("graphframes:graphframes:0") properties = { 'twitter': { 'res...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Pixiedust provides a nice visualization plugin for d3 style plots. Have a look at https Step2: When the library has been loaded successfully yo...
7,694
<ASSISTANT_TASK:> Python Code: import glob import os import time import imageio import matplotlib.pyplot as plt import numpy as np import PIL import tensorflow as tf from IPython import display from tensorflow.keras import layers np.random.seed(1) tf.random.set_seed(1) BATCH_SIZE = 128 BUFFER_SIZE = 60000 EPOCHS = 60 ...
<SYSTEM_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 define some of the environment variables we'll use in this notebook. Note that we are setting the EMBED_DIM to be 64. This is the di...
7,695
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.read_csv("provstore/data.csv") df.head() df.describe() # The number of each label in the dataset df.label.value_counts() from analytics import test_classification results, importances = test_classification(df) from analytics import balance_smote df = balanc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Classification on unbalanced (original) data Step2: Cross Validation tests Step3: ## Classification on balanced data Step4: Balancing the dat...
7,696
<ASSISTANT_TASK:> Python Code: import os, sys import shutil, time, warnings from contextlib import redirect_stdout import numpy as np import matplotlib.pyplot as plt from astropy.table import Table, vstack from PIL import Image, ImageDraw, ImageFont import multiprocessing nproc = multiprocessing.cpu_count() // 2 %matpl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Preliminaries Step2: Build a sample with the objects of interest. Step3: Some rejected objects. Step8: Ensure all objects are in the DR6+DR7 ...
7,697
<ASSISTANT_TASK:> Python Code: from scipy import sparse import numpy as np sa = sparse.csr_matrix(np.array([[1,2,3],[4,5,6],[7,8,9]])) sb = sparse.csr_matrix(np.array([0,1,2])) result = sa.multiply(sb) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
7,698
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import sys sys.path.append("../../../bayesianpy") import bayesianpy from bayesianpy.network import Builder as builder import logging import os import math import numpy as np import scipy.stats as ss import matplotlib.pyplot as plt import seaborn as 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: Create the network, specifying a latent variable. Step2: And finally, query the model, specifying each variable in a separate query (otherwise ...
7,699
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from topoflow.components.met_base import met_component m = met_component() cfg_file = './input/meteorology.cfg' m.initialize(cfg_file) precip = m.get_value('atmosphere_water__precipitation_leq-volume_flux') # `P` internally print type(precip) prin...
<SYSTEM_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 the Meteorology component and create an instance Step2: Locate the cfg file and initialize the component Step3: Despite setting a value...