Unnamed: 0
int64
0
16k
text_prompt
stringlengths
149
45.7k
code_prompt
stringlengths
67
140k
800
<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 1 Step1: Ejercicio1 Escribe los metodos repr y str para la clase Array de forma que se imprima legiblemente como en numpy arrays. Step2: Ejerci...
<ASSISTANT_TASK:> Python Code: class Array: "Una clase minima para algebra lineal" def __init__(self, list_of_rows): "Constructor y validador" # obtener dimensiones self.data = list_of_rows nrow = len(list_of_rows) # ___caso vector: redimensionar correctame...
801
<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 notebook a sensitivity analysis will be performed. The best Automatic Trader will be trained and tested many times, with the SPY symbol, to ass...
<ASSISTANT_TASK:> Python Code: # Basic imports import os import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime as dt import scipy.optimize as spo import sys from time import time from sklearn.metrics import r2_score, median_absolute_error from multiprocessing import Pool import pickle %...
802
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Multilabel Design Pattern The Multilabel Design Pattern refers to models that can assign more than one label to a given input. This design requires cha...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import tensorflow as tf from tensorflow import keras from tensorflow.keras import Model from tensorflow.keras.layers import Dense, Embedding, Input, Flatten, Conv2D, MaxPooling2D from sklearn.utils import shuffle from sklearn.preprocessing import Mul...
803
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Batch Normalization – Practice Batch normalization is most useful when building deep neural networks. To demonstrate this, we'll create a convolutional...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False) Explanation: Batch Normalization – Practice Batch normalization is most useful when building deep neural networks. To demonstrat...
804
<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 Complications Author Step1: Now we plot a single example of both classes, to show what the data looks like. First the pulsar example....
<ASSISTANT_TASK:> Python Code: # Import the libraries to be used throughout. %pylab inline import matplotlib.pyplot as plt # The HTRU 2 profile data is split - one file containing the real pulsar # profiles, one file containing noise/interference profiles. We load both # these data sources here. First we construct rela...
805
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Experiment Step1: Load and check data Step2: ## Analysis
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import glob import tabulate import pprint import click import numpy as np import pandas as pd from ray.tune.commands import * from nupi...
806
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Determining the worst winter ever in Minneapolis The object of this exercise is to take weather observations from past winters in Minneapolis and deter...
<ASSISTANT_TASK:> Python Code: import pandas as pd # Read data, sort by year & month dateparse = lambda x: pd.datetime.strptime(x, '%Y%m%d') noaa_monthly = pd.read_csv('mpls-noaa.csv', index_col=2, parse_dates=True, date_parser=dateparse, na_values=-9999) noaa_monthly = noaa_monthly.groupby([...
807
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Define a kernel and function Here we define a kernel. The function is drawn at random from the GP and is corrupted my Gaussian noise Step1: Interactiv...
<ASSISTANT_TASK:> Python Code: # Measurement noise noise_var = 0.05 ** 2 # Bounds on the inputs variable bounds = [(-5., 5.), (-5., 5.)] # Define Kernel kernel = GPy.kern.RBF(input_dim=len(bounds), variance=2., lengthscale=1.0, ARD=True) # Initial safe point x0 = np.zeros((1, len(bounds))) # Gener...
808
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Mapping with splot and PySAL Imports Step1: Data Preparation Load example data into a geopandas.GeoDataFrame and inspect column names. In this example...
<ASSISTANT_TASK:> Python Code: import pysal.lib as lp from pysal.lib import examples import geopandas as gpd import pandas as pd import matplotlib.pyplot as plt import matplotlib import numpy as np %matplotlib inline Explanation: Mapping with splot and PySAL Imports End of explanation link_to_data = examples.get_path('...
809
<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 Step1: Distribution of Passengers Gender - Analysis | Graph <a id="Gender - Analysis | Graph"></a> Distribution of Genders in Pass...
<ASSISTANT_TASK:> Python Code: # Imports for pandas, and numpy import numpy as np import pandas as pd # imports for seaborn to and matplotlib to allow graphing import matplotlib.pyplot as plt import seaborn as sns sns.set(style="whitegrid") %matplotlib inline # import Titanic CSV - NOTE: adjust file path as neccessar...
810
<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><h2>Scale your pandas workflows by changing one line of code</h2> Exercise 2 Step1: Dataset Step2: pandas.read_csv Step3: Expect pandas to t...
<ASSISTANT_TASK:> Python Code: import modin.pandas as pd import pandas import time import modin.config as cfg cfg.StorageFormat.put("omnisci") Explanation: <center><h2>Scale your pandas workflows by changing one line of code</h2> Exercise 2: Speed improvements GOAL: Learn about common functionality that Modin speeds up...
811
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Importing Cells in NetPyNE (1) Clone repository and compile mod files Determine your location in the directory structure Step1: Move to (or stay in) t...
<ASSISTANT_TASK:> Python Code: !pwd Explanation: Importing Cells in NetPyNE (1) Clone repository and compile mod files Determine your location in the directory structure End of explanation %cd /content/ Explanation: Move to (or stay in) the '/content' directory End of explanation !pwd Explanation: Ensure you are in the...
812
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Here, we construct a simple neural network transform with the ability to add layers and change the optimizer while training. Note that this code is lar...
<ASSISTANT_TASK:> Python Code: from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation from keras.optimizers import SGD class SimpleNN(ContinuousTransform): def init_func(self,target_df,X_train_df,y_train_df,X_test_df,y_test_df): model=Sequential() model.add(Dens...
813
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: DM_Halos and DM_IGM Splitting $\langle DM_{cosmic}\rangle$ into its constituents. Step1: $\langle \rho_{diffuse, cosmic}\rangle$ Use f_diffuse to calc...
<ASSISTANT_TASK:> Python Code: # imports from importlib import reload import numpy as np from scipy.interpolate import InterpolatedUnivariateSpline as IUS from astropy import units as u from frb.halos import ModifiedNFW from frb import halos as frb_halos from frb import igm as frb_igm from frb.figures import utils as f...
814
<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: Below, the first computation shows that the type K thermocouple emf at 42 °C, with reference junction at 0 °C, is 1.694 mV (comp...
<ASSISTANT_TASK:> Python Code: # First let's install the module !pip install thermocouples_reference Explanation: <a href="https://colab.research.google.com/github/agmarrugo/sensors-actuators/blob/master/notebooks/thermocouples_reference_tables.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/...
815
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: First step In this tutorial we will use Brython, an implementation of Python written in javascript and Python, to access the Highcharts javascript libr...
<ASSISTANT_TASK:> Python Code: %load_ext brythonmagic Explanation: First step In this tutorial we will use Brython, an implementation of Python written in javascript and Python, to access the Highcharts javascript library and to manage the data to be used in the maps. To integrate Brython in the IPython notebook we are...
816
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Übungsblatt 12 Präsenzaufgaben Aufgabe 1 &nbsp;&nbsp;&nbsp; Evaluationsmetriken Step1: Betrachten Sie folgende Daten. Es handelt sich um ein vereinfac...
<ASSISTANT_TASK:> Python Code: from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score Explanation: Übungsblatt 12 Präsenzaufgaben Aufgabe 1 &nbsp;&nbsp;&nbsp; Evaluationsmetriken End of explanation ground_truth = [1,0,1,0,0,1,1,1,1,0] chunker1 = [1,1,1,0,1,0,1,1,1,1] chunker2 = [1,0...
817
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Fashion MNIST with Keras and TPUs <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step1: Defining our model...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np (x_train, y_train), (x_test, y_test) = tf.keras.datasets.fashion_mnist.load_data() # add empty color dimension x_train = np.expand_dims(x_train, -1) x_test = np.expand_dims(x_test, -1) Explanation: Fashion MNIST with Keras and TPUs <table class="...
818
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Heterojunction offsets Heterojunctions are the basis of much of the semiconductor technology. From computer memory, to flat-panel display to photovolta...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import macrodensity as md import math import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl extrema = md.vasp_tools.get_band_extrema('OUTCAR_ZnO') print extrema extrema = md.vasp_tools.get_band_extrema('OUTCAR_ZnS') print extrema input_file = 'LOCP...
819
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Copyright 2020 Google LLC. Licensed under the Apache License, Version 2.0 (the "License"); Measuring Signal Properties of Various Initialization...
<ASSISTANT_TASK:> Python Code: #@title Imports and Definitions import numpy as np import os import tensorflow.compat.v2 as tf tf.enable_v2_behavior() import gin from rigl import sparse_utils from rigl.rigl_tf2 import init_utils from rigl.rigl_tf2 import utils from rigl.rigl_tf2 import train from rigl.rigl_tf2 import ne...
820
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Viewing CNN Filters Review At this point, I've tested my CNN a little bit and learned that the hair really matters. If the CNN sees a lighter object re...
<ASSISTANT_TASK:> Python Code: import cv2 import numpy as np from matplotlib import pyplot as plt %matplotlib inline # TFlearn libraries import tflearn from tflearn.layers.conv import conv_2d, max_pool_2d from tflearn.layers.core import input_data, dropout, fully_connected from tflearn.layers.estimator import regressio...
821
<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 the mean flux before transit is significantly different from the mean flux after transit, mask those results. Step1: If the distribution of fluxs b...
<ASSISTANT_TASK:> Python Code: [n for n in table.colnames if n.startswith('ks')] p = table['ttest:out_of_transit&before_midtransit-vs-out_of_transit&after_midtransit'] poorly_normalized_oot_threshold = -1 mask_poorly_normalized_oot = np.log(p) > poorly_normalized_oot_threshold plt.hist(np.log(p[~np.isnan(p)])) plt.axv...
822
<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) 2016, 2017, 2018 Massachusetts Institute of Technology<br> Authors Step1: Get scale factor Step2: Plot EWD $\...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt plt.rcParams['figure.dpi']=150 # Gravity Recovery and Climate Experiment (GRACE) Data # Source: http://grace.jpl.nasa.gov/ # Current surface mass change data, measuring equivalent water thickness in cm, versus time # This data fetcher use...
823
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: More on data structures Iterable vs. Iterators Lists are examples of iterable data structures, which means that you can iterate over the actual objects...
<ASSISTANT_TASK:> Python Code: # iterating over a list by object x = ['bob', 'sue', 'mary'] for name in x: print(name.upper() + ' WAS HERE') # alternatively, you could iterate over position for i in range(len(x)): print(x[i].upper() + ' WAS HERE') dir(x) # ignore the __ methods for now Explanation: More on da...
824
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ABU量化系统使用文档 <center> <img src="./image/abu_logo.png" alt="" style="vertical-align Step1: 之前的章节无论讲解策略优化,还是针对回测进行滑点或是手续费都是针对一支股票进行择时操作。 本节将示例讲解多...
<ASSISTANT_TASK:> Python Code: from __future__ import print_function from __future__ import division import warnings warnings.filterwarnings('ignore') warnings.simplefilter('ignore') import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import os import sys # 使用insert 0即只使用github,避免交...
825
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: EIT lab notes A notebook for relevant calculations regarding the observation conditions for EIT slow light Goal Step1: Notes from Klein et al 2011 (do...
<ASSISTANT_TASK:> Python Code: from numpy import pi from scipy.constants import hbar Explanation: EIT lab notes A notebook for relevant calculations regarding the observation conditions for EIT slow light Goal: observe slow light with 10% pulse delay by Nov 1, 2018 End of explanation # Find the power for a 3 mm diamete...
826
<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 1 Step1: Exercise 2 Step2: Exercise 3
<ASSISTANT_TASK:> Python Code: price = 0.9 # Print the header print('Balls: Price: Balls: Price:') # Print prices in two columns for balls in range(1,11): left = balls right = balls + 10 skeletton = '{:^6} {:^6.2f} {:^6} {:^6.2f}' print(skeletton.format(left, left*price, ri...
827
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Jupyter notebook illustrating the use of PmagPy for analysis of paleomagnetic data Before you begin You may be viewing this notebook as a rendered html...
<ASSISTANT_TASK:> Python Code: import pmagpy.ipmag as ipmag import pmagpy.pmag as pmag Explanation: Jupyter notebook illustrating the use of PmagPy for analysis of paleomagnetic data Before you begin You may be viewing this notebook as a rendered html webpage (which can be seen at this link: http://pmagpy.github.io/Exa...
828
<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 <img style="float Step1: The original data is 90 degree off. So in data loading function, I use transpose to fix it. However, the transposed dat...
<ASSISTANT_TASK:> Python Code: theta1, theta2 = nn.load_weight('ex3weights.mat') theta1.shape, theta2.shape Explanation: model <img style="float: left;" src="../img/nn_model.png"> load weights and data End of explanation X, y = nn.load_data('ex3data1.mat',transpose=False) X = np.insert(X, 0, values=np.ones(X.shape[0]),...
829
<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 of DOV search methods for interpretations (informele hydrogeologische stratigrafie) Use cases explained below Get 'informele hydrogeologische s...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import inspect, sys # check pydov path import pydov Explanation: Example of DOV search methods for interpretations (informele hydrogeologische stratigrafie) Use cases explained below Get 'informele hydrogeologische stratigrafie' in a bounding box Get 'informele hydrogeo...
830
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Examples of Incremental AI Step1: Part 1 Step2: Sklearn function to generate random points Step3: Function to compute kmeans and plot clusters. Step...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns; sns.set() # for plot styling import numpy as np import threading import time from sklearn.datasets.samples_generator import make_blobs from sklearn.cluster import KMeans import sys sys.path.append("../") from IoTPy...
831
<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: The Fashion MNIST data is available directly in the tf.keras datasets API. You load it like this Step2: Calling load_data on th...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf print(tf.__version__) Explanation: <a href="https://colab.research.google.com/github/leopardbruce/FileFun/blob/master/%E2%80%9CCourse_1_Part_4_Lesson_2_Notebook_ipynb%E2%80%9D.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.sv...
832
<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 computation graph TensorFlow programs are usually structured into a construction phase, that assembles a graph, and an execution phase that uses a ...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf # Create a Constant op that produces a 1x2 matrix. The op is # added as a node to the default graph. # # The value returned by the constructor represents the output # of the Constant op. matrix1 = tf.constant([[3., 3.]]) # Create another Constant that produces a 2...
833
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: [3-1] 動画作成用のモジュールをインポートして、動画を表示可能なモードにセットします。 Step1: [3-2] x=0〜1の範囲で棒グラフを描いて面積を計算する関数integralを定義します。 Step2: [3-3] 二次関数 y=x*x を用意して、関数integralを呼び出します。...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation %matplotlib nbagg Explanation: [3-1] 動画作成用のモジュールをインポートして、動画を表示可能なモードにセットします。 End of explanation def integral(f, filename): fig = plt.figure(figsize=(4,4)) images = [] step = 0.5 ...
834
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: DSGRN Query Functions Step1: We show here the network being considered in this example Step2: Query Overview In order to perform queries on the datab...
<ASSISTANT_TASK:> Python Code: from DSGRN import * database = Database("querytest.db") database.parametergraph.dimension() Explanation: DSGRN Query Functions End of explanation database print(database.network.specification()) Explanation: We show here the network being considered in this example: End of explanation mon...
835
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Binding Site Prediction In this notebook we perform various machine learning methods and compare various aspects of machine learning paradigms Step1: ...
<ASSISTANT_TASK:> Python Code: ## matrix and vector tools import pandas as pd from pandas import DataFrame as df from pandas import Series import numpy as np ## sklearn from sklearn.datasets import make_friedman1 from sklearn.feature_selection import RFE from sklearn.svm import SVR from sklearn.svm import SVC from skle...
836
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Blastocyst Development in Mice Step1: Next we load in the data. We've provided a convenience function for loading in the data with GPy. It is loaded i...
<ASSISTANT_TASK:> Python Code: import pods, GPy, itertools %matplotlib inline from matplotlib import pyplot as plt Explanation: Blastocyst Development in Mice: Single Cell TaqMan Arrays presented at the EBI BioPreDyn Course 'The Systems Biology Modelling Cycle' Max Zwiessele, Oliver Stegle, Neil Lawrence 12th May 2014 ...
837
<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 an ML App Now that we have a machine learning model to predict the defaults, let us try to build a web application to lend loans. It'll have ...
<ASSISTANT_TASK:> Python Code: %%file sq.py def square(n): return n*n Explanation: Building an ML App Now that we have a machine learning model to predict the defaults, let us try to build a web application to lend loans. It'll have two parts: a form to submit the loans admin panel to look at the submitted loans ...
838
<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 isotherm fitting Our strategy here is to generate data points that follow a given isotherm model, then fit an isotherm model to the data using pyI...
<ASSISTANT_TASK:> Python Code: import pyiast import numpy as np import matplotlib.pyplot as plt import pandas as pd %matplotlib inline Explanation: Test isotherm fitting Our strategy here is to generate data points that follow a given isotherm model, then fit an isotherm model to the data using pyIAST, and check that p...
839
<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 SDK Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Once you've installed the addition...
<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 SDK: AutoML training tabular forecasting model for batch predict...
840
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Let's say we want to prepare data and try some scalers and classifiers for prediction in a classification problem. We will tune paramaters of classifie...
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import make_classification X, y = make_classification() Explanation: Let's say we want to prepare data and try some scalers and classifiers for prediction in a classification problem. We will tune paramaters of classifiers by grid search technique. Data preparing: En...
841
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tutorial for flexx.app - connecting to the browser Step1: In normal operation, one uses flx.launch() to fire up a browser (or desktop app) to run the ...
<ASSISTANT_TASK:> Python Code: from flexx import flx Explanation: Tutorial for flexx.app - connecting to the browser End of explanation %gui asyncio flx.init_notebook() class MyComponent(flx.JsComponent): foo = flx.StringProp('', settable=True) @flx.reaction('foo') def on_foo(self, *events): ...
842
<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 histogram above shows the dataset is unbalanced. We will now go ahead and drop most of the zero steering angles, which correspond to mostly straigh...
<ASSISTANT_TASK:> Python Code: zero_steering = drive_log_df[drive_log_df.steering == 0].sample(frac=0.9) drive_log_df = drive_log_df.drop(zero_steering.index) plt.figure(figsize=(10,4)) drive_log_df.steering.hist(bins=100, color='r') plt.xlabel('steering angle bins') plt.ylabel('counts') plt.show() print("Current Datas...
843
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Summarizing Images Images are high dimensional objects Step1: How Many Photons Came From the Cluster? Let's estimate the total counts due to the clust...
<ASSISTANT_TASK:> Python Code: import astropy.io.fits as pyfits import numpy as np import astropy.visualization as viz import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 10.0) targdir = 'a1835_xmm/' imagefile = targdir+'P0098010101M2U009IMAGE_3000.FTZ' expmapfile = targdir+'P009...
844
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tricks of the trade Step1: Introducing randomized search We have already built a random forest classifier, tuned using grid search, to predict spam em...
<ASSISTANT_TASK:> Python Code: import wget import pandas as pd import numpy as np from sklearn.cross_validation import train_test_split # Import the dataset data_url = 'https://raw.githubusercontent.com/nslatysheva/data_science_blogging/master/datasets/spam/spam_dataset.csv' dataset = wget.download(data_url) dataset = ...
845
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Jennifer 8. Lee et al have been using a Google spreadsheet to track the production of books in Project GITenberg Step1: Getting access to the spreadsh...
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import gspread import json # rtc50_settings.py holds URL related to the Google spreadsheet from rtc50_settings import (g_name, g_url, g_key) OFFICIAL_NAME_KEY = "Name in rtc/books.json, Official Name" Explanation: Jennifer 8. Lee et al have been usin...
846
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Matplotlib <img src="images/matplotlib.svg" alt="matplotlib" style="width Step1: File Reading Line Plots plt.plot Plot lines and/or markers Step2: Sc...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt %matplotlib inline import numpy as np Explanation: Matplotlib <img src="images/matplotlib.svg" alt="matplotlib" style="width: 600px;"/> Using matplotlib in Jupyter notebook End of explanation x = np.arange(-np.pi,np.pi,0.01) # Create an array of x values fr...
847
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Modules and Connection to MongoDb Step1: Extraction of Data from MongoDB and Creating DataFrame Step2: First five rows from the dataframe Step3: Dat...
<ASSISTANT_TASK:> Python Code: from pymongo import MongoClient import time import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from matplotlib.pyplot import * import datetime as dt import random as rnd import warnings import datetime as dt import csv %matplotlib inline warnings....
848
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 확률 분포, 확률 변수, 확률 모형의 의미 분포 확률 분포 확률 변수 확률 모형 샘플링 모집단 확률 분포 자료의 분포(distribution)란 자료가 어떤 수치적인 값을 가지는지를 그 전반적인 특징을 서술한 것을 말한다. 어떤 경우에 자료의 분포가 필요할까? 다음의 ...
<ASSISTANT_TASK:> Python Code: sp.random.seed(0) x = sp.random.normal(size=1000) x ns, bins, ps = plt.hist(x, bins=10) ns bins ps pd.DataFrame([bins, ns/1000]) Explanation: 확률 분포, 확률 변수, 확률 모형의 의미 분포 확률 분포 확률 변수 확률 모형 샘플링 모집단 확률 분포 자료의 분포(distribution)란 자료가 어떤 수치적인 값을 가지는지를 그 전반적인 특징을 서술한 것을 말한다. 어떤 경우에 자료의 분포가 필요할까? ...
849
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: seaborn.heatmap Heat maps display numeric tabular data where the cells are colored depending upon the contained value. Heat maps are great for making t...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np plt.rcParams['figure.figsize'] = (20.0, 10.0) plt.rcParams['font.family'] = "serif" df = pd.pivot_table(data=sns.load_dataset("flights"), index='month', ...
850
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Useful Scripts Location of the scripts Here are some scripts that you may find useful. They are in the folder "./eppy/useful_scripts" And now for some ...
<ASSISTANT_TASK:> Python Code: import os os.chdir("../eppy/useful_scripts") # changes directory, so we are where the scripts are located # you would normaly install eppy by doing # python setup.py install # or # pip install eppy # or # easy_install eppy # if you have not done so, the following three lines are needed im...
851
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Pandas and data wrangling Pandas is a tool for accessing columnar data, like that in SQL tables or CSV files. Step1: Let's start by reading in a datas...
<ASSISTANT_TASK:> Python Code: # convention recommended in documentation import pandas as pd import numpy as np import matplotlib.pyplot as plt #enable inline plotting in notebook %matplotlib inline Explanation: Pandas and data wrangling Pandas is a tool for accessing columnar data, like that in SQL tables or CSV files...
852
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Transit-Network Making plots for my SETI idea, dreamed up on the airplane home from AAS 227 SHELVED I put this idea on the backburner and removed it fr...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.patches as mpatches import matplotlib.cm as cm import matplotlib matplotlib.rcParams.update({'font.size':18}) matplotlib.rcParams.update({'font.family':'serif'}) Explanation: Transi...
853
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: GWAS Tutorial This notebook is designed to provide a broad overview of Hail's functionality, with emphasis on the functionality to manipulate and query...
<ASSISTANT_TASK:> Python Code: import hail as hl hl.init() Explanation: GWAS Tutorial This notebook is designed to provide a broad overview of Hail's functionality, with emphasis on the functionality to manipulate and query a genetic dataset. We walk through a genome-wide SNP association test, and demonstrate the need ...
854
<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 model buils a simple Hierarchial mixed effect model to look at dose response from 5 clinical trials. In this example we are model the mean respons...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt %matplotlib inline from pymc3 import Model, Normal, Lognormal, Uniform, trace_to_dataframe, df_summary Explanation: This model buils a simple Hierarchial mixed effect model to look at dose respon...
855
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: DSGRN Python Interface Tutorial This notebook shows the basics of manipulating DSGRN with the python interface. Step1: Network The starting point of t...
<ASSISTANT_TASK:> Python Code: import DSGRN Explanation: DSGRN Python Interface Tutorial This notebook shows the basics of manipulating DSGRN with the python interface. End of explanation network = DSGRN.Network("network.txt") print(network) print(network.graphviz()) Explanation: Network The starting point of the DSGRN...
856
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Regression 1. Information Generation Simulation of values to train and test the linear regression model. Step1: 2. ages_train vs ages_test relationshi...
<ASSISTANT_TASK:> Python Code: # importing packages import numpy import random import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression # setting ageNetWorthData def ageNetWorthData(): random.seed(42) numpy.random.seed(42) ages = [] for ii in range(100): ages.append( ran...
857
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Fibonacci Stretch Step1: You can also jump to Part 6 for more audio examples. Part 1 - Representing rhythm as symbolic data 1.1 Rhythms as arrays The ...
<ASSISTANT_TASK:> Python Code: import IPython.display as ipd ipd.Audio("../data/out_humannature_90s_stretched.mp3", rate=44100) Explanation: Fibonacci Stretch: An Exploration Through Code by David Su This notebook and its associated code are also available on GitHub. Contents Introduction A sneak peek at the final resu...
858
<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 is garbage In this example, we are looking for a link to some source code Step1: PDF is garbage, continued If we remove line breaks to fix URLs t...
<ASSISTANT_TASK:> Python Code: urlre = re.compile( '(?P<url>https?://[^\s]+)' ) for page in doc : print urlre.findall( page ) Explanation: PDF is garbage In this example, we are looking for a link to some source code : http://prodege.jgi-psf.org//downloads/src However, in the PDF, the URL is line wrapped, so the sr...
859
<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 Effect Import and settings In this example, we need to import numpy, pandas, and graphviz in addition to lingam. Step1: Utility function We def...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import graphviz import lingam print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__]) np.set_printoptions(precision=3, suppress=True) np.random.seed(0) Explanation: Causal Effect Import and settings In this example, we need ...
860
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: K-means Clustering in sci-kit learn This example uses a dataset downloaded from https Step1: Unarchive Step2: Tokenizing and Filtering a Vocabulary S...
<ASSISTANT_TASK:> Python Code: import pandas as pd import sys sys.version Explanation: K-means Clustering in sci-kit learn This example uses a dataset downloaded from https://www.opensubtitles.org/en/search/vip and the raw data at opus.lingfil.uu.se/OpenSubtitles2016/raw/en. Metadata such as title actor and director ...
861
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ATM 623 Step1: Contents Simulation versus parameterization of heat transport The temperature diffusion parameterization Solving the temperature diffus...
<ASSISTANT_TASK:> Python Code: # Ensure compatibility with Python 2 and 3 from __future__ import print_function, division Explanation: ATM 623: Climate Modeling Brian E. J. Rose, University at Albany Lecture 18: The one-dimensional energy balance model Warning: content out of date and not maintained You really should ...
862
<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 id="tocheading">Table of Contents</h1> <div id="toc"></div> Step1: Getting and Knowing your Data Task Step2: Task Step3: Task Step4: Groupby Ta...
<ASSISTANT_TASK:> Python Code: %%javascript $.getScript('misc/kmahelona_ipython_notebook_toc.js') Explanation: <h1 id="tocheading">Table of Contents</h1> <div id="toc"></div> End of explanation fn = r"data/drinks.csv" # Answer: df = pd.read_csv(fn, sep=",") Explanation: Getting and Knowing your Data Task: load the fol...
863
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Use the cleaner chaining method for transforming the data https Step1: The sale price is in hte hundreds of thousands, so let's divide the price by 10...
<ASSISTANT_TASK:> Python Code: target = pd.read_csv('../data/train_target.csv') target.describe() Explanation: Use the cleaner chaining method for transforming the data https://tomaugspurger.github.io/method-chaining.html Sale price distribution First step is to look at the target sale price for the training data set, ...
864
<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: Two major version branches Python 2.x Latest Step2: Mis-Conceptions python does not have types? No! Python does have ty...
<ASSISTANT_TASK:> Python Code: print("Hello World") Explanation: <div style="text-align: center;"> <h1> Python - Why should you learn? </h1> <h3> Thamme Gowda </h3> <h4> Feb 9th, 2018. SJCIT </h4> <br/> <a href="https://twitter.com/thammegowda">@thammegowda</a> <br/> <a href="https://isi.edu/~tg">https://isi.edu/~tg <...
865
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Executed Step1: Multi-spot vs usALEX FRET histogram comparison Load FRETBursts software Step2: 8-spot paper plot style Step3: Data files Data folder...
<ASSISTANT_TASK:> Python Code: data_id = '17d' ph_sel_name = "None" data_id = "17d" Explanation: Executed: Mon Mar 27 22:24:30 2017 Duration: 12 seconds. End of explanation from fretbursts import * sns = init_notebook() import os import pandas as pd from IPython.display import display, Math import lmfit print('lmfit ve...
866
<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: Baselines Step2: Dense example Step3: Sparse example Step4: Regression example Step5: n_features/time complexity Step6: Logging ...
<ASSISTANT_TASK:> Python Code: from tensorflow.examples.tutorials.mnist import input_data from sklearn.datasets import fetch_mldata from sklearn.preprocessing import scale from sklearn.model_selection import train_test_split from sklearn.metrics import roc_auc_score, accuracy_score mnist = input_data.read_data_sets("MN...
867
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Profiling BatchFlow code A profile is a set of statistics that describes how often and for how long various parts of the program executed. This noteboo...
<ASSISTANT_TASK:> Python Code: import sys sys.path.append("../../..") from batchflow import B, V, W from batchflow.opensets import MNIST from batchflow.models.torch import ResNet18 dataset = MNIST() Explanation: Profiling BatchFlow code A profile is a set of statistics that describes how often and for how long various ...
868
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Тест. Практика проверки гипотез По данным опроса, 75% работников ресторанов утверждают, что испытывают на работе существенный стресс, оказывающий негат...
<ASSISTANT_TASK:> Python Code: from __future__ import division import numpy as np import pandas as pd from scipy import stats import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" n = 100 prob =...
869
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Charge Noise Mask Design General Notes Step1: CPW We want to use the same cpw dimensions for resonator and feedline/purcell filter cpw's so the kineti...
<ASSISTANT_TASK:> Python Code: ri = (40, 50, 60, 70, 80, 90, 100, 108) ro = (40.7, 52.9, 69, 90.5, 123, 182, 305, 500) Cq = (46.3, 47.0, 46.9, 47.0, 47.0, 47.0, 46.9, 46.9) #Cq = (46.3, 49.5, 46.9, 49.5, 47.0, 51.7, 46.9, 54) Cg = (1.5, 1.44, 1.47, 1.45, 1.46, 1.49, 1.42, 1.48) Cgnd = (39.0...
870
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Heapsort Graphical Representation Step1: The function toDot takes four arguments Step2: HeapSort The function call swap(A, i, j) takes an array A and...
<ASSISTANT_TASK:> Python Code: import graphviz as gv Explanation: Heapsort Graphical Representation End of explanation def toDot(A, f, g, u=None): n = len(A) dot = gv.Digraph(node_attr={'shape': 'record'}) for k, p in enumerate(A): if k == u: dot.node(str(k), label='{' + str(p) + '|' +...
871
<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 - Advanced topics - 1 axis torque tube Shading for 1 day (Research Documentation) Recreating JPV 2019 / PVSC 2018 Fig. 13 Calculating and plotting sh...
<ASSISTANT_TASK:> Python Code: import os from pathlib import Path testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'Tutorial_09') if not os.path.exists(testfolder): os.makedirs(testfolder) print ("Your simulation will be stored in %s" % testfolder) # VARIABLES of the simulation: lat...
872
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: HoloCube is a Python library that makes it easy to explore and visualize geographical, meterological, oceanographic, and other multidimensional gridded...
<ASSISTANT_TASK:> Python Code: import holoviews as hv import holocube as hc from cartopy import crs from cartopy import feature as cf hv.notebook_extension() %%opts GeoFeature [projection=crs.Geostationary()] coasts = hc.GeoFeature(cf.COASTLINE) borders = hc.GeoFeature(cf.BORDERS) ocean = hc.GeoFeature(cf.OCEAN) oce...
873
<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 the Lomb-Scargle Periodogram Version 0.2 By AA Miller (Northwester/CIERA) 15 Sep 2021 Today we examine the detection of periodic signal...
<ASSISTANT_TASK:> Python Code: def gen_periodic_data(x, period=1, amplitude=1, phase=0, noise=0): '''Generate periodic data given the function inputs y = A*sin(2*pi*x/p - phase) + noise Parameters ---------- x : array-like input values to evaluate the array period : float ...
874
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Short-Sentence Similarity using Gensim Word Mover Distance 1. Gensim Word-Movers model Reference Step1: Load the Google's pre-trained model Step2: Al...
<ASSISTANT_TASK:> Python Code: # Importing the dependecies import gensim Explanation: Short-Sentence Similarity using Gensim Word Mover Distance 1. Gensim Word-Movers model Reference: Note: Refer to other similarity functions https://radimrehurek.com/gensim/models/word2vec.html End of explanation #load word2vec model, ...
875
<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 the true normal human body temperature? Background The mean normal body temperature was held to be 37$^{\circ}$C or 98.6$^{\circ}$F for more th...
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.read_csv('data/human_body_temperature.csv') df.info() df.head() Explanation: What is the true normal human body temperature? Background The mean normal body temperature was held to be 37$^{\circ}$C or 98.6$^{\circ}$F for more than 120 years since it was first c...
876
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: def sghmc(Y, X, stogradU, M, eps, m, theta, C, V) Step1: Correct coefficients Step2: Our code - SGHMC Step3: Our code - Gradient descent Step5: Cli...
<ASSISTANT_TASK:> Python Code: # Load data X = np.concatenate((np.ones((pima.shape[0],1)),pima[:,0:8]), axis=1) Y = pima[:,8] Xs = (X - np.mean(X, axis=0))/np.concatenate((np.ones(1),np.std(X[:,1:], axis=0))) n, p = X.shape M = np.identity(p) ### HMC version def logistic(x): return 1/(1+np.exp(-x)) def U(theta, Y, ...
877
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Telecom subscriber churn prediction on Vertex AI <table align="left"> <td> <a href="https Step1: Restart the kernel Once you've installed the ad...
<ASSISTANT_TASK:> Python Code: import os # The Google Cloud Notebook product has specific requirements IS_GOOGLE_CLOUD_NOTEBOOK = os.path.exists("/opt/deeplearning/metadata/env_version") USER_FLAG = "" # Google Cloud Notebook requires dependencies to be installed with '--user' if IS_GOOGLE_CLOUD_NOTEBOOK: USER_FLAG...
878
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: FASTA This notebook briefly explores the FASTA format, a very common format for storing DNA sequences. FASTA is the preferred format for storing refer...
<ASSISTANT_TASK:> Python Code: import gzip import urllib.request url = 'ftp://ftp.ncbi.nlm.nih.gov/genomes/archive/old_genbank/Eukaryotes/vertebrates_mammals/Homo_sapiens/GRCh38/non-nuclear/assembled_chromosomes/FASTA/chrMT.fa.gz' response = urllib.request.urlopen(url) print(gzip.decompress(response.read()).decode('UTF...
879
<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 programming with the SciPy stack Pandas Import libraries and check versions. Step1: Read the data and get a row count. Data source Step2: ...
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import sys print('Python version ' + sys.version) print('Pandas version ' + pd.__version__) print('Numpy version ' + np.__version__) Explanation: Scientific programming with the SciPy stack Pandas Import libraries and check versions. End of explanati...
880
<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 charts below have dollar signs in their titles, which get formatted into mathematical notation by Mathjax, which messes up the intended title Step...
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('../') import mustaching as ms %load_ext autoreload %autoreload 2 Explanation: The charts below have dollar signs in their titles, which get formatted into mathematical notation by Mathjax, which messes up the intended title :( The only way i know to avoid this ...
881
<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 data The gas data $\mathbf{H_2}$ McKee et al. (2015) take their spatial distribution from Dame et al. (1987). Dame et al. estimate the FWHM of the ...
<ASSISTANT_TASK:> Python Code: cloud_name= 'apjaa4dfdt1_mrt.txt' if not os.path.exists(cloud_name): !wget http://iopscience.iop.org/0004-637X/834/1/57/suppdata/apjaa4dfdt1_mrt.txt cloud_data= ascii.read(cloud_name,format='cds') # Compute distsance and height z based on whether near of far kinematic distance is more...
882
<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: Getting a dataset The first step is going to be to load our data. As our example, we will be using the dataset CalTech-101, whic...
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import os #if using Theano with GPU #os.environ["KERAS_BACKEND"] = "tensorflow" import random import numpy as np import keras import matplotlib.pyplot as plt from matplotlib.pyplot import imshow from keras.preprocessing import image from keras.applica...
883
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This is the ipython notebook you should use as a template for your agent. Your task for this assignment is to implement a winning AI for the gam...
<ASSISTANT_TASK:> Python Code: from random import randint class RandomPlayer(): Player that chooses a move randomly. def move(self, game, legal_moves, time_left): if not legal_moves: return (-1,-1) return legal_moves[randint(0,len(legal_moves)-1)] Explanation: This is the ipython notebook you sh...
884
<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: Introduction to Regular Expressions Regular Expressions are a powerful feature of the Python programming language. You can acces...
<ASSISTANT_TASK:> Python Code: # 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 writing, sof...
885
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Translation of Numeric Phrases with Seq2Seq In the following we will try to build a translation model from french phrases describing numbers to the cor...
<ASSISTANT_TASK:> Python Code: from french_numbers import to_french_phrase for x in [21, 80, 81, 300, 213, 1100, 1201, 301000, 80080]: print(str(x).rjust(6), to_french_phrase(x)) Explanation: Translation of Numeric Phrases with Seq2Seq In the following we will try to build a translation model from french phrases de...
886
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: pyISC Example Step1: Data Creation Create two arrays with normal and anomalous frequency data respectively.</b> Step2: Create an 2D array with two co...
<ASSISTANT_TASK:> Python Code: import pyisc; import numpy as np from scipy.stats import poisson %matplotlib inline from pylab import hist, plot, figure Explanation: pyISC Example: Simple Anomaly Detection with Frequency Data This is a simple example on how to use the pyISC anomaly detector for computing the anomaly sco...
887
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Learning to Resize in Computer Vision Author Step1: Define hyperparameters In order to facilitate mini-batch learning, we need to have a fixed shape f...
<ASSISTANT_TASK:> Python Code: from tensorflow.keras import layers from tensorflow import keras import tensorflow as tf import tensorflow_datasets as tfds tfds.disable_progress_bar() import matplotlib.pyplot as plt import numpy as np Explanation: Learning to Resize in Computer Vision Author: Sayak Paul<br> Date created...
888
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step5: Basic Idea of Count Min sketch We map the input value to multiple points in a relatively small output space. Therefore, the count associated wit...
<ASSISTANT_TASK:> Python Code: import sys import random import numpy as np import heapq import json import time BIG_PRIME = 9223372036854775783 def random_parameter(): return random.randrange(0, BIG_PRIME - 1) class Sketch: def __init__(self, delta, epsilon, k): Setup a new count-min sketch wit...
889
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Routing electrical For routing low speed DC electrical ports you can use sharp corners instead of smooth bends. You can also define port.orientation = ...
<ASSISTANT_TASK:> Python Code: import gdsfactory as gf c = gf.Component("pads") pt = c << gf.components.pad_array(orientation=270, columns=3) pb = c << gf.components.pad_array(orientation=90, columns=3) pt.move((70, 200)) c c = gf.Component("pads_with_routes_with_bends") pt = c << gf.components.pad_array(orientation=27...
890
<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: Fitting a model using sklearn Models in the sklearn library support the fit method for parameter estimation. Under the hood, thi...
<ASSISTANT_TASK:> Python Code: import sklearn import scipy import scipy.optimize import matplotlib.pyplot as plt import warnings warnings.filterwarnings("ignore") import itertools import time from functools import partial import os import numpy as np # np.set_printoptions(precision=3) np.set_printoptions(formatter={"fl...
891
<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: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details. Step2: And we'll attac...
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.1,<2.2" Explanation: Advanced: Alternate Backends Setup Let's first make sure we have the latest version of PHOEBE 2.1 installed. (You can comment out this line if you don't use pip for your installation or don't want to update to the latest release). End of exp...
892
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Processing Steps Determine noise parameters of noise model This will be based on <a href="http Step1: First we will take a look at the fluorescence "b...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from load_environment import * # python file with imports and basics to set up this computing environment Explanation: Processing Steps Determine noise parameters of noise model This will be based on <a href="http://www.cs.tut.fi/~foi/papers/Foi-PoissonianGaussianClippe...
893
<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><center>[Notebooks](../) - [Numerical Cartography](../numerical cartography)</center></h1> The Geodesic Problem Distances and angles The distances ...
<ASSISTANT_TASK:> Python Code: from pyproj import Geod g = Geod(ellps='WGS84') Explanation: <h1><center>[Notebooks](../) - [Numerical Cartography](../numerical cartography)</center></h1> The Geodesic Problem Distances and angles The distances between two points can be axpressesd as the shortest path between the points ...
894
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Adding Multiple Wells This notebook shows how a WellModel can be used to fit multiple wells with one response function. The influence of the individual...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import pastas as ps import matplotlib.pyplot as plt ps.show_versions() Explanation: Adding Multiple Wells This notebook shows how a WellModel can be used to fit multiple wells with one response function. The influence of the individual wells is scale...
895
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Gaussian Process (GP) smoothing This example deals with the case when we want to smooth the observed data points $(x_i, y_i)$ of some 1-dimensional fun...
<ASSISTANT_TASK:> Python Code: %pylab inline figsize(12, 6); import numpy as np import scipy.stats as stats x = np.linspace(0, 50, 100) y = (np.exp(1.0 + np.power(x, 0.5) - np.exp(x/15.0)) + np.random.normal(scale=1.0, size=x.shape)) plot(x, y); xlabel("x"); ylabel("y"); title("Observed Data"); Explanation: Gauss...
896
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Using the Illumina InterOp Library in Python Step1: Getting SAV Imaging Tab-like Metrics The run_metrics class encapsulates the model for all the indi...
<ASSISTANT_TASK:> Python Code: run_folder = r"" Explanation: Using the Illumina InterOp Library in Python: Part 5 Install If you do not have the Python InterOp library installed, then you can do the following: $ pip install interop You can verify that InterOp is properly installed: $ python -m interop --test Before you...
897
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Quiz - Week 5B Q1. We wish to cluster the following set of points Step1: Q2. When performing a k-means clustering, success depends very much on the in...
<ASSISTANT_TASK:> Python Code: # Solution import numpy as np import math def dist(pt1, pt2): return math.sqrt( (pt1[0] - pt2[0])**2 + (pt1[1] - pt2[1])**2 ) pts1 = [ (25,125), (44,105), (29,97), (35, 63), (55, 63), (42, 57), (23, 40), (64,37), (33,22), (55,20) ] pts2 = [ (28,145), (38,115), (50,130),(65,140), (55,...
898
<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 was created by Svitozar Serkez. Source and license info is on GitHub. August 2016. * Tutorial N5 Step1: Setting input parameters electr...
<ASSISTANT_TASK:> Python Code: # the output of plotting commands is displayed inline within frontends, # directly below the code cell that produced it %matplotlib inline from __future__ import print_function # this python library provides generic shallow (copy) and deep copy (deepcopy) operations from copy import dee...
899
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 10 For-Loop-Rückblick-Übungen In den Teilen der folgenden Übungen habe ich den Code mit "XXX" ausgewechselt. Es gilt in allen Übungen, den korrekten Co...
<ASSISTANT_TASK:> Python Code: primzweibissieben = [2, 3, 5, 7] for prime in primzweibissieben: print(prime) Explanation: 10 For-Loop-Rückblick-Übungen In den Teilen der folgenden Übungen habe ich den Code mit "XXX" ausgewechselt. Es gilt in allen Übungen, den korrekten Code auszuführen und die Zelle dann auszuführ...