Unnamed: 0
int64
0
16k
text_prompt
stringlengths
149
45.7k
code_prompt
stringlengths
67
140k
200
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tour of Free(mium) HERE APIs A short "teaser" presentation rushing through a small subset of many free APIs made by HERE Technologies under the Freemiu...
<ASSISTANT_TASK:> Python Code: import random import urllib import utils app_id = utils.app_id app_code = utils.app_code berlin_lat_lon = [52.5, 13.4] here_berlin_addr = 'Invalidenstr. 116, 10115 Berlin, Germany' Explanation: Tour of Free(mium) HERE APIs A short "teaser" presentation rushing through a small subset of ...
201
<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 Deeper Understanding of Deep Learning Time for another mini-movie! In this video, Dan introduces stochastic gradient descent (SGD) and back-propagati...
<ASSISTANT_TASK:> Python Code: from IPython.display import YouTubeVideo YouTubeVideo('kQmHaI5Jw1c', width=800, height=450) Explanation: A Deeper Understanding of Deep Learning Time for another mini-movie! In this video, Dan introduces stochastic gradient descent (SGD) and back-propagation and explains how they are used...
202
<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 - Atmoschem 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-mh', 'atmoschem') Explanation: ES-DOC CMIP6 Model Properties - Atmoschem MIP Era: CMIP6 Institute: NCC Source ID: NORESM2-MH Topic: Atmoschem Sub-Topi...
203
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Interferometry The idea behind interferometry is that electromagnetic waves emitted from a certain point in the sky will cause characteristic interfere...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt from matplotlib import cm, colors import numpy as np from ipywidgets import interact plt.rcParams['figure.figsize'] = 16, 8 import sys sys.path.append('../..') from crocodile.simulate import * from crocodile.synthesis import * from util.v...
204
<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> <tr align=left><td><img align=left src="./images/CC-BY.png"> <td>Text provided under a Creative Commons Attribution license, CC-BY. All code ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import scipy.linalg as la import matplotlib.pyplot as plt Explanation: <table> <tr align=left><td><img align=left src="./images/CC-BY.png"> <td>Text provided under a Creative Commons Attribution license, CC-BY. All code is made available under the F...
205
<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 Lattice와 형상 제약 조건 <table class="tfo-notebook-buttons" align="left"> <td><a target="_blank" ...
<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...
206
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Project 1 Used Vehicle Price Prediction Introduction 1.2 Million listings scraped from TrueCar.com - Price, Mileage, Make, Model dataset from Kaggle St...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd data = pd.read_csv('https://github.com/albahnsen/PracticalMachineLearningClass/raw/master/datasets/dataTrain_carListings.zip') data.head() data.shape data.Price.describe() data.plot(kind='scatter', y='Price', x='Year') data.plot(kind='scatter', y='Pr...
207
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Automated Assessment of Car Damage Photos using SAS Import the required packages including swat for accessing CAS actions https Step1: Set up the envi...
<ASSISTANT_TASK:> Python Code: # import the required packages from swat import * from pprint import pprint import numpy as np import matplotlib.pyplot as plt import cv2 # define the function to display the processed image files. def imageShow(session, casTable, imageId, nimages): a = session.table.fetch(sastypes=F...
208
<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...
209
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: On this notebook the best models and input parameters will be searched for. The problem at hand is predicting the price of any stock symbol 14 days ahe...
<ASSISTANT_TASK:> Python Code: # Basic imports import os import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime as dt import scipy.optimize as spo import sys from time import time from sklearn.metrics import r2_score, median_absolute_error %matplotlib inline %pylab inline pylab.rcParams[...
210
<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 Welcome to the Petals to the Metal competition! In this competition, you’re challenged to build a machine learning model that identifies t...
<ASSISTANT_TASK:> Python Code: from petal_helper import * import tensorflow as tf Explanation: Introduction Welcome to the Petals to the Metal competition! In this competition, you’re challenged to build a machine learning model that identifies the type of flowers in a dataset of images. In this tutorial notebook, you'...
211
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Collect all tweets from @realDonaldTrump Step1: To sort tweets by favorites or retweets, need to convert unicode to integers Step2: For some reason t...
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('..') from twords.twords import Twords import matplotlib.pyplot as plt %matplotlib inline import pandas as pd # this pandas line makes the dataframe display all text in a line; useful for seeing entire tweets pd.set_option('display.max_colwidth', -1) twit = Two...
212
<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: Numerical Methods For Numerical Relativity, we need to evolve the spacetime (hyperbolic PDEs with "smooth" fields); evolve the matter (hyperboli...
<ASSISTANT_TASK:> Python Code: def backward_differencing(f, x_i, dx): Backward differencing of f at x_i with grid spacing dx. f_i = f(x_i) f_i_minus_1 = f(x_i - dx) return (f_i - f_i_minus_1) / dx def forward_differencing(f, x_i, dx): Forward differencing of f at x_i with grid sp...
213
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: beapy beapy is a Python package for obtaining data from the API of the Bureau of Economic Analysis. Step1: Methods for searching for data getDataSetLi...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import urllib import datetime import matplotlib.pyplot as plt %matplotlib inline %load_ext autoreload %autoreload 2 import beapy apiKey = '3EDEAA66-4B2B-4926-83C9-FD2089747A5B' bea = beapy.initialize(apiKey =apiKey) Explanation: beapy beapy is a Pyth...
214
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Cartopy Cartopy is a Python package designed for geospatial data processing in order to produce maps and other geospatial data analyses. We test here a...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (16, 10) import cartopy.crs as ccrs Explanation: Cartopy Cartopy is a Python package designed for geospatial data processing in order to produce maps and other geospatial data analyses. We test here a few ...
215
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Calculate Political Opinion Models Step1: Training the Base Model Calculate the base model (from german wiki), that is later used as a base for traini...
<ASSISTANT_TASK:> Python Code: # import logging # logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s') # logging.root.level = logging.INFO from os import path from random import shuffle from corputil import FileCorpus, ListCorpus from corputil.utils import load_stopwords from gensim.models.word2vec i...
216
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Supervised and Unsupervised learning example We are going to try to be able to identify handwritten digits These handwritten digits are contained in th...
<ASSISTANT_TASK:> Python Code: # Let's import the relevant packages first import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from sklearn import manifold import gzip, cPickle import pandas as pd from sklearn.cluster import KMeans from sklearn import metrics Explanation: Supervised and Unsupervi...
217
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Data The data can be downloaded from https Step1: Check the total data sets agree The files filename and filename1 were downloaded from, respectively,...
<ASSISTANT_TASK:> Python Code: import sys, os, csv, lzma import open_cp.sources.chicago as chicago filename = os.path.join("..", "..", "open_cp", "sources", "chicago.csv") filename1 = os.path.join("..", "..", "open_cp", "sources", "chicago1.csv") filename_all = os.path.join("..", "..", "open_cp", "sources", "chicago_al...
218
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Symmetric random walk on uniform distribution Step1: We genereate samples from following distribution $$ P(x)= \begin{cases}1 / 21 & x \in{0,1,2, \ldo...
<ASSISTANT_TASK:> Python Code: # Example from section 29.4 & 29.6 (Fig 29.14 & 29.15) of https://www.inference.org.uk/itprnn/book.pdf try: import probml_utils as pml except ModuleNotFoundError: %pip install -qq git+https://github.com/probml/probml-utils.git import probml_utils as pml import matplotlib.pyplo...
219
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 5. Squared Wheel and Other Reinventions Many a times, we hear discussions about writing programs using Python in the "most Pythonic way." Sometimes it'...
<ASSISTANT_TASK:> Python Code: # Task: Concatenate a list of strings into a single string # delimited by spaces. list_of_words = ['the', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy', 'dog'] i = 0 # A counter to maintain the current position in the list new_string = '' # String to hold the output while i < l...
220
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: AlexNet in Keras In this notebook, we leverage an AlexNet-like deep, convolutional neural network to classify flowers into the 17 categories of the Oxf...
<ASSISTANT_TASK:> Python Code: import numpy as np np.random.seed(42) Explanation: AlexNet in Keras In this notebook, we leverage an AlexNet-like deep, convolutional neural network to classify flowers into the 17 categories of the Oxford Flowers data set. Derived from this earlier notebook. Set seed for reproducibility ...
221
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Single Particle Systems Step1: Next, we construct the fermion basis using the constructor spinless_fermion_basis_1d. Since we are interested in a free...
<ASSISTANT_TASK:> Python Code: from quspin.operators import hamiltonian # Hamiltonians and operators from quspin.basis import spinless_fermion_basis_1d # Hilbert space fermion basis from quspin.tools.block_tools import block_diag_hamiltonian # block diagonalisation import numpy as np # generic math functions # ##### de...
222
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Outline Glossary 7. Observing Systems Previous Step1: Import section specific modules Step2: 7.7 Propagation effects <a id='instrum Step3: Figure ...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS Explanation: Outline Glossary 7. Observing Systems Previous: 7.6 Polarization and Antenna Feeds Next: 7.8 Radio Frequency Interference (...
223
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Interact Exercise 2 Imports Step1: Plotting with parameters Write a plot_sin1(a, b) function that plots $sin(ax+b)$ over the interval $[0,4\pi]$. Cust...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display Explanation: Interact Exercise 2 Imports End of explanation def plot_sine1(a, b): f = plt.figure(figsize=(16,2))...
224
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: XOR Network Data generation Step1: Xor cannot be solved with single layer of neural network Step2: Notice that the error is far from zero. Actually n...
<ASSISTANT_TASK:> Python Code: def create_examples(N, batch_size): A = np.random.binomial(n=1, p=0.5, size=(batch_size, N)) B = np.random.binomial(n=1, p=0.5, size=(batch_size, N,)) X = np.zeros((batch_size, 2 *N,), dtype=np.float32) X[:,:N], X[:,N:] = A, B Y = (A ^ B).astype(np.float32) return ...
225
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Sensitivity, accuracy, errors, and repeatability Linear approximation of nonlinear transfer function. The response of a temperature sensor is given as ...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np from math import log, exp %matplotlib inline # Evaluate beta for this sensor T_0=273.15+20; N=(1/273.15-1/293.15)-(1/298.15-1/293.15); beta= log(3000/1000)/N; R_0=1000/exp(beta*((1/298.15)-(1/293.15))); ## Results print('Beta for this se...
226
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Entity Extraction from Contract Documents Problem Statement Step1: Figure 1 Step2: Loading the data Step3: Converting the rawtext into sentences Ste...
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image(filename='entity_extraction_process.png') # Note: this image is taken from NLTK Book and requires citation Explanation: Entity Extraction from Contract Documents Problem Statement: Many companies deal with the understanding of large amount text data...
227
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: minimask mosaic example Construct a mosaic of squares over the sky Step1: Specify the location of the mask file to write Step2: Construct a mask usin...
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import os import numpy as np import tempfile import matplotlib.pyplot as pyplot import logging logging.basicConfig(level=logging.INFO) import minimask.mask as mask import minimask.healpix_projection as hp import minimask.io.mosaic as mosaic Explanation: minimask mosai...
228
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: EEG source localization given electrode locations on an MRI This tutorial explains how to compute the forward operator from EEG data when the electrode...
<ASSISTANT_TASK:> Python Code: # Authors: Eric Larson <larson.eric.d@gmail.com> # # License: BSD Style. import os.path as op import nibabel from nilearn.plotting import plot_glass_brain import numpy as np import mne from mne.channels import compute_native_head_t, read_custom_montage from mne.viz import plot_alignment E...
229
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Demo Strategic Redesign für das Projekt „Spring Petclinic“ Auslastungsdaten vom Produktivbetrieb Datenquelle Step1: Berechnung wesentlicher Metriken f...
<ASSISTANT_TASK:> Python Code: import pandas as pd coverage = pd.read_csv("../dataset/jacoco_production_coverage_spring_petclinic.csv") coverage.head() Explanation: Demo Strategic Redesign für das Projekt „Spring Petclinic“ Auslastungsdaten vom Produktivbetrieb Datenquelle: Gemessen wurde der Anwendungsbetrieb der Soft...
230
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Метод главных компонент В данном задании вам будет предложено ознакомиться с подходом, который переоткрывался в самых разных областях, имеет множество ...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib from matplotlib import pyplot as plt import matplotlib.patches as mpatches matplotlib.style.use('ggplot') %matplotlib inline Explanation: Метод главных компонент В данном задании вам будет предложено ознакомиться с подходом, который...
231
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <h1> Repeatable splitting </h1> In this notebook, we will explore the impact of different ways of creating machine learning datasets. <p> Repeatability...
<ASSISTANT_TASK:> Python Code: from google.cloud import bigquery Explanation: <h1> Repeatable splitting </h1> In this notebook, we will explore the impact of different ways of creating machine learning datasets. <p> Repeatability is important in machine learning. If you do the same thing now and 5 minutes from now and ...
232
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 2018 NUS-MIT Datathon Tutorial Step1: Next, we need to authenticate ourselves to Google Cloud Platform. If you are running the code cell below for the...
<ASSISTANT_TASK:> Python Code: import numpy as np import os import pandas as pd import random import tensorflow as tf from google.colab import auth from google.cloud import storage from io import BytesIO # The next import is used to print out pretty pandas dataframes from IPython.display import display, HTML from PIL i...
233
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Below I use my stemming/tokenizing and tokenizing functions to iterate over the list of synopses to create two vocabularies Step1: Tf-idf and document...
<ASSISTANT_TASK:> Python Code: df = pd.read_csv('../data/wiki/wiki.csv.gz', encoding='utf8', index_col=None) df['text'] = df.text.str[:3000] totalvocab_stemmed = [] totalvocab_tokenized = [] for doc_text in df.text: allwords_stemmed = tokenize_and_stem(doc_text) #for each item in 'synopses', tokenize/stem total...
234
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Übungsblatt 7 Präsenzaufgaben Aufgabe 1 &nbsp;&nbsp;&nbsp; CFG Step3: Aufgabe 2 &nbsp;&nbsp;&nbsp; CFG Step5: Hausaufgaben Aufgabe 7 &nbsp;&nb...
<ASSISTANT_TASK:> Python Code: grammar = S -> NP VP NP -> DET NOM NOM -> ADJ NOM | N ADJ -> "schöne" | "kluge" | "dicke" DET -> "der" | "die" | "das" N -> "Mann" | "Frau" | "Buch" VP -> V NP NP | V NP | V V -> "gibt" | "schenkt" | "schläft" | "gefällt" | "kennt" import nltk from IPython.display import display import s...
235
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Vertex AI Pipelines Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Install the latest GA version of google-clou...
<ASSISTANT_TASK:> Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG Explanation: Vertex AI Pipelines: model train, upload, and deploy using google-clou...
236
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Python fundamentals A quick introduction to the Python programming language and Jupyter notebooks. (We're using Python 3, not Python 2.) Basic data typ...
<ASSISTANT_TASK:> Python Code: # variable assignment # https://www.digitalocean.com/community/tutorials/how-to-use-variables-in-python-3 # strings -- enclose in single or double quotes, just make sure they match # numbers # the print function # booleans Explanation: Python fundamentals A quick introduction to the Pytho...
237
<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 US Traffic Fatality Data By Ben Van Dyke The National Highway Traffic Safety Administration maintains a fatality dataset called the Fatality ...
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib import matplotlib.pyplot as plt import StringIO import zipfile import urllib from __future__ import division, print_function matplotlib.style.use('fivethirtyeight') %matplotlib inline # Download and extract the 2015 FARS file output...
238
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Iris Project Data Exploration and Analysis Step1: Iris Data from Seaborn Step2: Visualisation Step3: scikit-learn url = http Step4: Key points Data...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set(color_codes=True) %matplotlib inline df = pd.read_csv('iris.data') df.head() df = pd.read_csv('iris.data', header=-1) df.head() col_name = ['sepal length', 'sepal width', 'petal length',...
239
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Train / Test We'll start by creating some data set that we want to build a model for (in this case a polynomial regression) Step1: Now we'll split the...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from pylab import * np.random.seed(2) pageSpeeds = np.random.normal(3.0, 1.0, 100) purchaseAmount = np.random.normal(50.0, 30.0, 100) / pageSpeeds scatter(pageSpeeds, purchaseAmount) Explanation: Train / Test We'll start by creating some data set that...
240
<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 2018 The TensorFlow Probability Authors. Licensed under the Apache License, Version 2.0 (the "License"); Step1: コピュラ入門 <table class="tfo-not...
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" } # 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 l...
241
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Populate local MDCS instance with student data and metadata Import MDCS API tool module Step1: Host and user information Step2: List of file prefixes...
<ASSISTANT_TASK:> Python Code: import mdcs Explanation: Populate local MDCS instance with student data and metadata Import MDCS API tool module End of explanation user='admin' pswd='admin' host='http://127.0.0.1:8000' template_name='DiffusionDemo' Explanation: Host and user information End of explanation name_list=[ ...
242
<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 Step1: Import raw data The user needs to specify the directories containing the data of interest. Each sample type should have a key whic...
<ASSISTANT_TASK:> Python Code: import deltascope as ds import deltascope.alignment as ut import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.preprocessing import normalize from scipy.optimize import minimize import os import tqdm import json import datetime Explanation: Introduction: Lan...
243
<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 this post, we'll use data from a tensile test to build a stress strain curve with Python and Matplotlib. A tensile test is a type of mechanical test...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline print("NumPy version:",np.__version__) print("Pandas version:",pd.__version__) Explanation: In this post, we'll use data from a tensile test to build a stress strain curve with Python and Matplotlib....
244
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: An introduction to solving biological problems with Python Session 1.3 Step1: You can of course use variables in tuples and other data structures Step...
<ASSISTANT_TASK:> Python Code: a = (123, 54, 92) # tuple of 4 integers b = () # empty tuple c = ("Ala",) # tuple of a single string (note the trailing ",") d = (2, 3, False, "Arg", None) # a tuple of mixed types print(a) print(b) print(c) print(d) Explanation: An introduction to solving biological problems with Python ...
245
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Chemical-Disease Relation (CDR) Tutorial In this example, we'll be writing an application to extract mentions of chemical-induced-disease relationships...
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline from snorkel import SnorkelSession session = SnorkelSession() from snorkel.models import candidate_subclass ChemicalDisease = candidate_subclass('ChemicalDisease', ['chemical', 'disease']) train_cands = session.query(ChemicalDisease).f...
246
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: title Step1: 对于变量x来说,不需要知道它是字符串还是列表,就可以调用它的count方法—不用管它是什么类型(只要提供一个字符作为参数即可)。 任何不知道对象到底是什么类型,但是又要对对象“做点什么”的时候,都会用到多态。这不仅限于方法,很多内建运算符和函数都有多态的性质: Step...
<ASSISTANT_TASK:> Python Code: 'abc'.count('a') [1,2,'a'].count('a') Explanation: title: 对象 create: 2016.12.7 modified: 2016.12.7 tags: python 多态 封装 方法 5 [TOC] 之前介绍了Python主要的内建对象类型(数字int、字符串str、列表list、元组tuple和字典dict),以及内建函数和标准库的用法,还有自定义函数的方式。接下来将介绍如何创建自己的对象? 为什么要自定义对象呢?使用字典、序列、数字和字符串来创建函数,完成这项...
247
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: NYGC 30x HighCov samples Hail Table Step1: Phased genotypes Creating MTs for the phased data is straightforward, as multiallelic variants were split d...
<ASSISTANT_TASK:> Python Code: ht_samples = hl.import_table( "gs://hail-datasets-tmp/1000_Genomes_NYGC_30x/1000_Genomes_NYGC_30x_samples_ped_population.txt.bgz", delimiter="\s+", impute=True ) ht_samples = ht_samples.annotate( FatherID = hl.if_else(ht_samples.FatherID == "0", ...
248
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Skip-gram word2vec In this notebook, I'll lead you through using TensorFlow to implement the word2vec algorithm using the skip-gram architecture. By im...
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf import utils Explanation: Skip-gram word2vec In this notebook, I'll lead you through using TensorFlow to implement the word2vec algorithm using the skip-gram architecture. By implementing this, you'll learn about embedding words for u...
249
<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 a LAS file from scratch Step1: Step 1 Create some fake data, and make some of the values at the bottom NULL (numpy.nan). Note that of course ...
<ASSISTANT_TASK:> Python Code: import lasio import datetime import numpy import os import matplotlib.pyplot as plt %matplotlib inline Explanation: Building a LAS file from scratch End of explanation depths = numpy.arange(10, 50, 0.5) fake_curve = numpy.random.random(len(depths)) fake_curve[-10:] = numpy.nan # Add som...
250
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Homework 1 Step1: If you've set up your environment properly, this cell should run without problems Step2: Now, run this cell to log into OkPy. This ...
<ASSISTANT_TASK:> Python Code: !pip install -U okpy Explanation: Homework 1: Setup and (Re-)Introduction to Python Course Policies Here are some important course policies. These are also located at http://www.ds100.org/sp17/. Tentative Grading There will be 7 challenging homework assignments. Homeworks must be complete...
251
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Your first neural network In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've provided som...
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' import numpy as np import pandas as pd import matplotlib.pyplot as plt Explanation: Your first neural network In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've ...
252
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Welcome to the Tutorial! First I'll introduce the theory behind neural nets. then we will implement one from scratch in numpy, (which is installed on t...
<ASSISTANT_TASK:> Python Code: import numpy as np my_vector = np.asarray([1,2,3]) my_matrix = np.asarray([[1,2,3],[10,10,10]]) print(my_matrix*my_vector) Explanation: Welcome to the Tutorial! First I'll introduce the theory behind neural nets. then we will implement one from scratch in numpy, (which is installed on the...
253
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Handwritten Number Recognition with TFLearn and MNIST In this notebook, we'll be building a neural network that recognizes handwritten numbers 0-9. Th...
<ASSISTANT_TASK:> Python Code: # Import Numpy, TensorFlow, TFLearn, and MNIST data import numpy as np import tensorflow as tf import tflearn import tflearn.datasets.mnist as mnist Explanation: Handwritten Number Recognition with TFLearn and MNIST In this notebook, we'll be building a neural network that recognizes hand...
254
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Algorithms Exercise 3 Imports Step2: Character counting and entropy Write a function char_probs that takes a string and computes the probabilities of ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact Explanation: Algorithms Exercise 3 Imports End of explanation def char_probs(s): Find the probabilities of the unique characters in the string s. Parameters ...
255
<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 H SAF Metop ASCAT SSM DR products The following example shows how to read and plot H SAF Metop ASCAT SSM data record products using the test da...
<ASSISTANT_TASK:> Python Code: import os import matplotlib.pyplot as plt from ascat.h_saf import AscatSsmDataRecord test_data_path = os.path.join('..', 'tests','ascat_test_data', 'hsaf') h109_path = os.path.join(test_data_path, 'h109') h110_path = os.path.join(test_data_path, 'h110') h111_path = os.path.join(test_data_...
256
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: GEE nested covariance structure simulation study This notebook is a simulation study that illustrates and evaluates the performance of the GEE nested c...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import statsmodels.api as sm Explanation: GEE nested covariance structure simulation study This notebook is a simulation study that illustrates and evaluates the performance of the GEE nested covariance structure. A nested covariance structure is bas...
257
<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 notebook counts the number of evolutions and reversions in a binary trait on a large phylogenetic tree. Import the dependencies - Dendropy and Pan...
<ASSISTANT_TASK:> Python Code: import dendropy import pandas as pd Explanation: This notebook counts the number of evolutions and reversions in a binary trait on a large phylogenetic tree. Import the dependencies - Dendropy and Pandas End of explanation data = pd.read_csv('../Data/PyronParityData.csv', index_col=0, hea...
258
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: CS231n Python Tutorial With Jupyter Notebook This tutorial was originally written by Justin Johnson for cs231n and adapted as a Jupyter notebook for cs...
<ASSISTANT_TASK:> Python Code: x = 1 print(x) Explanation: CS231n Python Tutorial With Jupyter Notebook This tutorial was originally written by Justin Johnson for cs231n and adapted as a Jupyter notebook for cs228 by Volodymyr Kuleshov and Isaac Caswell. This current version has been adapted as a Jupyter notebook with ...
259
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Hyperparameter tuning Learning Objectives 1. Learn how to use cloudml-hypertune to report the results for Cloud hyperparameter tuning trial runs 2. Lea...
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst PROJECT = "<YOUR PROJECT>" BUCKET = "<YOUR BUCKET>" REGION = "<YOUR REGION>" TFVERSION = "2.3.0" # TF version for AI Platform to use import os os.environ["PROJECT"] = PROJECT os.environ["BUCKET"] = BUCKET o...
260
<SYSTEM_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 In this project, you'll generate your own Simpsons TV scripts using RNNs. You'll be using part of the Simpsons dataset of ...
<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:] Explanation: TV Script Generation In this project, you'll generate your own ...
261
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Output Containers and Layout Managers Output containers are objects that hold a collection of other objects, and displays all its contents, even when t...
<ASSISTANT_TASK:> Python Code: from beakerx import * o = OutputContainer() o.addItem("simplest example") o.addItem([2, 3, 5, 7]) o.addItem(HTML("<h1>title</h1>")) o.addItem(None) o rates = pd.read_csv('../resources/data/interest-rates.csv') c = Color(120, 120, 120, 100) plot1 = Plot(initWidth= 300, initHeight= 400) pl...
262
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Lesson 3 Step1: Loops - Repeat with "while" and Iterate with "for" While loop A loop statement allows us to execute a statement or group of statements...
<ASSISTANT_TASK:> Python Code: from random import randint #From the random library we import the randint function. def dice(user_input): '''This function mimics a dice. It generates a random number between 1 and 6 and sees if the value given by the user equals to the dice value''' dice_value = randin...
263
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Traffic flow with an on-ramp In this chapter we return to the LWR traffic model that we investigated in two earlier chapters. The LWR model involves a...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from clawpack import pyclaw from clawpack import riemann from ipywidgets import interact from ipywidgets import widgets from exact_solvers import traffic_ramps from utils import riemann_tools def c(rho, xi): return ...
264
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Title Step1: Make a dataframe Step2: Add a new column for elderly
<ASSISTANT_TASK:> Python Code: # Import required modules import pandas as pd import numpy as np Explanation: Title: Create a Column Based on a Conditional in pandas Slug: pandas_create_column_using_conditional Summary: Create a Column Based on a Conditional in pandas Date: 2016-05-01 12:00 Category: Python Tags: Data W...
265
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Reading µs-ALEX data from Photon-HDF5 with h5py In this notebook we show how to read a µs-ALEX smFRET measurement stored in Photon-HDF5 format using py...
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function # only needed on py2 %matplotlib inline import numpy as np import h5py import matplotlib.pyplot as plt Explanation: Reading µs-ALEX data from Photon-HDF5 with h5py In this notebook we show how to read a µs-ALEX smFRET measurement stored in ...
266
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: English Wikipedia page views, 2008 - 2017 For this assignment, your job is to analyze traffic on English Wikipedia over time, and then document your pr...
<ASSISTANT_TASK:> Python Code: #current import requests endpoint = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/aggregate/{project}/{access}/{agent}/{granularity}/{start}/{end}' headers={'User-Agent' : 'https://github.com/your_github_username', 'From' : 'abhiv@uw.edu'} params = {'project' : 'en.wikipedia.org', ...
267
<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: Manipulating data without using TFDS We first illustrate how to make streams of minibatches using vanilla numpy code. TFDS will ...
<ASSISTANT_TASK:> Python Code: # Standard Python libraries from __future__ import absolute_import, division, print_function, unicode_literals from typing import Any, Iterator, Mapping, NamedTuple, Sequence, Tuple import os import time import numpy as np import glob import matplotlib.pyplot as plt import PIL import imag...
268
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Day 6 - pre-class assignment Goals for today's pre-class assignment Use the NumPy module to manipulate arrays of data Write a program using if statemen...
<ASSISTANT_TASK:> Python Code: # Imports the functionality that we need to display YouTube videos in # a Jupyter Notebook. # You need to run this cell before you run ANY of the YouTube videos. from IPython.display import YouTubeVideo # Don't forget to watch the video in full-screen mode! YouTubeVideo("BTXyE3KLIOs"...
269
<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: LightGBM Custom Loss Function
<ASSISTANT_TASK:> Python Code:: import LightGBM as lgb def custom_loss(y_pred, data): y_true = data.get_label() error = y_pred-y_true #1st derivative of loss function grad = 2 * error #2nd derivative of loss function hess = 0 * error + 2 return grad, hess params = {"learning_rate" ...
270
<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 a dataset? A dataset is a collection of information (or data) that can be used by a computer. A dataset typically has some number of examples, ...
<ASSISTANT_TASK:> Python Code: # Print figures in the notebook %matplotlib inline import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap from sklearn import datasets # Import datasets from scikit-learn # Import patch for drawing rectangles in the legend from matplotlib.patches ...
271
<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 Grove PIR Motion Sensor This example shows how to use the Grove PIR motion sensor. This demo requires the Grove PIR motion sensor and PYNQ Grove A...
<ASSISTANT_TASK:> Python Code: from time import sleep from pynq import Overlay from pynq.board import LED from pynq.iop import Grove_PIR from pynq.iop import PMODA from pynq.iop import PMOD_GROVE_G1 ol1 = Overlay("base.bit") ol1.download() pir = Grove_PIR(PMODA,PMOD_GROVE_G1) Explanation: PMOD Grove PIR Motion Sensor T...
272
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: True Values The "true" values can be computed analytically in this case, so we did so. We can also compute the distribution for weighting the errors. S...
<ASSISTANT_TASK:> Python Code: num_states = 8 gamma = 0.9 true_values = gamma**np.arange(num_states)[::-1] d_pi = np.ones(num_states)/num_states D_pi = np.diag(d_pi) print("True values:") print(true_values) print("On-policy distribution:") print(d_pi) def compute_value_dct(theta_lst, features): return [{s: np.dot(t...
273
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Constraint Satisfaction Problems (CSPs) This IPy notebook acts as supporting material for topics covered in Chapter 6 Constraint Satisfaction Problems ...
<ASSISTANT_TASK:> Python Code: from csp import * Explanation: Constraint Satisfaction Problems (CSPs) This IPy notebook acts as supporting material for topics covered in Chapter 6 Constraint Satisfaction Problems of the book Artificial Intelligence: A Modern Approach. We make use of the implementations in csp.py module...
274
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: The train_y_nll, valid_y_nll and valid_objective show massive overfitting. Step1: Hard to see whether it is still learning...
<ASSISTANT_TASK:> Python Code: m.layer_names channel = m.monitor.channels["valid_y_nll"] hl.Curve(zip(channel.epoch_record, channel.val_record),label="valid_y_nll") channel = m.monitor.channels["valid_y_nll"] plt.plot(channel.epoch_record, channel.val_record) Explanation: The train_y_nll, valid_y_nll and valid_objectiv...
275
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: The MIT License (MIT)<br> Copyright (c) 2017 Massachusetts Institute of Technology<br> Author Step1: Specify list of dates Step2: Enter Research Data...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt plt.rcParams['figure.dpi'] = 150 from getpass import getpass import pandas as pd from skdaccess.framework.param_class import * from skdaccess.geo.era_interim.cache import DataFetcher as EDF Explanation: The MIT License (MIT)<br> Copyright...
276
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <h1>2b. Machine Learning using tf.estimator </h1> In this notebook, we will create a machine learning model using tf.estimator and evaluate its perform...
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst # Ensure the right version of Tensorflow is installed. !pip freeze | grep tensorflow==2.6 import tensorflow as tf import pandas as pd import numpy as np import shutil print(tf.__version__) Explanation: <h1>2b. Machine Lear...
277
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Scientific Python Quickstart John Stachurski ANU This is a fast-paced, hands-on introduction to scientific computing with Python, contained in a Jupyte...
<ASSISTANT_TASK:> Python Code: import sys print(sys.version) Explanation: Scientific Python Quickstart John Stachurski ANU This is a fast-paced, hands-on introduction to scientific computing with Python, contained in a Jupyter notebook. The main focus will be on introducing Python's four most important scientific libr...
278
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: DDM for All Control Data Parse all control data to a single CSV, then check if subject data can fit a hierarchical drift decision model for different s...
<ASSISTANT_TASK:> Python Code: def parse_condition(stim_num): if stim_num == '1': return 'SS' if stim_num == '2': return 'CP' if stim_num == '3': return 'CS' if stim_num == '4': return 'US' import csv import glob csv_dir = '../data/pilot_subjects/' subjects = [] for csv_...
279
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Exceptions An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. You'v...
<ASSISTANT_TASK:> Python Code: def divide1(numerator, denominator): try: result = numerator/denominator print("result = %f" % result) except: print("You can't divide by 0!!") divide1(1.0, 2) divide1(1.0, 0) divide1("x", 2) Explanation: Exceptions An exception is an event, which occurs during t...
280
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described. <END_TASK> <USER_TASK:> Description: Divide a sorted array in K parts with sum of difference of max and min minimized in each part Function to find the minimum sum of differences possible for the given array...
<ASSISTANT_TASK:> Python Code: def calculate_minimum_split(a , k ) : p =[] n = len(a ) for i in range(1 , n ) : p . append(a[i ] - a[i - 1 ] )  p . sort(reverse = True ) min_sum = sum(p[: k - 1 ] ) res = a[n - 1 ] - a[0 ] - min_sum return res  / * Driver code * / if __name__== "__main __": ar...
281
<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 this exercise, you will leverage what you've learned to tune a machine learning model with cross-validation. Setup The questions below will give you...
<ASSISTANT_TASK:> Python Code: # Set up code checking import os if not os.path.exists("../input/train.csv"): os.symlink("../input/home-data-for-ml-course/train.csv", "../input/train.csv") os.symlink("../input/home-data-for-ml-course/test.csv", "../input/test.csv") from learntools.core import binder binder.bi...
282
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tarea 04 Step1: Lectura y grafica de los datos de 'TSI2.tx' Step2: Transformada de fourier de los datos Step3: Análisis De la grafica de amplitudes,...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib import pylab as plt import scipy.misc as pim from scipy import stats % matplotlib inline font = {'weight' : 'bold', 'size' : 12} matplotlib.rc('font', **font) Explanation: Tarea 04: Análisis de Fourier - ciclos solares Alejando Mesa y Yennife...
283
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: version 1.0.2 + Introduction to Machine Learning with Apache Spark Predicting Movie Ratings One of the most common uses of big data is to predict wha...
<ASSISTANT_TASK:> Python Code: import sys import os from test_helper import Test baseDir = os.path.join('data') inputPath = os.path.join('cs100', 'lab4', 'small') ratingsFilename = os.path.join(baseDir, inputPath, 'ratings.dat.gz') moviesFilename = os.path.join(baseDir, inputPath, 'movies.dat') Explanation: version 1.0...
284
<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 - Land 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', 'cmcc', 'cmcc-cm2-vhr4', 'land') Explanation: ES-DOC CMIP6 Model Properties - Land MIP Era: CMIP6 Institute: CMCC Source ID: CMCC-CM2-VHR4 Topic: Land Sub-Topics: Soi...
285
<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: Problem 0 - Accessing the GPU 0a) In order to run Numba functions using the GPU, we have to do a couple of things. First, go to ...
<ASSISTANT_TASK:> Python Code: import numpy as np import math from numba import vectorize, cuda from matplotlib import pyplot as plt %matplotlib inline Explanation: <a href="https://colab.research.google.com/github/evaneschneider/parallel-programming/blob/master/gpu_intro_solutions.ipynb" target="_parent"><img src="htt...
286
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <p><font size="6"><b>Jupyter notebook INTRODUCTION </b></font></p> DS Data manipulation, analysis and visualisation in Python December, 2017 © 2016, Jo...
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image(url='http://python.org/images/python-logo.gif') Explanation: <p><font size="6"><b>Jupyter notebook INTRODUCTION </b></font></p> DS Data manipulation, analysis and visualisation in Python December, 2017 © 2016, Joris Van den Bossche and Stijn Van Hoe...
287
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Memory-efficient embeddings for recommendation systems Author Step1: Prepare the data Download and process data Step2: Create train and eval data spl...
<ASSISTANT_TASK:> Python Code: import os import math from zipfile import ZipFile from urllib.request import urlretrieve import numpy as np import pandas as pd import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras.layers import StringLookup import matplotlib.pyplo...
288
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Unit Tests Overview and Principles Testing is the process by which you exercise your code to determine if it performs as expected. The code you are tes...
<ASSISTANT_TASK:> Python Code: import numpy as np # Code Under Test def entropy(ps): items = ps * np.log(ps) if any(np.isnan(items)): raise ValueError("Cannot compute log of ps!") return -np.sum(items) np.isnan([.1, .9]) # Smoke test entropy([0.5, 0.5]) Explanation: Unit Tests Overview and Principle...
289
<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 this document I would like to go through some functional idioms in Python involving the use of iterators and highlight some parallels with the equiv...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from random import random, randint, choice from itertools import cycle, ifilter, imap, islice, izip, starmap, tee from collections import defaultdict from operator import add, mul from pymonad.Maybe import * from pymona...
290
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Simulating data and power analysis Tom Ellis, August 2017 Before committing to the time and cost of genotyping samples for a paternity study, it is alw...
<ASSISTANT_TASK:> Python Code: import numpy as np import faps as fp import matplotlib.pylab as plt import pandas as pd from time import time, localtime, asctime np.random.seed(37) allele_freqs = np.random.uniform(0.2, 0.5, 50) adults = fp.make_parents(10, allele_freqs, family_name='adult') Explanation: Simulating data...
291
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Multigroup Mode Part II Step1: We will begin by creating three materials for the fuel, water, and cladding of the fuel pins. Step2: With our three ma...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import os import openmc %matplotlib inline Explanation: Multigroup Mode Part II: MGXS Library Generation with OpenMC The previous Notebook in this series used multi-group mode to perform a calculation with previously defined cross section...
292
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: PDF Analysis Tutorial Introduction This tutorial demonstrates how to acquire a multidimensional pair distribution function (PDF) from both a flat field...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import hyperspy.api as hs import pyxem as pxm import numpy as np Explanation: PDF Analysis Tutorial Introduction This tutorial demonstrates how to acquire a multidimensional pair distribution function (PDF) from both a flat field electron diffraction pattern and a scann...
293
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Generador de descuentos Objetivos Incentivar nuevas compras del cliente en el establecimiento Fomentar el consumo de otros productos Fomentar el consum...
<ASSISTANT_TASK:> Python Code: import re from pyknow import * Explanation: Generador de descuentos Objetivos Incentivar nuevas compras del cliente en el establecimiento Fomentar el consumo de otros productos Fomentar el consumo de productos con más margen de beneficio Entradas y Salidas Entrada: Lista de artículos que ...
294
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Advanced Step1: Let's get started with some basic imports. Step2: And then we'll build a synthetic "dataset" and initialize a new bundle with those d...
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.3,<2.4" Explanation: Advanced: mask_phases and mask_enabled Setup Let's first make sure we have the latest version of PHOEBE 2.3 installed (uncomment this line if running in an online notebook session such as colab). End of explanation import phoebe from phoebe...
295
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <img style='float Step1: Connect to server Step2: <hr> Random binary network A random graph where every node has the same degree, with default stylin...
<ASSISTANT_TASK:> Python Code: import os from lightning import Lightning from numpy import random, asarray, linspace, corrcoef from colorsys import hsv_to_rgb from sklearn import datasets import networkx as nx Explanation: <img style='float: left' src="http://lightning-viz.github.io/images/logo.png"> <br> <br> &nbsp;&n...
296
<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: Weight clustering in Keras example <table class="tfo-notebook-buttons" align="left"> <td> <a targe...
<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...
297
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Reading BEM surfaces from a forward solution Plot BEM surfaces used for forward solution generation. Step1: Show result
<ASSISTANT_TASK:> Python Code: # Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import mne from mne.datasets import sample print(__doc__) data_path = sample.data_path() fname = data_path + '/subjects/sample/bem/sample-5120-5120-5120-bem-sol.fif' surfaces = mne.read_bem_...
298
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ================================================== Background on Independent Component Analysis (ICA) =================================================...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from scipy import signal from sklearn.decomposition import FastICA, PCA np.random.seed(0) # set seed for reproducible results n_samples = 2000 time = np.linspace(0, 8, n_samples) s1 = np.sin(2 * time) # Signal 1 : sinusoidal signal s2 =...
299
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 模擬瀏覽器來抓 selenium (https Step1: 找出圖片的網址 Step2: Q 直接用 urlopen 來找找看圖片網址 有了網址, 可以用 urllib 抓下來。 也可以用 spynner 來抓。 Step3: 如何換頁? Step4: 開始回圈來抓圖吧 Step5: 已經...
<ASSISTANT_TASK:> Python Code: import spynner import os, sys from IPython.display import display, Image # 用 spynner 打開瀏覽器 browser = spynner.Browser(debug_level=spynner.ERROR, debug_stream=sys.stderr) browser.show() # 告訴 browser,要它之後不要隱身 # 在 ?????? 填入適當網址 base_url = 'http://v.??????.com/online/comic-7340.html?ch=' bo...