Unnamed: 0 int64 0 16k | text_prompt stringlengths 149 45.7k | code_prompt stringlengths 67 140k |
|---|---|---|
500 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Concurrences
One of the tools in Contact Map Explorer is the ability to look at simultaneous contacts. The idea is that you might have a set of contact... | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from contact_map import ContactFrequency, ResidueContactConcurrence, plot_concurrence
import mdtraj as md
traj = md.load("data/gsk3b_example.h5")
print(traj) # to see number of fra... |
501 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Run code to get all URLs
```
with open("all_urls.txt", "wb+") as fp
Step2: Load expanded data
Step3: Extract tweet features | <ASSISTANT_TASK:>
Python Code:
len(data)
data[0].keys()
data[0][u'source']
data[0][u'is_quote_status']
data[0][u'quoted_status']['text']
data[0]['text']
count_quoted = 0
has_coordinates = 0
count_replies = 0
language_ids = defaultdict(int)
count_user_locs = 0
user_locs = Counter()
count_verified = 0
for d in data:
... |
502 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Anna KaRNNa
In this notebook, we'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate n... | <ASSISTANT_TASK:>
Python Code:
import time
from collections import namedtuple
import numpy as np
import tensorflow as tf
Explanation: Anna KaRNNa
In this notebook, we'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate new text based on the text from the ... |
503 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
コブ・ダクラス型生産関数と課題文で例に出された関数を用いる。
いずれも定義域は0≤x≤1である。
<P>コブ・ダグラス型生産関数は以下の通りである。</P>
<P>z = x_1**0.5*x_2*0.5</P>
Step1: <P>課題の例で使われた関数は以下の通りである。</P>
<P>z = ... | <ASSISTANT_TASK:>
Python Code:
def example1(x_1, x_2):
z = x_1**0.5*x_2*0.5
return z
fig = pl.figure()
ax = Axes3D(fig)
X = np.arange(0, 1, 0.1)
Y = np.arange(0, 1, 0.1)
X, Y = np.meshgrid(X, Y)
Z = example1(X, Y)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1)
pl.show()
Explanation: コブ・ダクラス型生産関数と課題文で例に出された関数を用い... |
504 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Your first neural network
In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've provided som... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Explanation: Your first neural network
In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've ... |
505 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Introducing MLib package of PySpark
Load and transform the data
Just like in the previous chapter, we first specify the schema of our dataset.
Step1: ... | <ASSISTANT_TASK:>
Python Code:
import pyspark.sql.types as typ
labels = [
('INFANT_ALIVE_AT_REPORT', typ.StringType()),
('BIRTH_YEAR', typ.IntegerType()),
('BIRTH_MONTH', typ.IntegerType()),
('BIRTH_PLACE', typ.StringType()),
('MOTHER_AGE_YEARS', typ.IntegerType()),
('MOTHER_RACE_6CODE', typ.Str... |
506 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Introduction to NumPy
Numpy is a library that provides multi-dimensional array objects. You can think of these somewhat like normal Python lists, excep... | <ASSISTANT_TASK:>
Python Code:
x = [1,2,3]
y = [4,5,6]
x + y
Explanation: Introduction to NumPy
Numpy is a library that provides multi-dimensional array objects. You can think of these somewhat like normal Python lists, except they have a number of qualities that make them better for numeric computations.
Let's try add... |
507 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Point cloud classification with PointNet
Author
Step1: Load dataset
We use the ModelNet10 model dataset, the smaller 10 class version of the ModelNet4... | <ASSISTANT_TASK:>
Python Code:
import os
import glob
import trimesh
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from matplotlib import pyplot as plt
tf.random.set_seed(1234)
Explanation: Point cloud classification with PointNet
Author: David Griffiths<br>
... |
508 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
A Look Into Affordances of Citi and Capital Bikeshare Stations
Part 1
Step1: In looking at the top 10 trips for each station, we see some very interes... | <ASSISTANT_TASK:>
Python Code:
import glob
import csv
from collections import Counter
import numpy as np
from matplotlib import pyplot as plt
import re
%matplotlib inline
def get_top_trips(path,N=10):
#the headers on the CSV are slightly different depending on whether the data is from Citi or Capital
if pa... |
509 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Synthetic Data
Developed by Stijn Klop and Mark Bakker
This Notebook contains a number of examples and tests with synthetic data. The purpose of this n... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import gammainc, gammaincinv
import pandas as pd
import pastas as ps
ps.show_versions()
Explanation: Synthetic Data
Developed by Stijn Klop and Mark Bakker
This Notebook contains a number of examples and tests with synt... |
510 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Introduction
This tutorial introduces the basic features for simulating titratable systems via the constant pH method.
The constant pH method is one of... | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import scipy.constants # physical constants
import espressomd
import pint # module for working with units and dimensions
from espressomd import electrostatics, polymer, reaction_ensemble
from espressomd.interactions import HarmonicBond
... |
511 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
TPOT tutorial on the Titanic dataset
The Titanic machine learning competition on Kaggle is one of the most popular beginner's competitions on the platf... | <ASSISTANT_TASK:>
Python Code:
# Import required libraries
from tpot import TPOTClassifier
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
# Load the data
titanic = pd.read_csv('data/titanic_train.csv')
titanic.head(5)
Explanation: TPOT tutorial on the Titanic dataset
The Ti... |
512 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Doc2Vec Tutorial on the Lee Dataset
Step1: What is it?
Doc2Vec is an NLP tool for representing documents as a vector and is a generalizing of the Word... | <ASSISTANT_TASK:>
Python Code:
import gensim
import os
import collections
import smart_open
import random
Explanation: Doc2Vec Tutorial on the Lee Dataset
End of explanation
# Set file names for train and test data
test_data_dir = '{}'.format(os.sep).join([gensim.__path__[0], 'test', 'test_data'])
lee_train_file = test... |
513 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
<!--BOOK_INFORMATION-->
<a href="https
Step1: Then the goal is to loop over all possible values of $k$. As we do this, we want to keep track of
the be... | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
import numpy as np
iris = load_iris()
X = iris.data.astype(np.float32)
y = iris.target
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(
X, y, random_state=37
)
Explanation: <!--BOOK_INFORMA... |
514 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Try to write temperature-based potential evaporation (PET) model
Step1: Source
Step2: Kharrufa method. Kharrufa (1985) derived an equation through co... | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
data = pd.read_csv('../data/hbv_s_data.csv', index_col=0, parse_dates=True)
Explanation: Try to write temperature-based potential evaporation (PET) model
End of explanation
evap_true = np.array([0.6,... |
515 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
PixelCNN
Author
Step1: Getting the data
Step2: Create two classes for the requisite Layers for the model
Step3: Build the model based on the origina... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tqdm import tqdm
Explanation: PixelCNN
Author: ADMoreau<br>
Date created: 2020/05/17<br>
Last modified: 2020/05/23<br>
Description: PixelCNN implemented in Keras.
Introduction
... |
516 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Timeseries classification with a Transformer model
Author
Step1: Build the model
Our model processes a tensor of shape (batch size, sequence length, f... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def readucr(filename):
data = np.loadtxt(filename, delimiter="\t")
y = data[:, 0]
x = data[:, 1:]
return x, y.astype(int)
root_url = "https://raw.githubusercontent.com/hfawaz/cd-diagram/master/FordA/"
x_train, y_train = readucr(root_url + "FordA_TRAIN.ts... |
517 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Version control for fun and profit
Step1: A repository
Step2: And this is pretty much the essence of Git!
First
Step3: Other settings
Change how you... | <ASSISTANT_TASK:>
Python Code:
!ls
Explanation: Version control for fun and profit:
Git: the tool you didn't know you needed
Sources of this material:
This tutorial is adapted from
"Version Control for Fun and Profit" by Fernando Perez
For an excellent list of Git resources for scientists, see Fernando's Page.
Fernand... |
518 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Decoding source space data
Decoding to MEG data in source space on the left cortical surface. Here
univariate feature selection is employed for speed p... | <ASSISTANT_TASK:>
Python Code:
# Author: Denis A. Engemann <denis.engemann@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Jean-Remi King <jeanremi.king@gmail.com>
#
# License: BSD (3-clause)
import os
import numpy as np
import matplotlib.pyplot as plt
from sklearn.pipeline i... |
519 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Maxwell filter data with movement compensation
Demonstrate movement compensation on simulated data. The simulated data
contains bilateral activation of... | <ASSISTANT_TASK:>
Python Code:
# Authors: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
from os import path as op
import mne
from mne.preprocessing import maxwell_filter
print(__doc__)
data_path = op.join(mne.datasets.misc.data_path(verbose=True), 'movement')
head_pos = mne.chpi.read_head_pos(op.joi... |
520 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
<table align="left">
<td>
<a href="https
Step1: Restart the kernel
After you install the SDK, you need to restart the notebook kernel so it can ... | <ASSISTANT_TASK:>
Python Code:
import os
# The Google Cloud Notebook product has specific requirements
IS_GOOGLE_CLOUD_NOTEBOOK = os.path.exists("/opt/deeplearning/metadata/env_version")
# Google Cloud Notebook requires dependencies to be installed with '--user'
USER_FLAG = ""
if IS_GOOGLE_CLOUD_NOTEBOOK:
USER_FLAG... |
521 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Parse Data to Tfrecord
This file parses bbox and confidence score from the tfrecord files generated by the storefront detector model on the UCF dataset... | <ASSISTANT_TASK:>
Python Code:
from parse_data_to_tfrecord_lib import read_tfrecord, write_tfrecord_from_images, filter_image_with_confidence_threshold, batch_read_write_tfrecords
import numpy as np
import tensorflow as tf
import os # used for directory operations
from shutil import copyfile
tf.enable_eager_execution(... |
522 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Yet another random forest script, this time with simple cross validation
Import stuffs, prepare your data and the submission file
Step1: Main part
Ste... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
train = pd.read_csv("data/train.csv", dtype={"Age": np.float64}, )
test = pd.read_csv("data/test.csv", dtype={"Age": np.float64}, )
def harmonize_data(titanic):
titanic["Age"] = titanic["Age"].fillna(titanic["Age"].median())
titanic["Ag... |
523 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
1) Make a request from the Forecast.io API for where you were born (or lived, or want to visit!).
Tip
Step1: 2) What's the current wind speed? How muc... | <ASSISTANT_TASK:>
Python Code:
#api KEY = c9d64e80aa02ca113562a075e57256d7
https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036
import requests
response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036")
forecast = response.json()
print(fore... |
524 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Práctica 4 - Control
En este documento se van a importar las librerias necesarias para graficar los datos simulados por medio de los métodos numéricos ... | <ASSISTANT_TASK:>
Python Code:
from robots.robots import Robot
from numpy import pi
Explanation: Práctica 4 - Control
En este documento se van a importar las librerias necesarias para graficar los datos simulados por medio de los métodos numéricos descritos en el documento (numerico.ipynb).
Este documento debe estar ab... |
525 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
<a href="https
Step2: Environment
Step3: Try out Environment
Step4: Baseline
Step5: Train model
Estimation
* total cost when travelling all paths (... | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/openai/baselines >/dev/null
!pip install gym >/dev/null
Explanation: <a href="https://colab.research.google.com/github/DJCordhose/ai/blob/master/notebooks/rl/berater-v11-higher.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/c... |
526 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
First we import some libraries. Libraries (such as matplotlib, os, pandas, urllib) allow you to do more things than with Python's base functionality. T... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('seaborn')
Explanation: First we import some libraries. Libraries (such as matplotlib, os, pandas, urllib) allow you to do more things than with Python's base functionality. They contain functions that have specific purposes... |
527 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
ETL with PySpark SQL
Step1: Importing and creating SparkSession
Step2: Setting filesystem and files
Load all CSV's files from HiggsTwitter dataset (h... | <ASSISTANT_TASK:>
Python Code:
import os
import sys
os.environ["SPARK_HOME"] = "/Users/projects/.pyenv/versions/3.7.10/envs/tatapower/lib/python3.7/site-packages/pyspark"
# os.environ["HADOOP_HOME"] = ""
# os.environ["PYSPARK_PYTHON"] = "/opt/cloudera/parcels/Anaconda/bin/python"
# os.environ["JAVA_HOME"] = "/usr/java/... |
528 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Week 4. Training Issues
In this part, we will formally set up a simple but powerful classification network, to recogize 0-9 nubmers in MNIST dataset. ... | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
Explanation: Week 4. Training Issues
In this part, we will formally set up a simple but powerful classification network, to recogize 0-9 nubmers in MNIST dataset.
Yep, we will build a classification network and train from scratch.
We would introduce... |
529 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Copyright 2021 The TF-Agents Authors.
Step1: REINFORCE agent
<table class="tfo-notebook-buttons" align="left">
<td>
<a target="_blank" href="htt... | <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... |
530 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Creating summary statistics with tableone
This document demonstrates how the tableone package can be used to create a table of summary statistics for a... | <ASSISTANT_TASK:>
Python Code:
# Import libraries
from tableone import TableOne
import pandas as pd
import matplotlib.pyplot as plt
import psycopg2
import getpass
%matplotlib inline
plt.style.use('ggplot')
Explanation: Creating summary statistics with tableone
This document demonstrates how the tableone package can be... |
531 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Deep Convolutional GANs
In this notebook, you'll build a GAN using convolutional layers in the generator and discriminator. This is called a Deep Convo... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat
import tensorflow as tf
!mkdir data
Explanation: Deep Convolutional GANs
In this notebook, you'll build a GAN using convolutional layers in the generator and discriminat... |
532 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Lecture 3
Step1: It's easy to determine the name of the variable; in this case, the name is $x$. It can be a bit more complicated to determine the typ... | <ASSISTANT_TASK:>
Python Code:
x = 2
Explanation: Lecture 3: Python Variables and Syntax
CSCI 1360E: Foundations for Informatics and Analytics
Overview and Objectives
In this lecture, we'll get into more detail on Python variables, as well as language syntax. By the end, you should be able to:
Define variables of strin... |
533 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
A Two-Level, Three-Factor Full Factorial Design
<br />
<br />
<br />
Table of Contents
Introduction
Factorial Experimental Design
Step1: Box and Drape... | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from numpy.random import rand
Explanation: A Two-Level, Three-Factor Full Factorial Design
<br />
<br />
<br />
Table of Contents
Introduction
Factorial Experimental Design:
Two-Level Three-Factor Full Factorial Design
Design of the Experiment
Inputs... |
534 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
New experimental MS2LDA workflow
Based on Luigi, a Python-based pipeline engine. Also see the slides here.
Pros
Step1: These are what we want from the... | <ASSISTANT_TASK:>
Python Code:
import luigi as lg
import json
import pickle
import sys
basedir = '/Users/joewandy/git/lda/code/'
sys.path.append(basedir)
from multifile_feature import SparseFeatureExtractor
from lda import MultiFileVariationalLDA
Explanation: New experimental MS2LDA workflow
Based on Luigi, a Python-ba... |
535 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
ES-DOC CMIP6 Model Properties - Land
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
... | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'hammoz-consortium', 'sandbox-3', 'land')
Explanation: ES-DOC CMIP6 Model Properties - Land
MIP Era: CMIP6
Institute: HAMMOZ-CONSORTIUM
Source ID: SANDBOX-3
Topic: La... |
536 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Function isccsym
Description
Check if the input image is symmetric and return a boolean value.
Synopse
Check for conjugate symmetry
b = isccsym(F)
b
S... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def isccsym2(F):
if len(F.shape) == 1: F = F[np.newaxis,np.newaxis,:]
if len(F.shape) == 2: F = F[np.newaxis,:,:]
n,m,p = F.shape
x,y,z = np.indices((n,m,p))
Xnovo = np.mod(-1*x,n)
Ynovo = np.mod(-1*y,m)
Znovo = np.mod(-1*z,p)
aux = ... |
537 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Function Approximation
Previous we tried using manually created buckets to discretize continuous states, effectively mapping continuous observations to... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tempfile
import base64
import pprint
import random
import json
import sys
import gym
import io
from gym import wrappers
from collections import deque
from subprocess import check_output
from IPython.display impo... |
538 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Learning a sensorimotor model with a sensorimotor context
In this notebook, we will see how to use the Explauto libarary to allow the learning and cont... | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
from explauto.environment.simple_arm import SimpleArmEnvironment
from explauto.environment import environments
env_cls = SimpleArmEnvironment
env_conf = environments['simple_arm'][1]['low_dimensional']
Explanation: Learning a sensorimotor model with a... |
539 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Data Output
Similarly important to data input is data output. Using a data output module allows you to restructure and rename computed output and to sp... | <ASSISTANT_TASK:>
Python Code:
from nipype import SelectFiles, Node
# Create SelectFiles node
templates={'func': '{subject_id}/func/{subject_id}_task-flanker_run-1_bold.nii.gz'}
sf = Node(SelectFiles(templates),
name='selectfiles')
sf.inputs.base_directory = '/data/ds102'
sf.inputs.subject_id = 'sub-01'
Expla... |
540 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Solution to a problem posted here
Step1: Here are some example values for x and y. I assume that there are no repeated values in x.
Step2: indices i... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
Explanation: Solution to a problem posted here:
http://stackoverflow.com/questions/36455104/create-a-random-order-of-x-y-pairs-without-repeating-subsequent-xs#
Say I have a list of valid X = [1, 2, 3, 4, 5] and a list of valid Y = [1, 2, 3, 4, 5].
I need to generate all... |
541 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Algorithms Exercise 1
Imports
Step3: Word counting
Write a function tokenize that takes a string of English text returns a list of words. It should al... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
Explanation: Algorithms Exercise 1
Imports
End of explanation
def tokenize(s, stop_words=None, punctuation='`~!@#$%^&*()_-+={[}]|\:;"<,>.?/}\t'):
Split a string into a list of words, removing punctuation and st... |
542 | <SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
Given a pandas DataFrame, how does one convert several binary columns (where 0 denotes the value exists, 1 denotes it doesn't) into a single c... | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'A': [0, 1, 1, 1, 0, 1],
'B': [1, 0, 1, 1, 1, 0],
'C': [1, 1, 0, 1, 1, 1],
'D': [1, 1, 1, 0, 1, 1]})
df["category"] = df.idxmin(axis=1)
<END_TASK> |
543 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
A few things that work best/only at the IPython terminal or Qt console clients
Running code with %run
Step1: Event loop and GUI integration
The %gui m... | <ASSISTANT_TASK:>
Python Code:
%%writefile script.py
x = 10
y = 20
z = x+y
print('z is: %s' % z)
%run script
x
Explanation: A few things that work best/only at the IPython terminal or Qt console clients
Running code with %run
End of explanation
%gui qt
Explanation: Event loop and GUI integration
The %gui magic enables ... |
544 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Map of Flights Taken
The goal of this post is to visualize flights taken from Google location data using Python
* This post utilizes code from Tyler Ha... | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpl_toolkits.basemap import Basemap
from shapely.geometry import Point, Polygon, MultiPoint, MultiPolygon
from shapely.prepared import prep
import fiona
from matplotlib.collections import PatchCollection
from desc... |
545 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Kapr v medu
moto
Step1: Pokud vzpomínáte, tak ke sloupci T jsme přistupovali takto
Step2: Proč jsme nemohli jednoduše vykonat následující?
Step3: A... | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
data = pd.read_csv('data.csv')
data
Explanation: Kapr v medu
moto:
Spadne kapr do medu a říká:
"Hustý, to je hustý..."
Z.Janák, písemka z TM
Osnova
Úvod
Alias vs hodnota
String
Mutanti a nemutanti
Práce se souborem
Elegance pythonu
Závěrečné cvičení
Úvod
V této lekci... |
546 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Data Mining OCR PDFs - Using pdftabextract to liberate tabular data from scanned documents
This is an example on how to use pdftabextract for data mini... | <ASSISTANT_TASK:>
Python Code:
!cd data/ && pdftohtml -c -hidden -xml ALA1934_RR-excerpt.pdf ALA1934_RR-excerpt.pdf.xml
!ls -1 data/
!head -n 30 data/ALA1934_RR-excerpt.pdf.xml
Explanation: Data Mining OCR PDFs - Using pdftabextract to liberate tabular data from scanned documents
This is an example on how to use pdftab... |
547 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Distance Ladder Numerical and Data Exercises
2. Distances using RR Lyrae standard candles
Author
Step1: First, let's construst our query. We use the p... | <ASSISTANT_TASK:>
Python Code:
tables = Gaia.load_tables()
Explanation: Distance Ladder Numerical and Data Exercises
2. Distances using RR Lyrae standard candles
Author: Dave Mykytyn
The Clementini et al. 2018 RR Lyrae results are available from the Gaia data set, which we can access through the astroquery Python packa... |
548 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
网络科学简介
王成军
wangchengjun@nju.edu.cn
计算传播网 http
Step1: Directed
Links
Step2: <img src = './img/networks.png' width = 1000>
Degree, Average Degree and ... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import networkx as nx
Gu = nx.Graph()
for i, j in [(1, 2), (1, 4), (4, 2), (4, 3)]:
Gu.add_edge(i,j)
nx.draw(Gu, with_labels = True)
Explanation: 网络科学简介
王成军
wangchengjun@nju.edu.cn
计算传播网 http://computational-communication.com
FROM SA... |
549 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
This notebook demonstrates how systematic analysis of tally scores is possible using Pandas dataframes. A dataframe can be automatically generated usin... | <ASSISTANT_TASK:>
Python Code:
import glob
from IPython.display import Image
import matplotlib.pylab as pylab
import scipy.stats
import numpy as np
import openmc
from openmc.statepoint import StatePoint
from openmc.summary import Summary
%matplotlib inline
Explanation: This notebook demonstrates how systematic analysis... |
550 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Source localization with MNE/dSPM/sLORETA/eLORETA
The aim of this tutorial is to teach you how to compute and apply a linear
minimum-norm inverse metho... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.datasets import sample
from mne.minimum_norm import make_inverse_operator, apply_inverse
Explanation: Source localization with MNE/dSPM/sLORETA/eLORETA
The aim of this tutorial is to teach you how to compute and apply ... |
551 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Este código faz com que primeiramente toda a primeira linha seja preenchida, em seguida a segunda e assim sucessivamente. Se nós quiséssemos que a prim... | <ASSISTANT_TASK:>
Python Code:
def cria_matriz(num_linhas, num_colunas):
matriz = [] #lista vazia
for i in range(num_linhas):
linha = []
for j in range(num_colunas):
linha.append(0)
matriz.append(linha)
for i in range(num_colunas):
for j in range(num_linhas):
... |
552 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Visualize Raw data
Step1: The visualization module (
Step2: The channels are color coded by channel type. Generally MEG channels are
colored in diffe... | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import mne
data_path = op.join(mne.datasets.sample.data_path(), 'MEG', 'sample')
raw = mne.io.read_raw_fif(op.join(data_path, 'sample_audvis_raw.fif'),
add_eeg_ref=False)
raw.set_eeg_reference() # set EEG average reference
events = mne.read_... |
553 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Example to showcase how to and how not to use in-place modification of mutable sequence.
*Scenario 1
Step1: *Scenario 2 | <ASSISTANT_TASK:>
Python Code:
palPhrase = ['r', 'i', 's', 'e', 't', 'o', 'v', 'o', 't', 'e', 's', 'i', 'r']
newLoopCnt = 0
print "==" * 2 + "direct (in-place modification) operations on the list" + "==" * 2
print "Length of the list : %d" %(len(palPhrase))
for ee in palPhrase:
print "Counter {0}".format(newLoopCnt... |
554 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Miranda (2000) for firm soils
This methodology, proposed in Miranda (2000), aims to estimate the maximum lateral inelastic displacement demands on a st... | <ASSISTANT_TASK:>
Python Code:
from rmtk.vulnerability.derivation_fragility.equivalent_linearization.miranda_2000_firm_soils import miranda_2000_firm_soils
from rmtk.vulnerability.common import utils
%matplotlib inline
Explanation: Miranda (2000) for firm soils
This methodology, proposed in Miranda (2000), aims to esti... |
555 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
K-Nearest Neighbors (KNN)
by Chiyuan Zhang and Sören Sonnenburg
This notebook illustrates the <a href="http
Step1: Let us plot the first five exa... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.io import loadmat, savemat
from numpy import random
from os import path
mat = loadmat('../../../data/multiclass/usps.mat')
Xall = mat['data']
Yall = np.array(mat['label'].squeeze(), dtype=np.double)
# map from 1..10 to 0..9, since shogun
# requires ... |
556 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
计算传播与机器学习
王成军
wangchengjun@nju.edu.cn
计算传播网 http
Step1: 使用sklearn做logistic回归
王成军
wangchengjun@nju.edu.cn
计算传播网 http
Step2: 使用sklearn实现贝叶斯预测
王成军
wangc... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from sklearn import datasets
from sklearn import linear_model
import matplotlib.pyplot as plt
import sklearn
print sklearn.__version__
# boston data
boston = datasets.load_boston()
y = boston.target
' '.join(dir(boston))
boston['feature_names']
regr = linear_model.Linea... |
557 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
QuTiP example
Step1: Deviation form thermal
Step2: Software version | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from qutip import *
import time
#number of states for each mode
N0=8
N1=8
N2=8
K=1.0
#damping rates
gamma0=0.1
gamma1=0.1
gamma2=0.4
alpha=sqrt(3)#initial coherent state param for mode 0
epsilon=0.5j #sqeezing parameter
tfinal=4.0
dt=0.05
tlist=arange(0.0,tfinal+dt,dt)
tauli... |
558 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Title
Step1: Create some text
Step2: Apply regex | <ASSISTANT_TASK:>
Python Code:
# Load regex package
import re
Explanation: Title: Match Times
Slug: match_times
Summary: Match Times
Date: 2016-05-01 12:00
Category: Regex
Tags: Basics
Authors: Chris Albon
Based on: StackOverflow
Preliminaries
End of explanation
# Create a variable containing a text string
text = 'Ch... |
559 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Here we are going to replace the less common regiments with 'other'
Step1: LLQ | <ASSISTANT_TASK:>
Python Code:
regimen = clinical['Regimen Type'].ix[pts].dropna()
print regimen.value_counts()
regimen = regimen[regimen.map(regimen.value_counts()) > 10]
regimen = regimen.ix[pts].fillna('Other')
regimen = regimen.str.replace(' Based','')
regimen = regimen.ix[ti(duration != 'Control')]
regimen.value_c... |
560 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
M-Estimators for Robust Linear Modeling
Step1: An M-estimator minimizes the function
$$Q(e_i, \rho) = \sum_i~\rho \left (\frac{e_i}{s}\right )$$
wher... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
from statsmodels.compat import lmap
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import statsmodels.api as sm
Explanation: M-Estimators for Robust Linear Modeling
End of explanation
norms = sm.robust.no... |
561 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Working with source-receptor matrices using https
Step2: Prepare emissions
For this example, we are going to estimate the air pollution-related health... | <ASSISTANT_TASK:>
Python Code:
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from builtins import *
Explanation: Working with source-receptor matrices using https://inmap.run and GeoPandas in Python
Air pollution source-receptor matrices give relationships ... |
562 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
IonQ ProjectQ Backend Example
This notebook will walk you through a basic example of using IonQ hardware to run ProjectQ circuits.
Setup
The only requi... | <ASSISTANT_TASK:>
Python Code:
# NOTE: Optional! This ignores warnings emitted from ProjectQ imports.
import warnings
warnings.filterwarnings('ignore')
# Import ProjectQ and IonQBackend objects, the setup an engine
import projectq.setups.ionq
from projectq import MainEngine
from projectq.backends import IonQBackend
# R... |
563 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Excercises Electric Machinery Fundamentals
Chapter 1
Problem 1-19
Step1: Description
Figure P1-14 shows a simple single-phase ac power system with thr... | <ASSISTANT_TASK:>
Python Code:
%pylab notebook
%precision %.4g
Explanation: Excercises Electric Machinery Fundamentals
Chapter 1
Problem 1-19
End of explanation
V = 240 # [V]
Z1 = 10.0 * exp(1j* 30/180*pi)
Z2 = 10.0 * exp(1j* 45/180*pi)
Z3 = 10.0 * exp(1j*-90/180*pi)
Explanation: Description
Figure P1-14 shows ... |
564 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Manipulation de séries financières avec la classe StockPrices
La classe StockPrices facilite la récupération de données financières via différents site... | <ASSISTANT_TASK:>
Python Code:
import pyensae
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
Explanation: Manipulation de séries financières avec la classe StockPrices
La classe StockPrices facilite la récupération de données fi... |
565 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Trace Analysis Examples
Tasks Latencies
This notebook shows the features provided for task latency profiling. It will be necessary to collect the follo... | <ASSISTANT_TASK:>
Python Code:
import logging
from conf import LisaLogging
LisaLogging.setup()
# Generate plots inline
%matplotlib inline
import json
import os
# Support to access the remote target
import devlib
from env import TestEnv
# Support for workload generation
from wlgen import RTA, Ramp
# Support for trace an... |
566 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Diagram bifurkacyjny dla równania logistycznego $x \to a x (1-x)$
Równanie logistyczne jest niezwykle prostym równaniem iteracyjnym wykazującym zaskaku... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pycuda.gpuarray as gpuarray
from pycuda.curandom import rand as curand
from pycuda.compiler import SourceModule
import pycuda.driver as cuda
try:
ctx.pop()
ctx.detach()
except:
print ("No CTX!")
cuda.... |
567 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Code Testing and CI
The notebook contains problems about code testing and continuous integration with Travis CI.
Original by E Tollerud 2017 for LSSTC ... | <ASSISTANT_TASK:>
Python Code:
!conda install pytest pytest-cov
Explanation: Code Testing and CI
The notebook contains problems about code testing and continuous integration with Travis CI.
Original by E Tollerud 2017 for LSSTC DSFP Session3 and AstroHackWeek, modified by B Sipocz
Problem 1: Set up py.test in you repo
... |
568 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Create BigQuery stored procedures
This notebook is the second of two notebooks that guide you through completing the prerequisites for running the Real... | <ASSISTANT_TASK:>
Python Code:
!pip install -q -U google-cloud-bigquery pyarrow
Explanation: Create BigQuery stored procedures
This notebook is the second of two notebooks that guide you through completing the prerequisites for running the Real-time Item-to-item Recommendation with BigQuery ML Matrix Factorization and ... |
569 | <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: Task
Include the curvature as an extra parameter to your likelihood
Step4: Now let's analize the chains
First just an histogram
Step5: How to ... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.integrate as integrate
def E(z,OmDE,OmM):
This function computes the integrand for the computation of the luminosity distance for a flat universe
z -> float
OmDE -> float
OmM -> float
gives
E -> float
Omk=1-OmDE-OmM
... |
570 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Data Transformations
Step1: 1) List the top 10 customers who had the maximum usage of all products
Step2: 2) List the top 3 users who has the most nu... | <ASSISTANT_TASK:>
Python Code:
# Convert the string which has a list of values to an actual python list
df["Amount"] = df["Amount"].apply(json.loads)
# Create a new column which has the sum of production application
df["Total_Amount"] = df["Amount"].apply(sum)
# Create a new column for the number of entries
df["No_of_e... |
571 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Data loading, storage, and file formats
Python has become a beloved language for text and file munging due to its simple syntax for interacting with fi... | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
from numpy.random import randn
import numpy as np
import os
import sys
import matplotlib.pyplot as plt
np.random.seed(12345)
plt.rc('figure', figsize=(10, 6))
from pandas import Series, DataFrame
import pandas as pd
np.set_printoptions(precision=4)
%pwd
Exp... |
572 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Interact Exercise 2
Imports
Step1: Plotting with parameters
Write a plot_sin1(a, b) function that plots $sin(ax+b)$ over the interval $[0,4\pi]$.
Cust... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
Explanation: Interact Exercise 2
Imports
End of explanation
plt.xticks?
def plot_sin1(a,b):
x=np.linspace(0,4*np... |
573 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
<h1>Building game trees</h1>
<i>Theodore L. Turocy</i><br/>
<i>University of East Anglia</i>
<br/><br/>
<h3>EC'16 Workshop
24 July 2016</h3>
Step1: On... | <ASSISTANT_TASK:>
Python Code:
import gambit
Explanation: <h1>Building game trees</h1>
<i>Theodore L. Turocy</i><br/>
<i>University of East Anglia</i>
<br/><br/>
<h3>EC'16 Workshop
24 July 2016</h3>
End of explanation
g = gambit.Game.new_tree()
g.title = "A simple poker example"
Explanation: One can build up extensive ... |
574 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Computable Document prototype
Step1: Preprocessing
Step2: Visualization of ELC usage data
Now that the ELC visit data has been cast into the appropri... | <ASSISTANT_TASK:>
Python Code:
#@title
#%%capture
import numpy as np #Linear algebra
import pandas as pd #Time series, datetime object manipulation
import matplotlib.pyplot as plt #plotting
#import seaborn as sb
#plt.style.use('fivethirtyeight') #Plot style preferred by author.
import calendar
from tabulate import tab... |
575 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
The LightCurve class
Background
What kind of physical data are we representing and what do these quantities mean?
Astrophysical variable sources includ... | <ASSISTANT_TASK:>
Python Code:
import sncosmo
import analyzeSN as ans
import numpy as np
from analyzeSN import LightCurve
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
Explanation: The LightCurve class
Background
What kind of physical data are we representing and what do these quant... |
576 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
DAC-ADC Pmod Examples using Matplotlib and Widget
Contents
Pmod DAC-ADC Feedback
Tracking the IO Error
Error plot with Matplotlib
Widget controlled plo... | <ASSISTANT_TASK:>
Python Code:
from pynq.overlays.base import BaseOverlay
from pynq.lib import Pmod_ADC, Pmod_DAC
Explanation: DAC-ADC Pmod Examples using Matplotlib and Widget
Contents
Pmod DAC-ADC Feedback
Tracking the IO Error
Error plot with Matplotlib
Widget controlled plot
Pmod DAC-ADC Feedback
This example shows... |
577 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Steps to use the TF Estimator APIs
Define dataset metadata
Define data input function to read the data from Pandas dataframe + apply feature processing... | <ASSISTANT_TASK:>
Python Code:
MODEL_NAME = 'reg-model-01'
TRAIN_DATA_FILE = 'data/train-data.csv'
VALID_DATA_FILE = 'data/valid-data.csv'
TEST_DATA_FILE = 'data/test-data.csv'
RESUME_TRAINING = False
PROCESS_FEATURES = True
MULTI_THREADING = False
Explanation: Steps to use the TF Estimator APIs
Define dataset metadata... |
578 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Autoregressive Moving Average (ARMA)
Step1: Sunpots Data
Step2: Does our model obey the theory?
Step3: This indicates a lack of fit.
In-sample dynam... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
import numpy as np
from scipy import stats
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
from statsmodels.graphics.api import qqplot
Explanation: Autoregressive Moving Average (ARMA): Sunspots data... |
579 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Load and pre-process data
Step1: Impute PE
First, I will impute PE by replacing missing values with the mean PE. Second, I will impute PE using a rand... | <ASSISTANT_TASK:>
Python Code:
from sklearn import preprocessing
filename = '../facies_vectors.csv'
train = pd.read_csv(filename)
# encode well name and formation features
le = preprocessing.LabelEncoder()
train["Well Name"] = le.fit_transform(train["Well Name"])
train["Formation"] = le.fit_transform(train["Formation"]... |
580 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Copyright 2021 Google LLC
Step1: Graph regularization for image classification using synthesized graphs
By Sayak Paul
<br>
<table class="tfo-notebook-... | <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... |
581 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Training a FFNN in dCGPANN vs. Keras (regression)
A Feed Forward Neural network is a widely used ANN model for regression and classification. Here we s... | <ASSISTANT_TASK:>
Python Code:
# Initial import
import dcgpy
# For plotting
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
# For scientific computing and more ...
import numpy as np
from tqdm import tqdm
f... |
582 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Chapter 2
Modeling and Simulation in Python
Copyright 2021 Allen Downey
License
Step1: This chapter presents a simple model of a bike share system and... | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import exists
filename = 'modsim.py'
if not exists(filename):
from urllib.request import urlretrieve
url = 'https://raw.githubusercontent.com/A... |
583 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
In this lab session we will learn how to pre-process feature vectors using numpy. For this purpose, lets create 10 feature vectors that have 5 features... | <ASSISTANT_TASK:>
Python Code:
import numpy
X = numpy.random.randn(10, 5)
Explanation: In this lab session we will learn how to pre-process feature vectors using numpy. For this purpose, lets create 10 feature vectors that have 5 features. We use numpy.random for generating these examples.
End of explanation
print X
Ex... |
584 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Data Boot-Camp Final Project
American Time Use Study (ATUS)
Sravya Boddu (sb5933), Sonal Jadwani (sj2280), Vineetha Kutty (vkk242) | May 5th, 2017
<img... | <ASSISTANT_TASK:>
Python Code:
# Importing all the required libraries
%matplotlib inline
import sys
import pandas as pd # data manipulation package
import datetime as dt # date tools, used to note current date
import matplotlib.pyplot as plt # graphics package
import matplotlib as m... |
585 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
<p style="font-size
Step1: Keeping the respository updated
Once you cloned the repository you can download any updates with a single command git pull
... | <ASSISTANT_TASK:>
Python Code:
%%sh
cd
ls -la
Explanation: <p style="font-size:16pt; font-weight:bold; color:red; padding-bottom:20px; float:right">Please rename this file before editing!</p>
Introduction
The objective of this session is to introduce some basic steps on how to work in our computing environment using t... |
586 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel$\rightarrow$Restart) a... | <ASSISTANT_TASK:>
Python Code:
NAME = "Alyssa P. Hacker"
COLLABORATORS = "Ben Bitdiddle"
Explanation: Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel$\rightarrow$Restart) and then run all cells (in the menubar, select Cell$\rightarrow$Run ... |
587 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Introduction
Now that you've built a baseline model, you are ready to improve it with some clever ways to work with categorical variables.
You are alr... | <ASSISTANT_TASK:>
Python Code:
#$HIDE_INPUT$
import pandas as pd
from sklearn.preprocessing import LabelEncoder
ks = pd.read_csv('../input/kickstarter-projects/ks-projects-201801.csv',
parse_dates=['deadline', 'launched'])
# Drop live projects
ks = ks.query('state != "live"')
# Add outcome column, "suc... |
588 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Companion notebook of the paper Fast sampling of $\beta$-ensembles
by Guillaume Gautier, Rémi Bardenet, and Michal Valko
See also the arXiv preprint
St... | <ASSISTANT_TASK:>
Python Code:
# !pip install dppy
Explanation: Companion notebook of the paper Fast sampling of $\beta$-ensembles
by Guillaume Gautier, Rémi Bardenet, and Michal Valko
See also the arXiv preprint: 2003.02344
<h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item">... |
589 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
<a href="https
Step1: Question 3
Display first 5 rows of the loaded data
Step2: ...and do a short summary about the data;
The resultant table comes f... | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
deaths_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv')
Explanation: <a href="https://colab.research.google.com/github/timomwa/50ForReel/blob/master/I... |
590 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
The Hipster Effect
Step2: This gives us a nice way to move from our preference $x_i$ to a probability of switching styles. Here $\beta$ is inversely r... | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import holoviews as hv
hv.notebook_extension(bokeh=True, width=90)
%%output backend='matplotlib'
%%opts NdOverlay [aspect=1.5 figure_size=200 legend_position='top_left']
x = np.linspace(-1, 1, 1000)
curves = hv.NdOverlay(key_dimensions=['$\\beta$'])
for beta in [0.1, 0.... |
591 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
MODULE 2
Introduction to Pytorch
Pytorch is a library that looks a lot like numpy. It deals with tensors and manipulation of tensors.
PyTorch Setup
Ste... | <ASSISTANT_TASK:>
Python Code:
!python -V
#!pip3 install torch torchvision
import torch
print("PyTorch version: ")
torch.__version__
print("Device Name: ")
torch.cuda.get_device_name(0)
print("CUDA Version: ")
print(torch.version.cuda)
print("cuDNN version is: ")
print(torch.backends.cudnn.version())
# NVIDIA profiling... |
592 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Symbulate Lab 4 - Poisson Processes
This Jupyter notebook provides a template for you to fill in. Read the notebook from start to finish, completing t... | <ASSISTANT_TASK:>
Python Code:
from symbulate import *
%matplotlib inline
Explanation: Symbulate Lab 4 - Poisson Processes
This Jupyter notebook provides a template for you to fill in. Read the notebook from start to finish, completing the parts as indicated. To run a cell, make sure the cell is highlighted by clicki... |
593 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Autoregressive Moving Average (ARMA)
Step1: Sunpots Data
Step2: Does our model obey the theory?
Step3: This indicates a lack of fit.
In-sample dynam... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
import numpy as np
from scipy import stats
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
from statsmodels.graphics.api import qqplot
Explanation: Autoregressive Moving Average (ARMA): Sunspots data... |
594 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Exercise 05
Logistic regression exercise to detect network intrusions
Software to detect network intrusions protects a computer network from unauthoriz... | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
pd.set_option('display.max_columns', 500)
import zipfile
with zipfile.ZipFile('../datasets/UNB_ISCX_NSL_KDD.csv.zip', 'r') as z:
f = z.open('UNB_ISCX_NSL_KDD.csv')
data = pd.io.parsers.read_table(f, sep=',')
data.head()
Explanation: Exercise 05
Logistic regress... |
595 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Introduction
Let's say y = f(x_1, x_2, ..., x_n)
If f is a mathematical function of x_1, x_2, x_3, ..., x_n then we can wire up a neural network to try... | <ASSISTANT_TASK:>
Python Code:
# Let's try to find the equation y = 2 * x
# We have 6 examples:- (x,y) = (0.1,0.2), (1,2), (2, 4), (3, 6), (-4, -8), (25, 50)
# Let's assume y is a linear combination of the features x, x^2, x^3
# We know that Normal Equation gives us the exact solution so let's first use that
N = 6
x =... |
596 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Comparison of criteria for correlating hits
This notebook shows how to use the KM3Net package to compare two different criteria for correlating L0 hits... | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as pyplot
from km3net.kernels import QuadraticDifferenceSparse, PurgingSparse
import km3net.util as util
window_width = 1500
N,x,y,z,ct = util.get_real_input_data("sample1.txt")
print ("Read", N, "hits from file")
Explanation:... |
597 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Recommendations on GCP with TensorFlow and WALS with Cloud Composer
This lab is adapted from the original solution created by lukmanr
This project dep... | <ASSISTANT_TASK:>
Python Code:
%%bash
pip install sh --upgrade pip # needed to execute shell scripts later
Explanation: Recommendations on GCP with TensorFlow and WALS with Cloud Composer
This lab is adapted from the original solution created by lukmanr
This project deploys a solution for a recommendation service on G... |
598 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Molpher-lib
New features in the 0.0.0b2dev0 development snapshot.
Initialization of a molecule using a string representation (SMILES and SDF file path ... | <ASSISTANT_TASK:>
Python Code:
from molpher.core import MolpherMol
cymene_smiles = MolpherMol("CC1=CC=C(C(C)C)C=C1")
print(cymene_smiles.smiles)
cymene_sdf = MolpherMol("cymene.sdf") # if the string ends with '.sdf', the library interprets it as a path to a file
print(cymene_sdf.smiles)
Explanation: Molpher-lib
New fea... |
599 | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Face Recognition for the Happy House
Welcome to the first assignment of week 4! Here you will build a face recognition system. Many of the ideas presen... | <ASSISTANT_TASK:>
Python Code:
from keras.models import Sequential
from keras.layers import Conv2D, ZeroPadding2D, Activation, Input, concatenate
from keras.models import Model
from keras.layers.normalization import BatchNormalization
from keras.layers.pooling import MaxPooling2D, AveragePooling2D
from keras.layers.mer... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.