Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k โ | cleaned_prompt stringlengths 168 30.3k โ |
|---|---|---|
4,600 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
# Loading airline data
import numpy as np
data = np.load('airline.npz')
X_train, Y_train = data['X_train'], data['Y_train']
D = Y_train.shape[1];
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xlabel('Time (years)')
ax.set_yla... | <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 set
Step2: Modeling
Step3: In total, a lot of hyperparameters must be optimized. Furthermore, the optimization surface of the spectral mi... |
4,601 | <ASSISTANT_TASK:>
Python Code:
import gachon_autograder_client as g_autograder
THE_TEMLABIO_ID = "#YOUR_ID"
PASSWORD = "#YOUR_PASSWORD"
ASSIGNMENT_NAME = "linear_algebra_basic_I" # I๋ ๋๋ฌธ์ i๋ฅผ ์๋ฏธํจ
g_autograder.get_assignment(THE_TEMLABIO_ID , PASSWORD, ASSIGNMENT_NAME)
def vector_size_check(*vector_variables):
retur... | <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: ์ ์์ค ์ฝ๋๋ฅผ .py ํ์ผ ๋๋ jupyter notebook์ ์
๋ ฅํ์ฌ ํ์ด์ฌ์ผ๋ก ์คํ ์ํค๋ฉด "linear_algebra_basic_I.ipynb" ํ์ผ์ด ์์ฑ๋๋ฉฐ, jupyter notebook์ผ๋ก ์คํํ๊ฑฐ๋, ์ฝ์์ฐฝ(cmd)์์ ํด๋น ํ์ผ์ด ์๋ ํด... |
4,602 | <ASSISTANT_TASK:>
Python Code:
maketimeseries() # Load this function from bottom of notebook to print.
# General libraries
%matplotlib inline
import pandas as pd
import warnings
warnings.simplefilter(action = "ignore", category = FutureWarning) # Supress some meaningless warnings.
#from tabulate import tabulate
from ... | <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. The semantic connections
Step2: A. Web of Science - Recursion 1.
Step3: Keyword analysis
Step4: Journal analysis
Step5: Scopus - Recursiv... |
4,603 | <ASSISTANT_TASK:>
Python Code:
# import python modules
import GPy
import numpy as np
from matplotlib import pyplot as plt
# call matplotlib with the inline command to make plots appear within the browser
%matplotlib inline
# The documentation to use the RBF function. There are several advanced options such as useGPU w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1 Covariance Functions
Step2: A summary of the kernel can be obtained using the command print k.
Step3: It is also possible to plot the kernel... |
4,604 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
sns.set_context('talk')
sns.set_style('darkgrid')
iris = sns.load_dataset('iris')
iris.head()
irisplot = sns.pairplot(iris, hue="species", palette='Set2', diag_kind="kde", siz... | <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 Iris Flower Dataset is a standard machine learning data set dating back to the 1930s. It contains measurements from 150 flowers, 50 from ea... |
4,605 | <ASSISTANT_TASK:>
Python Code:
from gensim.sklearn_api import LdaTransformer
from gensim.corpora import Dictionary
texts = [
['complier', 'system', 'computer'],
['eulerian', 'node', 'cycle', 'graph', 'tree', 'path'],
['graph', 'flow', 'network', 'graph'],
['loading', 'computer', 'system'],
['user',... | <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 will create a dummy set of texts and convert it into a corpus
Step2: Then to run the LdaModel on it
Step3: Integration with Sklearn
St... |
4,606 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
with open('reviews.txt', 'r') as f:
reviews = f.read()
with open('labels.txt', 'r') as f:
labels = f.read()
reviews[:2000]
from string import punctuation
all_text = ''.join([c for c in reviews if c not in punctuation])
reviews = all_text... | <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: Encoding the words
Step3: Encoding the labels
Step4: If you built labels correctly, you should see the next output.... |
4,607 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pyemu
la = pyemu.Schur("pest.jco",verbose=False)
la.drop_prior_information()
jco_ord = la.jco.get(la.pst.obs_names,la.pst.par_names)
ord_base = "pest_ord"
jco_ord.to_binary(ord_base... | <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: instaniate pyemu object and drop prior info. Then reorder the jacobian and save as binary. This is needed because the pest utilities require s... |
4,608 | <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 tarfile
import random
from IPython.display import display, Imag... | <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... |
4,609 | <ASSISTANT_TASK:>
Python Code:
ph_sel_name = "all-ph"
data_id = "7d"
# ph_sel_name = "all-ph"
# data_id = "7d"
from fretbursts import *
init_notebook()
from IPython.display import display
data_dir = './data/singlespot/'
import os
data_dir = os.path.abspath(data_dir) + '/'
assert os.path.exists(data_dir), "Path '%s' d... | <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 software and filenames definitions
Step2: Data folder
Step3: List of data files
Step4: Data load
Step5: Laser alternation selection
Ste... |
4,610 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from bqplot import Figure, LinearScale, ColorScale, Color, Axis, HeatMap, ColorAxis
from ipywidgets import Layout
x = np.linspace(-5, 5, 200)
y = np.linspace(-5, 5, 200)
X, Y = np.meshgrid(x, y)
color = np.cos(X ** 2 + Y ** 2)
x_sc, y_sc, col_sc = LinearScale(), Linea... | <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 Input
Step2: Plotting a 2-dimensional function
Step3: Displaying an image
|
4,611 | <ASSISTANT_TASK:>
Python Code:
%%javascript
delete requirejs.s.contexts._.defined.CustomViewModule;
define('CustomViewModule', ['jquery', 'widgets/js/widget'], function($, widget) {
var CustomView = widget.DOMWidgetView.extend({
});
return {CustomView: CustomView};
});
from IPython.html.widgets import DOMWi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using the template below, make a color picker widget. This can be done in a few steps
|
4,612 | <ASSISTANT_TASK:>
Python Code:
# Authors: Laura Gwilliams <laura.gwilliams@nyu.edu>
# Jean-Remi King <jeanremi.king@gmail.com>
# Alex Barachant <alexandre.barachant@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.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: Set parameters and read data
Step2: Loop through frequencies, apply classifier and save scores
Step3: Plot frequency results
Step4: Loop thro... |
4,613 | <ASSISTANT_TASK:>
Python Code:
mu, sigma = 64, 8
popn = np.random.normal(loc=mu,scale=sigma, size=100000)
truemu, truesigma = np.mean(popn), np.std(popn)
s = \
For the population of interest, the true mean is {}
and the true standard deviation is {}
print(s.format(truemu,truesigma))
plt.hist(popn, bins=50, color='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: Population distribution
Step2: This is what the population distribution looks like when represented as a frequency histogram.
Step4: Sample di... |
4,614 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from mpld3 import plugins, utils
import geopandas as gp
import pandas as pd
from shapely.wkt import loads
import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.pa... | <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. Interactive visualization
Step2: There are three elements that can be adjusted in this interactive visualization
|
4,615 | <ASSISTANT_TASK:>
Python Code:
# import libraries
# linear algebra
import numpy as np
# data processing
import pandas as pd
# data visualization
from matplotlib import pyplot as plt
# load the data with pandas
dataset = pd.read_csv('dataset.csv', header=None)
dataset = np.array(dataset)
plt.scatter(dataset[:,0], 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:
Step2: 1. Implementar o algoritmo K-means
Step3: Teste a funรงรฃo criada e visualize os centrรณides que foram calculados.
Step5: 1.2 Definir os clusters... |
4,616 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import tensorflow as tf
import numpy as np
from datetime import date
date.today()
author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises"
tf.__version__
np.__version__
sess = tf.InteractiveSession()
_X = np.array([[1,2,3], [4,5,6]])
X =... | <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: NOTE on notation
Step2: Q2. Compute the cumulative product of X along the second axis.
Step3: Segmentation
Step4: Q4. Compute the product alo... |
4,617 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
from builtins import range
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from singa import tensor
from singa import optimizer
from singa import loss
from singa import layer
#from singa.proto import model_pb2
# generate the bo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To import PySINGA modules
Step2: Task is to train a MLP model to classify 2-d points into the positive and negative categories.
Step3: We gene... |
4,618 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import torch
import matplotlib.pyplot as plt
from torchvision import datasets
import torchvision.transforms as transforms
# number of subprocesses to use for data loading
num_workers = 0
# how many samples per batch to load
batch_size = 64
# convert d... | <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: Visualize the data
Step2: Define the Model
Step3: Generator
Step4: Model hyperparameters
Step5: Build complete network
Step6: Discriminator... |
4,619 | <ASSISTANT_TASK:>
Python Code:
training_data = pd.read_csv('training_set_values.csv', index_col=0)
training_label = pd.read_csv('training_set_labels.csv', index_col=0)
test_data = pd.read_csv('test_set_values.csv', index_col=0)
# Merge test data and training data to apply same data management operations on them
data = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Measures
Step2: Analyzes
Step3: Descriptive Statistics
Step4: Bivariate analyzes
Step5: To visualize the influence of the quantitative varia... |
4,620 | <ASSISTANT_TASK:>
Python Code:
# Versรฃo da Linguagem Python
from platform import python_version
print('Versรฃo da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Criando uma funรงรฃo
def verificaPar(num):
if num % 2 == 0:
return True
else:
return False
# Chamando a funรงรฃo e pa... | <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: Filter
|
4,621 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo("3Md5KCCQX-0")
import numpy as np
from scipy import linalg
# https://en.wikipedia.org/wiki/Hermitian_matrix
A = np.matrix('2, 2+1j, 4; 2-1j, 3, 1j; 4, -1j, 1')
assert (A == A.H).all() # expect True
print("A", A, sep='\n')
print("A.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: Yes, you may embed Youtubes in your I-Python Notebooks, meaning you may follow up on a presentation with some example interactive code (or stati... |
4,622 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
from utils import plot_samples, plot_curves
import time
import numpy as np
# force random seed for results to be reproducible
SEED = 4242
np.random.seed(SEED)
from keras.datasets import mnist
from keras.utils import np_utils
# Load pre... | <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: Dataset
Step2: Multiclass softmax
Step3: Exercise
Step4: Categories need to be converted to one-hot vectors for training
Step5: We are now r... |
4,623 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# SOD PR-AUC vs SNN (ionosphere)
df = pd.read_csv('output_summary.csv', header=None, index_col=False, skiprows=3, nrows=5, usecols=[2,4])
fig = plt.figure(figsize=(5,3))
ax = fig.add_axes([0.12, 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: Discussion
Step2: Likewise, we need to know how running time is affected by increasing the size of the dataset. Below we plot several curves w... |
4,624 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import numpy as np
import SDSS
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import copy
# We want to select galaxies, and then are only interested in their positions on the sky.
data = pd.read_csv("downloads/SDSSobjects.csv",use... | <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 Correlation Function
Step2: Random Catalogs
Step3: Now let's plot both catalogs, and compare.
Step4: Estimating $\xi(\theta)$
|
4,625 | <ASSISTANT_TASK:>
Python Code:
from regraph import NXGraph, Neo4jHierarchy, Rule
from regraph import plot_graph, plot_instance, plot_rule
%matplotlib inline
# Define graph G
g = NXGraph()
g.add_nodes_from(["protein", "binding", "region", "compound"])
g.add_edges_from([("region", "protein"), ("protein", "binding"), ("r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Creating and modifying a hierarchy object
Step2: The method get_graph returns the graph object corresponding to the provided graph id.
Step3... |
4,626 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
from sympy.vector import CoordSys3D
N = CoordSys3D('N')
x1, x2, x3 = symbols("x_1 x_2 x_3")
alpha1, alpha2, alpha3 = symbols("alpha_1 alpha_2 alpha_3")
R, L, ga, gv = symbols("R L g_a g_v")
init_printing()
a1 = pi / 2 + (L / 2 - alpha1)/R
x = (R + alpha3 + ga * cos(gv... | <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: Corrugated cylindrical coordinates
Step2: Base Vectors $\vec{R}_1, \vec{R}_2, \vec{R}_3$
Step3: Base Vectors $\vec{R}^1, \vec{R}^2, \vec{R}^3$... |
4,627 | <ASSISTANT_TASK:>
Python Code:
def divide(numerator, denominator):
result = numerator/denominator
print("result = %f" % result)
divide(1.0, 0)
def divide1(numerator, denominator):
try:
GARBAGE
result = numerator/denominator
print("result = %f" % result)
except (ZeroDivisionError,... | <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: Why didn't we catch this SyntaxError?
Step3: What do you do when you get an exception?
|
4,628 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Eric Larson <larson.eric.d@gmail.com>
# Denis Engemannn <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
from numpy.random import randn
import matplotl... | <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: Read epochs for all channels, removing a bad one
Step3: Transform to source space
Step4: Transform to common cortical s... |
4,629 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame.read_csv('Philadelphia_Crime_Rate_noNA.csv/')
sales
graphlab.canvas.set_target('ipynb')
sales.show(view="Scatter Plot", x="CrimeRate", y="HousePrice")
crime_model = graphlab.linear_regression.create(sales, target='HousePrice', features=['CrimeRat... | <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 some house value vs. crime rate data
Step2: Exploring the data
Step3: Fit the regression model using crime as the feature
Step4: Let's s... |
4,630 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
vgg_dir = 'tensorflow_vgg/'
# Make sure vgg exists
if not isdir(vgg_dir):
raise Exception("VGG directory doesn't exist!")
class DLProgress(tqdm):
last_block = 0
def hook(self, block_... | <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: Flower power
Step2: ConvNet Codes
Step3: Below I'm running images through the VGG network in batches.
Step4: Building the Classifier
Step5: ... |
4,631 | <ASSISTANT_TASK:>
Python Code:
%%bash
cd /tmp
rm -rf playground #remove if it exists
git clone https://github.com/dsondak/playground.git
%%bash
ls -a /tmp/playground
%%bash
cd /tmp/playground
git log
%%bash
cd /tmp/playground
git status
%%bash
cd /tmp/playground
cat .git/config
%%bash
cd /tmp/playground
cat .gitign... | <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: Poking around
Step2: Each one of these "commits" is an SHA hash. It uniquely identifies all actions that have happened to this repository previ... |
4,632 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import tensorflow as tf
import helper
from tensorflow.examples.tutorials.mnist import input_data
print('Getting MNIST Dataset...')
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
print('Data Extracted.')
# Save the shapes of weights for each layer
layer_... | <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: Neural Network
Step2: Initialize Weights
Step3: As you can see the accuracy is close to guessing for both zeros and ones, around 10%.
Step4: ... |
4,633 | <ASSISTANT_TASK:>
Python Code:
df = unpickle_object("final_dataframe_for_analysis.pkl") #dataframe we got from webscraping and cleaning!
#see other notebooks for more info.
df.dtypes # there are all our features. Our target variable is Box_office
df.shape
df['Month'] = df['Month'].astype(object)
df['Year'] = df['Year'... | <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: Upon further thought, it doesnt make sense to have rank_in_genre as a predictor variable for box office budget. When the movie is release, it is... |
4,634 | <ASSISTANT_TASK:>
Python Code:
data_original = np.loadtxt('stanford_dl_ex/ex1/housing.data')
data = np.insert(data_original, 0, 1, axis=1)
np.random.shuffle(data)
train_X = data[:400, :-1]
train_y = data[:400, -1]
m, n = train_X.shape
theta = np.random.rand(n)
def cost_function(theta, X, y):
squared_errors = (X.d... | <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: Define some necessary functions.
Step2: Gradient Checking
Step3: Prepare theta step values (making use of numpy broadcasting).
Step4: Compute... |
4,635 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import requests
import os
# GET A CSV OF ALL STARBUCKS LOCATIONS
# If this link is ever broken, use the link above to get a new one
fname = 'All_Starbucks_Locations_in_the_World.csv'
if not(os.path.isfile(fname)):
print 'Getting file from Socrata... | <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: Copy is a gotcha
Step2: A few Pandas features used in this workshop
Step3: Indexes
Step4: Column renaming and dropping
|
4,636 | <ASSISTANT_TASK:>
Python Code:
# A dependency of the preprocessing for BERT inputs
!pip install -q --user tensorflow-text
!pip install -q --user tf-models-official
import os
import shutil
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
from official.nlp import optimization # to cre... | <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 will use the AdamW optimizer from tensorflow/models.
Step2: To check if you have a GPU attached. Run the following.
Step3: Sentiment Analy... |
4,637 | <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: ... |
4,638 | <ASSISTANT_TASK:>
Python Code:
N = 1000
alpha = 1.0
mu = 10.0
x, t = SSA(100,N,a=alpha,mu=mu)
x = x.astype(int) # path data supposed to be integers.
path_data = {
'N' : N,
't' : t,
'x' : x
}
print 'Simulated up to time T =', round(t[N-1])
# Setup STAN :
model_description =
data{
int<lower=0> N; ## 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: Inferring from long versus short-time regimes
Step2: Above we can see the inference from STAN. Remember that $a=1$ and $\mu=10$, which gives $\... |
4,639 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
data = pd.read_csv("thanksgiving.csv", encoding = 'Latin-1')
data.head()
data.columns
data['Do you celebrate Thanksgiving?'].value_counts()
filter_yes = data['Do you celebrate Thanksgiving?'] == "Yes"
data = data.loc[filter_yes]
data
data['What is typically the main ... | <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 need to filter out the people who didn't celebrate Thanksgiving.
Step2: What main dishes do people eat at Thanksgiving?
Step3: How many peo... |
4,640 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import statsmodels.api as sm
import dismalpy as dp
import matplotlib.pyplot as plt
np.set_printoptions(precision=4, suppress=True, linewidth=120)
from pandas.io.data import DataReader
# Get the datasets from FRED
start = '1979-01-0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note
Step2: Stock and Watson (1991) report that for their datasets, they could not reject the null hypothesis of a unit root in each series (so... |
4,641 | <ASSISTANT_TASK:>
Python Code:
#@title Imports & Utils
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style(style='white')
import warnings
warnings.filterwarnings("ignore")
!wget -O silica_train.npz https://www.dropbox.com/s/3dojk4u4di774ve/silica_train.npz?dl=0
!wget https://github.... | <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: Demo
Step2: Data from a quantum mechanical simulation of Silicon.
Step3: Visualize states inside colab.
Step4: Every simulation starts by def... |
4,642 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('../')
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
%matplotlib inline
import onsager.crystal as crystal
import onsager.OnsagerCalc as onsager
from scipy.constants import physical_constants
kB = physical_constants['Boltzm... | <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 an FCC Ni crystal.
Step2: Next, we construct our diffuser. For this problem, our thermodynamic range is out to the fourth neighbor; henc... |
4,643 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# Required imports
from wikitools import wiki
from wikitools import category
import nltk
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
import gensim
import numpy as np
import lda
import lda.datasets
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:
Step1: 1. Corpus acquisition.
Step2: You can try with any other categories. Take into account that the behavior of topic modelling algorithms may depe... |
4,644 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cas', 'sandbox-1', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "emai... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
4,645 | <ASSISTANT_TASK:>
Python Code:
import unicodedata
import string
import re
import random
import time
import datetime
import math
import socket
hostname = socket.gethostname()
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch import optim
import torch.nn.functional as F
from torch.nn.utils... | <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 will also define a constant to decide whether to use the GPU (with CUDA specifically) or the CPU. If you don't have a GPU, set this to F... |
4,646 | <ASSISTANT_TASK:>
Python Code:
As_soon_as_I_become_a_good_programmer_I_will_be_rich=False
# Let us test it :
if As_soon_as_I_become_a_good_programmer_I_will_be_rich: print("Then let us start programming !")
else: print('Do Algorithmics !')
## Check if the french word "ressasser" is a palindroma
# We first declare... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1.1) Declarative Knowledge on Palindromas
Step2: 2.1) Declarative Knowledge on square roots
Step3: 3) Conditional Instructions
Step4: 4) Usua... |
4,647 | <ASSISTANT_TASK:>
Python Code:
from bqplot import (DateScale, ColorScale, HeatMap,
Figure, LinearScale, OrdinalScale, Axis)
from scipy.stats import percentileofscore
from scipy.interpolate import interp1d
import bqplot.pyplot as plt
from traitlets import List, Float, observe
from ipywidgets import ... | <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 define the size of our matrix here. Larger matrices require a larger height.
Step2: Instead of setting the quantiles by the sliders, we can ... |
4,648 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import geopandas as gpd
import os
import numpy as np
import pandas as pd
#filename = os.path.join("/media", "disk", "tl_2013_17031_edges", "tl_2013_17031_edges.shp")
filename = os.path.join("..", "..", "..", "..", "..", "Data", "tl_2013_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: We only care about the columns "geometry" and "FULLNAME" (giving the road name) and LFROMADD, LTOADD, RFROMADD, RTOADD
Step2: Optionally projec... |
4,649 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time, os, json
import numpy as np
import skimage.io
import matplotlib.pyplot as plt
from cs231n.classifiers.pretrained_cnn import PretrainedCNN
from cs231n.data_utils import load_tiny_imagenet
from cs231n.image_utils import blur_image, deprocess_image
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:
Step1: Introducing TinyImageNet
Step2: TinyImageNet-100-A classes
Step3: Visualize Examples
Step4: Pretrained model
Step5: Pretrained model perform... |
4,650 | <ASSISTANT_TASK:>
Python Code:
import pandas
nI1 = pandas.read_excel('lab-3-3.xlsx', 'tab-1', header=None)
nI.head(5)
nI2 = pandas.DataFrame(nI.values[[0, 5, 6, 7, 8], :])
nI2.head()
nI3 = pandas.DataFrame(nI.values[[0, 9, 10, 11, 12], :])
nI3.head()
import matplotlib.pyplot
r1, r500, r3000 = nI1.values, nI2.values, nI... | <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: ะขะฐะบะธะผ ะพะฑัะฐะทะพะผ, ัะตะทะพะฝะฐะฝัะฝะฐั ัะฐััะพัะฐ ะฟัะธะผะตัะฝะพ ัะฐะฒะฝะฐ $f_p = 6.9~ะบะั$ ะธ ะฝะต ะทะฐะฒะธัะธั ะพั ัะพะฟัะพัะธะฒะปะตะฝะธั. ะญัะพ ัะฐัั
ะพะดะธััั ั ะพะถะธะดะฐะตะผัะผะธ ะดะฐะฝะฝัะผะธ. ะกะบะพัะตะต ะฒัะต... |
4,651 | <ASSISTANT_TASK:>
Python Code:
import cv2
import scipy.misc
import matplotlib.pyplot as plt
%matplotlib inline
# TODO: Feel free to try out your own images here by changing img_path
# to a file path to another image on your computer!
img_path = 'images/udacity_sdc.png'
# load color image
bgr_img = cv2.imread(img_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: 2. Specify the Filters
Step2: 3. Visualize the Activation Maps for Each Filter
|
4,652 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
%pylab inline
import math
import numpy as np
import copy
import seaborn as sns
sns.set(style="ticks", color_codes=True, font_scale=1.5)
sns.set_style({"xtick.direction": "in", "ytick.direction": "in"})
import mdtraj as md
from masterms... | <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: First we read the trajectory data, here corresponding to the Gromacs xtc files using the MDtraj library.
Step2: Then we discretize the data usi... |
4,653 | <ASSISTANT_TASK:>
Python Code:
%%html
<style>
.example-container { background: #999999; padding: 2px; min-height: 100px; }
.example-container.sm { min-height: 50px; }
.example-box { background: #9999FF; width: 50px; height: 50px; text-align: center; vertical-align: middle; color: white; font-weight: bold; margin: 2px;}... | <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: Basic styling
Step2: Parent/child relationships
Step3: After the parent is displayed
Step4: Fancy boxes
Step5: TabWidget
Step6: Alignment
S... |
4,654 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
from ipywidgets import interact
from exact_solvers import advection
interact(advection.characteristics);
interact(advection.solution);
interact(advection.riemann_demo);
q_l = 1.
q_r = 0.
advection.plot_riemann_solution(q_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: Characteristics
Step2: We can think of the initial values $q_0(x)$ being transmitted along these lines; we sometimes say that information is tr... |
4,655 | <ASSISTANT_TASK:>
Python Code:
# import the necessary package at the very beginning
import numpy as np
import pandas as pd
print(str(float(100*177/891)) + '%')
def foolOne(x): # note: assume x is a number
y = x * 2
y -= 25
return y
## Type Your Answer Below ##
foolOne_lambda = lambda x: x*2-25
# Generate a... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Please rewrite following functions to lambda expressions
Step2: 2. What's the difference between tuple and list?
Step3: 3. Why set is faste... |
4,656 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from owslib.wms import WebMapService
#We just need a WMS url from one TDS dataset...
serverurl ='http://thredds.ucar.edu/thredds/wms/grib/NCEP/NAM/CONUS_12km/best'
wms = WebMapService( serverurl, version='1.1.1')
#This is general information, common to all datasets in ... | <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 WebMapService object gets all the information available about the service through a GetCapabilities request
Step2: Bounding boxes, styles a... |
4,657 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-2', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contribu... | <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... |
4,658 | <ASSISTANT_TASK:>
Python Code:
from sklearn.tree import DecisionTreeClassifier
from sklearn.linear_model import LogisticRegression, Perceptron
import numpy as np
import matplotlib.pyplot as plt
from mlxtend.evaluate import plot_decision_regions
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
X = np.a... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Trees can fit XOR
Step2: When a linear models beat a decision tree
Step3: Depth matters
|
4,659 | <ASSISTANT_TASK:>
Python Code:
def pentagon_pyramidal(n ) :
return n * n *(n + 1 ) / 2
n = 4
print(int(pentagon_pyramidal(n ) ) )
<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:
|
4,660 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'snu', 'sandbox-2', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
4,661 | <ASSISTANT_TASK:>
Python Code:
a = 2 + 3j
print(a, type(a))
class NumeroComplesso(object):
def __init__(self, real, imag):
Metodo costruttore, chiamato quando viene
inizializzato un nuovo oggetto
self.a = real
self.b = imag
def somma(self, c):
Somma al numer... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step4: Definizione di un nuovo ADT
Step5: Danger ZONE !!!
Step8: Inheritance e Operator Overloading
Step9: Classes vs. Closures
Step10: NOTA
|
4,662 | <ASSISTANT_TASK:>
Python Code:
!pip install --upgrade tensorflow
import tensorflow as tf
print tf.__version__
import numpy as np
import tensorflow as tf
import seaborn as sns
import pandas as pd
SEQ_LEN = 10
def create_time_series():
freq = (np.random.random()*0.5) + 0.1 # 0.1 to 0.6
ampl = np.random.random() + 0.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h2> RNN </h2>
Step2: <h3> Input Fn to read CSV </h3>
Step3: Reading data using the Estimator API in tf.learn requires an input_fn. This input... |
4,663 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets.samples_generator import make_blobs
X_raw, y_raw = make_blobs(n_samples=100, centers=2,
cluster_std=5.2, random_state=42)
import numpy as np
X = X_raw.astype(np.float32)
from sklearn.preprocessing import OneHotEncoder
enc = OneHotEncoder(s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preprocessing the data
Step2: Furthermore, we need to think back to Chapter 4, Representing Data and Engineering and Features, and remember how... |
4,664 | <ASSISTANT_TASK:>
Python Code:
#untar and compile sample_stats
!tar zxf ms.tar.gz; cd msdir; gcc -o sample_stats sample_stats.c tajd.c -lm
#now move the program into the current working dir
!mv msdir/sample_stats .
#download discoal and compile it
!wget https://github.com/kern-lab/discoal/archive/master.zip; unzip mas... | <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 and compile discoal
Step2: Install scikit-learn
Step3: or if you don't use conda, you can use pip to install scikit-learn with
Step4: ... |
4,665 | <ASSISTANT_TASK:>
Python Code:
print("This is a "small" program")
print("This is a \"small\" program")
print('This is a text')
print("It's all good!")
print('It\'s all good!')
print('"Python" is a programming language.')
print("\"Python\" is a programming language.")
print("This is a backslash: \")
print("This ... | <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: Obratite paลพnju na to kako je kod obojen. Videฤete da je tekst prekinut ispred reฤi "small", a novi tekst je otpoฤet nakon reฤi "small". Sama re... |
4,666 | <ASSISTANT_TASK:>
Python Code:
import hail as hl
hl.init()
from bokeh.io import show, output_notebook
from bokeh.layouts import gridplot
output_notebook()
hl.utils.get_1kg('data/')
mt = hl.read_matrix_table('data/1kg.mt')
table = (hl.import_table('data/1kg_annotations.txt', impute=True)
.key_by('Sample'))
mt =... | <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: Histogram
Step2: This method, like all Hail plotting methods, also allows us to pass in fields of our data set directly. Choosing not to specif... |
4,667 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cccma', 'sandbox-2', 'landice')
# 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... |
4,668 | <ASSISTANT_TASK:>
Python Code:
import numpy
numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
Weight_kg = 55
print (Weight_kg)
print('Weight in pounds:', Weight_kg * 2.2)
Weight_kg = 57.5
print ('New weight: ', Weight_kg * 2.2)
%whos
data = numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
print (d... | <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: Variables
Step2: Tasks
|
4,669 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import psycopg2
import getpass
import pdvega
# for configuring connection
from configobj import ConfigObj
import os
%matplotlib inline
# Create a database connection using settings from config file
... | <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: Examine a single patient
Step4: Here we can see that this patient had an admission note highlighting they were allergic to nickel, tetracycline... |
4,670 | <ASSISTANT_TASK:>
Python Code:
!pip install hanlp -U
import hanlp
hanlp.pretrained.pos.ALL # ่ฏญ็ง่งๅ็งฐๆๅไธไธชๅญๆฎตๆ็ธๅบ่ฏญๆๅบ
pos = hanlp.load(hanlp.pretrained.pos.CTB9_POS_ELECTRA_SMALL)
pos(["ๆ", "็", "ๅธๆ", "ๆฏ", "ๅธๆ", "ๅผ ๆ้", "็", "่ๅฝฑ", "่ขซ", "ๆ้", "ๆ ็บข", "ใ"])
print(pos.dict_tags)
pos.dict_tags = {'HanLP': 'state-of-the-art-tool... | <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: ่ฐ็จhanlp.load่ฟ่กๅ ่ฝฝ๏ผๆจกๅไผ่ชๅจไธ่ฝฝๅฐๆฌๅฐ็ผๅญ๏ผ
Step3: ่ฏๆงๆ ๆณจ
Step4: ๆณจๆไธ้ขไธคไธชโๅธๆโ็่ฏๆงๅไธ็ธๅ๏ผไธไธชๆฏๅ่ฏๅฆไธไธชๆฏๅจ่ฏใ
Step5: ่ชๅฎไนๅไธช่ฏๆง๏ผ
Step6: ๆ นๆฎไธไธๆ่ชๅฎไน่ฏๆง๏ผ
|
4,671 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
def np_fact(n):
Compute n! = n*(n-1)*...*1 using Numpy.
LOL = np.arange(1, n+1, 1)
Factorial = np.cumprod(LOL)
if n == 0:
return 1
return Factorial[-1]
assert... | <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: Factorial
Step4: Write a function that computes the factorial of small numbers using a Python loop.
Step5: Use the %timeit magic to time both ... |
4,672 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
img = mnist.train.images[2]
plt.imshow(img.reshape((28, 28)), cmap='G... | <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: Network Architecture
Step2: Training
Step3: Denoising
Step4: Checking out the performance
|
4,673 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import itertools
import logging
from functools import partial
import gensim
import matplotlib.pyplot as plt
import numpy as np
import pandas as pnd
from sklearn.cluster import *
from sklearn.decomposition import PCA, RandomizedPCA
from sklearn.manifold import TSNE
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:
Step1: Notes
Step2: Preprocessing
Step3: Word embeddings
Step4: Topic model in word embedding space
Step5: PCA
Step6: t-SNE
Step7: t-SNE with PCA... |
4,674 | <ASSISTANT_TASK:>
Python Code:
print('hello world')
# This is an online comment: Python3
print('hello world')
# Python2:
print 'hello world'
1 * 1.0
a = 3.0
type(a)
b = 3 > 5
type(b)
a = int(a)
type(a)
# Different between Python2 and Python3
3 / 2
L = ['red', 'blue', 'green', 'black', 'white']
L[3], L[-2], L[3:], 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: As some you were asking about differences between Python2 and Python3, here is an example
Step2: More broadly speaking, some function interface... |
4,675 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('seaborn-whitegrid')
observations = pd.read_csv("data/observations.csv", index_col="occurrenceID")
observations.head()
observations.info()
observations["eventDat... | <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: Introduction
Step2: <div class="alert alert-success">
Step3: <div class="alert alert-success">
Step4: Cleaning the verbatimSex column
Step5: ... |
4,676 | <ASSISTANT_TASK:>
Python Code:
import os
import zipfile
import requests
import pandas as pd
from sklearn.decomposition import PCA
from sklearn.feature_selection import SelectFromModel
from sklearn.linear_model import Ridge, Lasso, ElasticNet
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
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: Fetch the data
Step2: Load the first dataset into a dataframe
Step3: Separate dataframe into features and targets
Step4: Regularization techn... |
4,677 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import concise.layers as cl
import keras.layers as kl
import concise.initializers as ci
import concise.regularizers as cr
from keras.callbacks import EarlyStopping
from concise.preprocessing import encodeDNA
from keras.models import Model... | <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: Concise is fully compatible with Keras; we can save and load the Keras models (note
|
4,678 | <ASSISTANT_TASK:>
Python Code:
def addFunction(inputNumber):
result = inputNumber + 2
return result
print(addFunction(2))
var = 2
print(addFunction(var))
def addFunction(inputNumber):
if inputNumber < 0:
return 'Number must be positive!'
result = inputNumber + 2
return result
print(addFun... | <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: On its own, this code will only define what the function does, but will not actually run any code. To execute the code inside the function you h... |
4,679 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import tensorflow.contrib.keras as keras
%matplotlib inline
# Dataset of 60,000 28x28 grayscale images of the 10 digits, along with a test set of 10,000 images.
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_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: Dataset pre-processing
Step2: Specifying the CNN model
Step3: The model can be visualized as follows
Step4: A convolutional layer 'Conv2D' lo... |
4,680 | <ASSISTANT_TASK:>
Python Code:
import scipy as sp
import numpy as np
# we will need to plot stuff later
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10, 8)
plt.rcParams['font.size'] = 16
plt.rcParams['lines.linewidth'] = 2
import scipy.constants as const
const.epsilon_0
# conver... | <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=physical_constants></a>
Step2: <a id=fitting></a>
Step3: <a id=uncertainties_guesses></a>
Step4: <a id=plot_corr_matrix></a>
Step5: <a... |
4,681 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib notebook
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from ripser import ripser
from persim import plot_diagrams
import time
# Create 100 points on the unit circle
N = 100
t = np.linspace(0, 2*np.pi, N+1)[0:N]
X = np.zeros((N, 2))... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example 1
Step2: Example 2
Step3: Exercises
Step4: Example 3
Step6: Now we will sample points from a "flat torus." The domain is $[0, 1] \t... |
4,682 | <ASSISTANT_TASK:>
Python Code:
%run ../bst/bst.py
%load ../bst/bst.py
def create_level_lists(root):
# TODO: Implement me
pass
%run ../utils/results.py
# %load test_tree_level_lists.py
from nose.tools import assert_equal
class TestTreeLevelLists(object):
def test_tree_level_lists(self):
node = Node(... | <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: Unit Test
|
4,683 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy import stats
import statsmodels.stats.proportion as smp
import pandas as pd
import matplotlib.pyplot as plt
def print_stats(data, hist_bins=10, hist_size=(8,4)):
print('--- Statistics ----')
display(data.describe())
print('\n')
print('--- Cou... | <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: Helper Functions
Step2: Load Excel
Step3: Basic Data
Step4: Age
Step5: Genre
Step6: Education
Step7: Type of Devices
Step8: Percentage of... |
4,684 | <ASSISTANT_TASK:>
Python Code:
import sys
# Diese Zeile muss angepasst werden!
sys.path.append("/home/moser/MG_2016/pyMG/")
import scipy as sp
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import pymg
from project.helmholtz1d import Helmholtz1D
from project.helmholtz1d_periodic import Helmholtz1... | <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: Systemmatrizen
Step2: Plotten Sie mithilfe von matrix_plot die Systemmatrizen fรผr $\sigma = 0$ und $n=10$.
Step3: Aufgabe
Step4: Iterationsma... |
4,685 | <ASSISTANT_TASK:>
Python Code:
import json
import math
import os
from pprint import pprint
import numpy as np
import tensorflow as tf
print(tf.version.VERSION)
N_POINTS = 10
X = tf.constant(range(N_POINTS), dtype=tf.float32)
Y = 2 * X + 10
# TODO 1
def create_dataset(X, Y, epochs, batch_size):
dataset = # TODO --... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loading data from memory
Step2: We begin with implementing a function that takes as input
Step3: Let's test our function by iterating twice ov... |
4,686 | <ASSISTANT_TASK:>
Python Code:
from GongSu21_Statistics_Averages import *
prices_pd.head()
california_pd['HighQ_dev'] = (california_pd['HighQ'] - ca_mean) ** 2
california_pd.head()
ca_HighQ_variance = california_pd.HighQ_dev.sum() / (ca_count - 1)
ca_HighQ_variance
# ์บ๋ฆฌํฌ๋์์์ ๊ฑฐ๋๋ ์ํ(HighQ) ๋ด๋ฐฐ(์๋ฌผ) ๋๋งค๊ฐ์ ํ์คํธ์ฐจ
ca_HighQ_... | <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: ์ด์ ์บ๋ฆฌํฌ๋์ ์ฃผ ๊ฑฐ๋๋ ์ํ(HighQ) ๋ด๋ฐฐ(์๋ฌผ)์ ๊ฑฐ๋๊ฐ ์ ์ฒด ๋ชจ์ง๋จ์ ๋ํ ๋ถ์ฐ ์ ์ถ์ ์ ๊ณ์ฐํ ์ ์๋ค.
Step4: ์ฃผ์
|
4,687 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import warnings
warnings.filterwarnings('ignore') #don't display warnings
# %load ../neon_aop_hyperspectral.py
Created on Wed Jun 20 10:34:49 2018
@author: bhass
import matplotlib.pyplot as plt
import numpy as np
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:
Step2: syncID
Step3: Read in SERC Reflectance Tile
Step4: Extract NIR and VIS bands
Step5: Calculate & Plot NDVI
Step6: We can use the function plo... |
4,688 | <ASSISTANT_TASK:>
Python Code:
# Load library
from nltk.stem.porter import PorterStemmer
# Create word tokens
tokenized_words = ['i', 'am', 'humbled', 'by', 'this', 'traditional', 'meeting']
# Create stemmer
porter = PorterStemmer()
# Apply stemmer
[porter.stem(word) for word in tokenized_words]
<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: Create Text Data
Step2: Stem Words
|
4,689 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.stats.stats import pearsonr
np.random.seed(101)
normal = np.random.normal(loc=0.0, scale= 1.0, size=1000)
print 'Mean: %0.3f Median: %0.3f Variance: %0.3f' % (np.mean(normal), np.median(normal), np.var(normal))
outlying = normal.copy()
outlying[0] = 50.0
prin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Finding more things that can go wrong with your data
Step2: Samples total 442<BR>
Step3: Leveraging on the Gaussian distribution
Step4: Mak... |
4,690 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import pandas as pd
import numpy as np
import seaborn as sns
raw_input = pd.read_pickle('input.pkl')
gp_mapper = {
1: 'A1', 2: 'A1', 3: 'A1',
4: 'A2', 5: 'A2', 6: 'A2',
7: 'B1', 8: 'B1', 9: 'B1',
... | <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: Map Level to Group
Step2: Train-test Split
Step3: For the rest of this notebook, we use the small sample dataset as input.
Step4: Check for C... |
4,691 | <ASSISTANT_TASK:>
Python Code:
import csv
!cat cars.csv || type cars.csv
with open('cars.csv') as handle:
reader = csv.DictReader(handle, delimiter=',')
kpl = [] # kilometer per litre
displacement = [] # engine displacement
for row in reader:
x = float(row['displacement']) * 0.0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data we want to read is contained in the <tt>csv</tt> file cars.csv, which is located in the subdirectory Python. In this file, the first c... |
4,692 | <ASSISTANT_TASK:>
Python Code:
import torch
import torch.nn as nn
import matplotlib.pyplot as plt
import numpy as np
from scipy import ndimage, misc
conv1 = nn.Conv2d(in_channels=1, out_channels=3,kernel_size=3)
Gx=torch.tensor([[1.0,0,-1.0],[2.0,0,-2.0],[1.0,0.0,-1.0]])
Gy=torch.tensor([[1.0,2.0,1.0],[0.0,0.0,0.0],... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a id="ref0"></a>
Step2: Pytorch randomly assigns values to each kernel. However, use kernels that have been developed to detect edges
Step3: ... |
4,693 | <ASSISTANT_TASK:>
Python Code:
import re
from bs4 import BeautifulSoup
def review_to_wordlist(review):
'''
Meant for converting each of the IMDB reviews into a list of words.
'''
# First remove the HTML.
review_text = BeautifulSoup(review).get_text()
# Use regular expressions to only incl... | <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 set up our function. This will clean all of the reviews for us.
Step2: Great! Now it is time to go ahead and load our data in. For this, pa... |
4,694 | <ASSISTANT_TASK:>
Python Code:
!pip install tokenizers
BIG_FILE_URL = 'https://raw.githubusercontent.com/dscape/spell/master/test/resources/big.txt'
# Let's download the file and save it somewhere
from requests import get
with open('big.txt', 'wb') as big_f:
response = get(BIG_FILE_URL, )
if response.statu... | <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 that we have our training data we need to create the overall pipeline for the tokenizer
Step2: The overall pipeline is now ready to be trai... |
4,695 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
df = pd.read_csv('../../data/processed/facilities-3-29-scrape.csv')
df.count()[0]
df[(df['offline'].isnull())].count()[0]
df[(df['... | <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: <h3>How many facilities are there?</h3>
Step2: <h3>How many facilities have accurate records online?</h3>
Step3: <h3>How many facilities have ... |
4,696 | <ASSISTANT_TASK:>
Python Code:
from paralleldomain.decoding.dgp.decoder import DGPDatasetDecoder
from paralleldomain.model.dataset import Dataset # optional import, just for type reference in this tutorial
dataset_path = "s3://pd-sdk-c6b4d2ea-0301-46c9-8b63-ef20c0d014e9/testset_dgp"
dgp_decoder = DGPDatasetDecoder(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: Alternatively you can also use the decode_dataset helper method.
Step2: If you want to load a dataset which is stored in Cityscapes or NuImages... |
4,697 | <ASSISTANT_TASK:>
Python Code:
from pygsf.spatial.rasters.geotransform import *
gt1 = GeoTransform(1500, 3000, 10, 10)
gt1
ijPixToxyGeogr(gt1, 0, 0)
xyGeogrToijPix(gt1, 1500, 3000)
ijPixToxyGeogr(gt1, 1, 1)
xyGeogrToijPix(gt1, 1510, 2990)
ijPixToxyGeogr(gt1, 10, 10)
xyGeogrToijPix(gt1, 1600, 3100)
X, Y = gtToxyCellCe... | <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: Forward and backward transformation examples
Step2: calculating the X, Y geographic coordinate arrays
|
4,698 | <ASSISTANT_TASK:>
Python Code:
# glass identification dataset
import pandas as pd
import numpy as np
url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/glass/glass.data'
col_names = ['id','ri','na','mg','al','si','k','ca','ba','fe','glass_type']
glass = pd.read_csv(url, names=col_names, index_col='id')
gla... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question
Step2: Refresher
Step3: Interpretation
Step4: Predicting a Categorical Response
Step5: Let's change our task, so that we're predict... |
4,699 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
pylab.style.use('ggplot')
import pandas as pd
import numpy as np
import seaborn as sns
train_url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data'
train_df = pd.read_csv(train_url, header=None)
train_df.head()
train_df.columns = ['age', 'workcla... | <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: Getting the Data
Step2: Attribute Information
Step3: Check for Missing Data
Step4: Check for Class Imbalance
Step5: Bivariate Analysis
Step6... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.