Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
6,000
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Artistic Style Transfer with TensorFlow Lite Step2: Download the content and style images, and the pre-trained TensorFlow Lite models. Step3: ...
6,001
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import os from os.path import join import sys import json idx = pd.IndexSlice cwd = os.getcwd() data_path = join(cwd, '..', 'Data storage') file_date = '2018-03-06' %load_ext watermark %watermark -iv -v # Load the "autoreload" extension %load_ext au...
<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: Date string for filenames Step2: Load data Step3: Adjusted facility emissions and generation Step4: Extra gen/fuels from non-reporting Step5:...
6,002
<ASSISTANT_TASK:> Python Code: n_neurons = 100 ac = AdaptiveControl(n_inputs=1, n_outputs=1, n_neurons=n_neurons, seed=1) inputs = np.linspace(-1, 1, 100) rates = np.zeros((len(inputs), n_neurons)) for i, input in enumerate(inputs): current = ac.compute_neuron_input([input]) activity = ac.neuron(current) ra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now let's try teaching the model to just output the identity function (i.e. the output should be the same as the input). We train it over a sin...
6,003
<ASSISTANT_TASK:> Python Code: from pysap.SAPEnqueue import * from IPython.display import display for dest in enqueue_dest_values: p = SAPEnqueue(dest=dest) print(enqueue_dest_values[dest]) display(p.canvas_dump()) for opcode in enqueue_server_admin_opcode_values: p = SAPEnqueue(dest=3, opcode=opcode)...
<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: SAP Enqueue packet Step2: SAP Enqueue Server Admin opcodes Step3: SAP Enqueue Connection Admin opcodes Step4: SAP Enqueue Connection Admin pa...
6,004
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mri', 'sandbox-3', 'ocnbgchem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,005
<ASSISTANT_TASK:> Python Code: x, y, y_unc = pollute_namespace() # complete # complete p = np.polyfit( # complete # complete # complete # complete p_yx = np.polyfit(y, x, 1) p_yx_eval = np.poly1d(p_yx) fig = plt.figure(figsize=(6,5)) ax = plt.subplot2grid((3,1), (0, 0), rowspan=2) ax_res = plt.subplot2grid((3,1), (...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You now have some data $x$ and $y$. Step2: Solution 2a Step3: There is a very good chance, though I am not specifically assuming anything, tha...
6,006
<ASSISTANT_TASK:> Python Code: meat_subset = meat[['date', 'beef', 'pork']] df = pd.melt(meat_subset, id_vars=['date']) df.head() ggplot(df, aes(x='date', y='value', color='variable')) + geom_line() <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now we'll setup our aesthetics so date is the x-axis value, variable is the color of each line and value is the y-axis value.
6,007
<ASSISTANT_TASK:> Python Code: from parse_data_to_tfrecord_lib import img_to_example, read_tfrecord, generate_tfexamples_from_detections, batch_read_write_tfrecords from PIL import Image # used to read images from directory import tensorflow as tf import os import io import IPython.display as display import numpy as n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Test function img_to_example() Step2: Function Test Step3: Test batch_read_write_tfrecords() Step4: Read back the generated tfrecords and che...
6,008
<ASSISTANT_TASK:> Python Code: import random deaths = 6 running = True while running: # Create a variable that randomly create a integer between 0 and 10. guess = random.randint(0,10) # if guess equals deaths, if guess == deaths: # then print this print('Correct!') # and then ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create a variable of the true number of deaths of an event Step2: Create a variable that is denotes if the while loop should keep running Step3...
6,009
<ASSISTANT_TASK:> Python Code: import platform import psutil import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.rcParams['figure.facecolor']='white' plt.rcParams['font.size']=16 import bioframe import pyranges print(f"Bioframe v.{bioframe.__version__}") print(f"PyRanges v.{pyranges.__version__}"...
<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: Below we define a function to generate random intervals with various properties, returning a dataframe of intervals. Step2: Overlap Step3: vs ...
6,010
<ASSISTANT_TASK:> Python Code: # Authors: Denis Engemann <denis.engemann@gmail.com> # Luke Bloy <luke.bloy@gmail.com> # Eric Larson <larson.eric.d@gmail.com> # # License: BSD (3-clause) import os.path as op from mne.filter import next_fast_len import mne print(__doc__) data_path = mne.datasets.opm.dat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load data, resample. We will store the raw objects in dicts with entries Step2: Do some minimal artifact rejection just for VectorView data Ste...
6,011
<ASSISTANT_TASK:> Python Code: import sqlite3 con = sqlite3.connect("onsgeocodes.sqlite") import pandas as pd #Create a function to grab a zip file from an online location and then grab a specified file from inside it import requests, zipfile #The following fudge copes with Python 2 and Python 3 try: from StringIO ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The .csv file contains metadata describing the geographies listed in separate sheets in the .xlsx file. Step2: Extracting Geography Codes Step3...
6,012
<ASSISTANT_TASK:> Python Code: import logging # python logging module # basic format for logging logFormat = "%(asctime)s - [%(levelname)s] (%(funcName)s:%(lineno)d) %(message)s" # logs will be stored in tweepy.log logging.basicConfig(filename='tweepytopuser.log', level=logging.INFO, format=logForma...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Authentication and Authorisation Step3: Post this step, we will have full access to twitter api's Step9: Streaming with tweepy Step10: Drawba...
6,013
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'miroc', 'sandbox-2', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,014
<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 from sklearn.decomposition import PCA mu = np.zeros(2) C = np.array([[3,1],[1,2]]) data = np.random.multiv...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Теория Step2: Путём диагонализации истинной матрицы ковариаций $C$, мы можем найти преобразование исходного набора данных, компоненты которого ...
6,015
<ASSISTANT_TASK:> Python Code: %load_ext sql %sql mysql://steinam:steinam@localhost/nordwind %%sql select l.`Kontaktperson` , a.`Artikelname` from artikel a, lieferanten l where a.`Kategorie-Nr` in ('1','2','3') %%sql select k.`Firma`,b.`BestellNr` ,p.`Nachname` from Kunden k, bestellungen b, personal p where p.`...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Schreiben Sie eine Abfrage, die Ihnen die Kontaktnamen der Lieferanten ausgibt, die Step2: Schreiben Sie eine Abfrage, die Ihnen die Kundennam...
6,016
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from sklearn import svm, datasets from sklearn.metrics import roc_curve, auc from sklearn.model_selection import train_test_split bc = datasets.load_breast_cancer() X = bc.data y = bc.target random_state = np.random.RandomState(0) # shuf...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import some data to play with Step2: Split the data and prepare data for ROC Curve Step3: Plot ROC Curve using Matplotlib Step4: Create ROCAU...
6,017
<ASSISTANT_TASK:> Python Code: # helper code needed for running in colab if 'google.colab' in str(get_ipython()): print('Downloading plot_helpers.py to util/ (only neded for colab') !mkdir util; wget https://raw.githubusercontent.com/minireference/noBSLAnotebooks/master/util/plot_helpers.py -P util # setup SymP...
<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: P4.2 Step2: So $z=s$ is a free variable, and the rest of the equation Step3: The free variable is $z=t$.
6,018
<ASSISTANT_TASK:> Python Code: # Put these at the top of every notebook, to get automatic reloading and inline plotting %reload_ext autoreload %autoreload 2 %matplotlib inline # This file contains all the main external libs we'll use from fastai.imports import * from fastai.transforms import * from fastai.conv_learner...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here we import the libraries we need. We'll learn about what each does during the course. Step2: making folder structure and downloading some i...
6,019
<ASSISTANT_TASK:> Python Code: %pylab inline x=[1,2,5] y=np.array([[0.41,0.44,0.47],[0.25,0.22,0.21]]).T plt.errorbar(x,y[:,0],yerr=0.7/9.3,fmt='d-b') plt.errorbar(x,y[:,1],yerr=0.7/9.3,fmt='o-g') plt.legend(['focal','non-focal'],loc=7) plt.grid(False,axis='x') plt.xlabel('Time pressure');plt.ylabel('choice probability...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The figure shows the choice probabilities for two of the options - focal and nonfocal. (Since the choice probabilities sum to one, the probabili...
6,020
<ASSISTANT_TASK:> Python Code: p = GMM([1.0], np.array([[0.5,0.05]])) num_samples = 1000 beg = 0.0 end = 1.0 t = np.linspace(beg,end,num_samples) num_neurons = len(p.pis) colors = [np.random.rand(num_neurons,) for i in range(num_neurons)] p_y = p(t) p_max = p_y.max() np.random.seed(110) num_neurons = 1 neuron = Neuron(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: I can assume $q(x)$ has two forms
6,021
<ASSISTANT_TASK:> Python Code: import mxnet as mx from mxnet import gluon, autograd, ndarray import numpy as np train_data = mx.gluon.data.DataLoader(mx.gluon.data.vision.MNIST(train=True, transform=lambda data, label: (data.astype(np.float32)/255, label)), batch_size=32, shuffle=...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Next, we use gluon.data.DataLoader, Gluon's data iterator, to hold the training and test data. Step2: Now, we are ready to define the actual ne...
6,022
<ASSISTANT_TASK:> Python Code: # import the dataset from quantopian.interactive.data.eventvestor import clinical_trials # or if you want to import the free dataset, use: # from quantopian.data.eventvestor import clinical_trials_free # import data operations from odo import odo # import other libraries we will use impor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's go over the columns Step2: Finally, suppose we want a DataFrame of GlaxoSmithKline Phase-III announcements, sorted in descending order by...
6,023
<ASSISTANT_TASK:> Python Code: import sqlalchemy sqlalchemy.__version__ from sqlalchemy import create_engine engine = create_engine('sqlite:///:memory:') from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey metadata = MetaData() user = Table('user', metadata, Column('id_user', Integer, prim...
<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: Fetch an SQLite engine and create an in memory database Step2: Now lets make a couple of tables and do some queries Step3: ... and let's add a...
6,024
<ASSISTANT_TASK:> Python Code: const.TRAIN_FILES const.TEST_FILES num_data = func.load_data_file(const.TRAIN_FILES[0], ftype='bin') cat_data = func.load_data_file(const.TRAIN_FILES[1], ftype='bin') num_data_te = func.load_data_file(const.TEST_FILES[0], ftype='bin') cat_data_te = func.load_data_file(const.TEST_FILES[1]...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load data Step2: Load and adjust lookup table Step3: Create paths per station Step4: Create hashes based on non-zero values of num and cat da...
6,025
<ASSISTANT_TASK:> Python Code: #!pip install --user miepython import importlib.resources import numpy as np import matplotlib.pyplot as plt try: import miepython except ModuleNotFoundError: print('miepython not installed. To install, uncomment and run the cell above.') print('Once installation is successful...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: When a monochromatic plane wave is incident on a sphere, it scatters and absorbs light depending on the properties of the light and sphere. The...
6,026
<ASSISTANT_TASK:> Python Code: import os import math import glob import cv2 from collections import deque import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg from moviepy.editor import VideoFileClip %matplotlib inline class cam_util(): util class for camera operations ...
<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: Create a utility class for camera calibration Step13: Create a class to keep track of lane detections Step16: Use the lane pixals identified t...
6,027
<ASSISTANT_TASK:> Python Code: # Environment setup %matplotlib inline %cd /lang_dec # Imports import warnings; warnings.filterwarnings('ignore') import hddm import numpy as np import matplotlib.pyplot as plt from utils import model_tools, signal_detection # Import control models controls_data = hddm.load_csv('/lang_dec...
<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: Reaction Time Distributions Step2: Model Fitness
6,028
<ASSISTANT_TASK:> Python Code: !cat publications.tsv import pandas as pd publications = pd.read_csv("publications.tsv", sep="\t", header=0) publications html_escape_table = { "&": "&amp;", '"': "&quot;", "'": "&apos;" } def html_escape(text): Produce entities within text. return "".join(html_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import pandas Step2: Import TSV Step4: Escape special characters Step7: Creating the markdown files Step8: These files are in the publicatio...
6,029
<ASSISTANT_TASK:> Python Code: # import required modules from mtpy.core.mt import MT # Define the path to your edi file edi_file = "C:/mtpywin/mtpy/examples/data/edi_files_2/Synth00.edi" # Create an MT object mt_obj = MT(edi_file) # To see the latitude and longitude print(mt_obj.lat, mt_obj.lon) # To see the easting, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The mt_obj contains all the data from the edi file, e.g. impedance, tipper, frequency as well as station information (lat/long). To look at any ...
6,030
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-1', 'ocean') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,031
<ASSISTANT_TASK:> Python Code: import os.path as op import mne from mne.datasets import sample data_path = sample.data_path() raw_empty_room_fname = op.join( data_path, 'MEG', 'sample', 'ernoise_raw.fif') raw_empty_room = mne.io.read_raw_fif(raw_empty_room_fname) raw_fname = op.join(data_path, 'MEG', 'sample', 'sa...
<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: Source estimation method such as MNE require a noise estimations from the Step2: The definition of noise depends on the paradigm. In MEG it is ...
6,032
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib.pyplot as plt %matplotlib inline df = pd.read_csv("thwfall2017-survey.csv") df = df[1:] df.columns[0:3] count = 0 for column in df.columns: if count < 43: df = df.rename(columns = {column:column[308:]}) print(len(column), column[...
<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: Importing data and previewing Step2: Oh no, these are some messy column names! Gotta clean them up, truncating the first 308 characters. Step3:...
6,033
<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...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Classification with TensorFlow Step2: And then download the dataset. Step3: And load the data into a DataFrame and take a peek. Step4: We can...
6,034
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr> # Eric Larson <larson.eric.d@gmail.com> # # License: BSD (3-clause) import matplotlib.pyplot as plt import matplotlib.patheffects as path_effects import mne from mne.datasets import sample from mne.minimum_norm import re...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Compute inverse solution Step2: View source activations Step3: Using vector solutions
6,035
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import matplotlib as mpl mpl.use('Agg') import pprint import numpy as np import matplotlib.pyplot as plt %matplotlib inline #import cvxpy as cp tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) from sklearn import preprocessing impor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data preprocessing Step2: Next, we'll create partitions of the test data depending on whether the spurious feature equals the label or not. Ste...
6,036
<ASSISTANT_TASK:> Python Code: import json import numpy as np from numpy import ma import io import re import itertools import random from bokeh.charts import Histogram import networkx as nx from nltk.stem import WordNetLemmatizer wnl = WordNetLemmatizer() from sklearn.feature_extraction import DictVectorizer from coll...
<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: Recipe Recommender Capstone Project Step4: Removing the Unrelated Words from Ingredients Step5: Ingredient Analysis Step6: Number of unique i...
6,037
<ASSISTANT_TASK:> Python Code: class newNode : def __init__(self , x ) : self . data = x self . left = self . right = None   def count(root ) : if(root == None ) : return 0  return(count(root . left ) + count(root . right ) + 1 )  def checkRec(root , n ) : if(root == None ) : return False ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
6,038
<ASSISTANT_TASK:> Python Code: # code for loading the format for the notebook import os # path : store the current path to convert back to it later path = os.getcwd() os.chdir(os.path.join('..', 'notebook_format')) from formats import load_style load_style(css_style = 'custom2.css') os.chdir(path) # 1. magic for inline...
<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: Decision Tree (Classification) Step2: Gini Index Step12: As we can see from the plot, there is not much differences (as in they both increase ...
6,039
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division import numpy as np import random import os import glob import cv2 import datetime import pandas as pd import time import h5py import csv from scipy.misc import imresize, imsave from sklearn.cross_validation import KFold, train_test_split fro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Configuration and Hyperparameters Step3: Then we'll set all the relevant paths and configurations Step4: Helper Functions For Loading Data Ste...
6,040
<ASSISTANT_TASK:> Python Code: import nltk abstract = It's morning, you settle in, check your dashboards and it looks like there is an increase of load coming through on some of your web server logs. What happened? You're about to deploy code that will hopefully fix some issues; how will you know that things worked we...
<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: Examples of text analysis Step2: First tokenize the text and then we tag the parts of speech Step3: Let's get a frequency distribution of the ...
6,041
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import make_blobs X, y = make_blobs(centers=2, random_state=0) print('X ~ n_samples x n_features:', X.shape) print('y ~ n_samples:', y.shape) print('\nFirst 5 samples:\n', X[:5, :]) print('\nFirst 5 labels:', y[:5]) plt.scatter(X[y == 0, 0], X[y == 0, 1], ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: As the data is two-dimensional, we can plot each sample as a point in a two-dimensional coordinate system, with the first feature being the x-ax...
6,042
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import matplotlib.pyplot as plt import numpy as np from __future__ import print_function from ipywidgets import interact, interactive, fixed import ipywidgets as widgets def plotSequence(y): n = np.linspace(0, y.size, y.size) plt.scatter(n, y) plt.plot([n,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Discrete time Step2: Linear Difference Equations Step3: Money exercises Step4: 10% per year, month compound Step5: 10% per year, day compoun...
6,043
<ASSISTANT_TASK:> Python Code: import tensorflow as tf print(tf.__version__) a = tf.constant(value = [5, 3, 8], dtype = tf.int32) b = tf.constant(value = [3, -1, 2], dtype = tf.int32) c = tf.add(x = a, y = b) print(c) with tf.Session() as sess: result = sess.run(fetches = c) print(result) a = tf.placeholder(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Graph Execution Step2: Run the Graph Step3: Can you mix eager and graph execution together? Step 1 Step4: Linear Regression Step5: Loss Func...
6,044
<ASSISTANT_TASK:> Python Code: from numpy.random import randint import matplotlib.pyplot as plt %matplotlib inline S = randint(low=0, high=11, size=15) # 10 random integers b/w 0 and 10 def f(x): Dummy function - returns identity return x print("1. S == {}".format(S)) y1 = [f(x) for x in S] print("2....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reading, and writing, comprehension(s) Step2: List comprehensions Step3: As you can see, the translation from the math to code is natural. Ste...
6,045
<ASSISTANT_TASK:> Python Code: %run import.ipynb import matplotlib.pyplot as plt isotherm = next(i for i in isotherms_n2_77k if i.material=='MCM-41') ax = isotherm.plot() import pygaps.graphing as pgg ax = pgg.plot_iso( isotherms_isosteric, branch = 'ads', logx = True, x_range=(None,1), lgd_keys=[...
<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: Isotherm display Step2: Isotherm plotting and comparison Step3: A black and white (color=False) full scale graph of both adsorption and desorp...
6,046
<ASSISTANT_TASK:> Python Code: lst = [11,2,34, 4,5,5111] len(lst) len([11,2,'sort',4,5,5111]) sorted(lst) lst lst.sort() lst min(lst) max(lst) str(1212) sum([1,2,2]) lst lst.remove(4) lst.append(4) string = 'hello, wie geht, es Dir?' string.split(',') import urllib import requests import glob import pandas from bs4 i...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2 Viel mächtigere Funktion Step2: 3 Aber wie sind Funktion, Modules und Libraries aufgebaut? Step3: 4 Bauen wir die eigenen Funktion Step4: U...
6,047
<ASSISTANT_TASK:> Python Code: try: import gi gi.require_version('NumCosmo', '1.0') gi.require_version('NumCosmoMath', '1.0') except: pass from gi.repository import GObject from gi.repository import NumCosmo as Nc from gi.repository import NumCosmoMath as Ncm import sys import math import numpy as np import mat...
<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: Initializing the NumCosmo library Step2: Initializing the objects Step3: Computing the normalized Hubble function Step4: Initializing the dis...
6,048
<ASSISTANT_TASK:> Python Code: import os os.chdir(os.getcwd() + '/..') # Run some setup code for this notebook import random import numpy as np import matplotlib.pyplot as plt from utils.data_utils import load_CIFAR10 %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots plt.rcPara...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We would now like to classify the test data with the kNN classifier. Recall that we can break down this process into two steps Step2: Inline Qu...
6,049
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline USAhousing = pd.read_csv('USA_Housing.csv') USAhousing.head() USAhousing.info() USAhousing.describe() USAhousing.columns sns.pairplot(USAhousing) sns.distplot(USAhousing['Pric...
<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: Check out the Data Step2: EDA Step3: Training a Linear Regression Model Step4: Train Test Split Step5: Creating and Training the Model Step6...
6,050
<ASSISTANT_TASK:> Python Code: from pynq.drivers.video import Frame, HDMI from IPython.display import Image hdmi=HDMI('in') hdmi.start() frame = hdmi.frame() orig_img_path = '/home/xilinx/jupyter_notebooks/examples/data/orig.jpg' frame.save_as_jpeg(orig_img_path) Image(filename=orig_img_path) from pynq.drivers.video ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2. Save frame and display JPG here Step2: 3. Gray Scale filter Step3: 4. Sobel filter Step4: Step 5
6,051
<ASSISTANT_TASK:> Python Code: %matplotlib inline from stemgraphic.num import stem_graphic import pandas as pd import numpy as np import math df = pd.read_csv('../datasets/iris.csv') df.describe() fig, ax = stem_graphic(df['sepal_length'], random_state=42, title='sepal_len...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading the iris dataset Step2: Let's combined both variables in one back-to-back stem-and-leaf plot Step3: And of course, we can save a pdf. ...
6,052
<ASSISTANT_TASK:> Python Code: import ndmg import ndmg.utils as mgu # run small demo for experiments print(mgu.execute_cmd('ndmg_demo-dwi', verb=True)[0]) import numpy as np fibs = np.load('/tmp/small_demo/outputs/fibers/KKI2009_113_1_DTI_s4_fibers.npz')['arr_0'] small_fibs = fibs[1:3] from ndmg.graph import biggraph ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The approach we will take is to take 2 fibers from our graph and verify that we end up with the appropriate voxels in our streamlines being conn...
6,053
<ASSISTANT_TASK:> Python Code: # Single word 'hello' # Entire phrase 'This is also a string' # We can also use double quote "String built with double quotes" # Be careful with quotes! ' I'm using single quotes, but will create an error' "Now I'm ready to use the single quotes inside a string!" # We can simply declar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The reason for the error above is because the single quote in I'm stopped the string. You can use combinations of double and single quotes to ge...
6,054
<ASSISTANT_TASK:> Python Code: #Define inputs filename = '../data/SERC/hyperspectral/NEON_D02_SERC_DP1_20160807_160559_reflectance.h5' sercRefl, sercRefl_md, wavelengths = h5refl2array(filename) clipExtDict = {} clipExtDict['xMin'] = 367400. clipExtDict['xMax'] = 368100. clipExtDict['yMin'] = 4305750. clipExtDict['yMax...
<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: Stack NIR and VIS bands Step2: Calculate NDVI & Plot Step3: Extract Spectra Using Masks Step4: Function to calculate the mean spectra for ref...
6,055
<ASSISTANT_TASK:> Python Code: def dice_samples(trials): prob = {1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/32} samples = np.zeros(trials + 1, dtype=int) samples[0] = 1 for i in range(trials): a = samples[i] b = np.random.random_integers(1, 6) # uniform a priori distribution ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We change the number of MC steps to give a view to the time evolution of the M-H chain Step2: So the constructed chains do converto our desired...
6,056
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import seaborn as sns import numpy as np sns.set_style("whitegrid") from matplotlib.colors import LogNorm %matplotlib inline #Three component competitive binding function #This function and its assumptions are defined in greater detail in this notebook: ##...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In this notebook we will explore experimental design of competition assays. Step2: We can use this function to help us decide the appropriate c...
6,057
<ASSISTANT_TASK:> Python Code: Image.fromarray(output) Image.fromarray(grayscale_image) native_output = image_org.filter(ImageFilter.MedianFilter(size = 3)) native_output deviation_native = np.sqrt(np.sum(np.square(grayscale_image-np.array(rgb2gray(np.array(native_output)))))) deviation_original = np.sum(np.square(gr...
<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: Original Image (converted to grayscale) Step2: Output with Python's native Median Filter function Step3: As shown from the above print, AMF re...
6,058
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division %matplotlib inline import numpy as np import brfss import thinkstats2 import thinkplot df = brfss.ReadBrfss(nrows=None) female = df[df.sex==2] female_heights = female.htm3.dropna() mean, std = female_heights.mean(), female_heights.std() me...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: I'll start with the data from the BRFSS again. Step2: Here are the mean and standard deviation of female height in cm. Step3: NormalPdf return...
6,059
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt data=np.load("decay_osc.npz") T=data["tdata"] Y=data["ydata"] dy=data["dy"] f=plt.figure(figsize=(15,10)) plt.errorbar(T,Y,yerr=dy,fmt='o'); assert True # leave this to grade the data impor...
<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: Fitting a decaying oscillation Step2: Now, using curve_fit to fit this model and determine the estimates and uncertainties for the parameters
6,060
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import time as tm import matplotlib.pyplot as plt # Discretization c1=20 # Number of grid points per dominant wavelength c2=0.5 # CFL-Number nx=2000 # Number of grid points T=10 # Total propagation time # Source Signal f0= 10 # Center fre...
<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: Input Parameter Step2: Preparation Step3: Create space and time vector Step4: Source signal - Ricker-wavelet Step5: Time stepping Step6: Sa...
6,061
<ASSISTANT_TASK:> Python Code: import datetime import os import numpy as np import pandas as pd import tensorflow as tf import time from tensorflow import keras from sklearn.model_selection import GridSearchCV from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score, f1_score # Fi...
<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: Grid search in Scikit-learn Step2: To keep things simple, we'll first convert the label column to numeric and then Step3: Next, we'll build o...
6,062
<ASSISTANT_TASK:> Python Code: %cat epochs_spec.cfg %cat epochs.cfg ep = burin.config.EpochParser('epochs.cfg', 'epochs_spec.cfg') ep.is_valid() ep.get('cal_version', date='20180101') ep.get('cal_version', date='20180101.120000') <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Specify an epoch parser with an epoch filename and the specification filename.
6,063
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import seaborn as sns from scipy.integrate import odeint from IPython.html.widgets import interact, fixed g = 9.81 # m/s^2 l = 0.5 # length of pendulum, in meters tmax = 50. # seconds t = np.linspace(0, tmax, int(...
<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: Damped, driven nonlinear pendulum Step4: Write a function derivs for usage with scipy.integrate.odeint that computes the derivatives for the da...
6,064
<ASSISTANT_TASK:> Python Code: %matplotlib inline # -*- coding:utf-8 -*- from __future__ import print_function import numpy as np import pandas as pd import statsmodels.api as sm from statsmodels.stats.stattools import durbin_watson import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # デー...
<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: 例題5-1 Step2: Durbin-Watson Step3: DW=1.094となり、上限分布において有意水準5%でも帰無仮説を棄却することができ、自己相関が存在すると結論することができる。
6,065
<ASSISTANT_TASK:> Python Code: # Set up code checking from learntools.core import binder binder.bind(globals()) from learntools.deep_learning.exercise_1 import * print("Setup Complete") horizontal_line_conv = [[1, 1], [-1, -1]] # load_my_image and visualize_conv are utility functions provided ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise 1 Step2: Now it's your turn. Instead of a horizontal line detector, you will create a vertical line detector. Step3: If you'd like a ...
6,066
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np a = pd.DataFrame(np.array([[1, 2],[3, 4]]), columns=['one', 'two']) b = pd.DataFrame(np.array([[5, 6],[7, 8],[9, 10]]), columns=['one', 'two']) def g(a,b): if len(a) < len(b): a = a.append(pd.DataFrame(np.array([[np.nan, np.nan]*(len(b)-l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
6,067
<ASSISTANT_TASK:> Python Code: import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier import sklearn.metrics as metrics data = pd.read_csv('../input/mobile-price-classification/train.csv') data.head() data.columns # Set variables for the targets and...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We create our feature and targets the same as before using train_test_split. This part looks like what you've already seen. Step2: Creating and...
6,068
<ASSISTANT_TASK:> Python Code: from matplotlib.colors import ListedColormap from sklearn import cross_validation, datasets, metrics, tree import numpy as np %pylab inline classification_problem = datasets.make_classification(n_features = 2, n_informative = 2, n_c...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Генерация данных Step2: Модель DecisionTreeClassifier Step3: Разделяющая поверхность
6,069
<ASSISTANT_TASK:> Python Code: # path to raw files ## CHANGE THIS! rawFileDir = "~/perl/projects/CLdb/data/Methanosarcina/" # directory where the CLdb database will be created ## CHANGE THIS! workDir = "~/t/CLdb_Methanosarcina/" # viewing file links import os import zipfile import csv from IPython.display import FileLi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The required files are in '../ecoli_raw/' Step2: Checking that CLdb is installed in PATH Step3: Setting up the CLdb directory Step4: Download...
6,070
<ASSISTANT_TASK:> Python Code: from keras.applications import imagenet_utils imagenet_utils.CLASS_INDEX_PATH from urllib.request import urlopen import json with urlopen(imagenet_utils.CLASS_INDEX_PATH) as jsonf: data = jsonf.read() class_dict = json.loads(data.decode()) [class_dict[str(i)][1] for i in range(1000)] ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Imagenet 2012 網頁
6,071
<ASSISTANT_TASK:> Python Code: theArray = range(0,100) key = 101 if key in theArray: print("The key is in the array.") else: print("The key is not in the array.") def linearSearch(theValues, target): n = len(theValues) for i in range(n): # If the target is in the ith element, return True ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Okay, using in operator gives us a great deal of simplicity, but we should know the behind the scenes of in operator. Step2: Finding a specific...
6,072
<ASSISTANT_TASK:> Python Code: # Authors: Denis Engemann <denis.engemann@gmail.com> # # License: BSD-3-Clause import mne from mne import io from mne.event import define_target_events from mne.datasets import sample import matplotlib.pyplot as plt print(__doc__) data_path = sample.data_path() raw_fname = data_path + '/...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Find stimulus event followed by quick button presses Step3: View evoked response
6,073
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'fio-ronm', 'sandbox-3', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,074
<ASSISTANT_TASK:> Python Code: !pip show kubeflow-fairing # Set docker registry to store image. # Ensure you have permission for pushing docker image requests. DOCKER_REGISTRY = 'index.docker.io/jinchi' # Set namespace. Note that the created PVC should be in the namespace. my_namespace = 'hejinchi' # You also can get...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configure the Docker Registry for Kubeflow Fairing Step2: Create PV/PVC to Store the Exported Model Step3: (Optional) Skip below creating PV/P...
6,075
<ASSISTANT_TASK:> Python Code: # SQLAlchemy from sqlalchemy import Table, Column, Integer, ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Date, Integer, String Base = declarative_base() class One(Base): __tablename__ = 'one'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: One To Many Step2: To establish a bidirectional relationship in one-to-many, where the “reverse” side is a many to one, specify an additional r...
6,076
<ASSISTANT_TASK:> Python Code: #import packages import heartpy as hp import matplotlib.pyplot as plt sample_rate = 250 data = hp.get_data('e0103.csv') plt.figure(figsize=(12,4)) plt.plot(data) plt.show() #run analysis wd, m = hp.process(data, sample_rate) #visualise in plot of custom size plt.figure(figsize=(12,4)) h...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's look at the first file and visualise it Step2: That is a very nice and clean signal. We don't need to do any preprocessing and can run an...
6,077
<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 ! pip3 install -U google-cloud-storage $USER_FLAG if os.environ["IS_TESTING"]: ...
<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: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
6,078
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import matplotlib.pyplot as plt import numpy as np import os import sys import time from datetime import timedelta import tarfile from IPython...
<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: First, we'll download the dataset to our local machine. The data consists of characters rendered in a variety of fonts on a 28x28 image. The lab...
6,079
<ASSISTANT_TASK:> Python Code: from scipy import optimize def f(X): Cost function. return (X**2).sum() X0 = [1.,1.] # Initial guess sol = optimize.minimize(f, X0, method = "nelder-mead") X = sol.x print "Solution: ", X def func(x, omega, tau): return np.exp(-x / tau) * np.sin(omega * x) xdata = np.lins...
<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: Optimization Step2: Curve fitting using least squares
6,080
<ASSISTANT_TASK:> Python Code: # Figure 1 Image(url="http://cntk.ai/jup/MNIST-image.jpg", width=300, height=300) # Import the relevant modules from __future__ import print_function # Use a function definition from future version (say 3.x from 2.7 interpreter) import matplotlib.pyplot as plt import numpy as np import o...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In this tutorial, we will use the MNIST hand-written digits data to show how images can be encoded and decoded (restored) using feed-forward net...
6,081
<ASSISTANT_TASK:> Python Code: from google.colab import auth auth.authenticate_user() #@markdown Please fill in the value below with your GCP project ID and then run the cell. # Please fill in these values. project_id = "" #@param {type:"string"} # Quick input validations. assert project_id, "⚠️ Please provide a Googl...
<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: 🔗 Connect Your Google Cloud Project Step2: ☁ Configure Your Google Cloud Project Step3: Enable the Cloud SQL Admin API within your project. S...
6,082
<ASSISTANT_TASK:> Python Code: 1+2 1+1 1+2 print(1+2) a = 4 b = 1.5 c = 121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212 d = 1j e = 1/3 f = True a+b a*c (b+d)*a a+f type(1.5) my_name = "Roshan" print(my_name) my_list = [1,2,3,4,5] my_list my_list + [6] my_l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The print function Step2: Variables Step3: Other Value Types Step4: Selecting / Slicing Step5: To access a single value in a list use this s...
6,083
<ASSISTANT_TASK:> Python Code: %run 'Set-up.ipynb' %run 'Loading scenes.ipynb' %run 'vrep_models/PioneerP3DX.ipynb' %%vrepsim '../scenes/OU_Pioneer.ttt' PioneerP3DX # Use the time library to set a wait duration import time #Tell the robot to move forward by setting both motors to speed 1 robot.move_forward(1) #Wait fo...
<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: Driving the Robot - Forwards, Backwards, Turns Step2: In the code cell below, see if you can write a programme that drives the robot forwards a...
6,084
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras import regularizers from sklearn.datasets import make_moons import numpy as np import matplotlib.pyplot as plt import tensorflow_probability as tfp data = make_moons(3000, noise...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the data Step2: Affine coupling layer Step4: Real NVP Step5: Model training Step6: Performance evaluation
6,085
<ASSISTANT_TASK:> Python Code: from nltk.tokenize import TreebankWordTokenizer sentence = "How does nltk tokenize this sentence?" tokenizer = TreebankWordTokenizer() tokenizer.tokenize(sentence) from nltk.tokenize.casual import casual_tokenize tweet = "OMG @twitterguy that was sooooooooo cool :D :D :D!!!!" print(casua...
<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: Tokenizing Social Media Step2: N-grams Step3: Stop-words Step4: Sentiment
6,086
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import emcee import corner nthreads = 2 # define our true relation m_true = 1.7 b_true = 2.7 f_true = 0.3 # generate some data N = 30 x = np.sort(10*np.random.rand(N)) yerr = 0.2+0.6*np.random.rand(N) y = m_true*x+b_t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Emcee has multithreadding support. Set this to the number of cores you would like to use. In this demo we will use the python multiprocessing mo...
6,087
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-2', 'ocnbgchem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,088
<ASSISTANT_TASK:> Python Code: ! pip install -q -U xarray matplotlib ! rm -rf data-driven-discretization-1d ! git clone https://github.com/google/data-driven-discretization-1d.git ! pip install -q -e data-driven-discretization-1d # install the seaborn bug-fix from https://github.com/mwaskom/seaborn/pull/1602 ! pip inst...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Run training Step2: Run evaluation Step3: See also ks_spectral.nc and kdv_spectral.nc in the same directory for reference simulations with KS ...
6,089
<ASSISTANT_TASK:> Python Code:: import pandas as pd from sklearn.preprocessing import OneHotEncoder from sklearn.compose import make_column_transformer ohe = OneHotEncoder() df = pd.read_csv('onehotend_data.csv') ohe.fit(df[['town']]) ct = make_column_transformer((OneHotEncoder(categories = ohe.categories_), ['town']),...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
6,090
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from scipy import stats from IPython.display import Image #this is for displaying the widgets in the github repo from shaolin.dashboards.graph import GraphCalculator forex_data = pd.read_hdf('gcalculator_data/forex_sample.h5') forex_data.items,forex_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <a id='sample_matrices'></a> Step3: <a id='sample_node_metrics'></a> Step4: <a id='components'></a> Step5: <a id='gc_parameters'></a> Step6: ...
6,091
<ASSISTANT_TASK:> Python Code: import pandas as pd pd.__version__ pd.show_versions() df = pd.DataFrame(data, index=labels) df.info() # ...or... df.describe() df.iloc[:3] # or equivalently df.head(3) df.loc[:, ['animal', 'age']] # or df[['animal', 'age']] df.loc[df.index[[3, 4, 8]], ['animal', 'age']] df[df['vis...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2. Print the version of pandas that has been imported. Step2: 3. Print out all the version information of the libraries that are required by th...
6,092
<ASSISTANT_TASK:> Python Code: import pandas as pd import zipfile with zipfile.ZipFile('../datasets/phishing.csv.zip', 'r') as z: f = z.open('phishing.csv') data = pd.read_csv(f, index_col=False) data.head() data.phishing.value_counts() data.url[data.phishing==1].sample(50, random_state=1).tolist() keywords =...
<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: Creating features Step2: Contain any of the following Step3: Lenght of the url Step4: Create Model Step5: Save model Step6: Part 2 Step7: ...
6,093
<ASSISTANT_TASK:> Python Code: from smact.structure_prediction import prediction, database, mutation, probability_models, structure, utilities import json import itertools from itertools import zip_longest import smact # An optional utility to display a progress bar # for long-running loops. `pip install tqdm`. from tq...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Querying the MP for garnets Step2: Structure matching Step3: Sorting out experimental data Step4: Other garnet structures Step5: Storing in ...
6,094
<ASSISTANT_TASK:> Python Code: import os # Configure Auth and Base URL # Planet Analytics API Base URL PAA_BASE_URL = "https://api.planet.com/analytics/" # API Key Config API_KEY = os.environ['PL_API_KEY'] # Alternatively, you can just set your API key directly as a string variable: # API_KEY = "YOUR_PLANET_API_KEY_HER...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We'll make a couple helper functions for "pretty printing" our responses Step2: Now let's use the Requests library to get the Subscription. We'...
6,095
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pylab as plt x=np.linspace(0,50,100) ts1=pd.Series(3.1*np.sin(x/1.5)+3.5) ts2=pd.Series(2.2*np.sin(x/3.5+2.4)+3.2) ts3=pd.Series(0.04*x+3.0) #ts1.plot() #ts2.plot() #ts3.plot() #plt.ylim(-2,10) #plt.legend(['ts1','ts2','ts3']) #plt....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the above example, it is clear that $ts1$ and $ts2$ are most similar (they are both $sin$ functions under different transformations). $ts3$ ...
6,096
<ASSISTANT_TASK:> Python Code: with tf.variable_scope("foo"): with tf.variable_scope("bar"): v = tf.get_variable("v", [1]) assert v.name == "foo/bar/v:0" with tf.variable_scope("foo"): v = tf.get_variable("v", [1]) tf.get_variable_scope().reuse_variables() v1 = tf.get_variable("v", [1])...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Variable scopes control variable (re)use Step2: You’ll need to use reuse_variables() to implement Deep Networks Step3: Case 2 Step4: <br/>
6,097
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import xgboost as xgb from xgboost.sklearn import XGBClassifier from sklearn import cross_validation, metrics from sklearn.grid_search import GridSearchCV import matplotlib.pylab as plt %matplotlib inline from matplotlib.pylab import rcParams rcParam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 载入数据 Step2: 建模与交叉验证 Step3: 第1步- 对于高的学习率找到最合适的estimators个数 Step4: Tune subsample and colsample_bytree Step5: tune subsample Step6: 对正则化做交叉验证...
6,098
<ASSISTANT_TASK:> Python Code: def square(x): Square of x. return x*x def cube(x): Cube of x. return x*x*x def root(x): Square root of x. return x**.5 # create a dictionary of functions funcs = { 'square': square, 'cube': cube, 'root': root, } x = 2 print square(x) print cube(x) prin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Functions Step5: Functions can be passed in as arguments Step6: $$ f(x) = 3x^2 + 5x + 3$$ Step9: Functions can also be returned by functions ...
6,099
<ASSISTANT_TASK:> Python Code: books = [ ("Klein, Bernd", "Einführung in Python", "Hanser", "3", 2017), ("Sweigart, Al", "Automate the Boring Stuff with Python", "No Starch Press", "1", 2015), ("Weigend, Michael", "Python", "mitp", "6., erw. Aufl.", 2016), ("Downey, Allen B.", "Programmieren lernen mit ...
<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: Auch die Step2: Für den Fall, dass ein Benutzer ein Buch entlehnen will, könnten wir eine Step3: Die Sache kann schnell komplex werden, wenn S...