Unnamed: 0
int64
0
16k
text_prompt
stringlengths
149
45.7k
code_prompt
stringlengths
67
140k
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: Tweedie Density Estimation This package follows the following 2 papers to estimate the density of a presumed Tweedie distribution Step1: And to prove ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function import numpy as np import scipy as sp from tweedie import tweedie import seaborn as sns import statsmodels.api as sm # Number of parameters for model p = 20 # Number of simulated observations n = 100000 np.random.seed(43) exog = np....
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: syncID Step1: We also need to import the following functions created in previous lessons Step2: Calculate Hillshade <img src="http Step3: Now that w...
<ASSISTANT_TASK:> Python Code: from osgeo import gdal import numpy as np import matplotlib.pyplot as plt %matplotlib inline import warnings warnings.filterwarnings('ignore') Explanation: syncID: 7e916532e9fa49aeba7464350e661778 title: "Create a Hillshade from a Terrain Raster in Python" description: "Learn how to creat...
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: GLM Step1: Local Functions Step2: Generate Data This dummy dataset is created to emulate some data created as part of a study into quantified self, a...
<ASSISTANT_TASK:> Python Code: ## Interactive magics %matplotlib inline import sys import warnings warnings.filterwarnings('ignore') import re import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import patsy as pt from scipy import optimize # pymc3 libraries import pymc3 as pm i...
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: Chapter 3 - Developing Templates Generating SoftMax distributions from normals could get quite tedious – for any sufficiently complicated shape, the nu...
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline from cops_and_robots.robo_tools.fusion.softmax import SoftMax, make_regular_2D_poly poly = make_regular_2D_poly(5, max_r=2, theta=-np.pi/4) labels = ['Interior','Heliport Facade','Mall Terrace Entrance', 'River Terrace Entrance', 'Concou...
4
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: .. _tut_stats_cluster_source_1samp Step1: Set parameters Step2: Read epochs for all channels, removing a bad one Step3: Transform to source space St...
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # Eric Larson <larson.eric.d@gmail.com> # License: BSD (3-clause) import os.path as op import numpy as np from numpy.random import randn from scipy import stats as stats import mne from mne import (io, spatia...
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: * Visualizing of genetic similarity with Lightning + GraphX * Setup lightning Step1: Load structure similarity data Public data from http Step2: Show...
<ASSISTANT_TASK:> Python Code: %libraryDependencies += "org.viz.lightning" %% "lightning-scala" % "0.1.6" %update import org.viz.lightning._ import org.apache.spark.graphx._ val lgn = Lightning(host="https://lightning-spark-summit.herokuapp.com" ) lgn.enableNotebook() Explanation: * Visualizing of genetic similarity wi...
6
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Ocean MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'sandbox-2', 'ocean') Explanation: ES-DOC CMIP6 Model Properties - Ocean MIP Era: CMIP6 Institute: NOAA-GFDL Source ID: SANDBOX-2 Topic: Ocean Sub-Topics...
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: Step2: Reframing Design Pattern The Reframing design pattern refers to changing the representation of the output of a machine learning problem. For exa...
<ASSISTANT_TASK:> Python Code: import numpy as np import seaborn as sns from google.cloud import bigquery import matplotlib as plt %matplotlib inline bq = bigquery.Client() query = SELECT weight_pounds, is_male, gestation_weeks, mother_age, plurality, mother_race FROM `bigquery-public-data.samples.natali...
8
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: YouTube Spam Collection Data Set (Part 2) Source Step1: <a id='section3b'></a> Read in the data from the first CSV alone Step2: <a id='section3c'></a...
<ASSISTANT_TASK:> Python Code: # Import modules import numpy as np import pandas as pd Explanation: YouTube Spam Collection Data Set (Part 2) Source: UCI Machine Learning Repository Original Source: YouTube Spam Collection v. 1 Alberto, T.C., Lochter J.V., Almeida, T.A. Filtragem Automática de Spam nos Comentários do Y...
9
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Table of Contents <p><div class="lev1 toc-item"><a href="#Building-an-ANN" data-toc-modified-id="Building-an-ANN-1"><span class="toc-item-num">1&nbsp;&...
<ASSISTANT_TASK:> Python Code: # Installing Theano # pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git # Installing Tensorflow # pip install tensorflow # Installing Keras # pip install --upgrade keras Explanation: Table of Contents <p><div class="lev1 toc-item"><a href="#Building-an-ANN" data-toc-m...
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: Enter State Farm Step1: Create Sample The following assumes you've already created your validation set - remember that the training and validation set...
<ASSISTANT_TASK:> Python Code: import theano import os, sys sys.path.insert(1, os.path.join(os.getcwd(), 'utils')) %matplotlib inline from __future__ import print_function, division # path = "data/sample/" path = "data/statefarm/sample/" import utils; reload(utils) from utils import * from IPython.display import FileLi...
11
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Import Step1: Reading initial data Step2: Remove rows with NAN from data Step3: Add diff_pt and cos(diff_phi) Step4: Add max, sum among PIDs Step5:...
<ASSISTANT_TASK:> Python Code: import pandas import numpy from folding_group import FoldingGroupClassifier from rep.data import LabeledDataStorage from rep.report import ClassificationReport from rep.report.metrics import RocAuc from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import roc_curve, ...
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: Feature selection Step1: Our first step is to count up all of the words in each of the documents. This conditional frequency distribution should look ...
<ASSISTANT_TASK:> Python Code: documents = nltk.corpus.PlaintextCorpusReader('../data/EmbryoProjectTexts/files', 'https.+') metadata = zotero.read('../data/EmbryoProjectTexts', index_by='link', follow_links=False) Explanation: Feature selection: keywords A major problem-area in text mining is determining the thematic o...
13
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Index Work WorkOk WorkSnowball Forward Snowballing Other WorkUnrelated WorkNoFile WorkLang Step1: Work Since this is the default class, it is used as ...
<ASSISTANT_TASK:> Python Code: import database from datetime import datetime from snowballing.operations import load_work, reload from snowballing.jupyter_utils import work_button, idisplay reload() Explanation: Index Work WorkOk WorkSnowball Forward Snowballing Other WorkUnrelated WorkNoFile WorkLang End of explanatio...
14
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Unity ML Agents Environment Basics This notebook contains a walkthrough of the basic functions of the Python API for Unity ML Agents. For instructions ...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np from unityagents import UnityEnvironment %matplotlib inline Explanation: Unity ML Agents Environment Basics This notebook contains a walkthrough of the basic functions of the Python API for Unity ML Agents. For instructions on building a ...
15
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <div Style="text-align Step1: Obtenemos nuestro clasificador Step2: Obtenemos la imagen ejemplo Step3: Definimos algunas funciones necesarias
<ASSISTANT_TASK:> Python Code: # Imports import pickle %matplotlib inline #para dibujar en el propio notebook import numpy as np #numpy como np import matplotlib.pyplot as plt #matplotlib como plot from skimage import io from skimage.transform import rescale from skimage.color import rgb2gray from skimage.io import i...
16
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Test the pretrained model Get the game screen as the input, and use the virtual joystick to steer the wheel. Step1: Load pretrained model, and check p...
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('../') from europilot.screen import stream_local_game_screen from europilot.screen import Box from europilot.joystick import LinuxVirtualJoystick Explanation: Test the pretrained model Get the game screen as the input, and use the virtual joystick to steer the w...
17
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Ordinary differential equations Euler method Step1: To check correctness we are going to solve simple differential equation $$y' = (x + y)^2,\ y(0) = ...
<ASSISTANT_TASK:> Python Code: def euler(f, x, y0): h = x[1] - x[0] y = np.empty_like(x) y[0] = y0 for i in range(1, len(x)): y[i] = y[i - 1] + h * f(x[i - 1], y[i - 1]) return y Explanation: Ordinary differential equations Euler method End of explanation dy = lambda x, y: x*x + y*y x = np.l...
18
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: .. _tut_io_export_pandas Step1: Export DataFrame Step2: Explore Pandas MultiIndex
<ASSISTANT_TASK:> Python Code: # Author: Denis Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import mne import matplotlib.pyplot as plt import numpy as np from mne.datasets import sample print(__doc__) data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'...
19
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Committors and Shooting Point Analysis There are several ways that we can calculate committors. This deals with two, in particular. First, we frequentl...
<ASSISTANT_TASK:> Python Code: pes = toys.LinearSlope(m=[0.0], c=[0.0]) # flat line topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes) integrator = toys.LeapfrogVerletIntegrator(0.1) options = { 'integ': integrator, 'n_frames_max': 1000, 'n_steps_per_frame': 1 } engine = toys.Engine(options=option...
20
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 1 entity referent self ("me") addressee ("you here") other ("somebody else") 2+ entity referent self, addressee ("me and you here" / inclusive we) self...
<ASSISTANT_TASK:> Python Code: from itertools import combinations, combinations_with_replacement referents = [] for i in xrange(1, len(entities) * 2): for combo in combinations_with_replacement(entities, i): # choral we is impossible if combo.count('self') > 1: continue ...
21
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Plotting and Visualization Step1: Landscape of Plotting Libraries matplotlib pandas seaborn mpld3 "Bringing matplotlib to the browser" d3py "a plottin...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib as mpl # used sparingly import matplotlib.pyplot as plt pd.set_option("notebook_repr_html", False) pd.set_option("max_rows", 10) Explanation: Plotting and Visualization End of explanation %matplotlib inline Explanation: Landscape o...
22
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Machine Learning Engineer Nanodegree Introduction and Foundations Project 0 Step1: From a sample of the RMS Titanic data, we can see the various featu...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd # RMS Titanic data visualization code from titanic_visualizations import survival_stats from IPython.display import display %matplotlib inline # Load the dataset in_file = 'titanic_data.csv' full_data = pd.read_csv(in_file) # Print the first few ent...
23
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Apply logistic regression to categorize whether a county had high mortality rate due to contamination 1. Import the necessary packages to read in the d...
<ASSISTANT_TASK:> Python Code: import pandas as pd %matplotlib inline import numpy as np from sklearn.linear_model import LogisticRegression Explanation: Apply logistic regression to categorize whether a county had high mortality rate due to contamination 1. Import the necessary packages to read in the data, plot, and ...
24
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: SC57 - Working with big, multi-dimensional geoscientific datasets in Python Step1: Basic data arrays in numpy Step2: numpy is a powerful but "low-lev...
<ASSISTANT_TASK:> Python Code: # standard imports import numpy as np import pandas as pd import matplotlib.pyplot as plt import xarray as xr import warnings %matplotlib inline np.set_printoptions(precision=3, linewidth=80, edgeitems=1) # make numpy less verbose xr.set_options(display_width=70) warnings.simplefilter('i...
25
<SYSTEM_TASK:> Given the following text problem statement, write Python code to implement the functionality described below in problem statement <END_TASK> <USER_TASK:> Problem: I have two arrays:
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.array( [[[ 0, 1], [ 2, 3], [ 4, 5]], [[ 6, 7], [ 8, 9], [10, 11]], [[12, 13], [14, 15], [16, 17]]] ) b = np.array( [[0, 1, 1], [1, 0, 1], [1, 1, 0]] ) result = np.take_along_axis(a, b[..., np.newaxis], ...
26
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Analyzing Locust Load Testing Results This Notebook demonstrates how to analyze AI Platform Prediction load testing runs using metrics captured in Clou...
<ASSISTANT_TASK:> Python Code: import time from datetime import datetime from typing import List import numpy as np import pandas as pd import google.auth from google.cloud import logging_v2 from google.cloud.monitoring_dashboard.v1 import DashboardsServiceClient from google.cloud.logging_v2 import MetricsServiceV2Clie...
27
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Building interactive plots using bqplot and ipywidgets bqplot is built on top of the ipywidgets framework ipwidgets and bqplot widgets can be seamlessl...
<ASSISTANT_TASK:> Python Code: import numpy as np import ipywidgets as widgets import bqplot.pyplot as plt Explanation: Building interactive plots using bqplot and ipywidgets bqplot is built on top of the ipywidgets framework ipwidgets and bqplot widgets can be seamlessly integrated to build interactive plots bqplot fi...
28
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Convolutional Neural Network (LeNet) Update of the example of CNN given on deeplearning.net. This notebook tries to explain all the code as if reader h...
<ASSISTANT_TASK:> Python Code: import cPickle import gzip import os import sys import timeit import numpy import theano import theano.tensor as T from theano.tensor.signal import downsample from theano.tensor.nnet import conv rng = numpy.random.RandomState(23455) # instantiate 4D tensor for input input = T.tensor4(name...
29
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: High level API We recommend using tf.keras as a high-level API for building neural networks. That said, most TensorFlow APIs are usable with eager exec...
<ASSISTANT_TASK:> Python Code: # 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 number # of output dimensions / channels. layer = tf.keras.layers.Dense(100) # The number of input dimensionss is often unnecessary, as it ca...
30
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Fitting Models Exercise 2 Imports Step1: Fitting a decaying oscillation For this problem you are given a raw dataset in the file decay_osc.npz. This f...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt Explanation: Fitting Models Exercise 2 Imports End of explanation def modl(t,A,o,l,d): return A*np.exp(-1*t)*np.cos(o*t)+d thetabest,thetacov=opt.curve_fit(modl,tdata,ydata,np.array((6,1...
31
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Analysis of the IAC Dataset Step1: Preprocessing The IAC corpus of 10,000 comments is preprocessed into a training set (80%) and a test set (20%). We ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import sklearn from sklearn.pipeline import Pipeline from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer from sklearn.ensemble import RandomForestRegressor from sklearn.linear_model import LinearRegression...
32
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Home Depot Product Search Relevance The challenge is to predict a relevance score for the provided combinations of search terms and products. To create...
<ASSISTANT_TASK:> Python Code: import graphlab as gl Explanation: Home Depot Product Search Relevance The challenge is to predict a relevance score for the provided combinations of search terms and products. To create the ground truth labels, Home Depot has crowdsourced the search/product pairs to multiple human raters...
33
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Example Usage of HDFWriter If properties of a class needs to be saved in a hdf file, then the class should inherit from HDFWriterMixin as demonstrated ...
<ASSISTANT_TASK:> Python Code: from tardis.io.util import HDFWriterMixin class ExampleClass(HDFWriterMixin): hdf_properties = ['property1', 'property2'] hdf_name = 'mock_setup' def __init__(self, property1, property2): self.property1 = property1 self.property2 = property2 import num...
34
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 2D Cylinder Overview The periodic shedding of laminar flow over a 2D cylinder at a Reynolds Number of 150 can be used to verify the time accuracy of th...
<ASSISTANT_TASK:> Python Code: remote_data = True remote_server_auto = True case_name = 'cylinder' data_dir='/gpfs/thirdparty/zenotech/home/dstandingford/VALIDATION/CYLINDER' data_host='dstandingford@vis03' paraview_cmd='mpiexec /gpfs/cfms/apps/zCFD/bin/pvserver' if not remote_server_auto: paraview_cmd=None if not ...
35
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <span style="float Step1: Contents A. View the crystal structure B. Build the biomolecular assembly C. Isolate the DNA D. Prep for simulation E. Dynam...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib.pyplot import * import moldesign as mdt from moldesign import units as u Explanation: <span style="float:right"><a href="http://moldesign.bionano.autodesk.com/" target="_blank" title="About">About</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://g...
36
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Polynomial Surrogate Model Consider a simple underlying function with Gaussian noise added to simulate experimental or noisy computational data. $$y = ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt n = 20 sigma = 1.0 xdata = np.linspace(-2, 2, n) fdata = 3*xdata**2 + 2*xdata + 1 + np.random.randn(n)*sigma plt.figure() plt.plot(xdata, fdata, 'o') plt.xlabel('x') plt.ylabel('f') plt.show() Explanation: Polynomial Su...
37
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Composites simulation Step1: We need to import here the data, modify them if needed and proceed
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt from simmit import smartplus as sim import os dir = os.path.dirname(os.path.realpath('__file__')) Explanation: Composites simulation : plastic plies End of explanation umat_name = 'MIPLN' #This is t...
38
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Original url Step1: For the record, we should mention that there exist many other libraries in Python to parse XML, such as minidom or BeautifulSoup w...
<ASSISTANT_TASK:> Python Code: from lxml import etree Explanation: Original url: https://github.com/mikekestemont/ghent1516/blob/master/Chapter%208%20-%20Parsing%20XML.ipynb XML in a nutshell So far, we have primarily dealt with unstructured data in this course: we have learned to read, for example, the contents of pla...
39
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Errors and Exceptions Homework - Solution Problem 1 Handle the exception thrown by the code below by using try and except blocks. Step1: Problem 2 Han...
<ASSISTANT_TASK:> Python Code: try: for i in ['a','b','c']: print i**2 except: print "An error ocurred!" Explanation: Errors and Exceptions Homework - Solution Problem 1 Handle the exception thrown by the code below by using try and except blocks. End of explanation x = 5 y = 0 try: z = x/y except Z...
40
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Exploring the Training Set Author(s) Step2: Eyes on the data! Step4: Check out the colors at rapidtables.com/web/color/RGB_Color, but don't forget to...
<ASSISTANT_TASK:> Python Code: # Enter your username: YOUR_GMAIL_ACCOUNT = '******' # Whatever is before @gmail.com in your email address # Libraries for this section: import os import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import pandas as pd import cv2 import warnings warnings.fi...
41
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2020 The TensorFlow Authors. Step1: TF.Text Metrics <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="ht...
<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...
42
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <a href="https Step1: Computing receptive field parameters of tf.keras.applications models. Step2: Bonus stuff
<ASSISTANT_TASK:> Python Code: from google.colab import drive drive.mount('/content/gdrive') ! mkdir gdrive/MyDrive/rf_keras %cd gdrive/MyDrive/rf_keras ! ls ! git clone https://github.com/google-research/receptive_field.git ! ls %cd receptive_field/ ! ls ! pip install . ! pip install tensorflow Explanation: <a href="h...
43
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <br> Weighted kernel density estimation to quickly reproduce the profile of a diffractometer <br> <br> This example shows a work-arround for a quick vi...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from ImageD11.columnfile import columnfile from ImageD11 import weighted_kde as wkde %matplotlib inline plt.rcParams['figure.figsize'] = (6,4) plt.rcParams['figure.dpi'] = 150 plt.rcParams['mathtext.fontset'] = 'c...
44
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Combining different machine learning algorithms into an ensemble model Model ensembling is a class of techniques for aggregating together multiple diff...
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np # Import the dataset dataset_path = "spam_dataset.csv" dataset = pd.read_csv(dataset_path, sep=",") # Take a peak at the data dataset.head() Explanation: Combining different machine learning algorithms into an ensemble model Model ensembling is a cla...
45
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: New function to make a list and to select calibrator I add a function to retrieve all the flux from the ALMA Calibrator list with its frequency and obs...
<ASSISTANT_TASK:> Python Code: file_listcal = "alma_sourcecat_searchresults_20180419.csv" q = databaseQuery() Explanation: New function to make a list and to select calibrator I add a function to retrieve all the flux from the ALMA Calibrator list with its frequency and observing date, and to retrieve redshift (z) from...
46
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2020 The TensorFlow Authors. Step1: TensorFlow Addons 图像:运算 <table class="tfo-notebook-buttons" align="left"> <td><a target="_blank" href=...
<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...
47
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <center> <a href="http Step1: 2.1 Valeurs propres et valeurs singulières de l'ACP non réduite Attention Les valeurs singulières sont celles de la déco...
<ASSISTANT_TASK:> Python Code: # Construire la matrice de notes import pandas as pd note=[[6,6,5,5.5],[8,8,8,8],[6,7,11,9.5],[14.5,14.5,15.5,15], [14,14,12,12.5],[11,10,5.5,7],[5.5,7,14,11.5],[13,12.5,8.5,9.5], [9,9.5,12.5,12]] dat=pd.DataFrame(note,index=["jean","alai","anni","moni","didi","andr","pier","brig","...
48
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: [0] Database management Python provides a interface with the databases GadFly, mSQL, MySQL, PostgreSQL, Microsoft SQL Server 2000, Informix, Interbase,...
<ASSISTANT_TASK:> Python Code: # Source: Manuel Torres. Universidad de Almería. import pymysql # Establecemos la conexion con la base de datos bd = pymysql.connect("localhost", "root", "gebd", "RRHH") # Preparamos el cursor que nos va a ayudar a realizar las operaciones con la base de datos cursor = bd.cursor() # E...
49
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Personality prediction from tweet by Angelo Basile Step1: Dataset Step2: Baseline For the baseline we use an SVM with a sparse feature representation...
<ASSISTANT_TASK:> Python Code: import numpy as np np.random.seed(113) #set seed before any keras import import pandas as pd import random from sklearn.model_selection import train_test_split from collections import defaultdict from keras.preprocessing import sequence from collections import Counter import pydot Explana...
50
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Optimization Exercise 1 Imports Step1: Hat potential The following potential is often used in Physics and other fields to describe symmetry breaking a...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt Explanation: Optimization Exercise 1 Imports End of explanation def hat(x,a,b): return -1*a*(x**2) + b*(x**4) assert hat(0.0, 1.0, 1.0)==0.0 assert hat(0.0, 1.0, 1.0)==0.0 assert hat(1.0...
51
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Seaice MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributor...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'sandbox-1', 'seaice') Explanation: ES-DOC CMIP6 Model Properties - Seaice MIP Era: CMIP6 Institute: CNRM-CERFACS Source ID: SANDBOX-1 Topic: Seaice S...
52
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Causal Inference of Lalonde <table align="left"> <td> <a target="_blank" href="https Step1: Data The data are downloaded from Dehejia and Wahba ...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import patsy import seaborn as sns import statsmodels.api as sm # install and import ec !pip install -q git+https://github.com/google/empirical_calibration import empirical_calibration as ec sns.set_style('whitegrid') %config InlineBackend.figure_for...
53
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Ocnbgchem MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contribu...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-hh', 'ocnbgchem') Explanation: ES-DOC CMIP6 Model Properties - Ocnbgchem MIP Era: CMIP6 Institute: NCC Source ID: NORESM2-HH Topic: Ocnbgchem Sub-Topi...
54
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Introduction to data analytics with pandas Quentin Caudron PyData Seattle, July 2017 Systems check Do you have a working Python installation, with the ...
<ASSISTANT_TASK:> Python Code: import pandas as pd Explanation: Introduction to data analytics with pandas Quentin Caudron PyData Seattle, July 2017 Systems check Do you have a working Python installation, with the pandas package ? End of explanation import pandas as pd %matplotlib inline Explanation: Note : This cell ...
55
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Anna KaRNNa In this notebook, we'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate n...
<ASSISTANT_TASK:> Python Code: import time from collections import namedtuple import numpy as np import tensorflow as tf Explanation: Anna KaRNNa In this notebook, we'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate new text based on the text from the ...
56
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Parameterizing with Continuous Variables Step1: Continuous Factors Base Class for Continuous Factors Joint Gaussian Distributions Canonical Factors Li...
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Explanation: Parameterizing with Continuous Variables End of explanation import numpy as np from scipy.special import beta # Two variable drichlet ditribution with alpha = (1,2) def drichlet_pdf(x, y): return (np.power(x, 1)*np.power(y, 2))/beta(x, y...
57
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: MNIST ML Pros tutorial This notebook is based on the tutorial found here This tutorial is very similar to the beginners tutorial except for some increm...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/data/MNIST/",one_hot=True) sess = tf.InteractiveSession() Explanation: MNIST ML Pros tutorial This notebook is based on the tutorial found here This tutorial is very simi...
58
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Sensor space least squares regression Predict single trial activity from a continuous variable. A single-trial regression is performed in each sensor a...
<ASSISTANT_TASK:> Python Code: # Authors: Tal Linzen <linzen@nyu.edu> # Denis A. Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import numpy as np import mne from mne.datasets import sample from mne.stats.regression import linear_regression print(__doc__) data_path = sample.data_path() Explana...
59
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Model fitting with cluster-lensing & emcee Step1: Generate a noisy measurement to fit Step2: Write down likelihood, prior, and posterior probilities ...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import seaborn; seaborn.set() from clusterlensing import ClusterEnsemble import emcee import corner % matplotlib inline import matplotlib matplotlib.rcParams["axes.labelsize"] = 20 matplotlib.rcParams["legend.fontsize"] = 12 Explanation: ...
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: Edit this next cell to choose a different country / year report Step1: These next few conversions don't really work. The PPP data field seems wrong. S...
<ASSISTANT_TASK:> Python Code: # BGR_3_2001.json # BRA_3_2001.json # MWI_3_2010.23.json # ECU_3_2014.json # ARM_3_2010.json # NGA_3_2009.83.json # IDN_1_2014.json quite pointed / triangular # PHL_3_2009.json # ZAR_3_2012.4.json # TZA_3_2011.77.json # VNM_3_2008.json # MOZ_3_2008.67.json quite rounded # UZB_3_2003.json ...
61
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Language Classifier Step1: Text Classification from Folders Step2: Footnote Step3: Bigrams/Trigrams Step4: specify the ngram_range - the smallest n...
<ASSISTANT_TASK:> Python Code: count,feature_names=text.count_letters('data/languages/E3.txt') print((count,feature_names)) count,feature_names=text.count_letters('data/languages/E3.txt') print((count,feature_names)) p=text.letter_freq('English',feature_names) print(p) print((sum(count*log10(p)))) C=text.LanguageFileCl...
62
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Aerosol MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributo...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'sandbox-3', 'aerosol') Explanation: ES-DOC CMIP6 Model Properties - Aerosol MIP Era: CMIP6 Institute: MOHC Source ID: SANDBOX-3 Topic: Aerosol Sub-Topics: Tr...
63
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Exercicio 1 - Caixa Eletrônico Você está desenvolvendo o sistema de um caixa eletrônico para um banco. O cliente do banco fornece ao caixa quanto dinhe...
<ASSISTANT_TASK:> Python Code: def CaixaEletronico(valor): notas50 = valor // 50 valor = valor % 50 notas20 = valor // 20 valor = valor % 20 notas10 = valor // 10 valor = valor % 10 notas5 = valor // 5 valor = valor % 5 notas1 = valor // 1 return (notas50, notas20, notas10, notas...
64
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Module 3 Demo What is happening under the sea surface? Tidal Currents A current is generated by a difference in the sea surface elevation between diffe...
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image("Figures/EbbTideCurrent.jpg") Explanation: Module 3 Demo What is happening under the sea surface? Tidal Currents A current is generated by a difference in the sea surface elevation between different points in space, which makes water move back and f...
65
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Load Data Step1: Q Step2: The probability of being blocked after making a personal attack and increases as a function of how many times the user has ...
<ASSISTANT_TASK:> Python Code: # Load scored diffs and moderation event data d = load_diffs() df_block_events, df_blocked_user_text = load_block_events_and_users() df_warn_events, df_warned_user_text = load_warn_events_and_users() moderated_users = [('warned', df_warned_user_text), ('blocked', df_blo...
66
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Modeling and Simulation in Python Case study Step3: Testing make_system Step4: Testing slope_func Step5: Now we can run the simulation. Step6...
<ASSISTANT_TASK:> Python Code: # If you want the figures to appear in the notebook, # and you want to interact with them, use # %matplotlib notebook # If you want the figures to appear in the notebook, # and you don't want to interact with them, use # %matplotlib inline # If you want the figures to appear in separate...
67
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: If you don't care about the confidence interval of parameter Step1: If you want the confidence intervals
<ASSISTANT_TASK:> Python Code: from lmfit.models import GaussianModel # initialize the gaussian model gm = GaussianModel() # take a look at the parameter names print gm.param_names # I get RuntimeError since my numpy version is a little old # guess parameters par_guess = gm.guess(n,x=xpos) # fit data result = gm.fit(n,...
68
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Basic Tests Step1: I plot the error of the filtered wave. I use the absulte values of the difference between sine wave and median filtered wave and ca...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages % matplotlib inline Explanation: Basic Tests: Error of the median filter with different window lengths and wave number 5 2015.10.09 DW End of explanation def ErrorPlot( waveNumber,windo...
69
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: PMOD TIMER In this notebook, PMOD Timer functionalities are illustrated. The Timer has two sub-modules Step1: Instantiate Pmod_Timer class. The method...
<ASSISTANT_TASK:> Python Code: from pynq.overlays.base import BaseOverlay base = BaseOverlay("base.bit") Explanation: PMOD TIMER In this notebook, PMOD Timer functionalities are illustrated. The Timer has two sub-modules: Timer0 and Timer1. The Generate output and Capture Input of Timer 0 are assumed to be connected t...
70
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Moving to Shallow Neural Networks In this tutorial, you'll implement a shallow neural network to classify digits ranging from 0 to 9. The dataset you'l...
<ASSISTANT_TASK:> Python Code: # Download the dataset in this directory (does that work on Windows OS ?) ! wget http://deeplearning.net/data/mnist/mnist.pkl.gz import cPickle, gzip, numpy import numpy as np # Load the dataset f = gzip.open('mnist.pkl.gz', 'rb') train_set, valid_set, test_set = cPickle.load(f) f.close()...
71
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: In Paramz/GPy we can implement an own optimizer in a really simple way. We need to supply GPy with an implementation of the Optimizer class. The Optimi...
<ASSISTANT_TASK:> Python Code: # Get the parameters for Rprop of climin: climin.Rprop? class RProp(Optimizer): # We want the optimizer to know some things in the Optimizer implementation: def __init__(self, step_shrink=0.5, step_grow=1.2, min_step=1e-06, max_step=1, changes_max=0.1, *args, **kwargs): su...
72
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Creating records with date, time and timestamp fields Step1: Let's first import fmrest, its FileMakerError and requests. Step2: Now access the FMS an...
<ASSISTANT_TASK:> Python Code: import sys print(sys.version) Explanation: Creating records with date, time and timestamp fields End of explanation import fmrest print(fmrest.__version__) from fmrest.exceptions import FileMakerError import requests requests.packages.urllib3.disable_warnings() Explanation: Let's first im...
73
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <h3>Basic Recipe for Training a POS Tagger with SpaCy</h3> <ol> <li id="loaddatatitle"><a href="#-Load-Data-">Load Data </a> <ol><li>We'll be using a s...
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('/home/jupyter/site-packages/') import requests from spacy.syntax.arc_eager import PseudoProjectivity def read_conllx(text): bad_lines = 0 #t = text.strip() #print(type(t), type('\n\n')) # u = t.split(b'\n\n') n_sent = 0 n_li...
74
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: syncID Step1: As well as our function to read the hdf5 reflectance files and associated metadata Step2: Define the location where you are holding the...
<ASSISTANT_TASK:> Python Code: import h5py import csv import numpy as np import os import gdal import matplotlib.pyplot as plt import sys from math import floor import time import warnings warnings.filterwarnings('ignore') %matplotlib inline Explanation: syncID: 84457ead9b964c8d916eacde9f271ec7 title: "Assessing Spectr...
75
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Image Classification In this project, you'll classify images from the CIFAR-10 dataset. The dataset consists of airplanes, dogs, cats, and othe...
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' # Use Floyd's cifar-10 dataset if ...
76
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Different definitions of momentum By Evgenia "Jenny" Nitishinskaya Notebook released under the Creative Commons Attribution 4.0 License. A momentum str...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt k = 30 start = '2014-01-01' end = '2015-01-01' pricing = get_pricing('PEP', fields='price', start_date=start, end_date=end) fundamentals = init_fundamentals() num_shares = get_fundamentals(query(fundamentals.earnings_r...
77
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2020 The Cirq Developers Step3: Shor's algorithm <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https...
<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...
78
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Logistic Regression with a Neural Network mindset Welcome to your first (required) programming assignment! You will build a logistic regression classif...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import h5py import scipy from PIL import Image from scipy import ndimage from lr_utils import load_dataset %matplotlib inline Explanation: Logistic Regression with a Neural Network mindset Welcome to your first (required) programming assi...
79
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Visualizing output from the Mass Balance workflow This notebook is designed to work with output from the Mass Balance workflow [iceflow] developed duri...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import os import matplotlib.pyplot as plt # The two statements below are used mainly to set up a plotting # default style that's better than the default from matplotlib #import seaborn as sns plt.style.use('bmh') from shapely.geometry import Point #import pandas as pd i...
80
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Comparing Different Stream Environments This Jupyter Notebook compares four streams in different environments in the U.S. Using hydrofunctions, we are...
<ASSISTANT_TASK:> Python Code: import hydrofunctions as hf %matplotlib inline Explanation: Comparing Different Stream Environments This Jupyter Notebook compares four streams in different environments in the U.S. Using hydrofunctions, we are able to plot the flow duration graphs for all four streams and compare them. ...
81
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Take the set of pings, make sure we have actual clientIds and remove duplicate pings. We collect each unique ping. Step1: Transform and sanitize the p...
<ASSISTANT_TASK:> Python Code: def dedupe_pings(rdd): return rdd.filter(lambda p: p["meta/clientId"] is not None)\ .map(lambda p: (p["meta/documentId"], p))\ .reduceByKey(lambda x, y: x)\ .map(lambda x: x[1]) Explanation: Take the set of pings, make sure we have actual clie...
82
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Workshop Installation Guide 如何使用和开发微信聊天机器人的系列教程 A workshop to develop & use an intelligent and interactive chat-bot in WeChat WeChat is a popular socia...
<ASSISTANT_TASK:> Python Code: !python --version !pip install -U html !pip install -U pyqrcode !pip install -U config !pip install -U backports.tempfile !mv docs org_docs Explanation: Workshop Installation Guide 如何使用和开发微信聊天机器人的系列教程 A workshop to develop & use an intelligent and interactive chat-bot in WeChat WeChat is ...
83
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Introduction In the Intro to SQL micro-course, you learned how to use INNER JOIN to consolidate information from two different tables. Now you'll lear...
<ASSISTANT_TASK:> Python Code: #$HIDE_INPUT$ from google.cloud import bigquery # Create a "Client" object client = bigquery.Client() # Construct a reference to the "hacker_news" dataset dataset_ref = client.dataset("hacker_news", project="bigquery-public-data") # API request - fetch the dataset dataset = client.get_dat...
84
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: A Nonsensical Language Model using Theano LSTM Today we will train a nonsensical language model ! We will first collect some language data, convert it ...
<ASSISTANT_TASK:> Python Code: ## Fake dataset: class Sampler: def __init__(self, prob_table): total_prob = 0.0 if type(prob_table) is dict: for key, value in prob_table.items(): total_prob += value elif type(prob_table) is list: prob_table_gen = {} ...
85
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: In the tutorial, you learned about six different types of bias. In this exercise, you'll train a model with real data and get practice with identifyin...
<ASSISTANT_TASK:> Python Code: # Set up feedback system from learntools.core import binder binder.bind(globals()) from learntools.ethics.ex3 import * import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import CountVectorizer # Get the same res...
86
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Toplevel MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contribut...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nims-kma', 'sandbox-3', 'toplevel') Explanation: ES-DOC CMIP6 Model Properties - Toplevel MIP Era: CMIP6 Institute: NIMS-KMA Source ID: SANDBOX-3 Sub-Topics: Radiati...
87
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: W2 Lab Step1: You can check the version of the library. Because pandas is fast-evolving library, you want to make sure that you have the up-to-date ve...
<ASSISTANT_TASK:> Python Code: import pandas as pd Explanation: W2 Lab: Data processing basics and John Snow's map Follow the contents of this notebook and answer all questions (e.g. Q1: ...) If you are not familiar with Python yet... Maybe you can quickly review these basics first. numbers and strings; if and for stat...
88
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Looking for Correlations with Data Binned by time Since the data was collected at slightly different times by different sensors, we decided to make uni...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np # math import pandas as pd # manipulating data import matplotlib.pyplot as plt # graphing import os # useful for handling filenames etc. from scipy.stats import pearsonr # calculat...
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: You can use the single line call "analyze," which does all the available analysis simultaneously Step1: ... or call all the methods individually
<ASSISTANT_TASK:> Python Code: # NOTE: This will take several minutes depending on the performance of your machine audio_features = audioAnalyzer.analyze(audio_filename) # plot the features plt.rcParams['figure.figsize'] = [20, 8] audioAnalyzer.plot(audio_features) plt.show() Explanation: You can use the single line ca...
90
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: What is an Adsorption Isotherm? In a typical isotherm analysis, a small sample of material, which one wants to determine the surface properties of, is ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from micromeritics import util from micromeritics import isotherm_examples as ex import matplotlib.pyplot as plt carb = ex.carbon_black() # example isotherm of Carbon Black with N2 at 77K sial = ex.silica_alumina() # example isotherm of Silica Alumina with N2 at 77K m...
91
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <font color='blue'>Data Science Academy - Python Fundamentos - Capítulo 5</font> Download Step1: Exercícios
<ASSISTANT_TASK:> Python Code: # Versão da Linguagem Python from platform import python_version print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version()) Explanation: <font color='blue'>Data Science Academy - Python Fundamentos - Capítulo 5</font> Download: http://github.com/dsacademybr End of...
92
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Solving problems by Searching This notebook serves as supporting material for topics covered in Chapter 3 - Solving Problems by Searching and Chapter 4...
<ASSISTANT_TASK:> Python Code: from search import * from notebook import psource, heatmap, gaussian_kernel, show_map, final_path_colors, display_visual, plot_NQueens # Needed to hide warnings in the matplotlib sections import warnings warnings.filterwarnings("ignore") Explanation: Solving problems by Searching This not...
93
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lecture Step3: 2. List Methods -- 100xp, status Step5: 3. List Methods II -- 100xp, status
<ASSISTANT_TASK:> Python Code: Instructions: + Use the upper() method on room and store the result in room_up. Use the dot notation. + Print out room and room_up. Did both change? + Print out the number of o's on the variable room by calling count() on room and passing the letter "o...
94
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: robobrowser Step1: opds Step2: Failed attempt with requests to submit to yaml loader Step3: travis webhooks For https Step4: travis webhook authent...
<ASSISTANT_TASK:> Python Code: from robobrowser import RoboBrowser def post_to_yaml_loader(url, unglue_url="https://unglue.it/api/loader/yaml"): browser = RoboBrowser(history=True) browser.open(unglue_url) form = browser.get_forms()[0] form['repo_url'] = url # weird I have to manually set r...
95
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <h2><span style="color Step1: Development of the Processor class to calculate all the stats Step2: Prototyping the dcons function to split alleles pe...
<ASSISTANT_TASK:> Python Code: !hostname %load_ext autoreload %autoreload 2 %matplotlib inline import ipyrad import ipyrad.analysis as ipa import ipyparallel as ipp from ipyrad.analysis.popgen import Popgen from ipyrad import Assembly from ipyrad.analysis.locus_extracter import LocusExtracter ipyclient = ipp.Client(clu...
96
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 9. Линейная регрессия 2. В четырехугольнике $ABCD$ независимые равные по точности измерения углов $ABD$, $DBC$, $ABC$, $BCD$, $CDB$, $BDA$, $CDA$, $DAB...
<ASSISTANT_TASK:> Python Code: import numpy Explanation: 9. Линейная регрессия 2. В четырехугольнике $ABCD$ независимые равные по точности измерения углов $ABD$, $DBC$, $ABC$, $BCD$, $CDB$, $BDA$, $CDA$, $DAB$ (в градусах) дали результаты $50.78$, $30.25$, $78.29$, $99.57$, $50.42$, $40.59$, $88.87$, $89.86$ соответств...
97
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: This note will show you how to use BigBang to investigate a particular project participant's activity. We will focus on Fernando Perez's role within th...
<ASSISTANT_TASK:> Python Code: from bigbang.archive import Archive import matplotlib.pyplot as plt import numpy as np import pandas as pd Explanation: This note will show you how to use BigBang to investigate a particular project participant's activity. We will focus on Fernando Perez's role within the IPython communit...
98
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Update TOC trends analysis Tore has previously written code to calculate Mann-Kendall (M-K) trend statistics and Sen's slope estimates for data series ...
<ASSISTANT_TASK:> Python Code: # Read data and results from the Excel macro in_xlsx = (r'C:\Data\James_Work\Staff\Heleen_d_W\ICP_Waters\TOC_Trends_Analysis_2015' r'\Data\mk_sen_test_data.xlsx') raw_df = pd.read_excel(in_xlsx, sheetname='input') res_df = pd.read_excel(in_xlsx, sheetname='results') raw_df res_...
99
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Exercise 3 We're going to switch gears a little and talk about the astrophysical part of Astrophysical Machine Learning. This exercise will have you ex...
<ASSISTANT_TASK:> Python Code: from astropy.io import fits as fits fitsimage=fits.open('filename.fits') image=np.flipud(fitsimage[0].data) Explanation: Exercise 3 We're going to switch gears a little and talk about the astrophysical part of Astrophysical Machine Learning. This exercise will have you examine two differe...