Unnamed: 0
int64
0
16k
text_prompt
stringlengths
110
62.1k
code_prompt
stringlengths
37
152k
12,600
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction to Logistic Regression Learning Objectives Create Seaborn plots for Exploratory Data Analysis Train a Logistic Regression Model using Scikit-Learn Introduction This lab is in i...
Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst import os import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns %matplotlib inline Explanation: Introduction to Logistic Regression Learning Objectives Create Seaborn plots for Exploratory Data Analysi...
12,601
Given the following text description, write Python code to implement the functionality described below step by step Description: <h1 align="center">Mention Detection</h1> <h4 align="center">Jiarui Xu - jxu57@illinois.edu</h4> Step3: 1 Wikidata Alias In this section, we use wikidata to build lexicon, if a n-gram exist...
Python Code: import json import pyprind import sys import pickle data_folder = "/Volumes/backup/ccg_tweet_wikifier_data/" wikidata_file = "/Volumes/backup/ccg_tweet_wikifier_data/wikidata/wikidata-20160404-all.json" entity_alias_output_file = data_folder+"wikidata/entity_alias.txt" from corenlp import * corenlp = Stanf...
12,602
Given the following text description, write Python code to implement the functionality described below step by step Description: MODICE v04 area by country, 2000-2014 Step1: Reorder columns, descending area Use the first row of data to order the columns in descending area order Step2: Get 1 and 2strike data also Ste...
Python Code: import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import pandas as pd %pylab inline filename = 'modice_v4_3strikes_by_country_by_yr.txt' df3 = pd.read_csv( filename, delim_whitespace=True, index_col=0 ) df3 Explanation: MODICE v04 area by country, 2000-2014 End of explanation sort...
12,603
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2019 The TensorFlow Authors. Step1: 用 tf.data 加载 CSV 数据 <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step2: 加载数据 开始的时候,我们通过打印 CSV 文...
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 writing, software # dist...
12,604
Given the following text description, write Python code to implement the functionality described below step by step Description: Components We store our component functions inside the pp.components module. Each function there returns a Component object You can use dir or help over the pp.c module to see the all availa...
Python Code: import pp c = pp.c.mzi() pp.qp(c) c.ports c = pp.c.ring_single_bus() pp.qp(c) Explanation: Components We store our component functions inside the pp.components module. Each function there returns a Component object You can use dir or help over the pp.c module to see the all available components. Some of wh...
12,605
Given the following text description, write Python code to implement the functionality described below step by step Description: Bloques Faltantes Busco el nombre de los bloques faltantes Step1: Bloques Faltantes Primero, veo si puedo sacar el bloque de los otros años Step2: Scrapeo del Sitio de Senadores Los bloque...
Python Code: import difflib import requests import pandas as pd from bs4 import BeautifulSoup Explanation: Bloques Faltantes Busco el nombre de los bloques faltantes End of explanation # Join de todos los otros años csvs = ['../viajes_2012.csv', '../viajes_2015.csv', '../viajes_2016.csv', '../viajes_2017.csv'] for cnt,...
12,606
Given the following text description, write Python code to implement the functionality described below step by step Description: Combine a Matplotlib Basemap with IPython Widgets This is an experiment in creating a Jupyter notebook showing a world map with different parameters (including map projection) by combining a...
Python Code: # Make plots appear inline (inside the Jupyter notebook). %matplotlib inline import datetime import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap, supported_projections from ipywidgets import interact, interact_manual, FloatSlider Explanation: Combine a Matplotlib Bas...
12,607
Given the following text description, write Python code to implement the functionality described below step by step Description: Timestamps are contained in the Space Packet secondary header time code field. They are encoded as big-endian 32-bit integers counting the number of seconds elapsed since the J2000 epoch (20...
Python Code: def timestamps(packets): epoch = np.datetime64('2000-01-01T12:00:00') t = np.array([struct.unpack('>I', p[ccsds.SpacePacketPrimaryHeader.sizeof():][:4])[0] for p in packets], 'uint32') return epoch + t * np.timedelta64(1, 's') def load_frames(path): frame_size = 223 * 5 - ...
12,608
Given the following text description, write Python code to implement the functionality described below step by step Description: <table align="left"> <td> <a href="https Step1: Restart the kernel After you install the additional packages, you need to restart the notebook kernel so it can find the packages. Step...
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 = "--user" ! pip3...
12,609
Given the following text description, write Python code to implement the functionality described below step by step Description: Aufgaben zur personal-Datenbank Step1: Welcher Mitarbeiter steht in einer alphabetisch sortierten Liste an letzter Stelle? Es sollen die Mitarbeiternummer, der Nachname und der Vorname ange...
Python Code: %load_ext sql %sql mysql://steinam:steinam@localhost/personal Explanation: Aufgaben zur personal-Datenbank End of explanation %%sql select MNr, MName, MVorname from Mitarbeiter order by MName desc limit 1; Explanation: Welcher Mitarbeiter steht in einer alphabetisch sortierten Liste an letzter Stelle? Es ...
12,610
Given the following text description, write Python code to implement the functionality described below step by step Description: Exporting data from BigQuery to Google Cloud Storage In this notebook, we export BigQuery data to GCS so that we can reuse our Keras model that was developed on CSV data. Step1: Please igno...
Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst %pip install google-cloud-bigquery==1.25.0 Explanation: Exporting data from BigQuery to Google Cloud Storage In this notebook, we export BigQuery data to GCS so that we can reuse our Keras model that was developed on CSV data. End of explan...
12,611
Given the following text description, write Python code to implement the functionality described below step by step Description: Benchmarking MLDB This notebook contains the code to run "The Absolute Minimum Benchmark" for a machine learning tool. First we load the Python MLDB helper library Step1: Next we create the...
Python Code: from pymldb import Connection mldb = Connection("http://localhost/") Explanation: Benchmarking MLDB This notebook contains the code to run "The Absolute Minimum Benchmark" for a machine learning tool. First we load the Python MLDB helper library End of explanation mldb.put('/v1/procedures/import_bench_trai...
12,612
Given the following text description, write Python code to implement the functionality described below step by step Description: Plot point-spread functions (PSFs) and cross-talk functions (CTFs) Visualise PSF and CTF at one vertex for sLORETA. Step1: Visualize PSF Step2: CTF
Python Code: # Authors: Olaf Hauk <olaf.hauk@mrc-cbu.cam.ac.uk> # Alexandre Gramfort <alexandre.gramfort@inria.fr> # # License: BSD-3-Clause import mne from mne.datasets import sample from mne.minimum_norm import (make_inverse_resolution_matrix, get_cross_talk, get_point_spread) p...
12,613
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction This tutorial gives a short overview of the AD-module included in PorePy. For an example where the AD module has been used to solve non-linear compressible flow, see the tutoria...
Python Code: import numpy as np import scipy.sparse as sps from porepy.numerics.ad.forward_mode import Ad_array import porepy.numerics.ad.functions as af Explanation: Introduction This tutorial gives a short overview of the AD-module included in PorePy. For an example where the AD module has been used to solve non-line...
12,614
Given the following text description, write Python code to implement the functionality described below step by step Description: Markov decision processes (MDPs) This IPy notebook acts as supporting material for topics covered in Chapter 17 Making Complex Decisions of the book Artificial Intelligence Step1: CONTENTS ...
Python Code: from mdp import * from notebook import psource, pseudocode Explanation: Markov decision processes (MDPs) This IPy notebook acts as supporting material for topics covered in Chapter 17 Making Complex Decisions of the book Artificial Intelligence: A Modern Approach. We makes use of the implementations in mdp...
12,615
Given the following text description, write Python code to implement the functionality described below step by step Description: interp-acf demo Generate time series fluxes with two oscillation periods, and missing data Step1: Now we'll use two interpacf methods on these simulated fluxes Step2: Comparing with McQuil...
Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np # Make flux time-series with random noise, and # two periodic oscillations, one 70% the amplitude # of the other: np.random.seed(42) n_points = 1000 primary_period = 2.5*np.pi secondary_period = 1.3*np.pi all_times = np.linspace(0, 6*np...
12,616
Given the following text description, write Python code to implement the functionality described below step by step Description: a) Which thrillers were directed by Steven Spielberg? Step1: b) Who acted in at least 20 different films? Step2: c) List all shows of “Alice in Wonderland”. Step3: d) Who acted in his/her...
Python Code: cur.execute('''SELECT film.title FROM film, person, participation WHERE film.genre LIKE '%Thriller%' AND film.id = participation.film AND person.id = participation.person AND participation.function = "director" AND...
12,617
Given the following text description, write Python code to implement the functionality described below step by step Description: Lab 3 - Basic Artificial Neural Network In this lab we will build a very rudimentary Artificial Neural Network (ANN) and use it to solve some basic classification problems. This example is i...
Python Code: %matplotlib inline import random import numpy as np import matplotlib.pyplot as plt import seaborn as sns; sns.set(style="ticks", color_codes=True) from sklearn.preprocessing import OneHotEncoder from sklearn.utils import shuffle Explanation: Lab 3 - Basic Artificial Neural Network In this lab we will buil...
12,618
Given the following text description, write Python code to implement the functionality described below step by step Description: <h2 align="center">点击下列图标在线运行HanLP</h2> <div align="center"> <a href="https Step1: 加载模型 HanLP的工作流程是先加载模型,模型的标示符存储在hanlp.pretrained这个包中,按照NLP任务归类。 Step2: 调用hanlp.load进行加载,模型会自动下载到本地缓存。自...
Python Code: !pip install hanlp -U Explanation: <h2 align="center">点击下列图标在线运行HanLP</h2> <div align="center"> <a href="https://colab.research.google.com/github/hankcs/HanLP/blob/doc-zh/plugins/hanlp_demo/hanlp_demo/zh/sdp_mtl.ipynb" target="_blank"><img src="https://colab.research.google.com/assets/colab-badge.svg" ...
12,619
Given the following text description, write Python code to implement the functionality described below step by step Description: Calculate quantities for analysis These notebooks describe how to calculate the data and how to produce figures in the manuscript "Barnaba Step1: Now we calculate all the quantitites descr...
Python Code: import barnaba as bb import pickle top = "topology.pdb" traj = "trajectory.dcd" native = "2KOC.pdb" Explanation: Calculate quantities for analysis These notebooks describe how to calculate the data and how to produce figures in the manuscript "Barnaba: Software for Analysis of Nucleic Acids Structures a...
12,620
Given the following text description, write Python code to implement the functionality described below step by step Description: Keen readers of this blog (hi Mom!) might have noticed my recent focus on neural networks and deep learning. It's good for popularity, as deep learning posts are automatically cool (I'm real...
Python Code: import scrapy import re # for text parsing import logging class ChartSpider(scrapy.Spider): name = 'ukChartSpider' # page to scrape start_urls = ['http://www.officialcharts.com/charts/'] # if you want to impose a delay between sucessive scrapes # download_delay = 0.5 def parse(self, ...
12,621
Given the following text description, write Python code to implement the functionality described below step by step Description: TensorFlow Tutorial #13-B Visual Analysis (MNIST) by Magnus Erik Hvass Pedersen / GitHub / Videos on YouTube Introduction Tutorial #13 showed how to find input images that maximized the resp...
Python Code: %matplotlib inline import matplotlib.pyplot as plt import tensorflow as tf import numpy as np from sklearn.metrics import confusion_matrix import math Explanation: TensorFlow Tutorial #13-B Visual Analysis (MNIST) by Magnus Erik Hvass Pedersen / GitHub / Videos on YouTube Introduction Tutorial #13 showed h...
12,622
Given the following text description, write Python code to implement the functionality described below step by step Description: <figure> <IMG SRC="../../logo/logo.png" WIDTH=250 ALIGN="right"> </figure> IHE Python course, 2017 Time series manipulation T.N.Olsthoorn, April 18, 2017 Most scientists and engineers, in...
Python Code: import pandas as pd import matplotlib.pyplot as plt import numpy as np Explanation: <figure> <IMG SRC="../../logo/logo.png" WIDTH=250 ALIGN="right"> </figure> IHE Python course, 2017 Time series manipulation T.N.Olsthoorn, April 18, 2017 Most scientists and engineers, including hydrologists, physisists,...
12,623
Given the following text description, write Python code to implement the functionality described below step by step Description: Advanced Step1: MPI Modes As of the 2.1 release, PHOEBE officially support parallelization using MPI within run_compute. The 2.3 release introduced support for run_solver, including suppor...
Python Code: #!pip install -I "phoebe>=2.3,<2.4" import phoebe Explanation: Advanced: Running PHOEBE in MPI Setup Let's first make sure we have the latest version of PHOEBE 2.3 installed (uncomment this line if running in an online notebook session such as colab). End of explanation print(phoebe.mpi.enabled) print(phoe...
12,624
Given the following text description, write Python code to implement the functionality described below step by step Description: comment data 가져오기 및 전처리 Step1: user dataframe 만들기 Step2: user, book 인덱스 및 처리 Step3: user * book matrix 만들기 Step5: user * user cosine similarity 매트릭스 만들기 1 권 169464 명 1분 59초 2 권 57555 명...
Python Code: episode_comment = pd.read_csv("data/webnovel/episode_comments.csv", index_col=0, encoding="cp949") episode_comment["ID"] = episode_comment["object_id"].apply(lambda x: x.split("-")[0]) episode_comment["volume"] = episode_comment["object_id"].apply(lambda x: x.split("-")[1]).astype("int") episode_comment["w...
12,625
Given the following text description, write Python code to implement the functionality described below step by step Description: Matplotlib tutorial 02 Step1: Checking and Defining the Range of Axes Step2: "linspace" to Define X Values linspace can be used to create evenly spaced numbers over a specified interva...
Python Code: # import import numpy as np import matplotlib.pyplot as plt %matplotlib inline # generating some data points X = np.linspace(-np.pi, np.pi, 20, endpoint=True) C, S = np.cos(X), np.sin(X) # Simply plotting these in same plot plt.plot(X, C, X, S) plt.plot(X, C, X, C, 'oy', X, S, ...
12,626
Given the following text description, write Python code to implement the functionality described below step by step Description: Vector-space models Step1: Contents Overview Set-up The retrofitting model Examples Only node 0 has outgoing edges All nodes connected to all others As before, but now 2 has no outgoing edg...
Python Code: __author__ = "Christopher Potts" __version__ = "CS224u, Stanford, Spring 2022" Explanation: Vector-space models: retrofitting End of explanation from collections import defaultdict from nltk.corpus import wordnet as wn import numpy as np import os import pandas as pd import retrofitting from retrofitting i...
12,627
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2020 The TensorFlow Authors. Step1: 量化感知训练综合指南 <table class="tfo-notebook-buttons" align="left"> <td><a target="_blank" href="https Step2: 定义量化感知模型 通过按以下方式定义模型,可以获得概述页面中所列后端的部署...
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 writing, software # dist...
12,628
Given the following text description, write Python code to implement the functionality described below step by step Description: <a href="https Step1: Chapter 7 - Sets This chapter will introduce a different kind of container Step2: Curly brackets surround sets, and commas separate the elements in the set A set can ...
Python Code: %%capture !wget https://github.com/cltl/python-for-text-analysis/raw/master/zips/Data.zip !wget https://github.com/cltl/python-for-text-analysis/raw/master/zips/images.zip !wget https://github.com/cltl/python-for-text-analysis/raw/master/zips/Extra_Material.zip !unzip Data.zip -d ../ !unzip images.zip -d ....
12,629
Given the following text description, write Python code to implement the functionality described below step by step Description: DMP tutorial Introduction Dynamical movement primitives are dynamical systems that provide a means of robust, generalizable trajectory generation. I give an overview of their origins formall...
Python Code: import numpy as np import nengo model = nengo.Network() with model: # linearly increasing system with an oscillatory biased input ramp_osc = nengo.Ensemble(n_neurons=500, dimensions=2, radius=.01) # recurrent connections nengo.Connection(ramp_osc, ramp_osc, transform=np.e...
12,630
Given the following text description, write Python code to implement the functionality described below step by step Description: What-If Tool Image Smile Detection In this demo we demonstrate the use of what-if-tool for image recognition models. Our task is to predict if a person is smiling or not. We provide a CNN th...
Python Code: # Ensure the right version of Tensorflow is installed. !pip freeze | grep tensorflow==2.1 Explanation: What-If Tool Image Smile Detection In this demo we demonstrate the use of what-if-tool for image recognition models. Our task is to predict if a person is smiling or not. We provide a CNN that is trained ...
12,631
Given the following text description, write Python code to implement the functionality described below step by step Description: https Step1: 3 Step2: 4 Step3: 5
Python Code: # %sh # # download source file # wget https://raw.githubusercontent.com/fivethirtyeight/data/master/college-majors/all-ages.csv # wget https://raw.githubusercontent.com/fivethirtyeight/data/master/college-majors/recent-grads.csv # ls -l import pandas as pd all_ages = pd.read_csv("all-ages.csv") print all_a...
12,632
Given the following text description, write Python code to implement the functionality described. Description: Bitwise OR ( ) of all even number from 1 to N Function to return the bitwise OR of all the even numbers upto N ; Initialize result as 2 ; Driver code
Python Code: def bitwiseOrTillN(n ) : result = 2 ; for i in range(4 , n + 1 , 2 ) : result = result | i  return result  n = 10 ; print(bitwiseOrTillN(n ) ) ;
12,633
Given the following text description, write Python code to implement the functionality described below step by step Description: Getting ready to implement the Schelling model Goal for this assignment The goal of this assignment is to finish up the two functions that you started in class on the first day of this proje...
Python Code: # Put your code here, using additional cells if necessary. import random import math def initialize_list(array_size=32, randseed=8675309): ''' This function optionally takes in an array size and random seed and returns the initial neighborhood that we're going to start from - a string of z...
12,634
Given the following text description, write Python code to implement the functionality described below step by step Description: <small><i>This notebook was prepared by Donne Martin. Source and license info is on GitHub.</i></small> Challenge Notebook Problem Step1: Unit Test The following unit test is expected to fa...
Python Code: class Node(object): def __init__(self, data): # TODO: Implement me pass class Stack(object): def __init__(self, top=None): # TODO: Implement me pass def push(self, data): # TODO: Implement me pass def pop(self): # TODO: Implement me ...
12,635
Given the following text description, write Python code to implement the functionality described below step by step Description: String vs. Bytes Text in Python 3 is always Unicode and is represented by the str type, and binary data is represented by the bytes type. They cannot be mixed. Strings can be encoded to byte...
Python Code: s = 'Hello world!' print(s) print("length is", len(s)) us = 'Hello 世界!' print(us) print("length is", len(us)) Explanation: String vs. Bytes Text in Python 3 is always Unicode and is represented by the str type, and binary data is represented by the bytes type. They cannot be mixed. Strings can be encoded t...
12,636
Given the following text description, write Python code to implement the functionality described below step by step Description: Capstone 1 Data Wrangling Project Data Acquisition Summary A set of .csv files provided for the Kaggle March Machine Learning Mania contest (hereafter referred to as Kaggle data) were downlo...
Python Code: # importing packages for wrangling tasks import pandas as pd import numpy as np import re from fuzzywuzzy import process from fuzzywuzzy import fuzz from geopy.distance import great_circle # create a function to quickly tabulate a dataframe column def tab(dfcol): t = pd.crosstab(index=dfcol, columns="c...
12,637
Given the following text description, write Python code to implement the functionality described below step by step Description: Demonstrate Seq2Seq Wrapper with CMUDict dataset Step1: Create an instance of the Wrapper Step2: Create data generators Read data_utils.py for more information Step3: Computational graph ...
Python Code: import tensorflow as tf import numpy as np # preprocessed data from datasets.cmudict import data import data_utils # load data from pickle and npy files data_ctl, idx_words, idx_phonemes = data.load_data(PATH='datasets/cmudict/') (trainX, trainY), (testX, testY), (validX, validY) = data_utils.split_dataset...
12,638
Given the following text description, write Python code to implement the functionality described below step by step Description: Why Objects? Provide modularity and reuse through hierarchical structures Object oriented programming is a different way of thinking. Programming With Objects Step1: Initial concepts An obj...
Python Code: from IPython.display import Image Image(filename='Classes_vs_Objects.png') Explanation: Why Objects? Provide modularity and reuse through hierarchical structures Object oriented programming is a different way of thinking. Programming With Objects End of explanation # Definiting a Car class class Car(objec...
12,639
Given the following text description, write Python code to implement the functionality described below step by step Description: Getting Started with halomod In this tutorial, you'll get a basic familiarity with the layout of halomod and some of its features. This is in no way meant to be exhaustive! The first thing ...
Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from halomod import TracerHaloModel import halomod import hmf print("halomod version: ", halomod.__version__) print("hmf version:", hmf.__version__) Explanation: Getting Started with halomod In this tutorial, you'll get a basic familiari...
12,640
Given the following text description, write Python code to implement the functionality described below step by step Description: Stochastic Variational Optimization with SVIGP Pytorch adaptation of test_svi Notebook by Mark van der Wilk, 2016, edits by James Hensman, 2016 Pytorch version by Thomas Viehmann Step1: Sto...
Python Code: import sys, os import numpy import time sys.path.append(os.path.join(os.getcwd(),'..')) import candlegp from matplotlib import pyplot import torch from torch.autograd import Variable %matplotlib inline pyplot.style.use('ggplot') import IPython M = 50 def func(x): return torch.sin(x * 3*3.14) + 0.3*torc...
12,641
Given the following text description, write Python code to implement the functionality described below step by step Description: This is for the Thorlabs PDA36A at the 20dB setting. Step1: Note that we need at least 10mV to even resolve a signal on the scope. So the NEP is only part of the story Step2: This setting ...
Python Code: # Enter the specs of the detector nep = 2.34e-12 # in Watts per root hz BW = 10e6 # Bandwidth in Hz gain = 0.75e4 # gain in V/A responsivity = 0.5 # Amps per Watt (assume 800 nm) pmin = nep * np.sqrt(BW) volts_min = pmin * responsivity * gain print("voltage generated by p_min:",volts_min) Explanation: ...
12,642
Given the following text description, write Python code to implement the functionality described below step by step Description: Writing PB in file The API allows to write all the files the command line tools can. This includes the outputs of PBassign. The functions to handle several file formats are available in the ...
Python Code: from __future__ import print_function, division from pprint import pprint import os import pbxplore as pbx Explanation: Writing PB in file The API allows to write all the files the command line tools can. This includes the outputs of PBassign. The functions to handle several file formats are available in t...
12,643
Given the following text description, write Python code to implement the functionality described below step by step Description: This jupyter notebooks provides the code for classifying signals using the Continuous Wavelet Transform and Convolutional Neural Networks. To get some more background information, please hav...
Python Code: import pywt import numpy as np import matplotlib.pyplot as plt from collections import defaultdict, Counter import keras from keras.layers import Dense, Flatten from keras.layers import Conv2D, MaxPooling2D from keras.models import Sequential from keras.callbacks import History history = History() Explana...
12,644
Given the following text description, write Python code to implement the functionality described below step by step Description: Graficos de aprovados e reprovados Step1: Preparação para determinar Correlação entre média de notas e distância até a UF Step2: Determinar Correlação entre média de notas e distância até ...
Python Code: import numpy as np import scipy.special from bokeh.layouts import gridplot from bokeh.plotting import figure, show, output_file def cria_graficos_barras_apro_repro(array, disciplina, titulo_grafico): dados = [] anos= [2014, 2015, 2016] periodos = [1, 2] for ano in anos: f...
12,645
Given the following text description, write Python code to implement the functionality described below step by step Description: Numpy Exercise 4 Imports Step1: Complete graph Laplacian In discrete mathematics a Graph is a set of vertices or nodes that are connected to each other by edges or lines. If those edges don...
Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns Explanation: Numpy Exercise 4 Imports End of explanation import networkx as nx K_5=nx.complete_graph(5) nx.draw(K_5) Explanation: Complete graph Laplacian In discrete mathematics a Graph is a set of vertices or node...
12,646
Given the following text description, write Python code to implement the functionality described below step by step Description: Let's change gears and talk about Game of thrones or shall I say Network of Thrones. It is suprising right? What is the relationship between a fatansy TV show/novel and network science or py...
Python Code: import pandas as pd import networkx as nx import matplotlib.pyplot as plt import community import numpy as np import warnings warnings.filterwarnings('ignore') %matplotlib inline Explanation: Let's change gears and talk about Game of thrones or shall I say Network of Thrones. It is suprising right? What is...
12,647
Given the following text description, write Python code to implement the functionality described below step by step Description: Analysis of local base-steps parameters This tutorial discuss the analyses that can be performed using the dnaMD Python module included in the do_x3dna package. The tutorial is prepared usin...
Python Code: import numpy as np import matplotlib.pyplot as plt import dnaMD %matplotlib inline Explanation: Analysis of local base-steps parameters This tutorial discuss the analyses that can be performed using the dnaMD Python module included in the do_x3dna package. The tutorial is prepared using Jupyter Notebook an...
12,648
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Atmoschem MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Speci...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csir-csiro', 'sandbox-1', 'atmoschem') Explanation: ES-DOC CMIP6 Model Properties - Atmoschem MIP Era: CMIP6 Institute: CSIR-CSIRO Source ID: SANDBOX-1 Topic: Atmoschem Sub-Topics: Tr...
12,649
Given the following text description, write Python code to implement the functionality described below step by step Description: ionize Tutorial ionize is a Python module for calculating the properties of ions in aqueous solution. To load the library, simply import ionize. Step1: Ion The basic building block of an i...
Python Code: from __future__ import print_function, absolute_import, division import ionize # We'll also import numpy to set up some of our inputs. # And pprint to prettily print some lists. import numpy import pprint # And set up inline plotting. from matplotlib.pyplot import * %matplotlib inline # Prettify numpy pri...
12,650
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction Maps allow us to transform data in a DataFrame or Series one value at a time for an entire column. However, often we want to group our data, and then do something specific to th...
Python Code: #$HIDE_INPUT$ import pandas as pd reviews = pd.read_csv("../input/wine-reviews/winemag-data-130k-v2.csv", index_col=0) pd.set_option("display.max_rows", 5) reviews.groupby('points').points.count() Explanation: Introduction Maps allow us to transform data in a DataFrame or Series one value at a time for an ...
12,651
Given the following text description, write Python code to implement the functionality described below step by step Description: Flux Variability Anlysis (FVA) Load a few packages and functions. Step1: First we load a model from the BiGG database (and make a copy of it). Step2: Run flux variablity analysis Calculate...
Python Code: import pandas pandas.options.display.max_rows = 12 import escher from cameo import models, flux_variability_analysis, fba Explanation: Flux Variability Anlysis (FVA) Load a few packages and functions. End of explanation model = models.bigg.e_coli_core.copy() Explanation: First we load a model from the BiGG...
12,652
Given the following text description, write Python code to implement the functionality described below step by step Description: Implementing the EffTox Dose-Finding Design in the Matchpoint Trials This tutorial complements the manuscript Implementing the EffTox Dose-Finding Design in the Matchpoint Trial (Brock et al...
Python Code: import numpy as np from scipy.stats import norm from clintrials.dosefinding.efftox import EffTox, LpNormCurve real_doses = [7.5, 15, 30, 45] trial_size = 30 cohort_size = 3 first_dose = 3 prior_tox_probs = (0.025, 0.05, 0.1, 0.25) prior_eff_probs = (0.2, 0.3, 0.5, 0.6) tox_cutoff = 0.40 eff_cutoff = 0.45 t...
12,653
Given the following text description, write Python code to implement the functionality described below step by step Description: Test datasets http Step1: General guides to Bayesian regression http
Python Code: import pandas as pd import statsmodels.api as sm # Normal response variable stackloss_conversion = sm.datasets.get_rdataset("stackloss", "datasets") #print (stackloss_conversion.__doc__) # Lognormal response variable engel_food = sm.datasets.engel.load_pandas() #print (engel_food.data) # Binary response va...
12,654
Given the following text description, write Python code to implement the functionality described below step by step Description: Coroutines for IO-bound tasks In this notebook, we'll weave together our new (Tweet Parser)[https Step1: We can define a few constants here that will be used throughout our example. Step2: ...
Python Code: from IPython.display import HTML HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/dD9NgzLhbBM" frameborder="0" allowfullscreen></iframe>') %load_ext autoreload %autoreload 2 %matplotlib inline import itertools as it from functools import partial import seaborn as sns import pandas ...
12,655
Given the following text description, write Python code to implement the functionality described below step by step Description: Ex2 Step1: This example is a lot more tricky to fit, because the responses contain a few "bumps" and noise from the measurement. In such a case, finding a good number of initial poles can t...
Python Code: import skrf import numpy as np import matplotlib.pyplot as mplt Explanation: Ex2: Measured 190 GHz Active 2-Port The Vector Fitting feature is demonstrated using a 2-port S-matrix of an active circuit measured from 140 GHz to 220 GHz. Additional explanations and background information can be found in the V...
12,656
Given the following text description, write Python code to implement the functionality described below step by step Description: DI Her Step1: As always, let's do imports and initialize a logger and a new bundle. Step2: System Parameters We'll adopt and set parameters from the following sources Step3: Datasets Let'...
Python Code: #!pip install -I "phoebe>=2.3,<2.4" Explanation: DI Her: Misaligned Binary In this example, we'll reproduce Figure 8 in the misalignment release paper (Horvat et al. 2018). <img src="horvat+18_fig8.png" alt="Figure 8" width="400px"/> Setup Let's first make sure we have the latest version of PHOEBE 2.3 inst...
12,657
Given the following text description, write Python code to implement the functionality described below step by step Description: Examples and Exercises from Think Stats, 2nd Edition http Step1: I'll start with the data from the BRFSS again. Step2: Here are the mean and standard deviation of female height in cm. Step...
Python Code: from __future__ import print_function, division %matplotlib inline import numpy as np import brfss import thinkstats2 import thinkplot Explanation: Examples and Exercises from Think Stats, 2nd Edition http://thinkstats2.com Copyright 2016 Allen B. Downey MIT License: https://opensource.org/licenses/MIT End...
12,658
Given the following text description, write Python code to implement the functionality described below step by step Description: Imports Step1: Pyplot is the Matplotlib plotting backend and the inline magic to see the graph directly in the notebook Step2: Or you can use pylab, which simplifies all the calling to mat...
Python Code: # Panda will be usefull for quick data parsing import pandas as pd import numpy as np # Small trick to get a larger display from IPython.core.display import display, HTML display(HTML("<style>.container { width:90% !important; }</style>")) Explanation: Imports End of explanation import matplotlib.pyplot as...
12,659
Given the following text description, write Python code to implement the functionality described below step by step Description: Problem There's a fundamental problem with what I'm trying to do. It's that stupid connect1!!! What I should do is grep for all occurences of mesh_id = int(ftype[-1]) - 1 because any time th...
Python Code: %debug Explanation: Problem There's a fundamental problem with what I'm trying to do. It's that stupid connect1!!! What I should do is grep for all occurences of mesh_id = int(ftype[-1]) - 1 because any time that code occurs, it's going to disrupt what I'm trying to do. For now, I'm going to try this one m...
12,660
Given the following text description, write Python code to implement the functionality described below step by step Description: Notebook-3 Step1: Multiplication and Division Step2: A challenge for you! Do you think the results of these two operations will be identical? If not, why? Decide what you think the answer ...
Python Code: 3 - 2 + 10 Explanation: Notebook-3: The Basics In this first proper programming lesson we are going to use the Python interpreter to perform simple operations, like numeric calculations that you would normally do on a calculator and slightly more advanced operations on words. The interpreter is what reads ...
12,661
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Ocean MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Specify d...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'bnu', 'sandbox-2', 'ocean') Explanation: ES-DOC CMIP6 Model Properties - Ocean MIP Era: CMIP6 Institute: BNU Source ID: SANDBOX-2 Topic: Ocean Sub-Topics: Timestepping Framework, Adve...
12,662
Given the following text description, write Python code to implement the functionality described below step by step Description: Angelic Search Search using angelic semantics (is a hierarchical search), where the agent chooses the implementation of the HLA's. <br> The algorithms input is Step1: The Angelic search alg...
Python Code: from planning import * from notebook import psource Explanation: Angelic Search Search using angelic semantics (is a hierarchical search), where the agent chooses the implementation of the HLA's. <br> The algorithms input is: problem, hierarchy and initialPlan - problem is of type Problem - hierarchy i...
12,663
Given the following text description, write Python code to implement the functionality described below step by step Description: <u>Word prediction</u> Language Model based on n-gram Probabilistic Model Good Turing Smoothing Used with Backoff Highest Order n-gram used is Quadgram <u>Import corpus</u> Step1: <u>Do pre...
Python Code: from nltk.util import ngrams from collections import defaultdict from collections import OrderedDict import string import time import gc from math import log10 start_time = time.time() Explanation: <u>Word prediction</u> Language Model based on n-gram Probabilistic Model Good Turing Smoothing Used with Bac...
12,664
Given the following text description, write Python code to implement the functionality described below step by step Description: 数据抓取: Beautifulsoup简介 王成军 wangchengjun@nju.edu.cn 计算传播网 http Step1: 一般的数据抓取,使用urllib2和beautifulsoup配合就可以了。 尤其是对于翻页时url出现规则变化的网页,只需要处理规则化的url就可以了。 以简单的例子是抓取天涯论坛上关于某一个关键词的帖子。 在天涯论坛,关于雾霾的帖子的第一...
Python Code: import urllib2 from bs4 import BeautifulSoup Explanation: 数据抓取: Beautifulsoup简介 王成军 wangchengjun@nju.edu.cn 计算传播网 http://computational-communication.com 需要解决的问题 页面解析 获取Javascript隐藏源数据 自动翻页 自动登录 连接API接口 End of explanation url = 'file:///Users/chengjun/GitHub/cjc2016/data/test.html' content = urllib2.urlopen...
12,665
Given the following text description, write Python code to implement the functionality described below step by step Description: Tutorial 0 - First JOOMMF notebook The goal of this tutorial is for all participants to familiarise themselves with running JOOMMF simulations in Jupyter notebook. The only thing you need to...
Python Code: import oommfc as oc import discretisedfield as df %matplotlib inline Explanation: Tutorial 0 - First JOOMMF notebook The goal of this tutorial is for all participants to familiarise themselves with running JOOMMF simulations in Jupyter notebook. The only thing you need to know for this tutorial is how to e...
12,666
Given the following text description, write Python code to implement the functionality described below step by step Description: Additional forces REBOUND is a gravitational N-body integrator. But you can also use it to integrate systems with additional, non-gravitational forces. This tutorial gives you a very quick o...
Python Code: import rebound sim = rebound.Simulation() sim.integrator = "whfast" sim.add(m=1.) sim.add(m=1e-6,a=1.) sim.move_to_com() # Moves to the center of momentum frame Explanation: Additional forces REBOUND is a gravitational N-body integrator. But you can also use it to integrate systems with additional, non-gr...
12,667
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Atmoschem MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Speci...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nasa-giss', 'sandbox-1', 'atmoschem') Explanation: ES-DOC CMIP6 Model Properties - Atmoschem MIP Era: CMIP6 Institute: NASA-GISS Source ID: SANDBOX-1 Topic: Atmoschem Sub-Topics: Tran...
12,668
Given the following text description, write Python code to implement the functionality described below step by step Description: Model25 Step1: KMeans Step2: B. Modeling Step3: Original === Bench with ElasticNetCV
Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from utils import load_buzz, select, write_result from features import featurize, get_pos from containers import Questions, Users, Categories from nlp import extract_entities Explanation: Model25: using category accuracy per users End of...
12,669
Given the following text description, write Python code to implement the functionality described below step by step Description: LEDs aansturen met de Raspberry Pi GPIO pins Met deze notebook zullen we de General Purpose Input/Output (GPIO) pinnen op de Raspberry Pi gebruiken om een LED lampje te laten branden. GPIO p...
Python Code: #GPIO bibliotheek inladen import RPi.GPIO as GPIO #BCM (Broadcom) modus instellen voor het nummeren van de pins GPIO.setmode(GPIO.BCM) Explanation: LEDs aansturen met de Raspberry Pi GPIO pins Met deze notebook zullen we de General Purpose Input/Output (GPIO) pinnen op de Raspberry Pi gebruiken om een LED ...
12,670
Given the following text description, write Python code to implement the functionality described below step by step Description: Python Python is widely used general-purpose high-level programming language. Its design philosophy emphasizes code readability. It is very popular in science. Jupyter The Jupyter Notebook i...
Python Code: print('This is cell with code') Explanation: Python Python is widely used general-purpose high-level programming language. Its design philosophy emphasizes code readability. It is very popular in science. Jupyter The Jupyter Notebook is a web application that allows you to create and share documents that c...
12,671
Given the following text description, write Python code to implement the functionality described below step by step Description: The Counted (project by The Guardian to count the people killed by police in the US) Why is this necessary? From The Guardian's http Step1: # Open your dataset up using pandas in a Jupyter ...
Python Code: !pip install pandas !pip install matplotlib import pandas as pd import matplotlib.pyplot as plt %matplotlib inline Explanation: The Counted (project by The Guardian to count the people killed by police in the US) Why is this necessary? From The Guardian's http://www.theguardian.com/us-news/ng-interactive/2...
12,672
Given the following text description, write Python code to implement the functionality described below step by step Description: Finite Sequences Step1: Infinite Sequences Step2: Branching Sequences Sometimes we want to do multiple things with an infinite sequence. This is where the Python iterator abstraction star...
Python Code: import json data = ['{"name": "Alice", "value": 1}', '{"name": "Bob", "value": 2}', '{"name": "Alice", "value": 3}', '{"name": "Alice", "value": 4}', '{"name": "Charlie", "value": 5}', '{"name": "Bob", "value": 6}', '{"name": "Alice", "value": 7}'] seq = list...
12,673
Given the following text description, write Python code to implement the functionality described below step by step Description: Download the list of occultation periods from the MOC at Berkeley. Note that the occultation periods typically only are stored at Berkeley for the future and not for the past. So this is onl...
Python Code: fname = io.download_occultation_times(outdir='../data/') print(fname) Explanation: Download the list of occultation periods from the MOC at Berkeley. Note that the occultation periods typically only are stored at Berkeley for the future and not for the past. So this is only really useful for observation pl...
12,674
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: WASM demo - brainfuck Brainfuck is an esoteric language that consists of only eight simple commands Step3: Hello world example Step5: Fibonacci example
Python Code: import wasmfun as wf def _commands2instructions(commands): Compile brainfuck commands to WASM instructions (as tuples). instructions = [] while commands: c = commands.pop(0) if c == '>': instructions += [('get_local', 0), ('i32.const', 1), ('i32.add'), ('se...
12,675
Given the following text description, write Python code to implement the functionality described below step by step Description: One Dimensional Data Worksheet This worksheet reviews the concepts discussed about 1 dimensional data. The goal for these exercises is getting you to think in terms of vectorized computing....
Python Code: import pandas as pd import numpy as np Explanation: One Dimensional Data Worksheet This worksheet reviews the concepts discussed about 1 dimensional data. The goal for these exercises is getting you to think in terms of vectorized computing. This worksheet should take 20-30 minutes to complete. End of ex...
12,676
Given the following text description, write Python code to implement the functionality described below step by step Description: Statements Assessment Test Lets test your knowledge! Use for, split(), and if to create a Statement that will print out words that start with 's' Step1: Use range() to print all the even nu...
Python Code: st = 'Print only the words that start with s in this sentence' #Code here # to note: a for in for a string iterates through letters, not numbers for word in st.split(): letter = word[0].lower() if letter == 's': print word Explanation: Statements Assessment Test Lets test your knowledge! Us...
12,677
Given the following text description, write Python code to implement the functionality described below step by step Description: Versicherung on Paper Step1: Gesucht wird eine wiederholungsfreie Liste der Herstellerländer 3 P Step2: Listen Sie alle Fahrzeugtypen und die Anzahl Fahrzeuge dieses Typs, aber nur...
Python Code: %load_ext sql %sql mysql://steinam:steinam@localhost/versicherung_complete Explanation: Versicherung on Paper End of explanation %%sql -- meine Lösung select distinct(Land) from Fahrzeughersteller; %%sql -- deine Lösung select fahrzeughersteller.Land from fahrzeughersteller group by fahrzeughersteller.L...
12,678
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction This notebook facilitates the manual curation of sample alignment. Step1: Setup Parameters Step2: Directories Step3: Extract list of files Step4: Import raw data and perform...
Python Code: import deltascope.alignment as ut import numpy as np import pandas as pd import matplotlib.pyplot as plt import h5py import os import re import time import tqdm Explanation: Introduction This notebook facilitates the manual curation of sample alignment. End of explanation # --------------------------------...
12,679
Given the following text description, write Python code to implement the functionality described below step by step Description: Ordinary Differential Equations Exercise 3 Imports Step1: Damped, driven nonlinear pendulum The equations of motion for a simple pendulum of mass $m$, length $l$ are Step4: Write a functio...
Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import seaborn as sns from scipy.integrate import odeint from IPython.html.widgets import interact, fixed Explanation: Ordinary Differential Equations Exercise 3 Imports End of explanation g = 9.81 # m/s^2 l = 0.5 # length of pendul...
12,680
Given the following text description, write Python code to implement the functionality described below step by step Description: Applying Contextual Bandits for Recommendation systems using Tensorflow and Cloud Storage Learning objectives Install and import required libraries. Initialize and configure the MovieLens En...
Python Code: !pip install --quiet --upgrade --force-reinstall tensorflow==2.4 tensorflow_probability==0.12.1 tensorflow-io==0.17.0 --use-feature=2020-resolver !pip install tf_agents==0.7.1 --quiet gast==0.3.3 --upgrade --use-feature=2020-resolver import functools import os from absl import app from absl import flags im...
12,681
Given the following text description, write Python code to implement the functionality described below step by step Description: Let's scrape some death row data Texas executes a lot of criminals, and it has a web page that keeps track of people on its death row. Using what you've learned so far, let's scrape this tab...
Python Code: import csv import time import requests from bs4 import BeautifulSoup Explanation: Let's scrape some death row data Texas executes a lot of criminals, and it has a web page that keeps track of people on its death row. Using what you've learned so far, let's scrape this table into a CSV. Then we're going wri...
12,682
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: Batch Normalization One way to make deep networks easier to train is to use more sophisticated optimization procedures such as SGD+momentum, RMSProp, or Adam. Another strategy is to c...
Python Code: # As usual, a bit of setup import time import numpy as np import matplotlib.pyplot as plt from skynet.neural_network.classifiers.fc_net import * from skynet.utils.data_utils import get_CIFAR10_data from skynet.utils.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array from skynet.so...
12,683
Given the following text description, write Python code to implement the functionality described below step by step Description: pymofa tutorial last updated Step2: A discrete predetor prey dummy model First we need to create a dummy model. Let's use a discrete version of the famous predator prey model. Step3: Examp...
Python Code: # if you work with this notebook interactively, exectue # cd .. # to be at the pymofa root %matplotlib notebook import numpy as np import matplotlib.pyplot as plt Explanation: pymofa tutorial last updated: 2016-09-06 This notebook introduces the basic functionalities of pymofa, the python modeling framewor...
12,684
Given the following text description, write Python code to implement the functionality described below step by step Description: 关于泰坦尼克号生存率的数据分析 首先通过观察数据,可以了解到每位旅客的详细数据: Survived:是否存活(0代表否,1代表是) Pclass:舱位(一等舱,二等舱,三等舱) Name:船上乘客的名字 Sex:船上乘客的性别 Age:船上乘客的年龄(可能存在 NaN) SibSp:乘客在船上的兄弟姐妹和配偶的数量 Parch:乘客在船上的父母以及小孩的数量 Ticket:乘客...
Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import pylab as pl %matplotlib inline filename = './titanic-data.csv' titanic_df = pd.read_csv(filename) titanic_df.describe() Explanation: 关于泰坦尼克号生存率的数据分析 首先通过观察数据,可以了解到每位旅客的详细数据: Survived:是否存活(0代表否,1代表是) Pclass:舱位(一等舱,二等舱,三等舱) Name:船上...
12,685
Given the following text description, write Python code to implement the functionality described below step by step Description: Keras for Text Classification Learning Objectives 1. Learn how to create a text classification datasets using BigQuery 1. Learn how to tokenize and integerize a corpus of text for training i...
Python Code: import os import pandas as pd from google.cloud import bigquery %load_ext google.cloud.bigquery Explanation: Keras for Text Classification Learning Objectives 1. Learn how to create a text classification datasets using BigQuery 1. Learn how to tokenize and integerize a corpus of text for training in Keras ...
12,686
Given the following text description, write Python code to implement the functionality described below step by step Description: Vizualizing BigQuery data in a Jupyter notebook BigQuery is a petabyte-scale analytics data warehouse that you can use to run SQL queries over vast amounts of data in near realtime. Data vis...
Python Code: %%bigquery SELECT source_year AS year, COUNT(is_male) AS birth_count FROM `bigquery-public-data.samples.natality` GROUP BY year ORDER BY year DESC LIMIT 15 Explanation: Vizualizing BigQuery data in a Jupyter notebook BigQuery is a petabyte-scale analytics data warehouse that you can use to run SQL ...
12,687
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Ocean MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Specify d...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cccr-iitm', 'sandbox-1', 'ocean') Explanation: ES-DOC CMIP6 Model Properties - Ocean MIP Era: CMIP6 Institute: CCCR-IITM Source ID: SANDBOX-1 Topic: Ocean Sub-Topics: Timestepping Fra...
12,688
Given the following text description, write Python code to implement the functionality described below step by step Description: MCMC Demonstration Markov Chain Monte Carlo is a useful technique for fitting models to data and obtaining estimates for the uncertainties of the model parameters. There are a slew of python...
Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import emcee import corner Explanation: MCMC Demonstration Markov Chain Monte Carlo is a useful technique for fitting models to data and obtaining estimates for the uncertainties of the model parameters. There are a slew of python module...
12,689
Given the following text description, write Python code to implement the functionality described below step by step Description: matplotlib 폰트 설정 및 한글 사용 여기에서는 리눅스 운영체제에서 matplotlib 을 사용한 플롯에서 디폴트 폰트가 아닌 다른 폰트를 사용하거나 한글을 사용하기 위한 방법을 설명한다. 폰트 설치 matplotlib에서 특정한 폰트를 사용하기 위해서는 우선 시스템에 폰트가 설치되어 있어야 한다. 폰트 설치 여부는 fc-list...
Python Code: !fc-list !fc-list Explanation: matplotlib 폰트 설정 및 한글 사용 여기에서는 리눅스 운영체제에서 matplotlib 을 사용한 플롯에서 디폴트 폰트가 아닌 다른 폰트를 사용하거나 한글을 사용하기 위한 방법을 설명한다. 폰트 설치 matplotlib에서 특정한 폰트를 사용하기 위해서는 우선 시스템에 폰트가 설치되어 있어야 한다. 폰트 설치 여부는 fc-list 명령으로 확인할 수 있다. datascienceschool/rpython에는 다음과 같은 폰트들이 설치되어 있다. 한글 폰트로는 나눔폰트, 은폰트 등이 ...
12,690
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Atmos MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Specify d...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-3', 'atmos') Explanation: ES-DOC CMIP6 Model Properties - Atmos MIP Era: CMIP6 Institute: PCMDI Source ID: SANDBOX-3 Topic: Atmos Sub-Topics: Dynamical Core, Radiatio...
12,691
Given the following text description, write Python code to implement the functionality described below step by step Description: Class 04 ML Models Step1: We will start with a subset of this data to illustrate what we are trying to do here. We use the sample() function to get a small piece of the data (we use the ran...
Python Code: import pandas as pd import seaborn as sns sns.set_style("white") #Note the new use of the dtype option here. We can directly tell pandas to use the Speed column as a category in one step. speeddf = pd.read_csv("Class04_speed_data.csv",dtype={'Speed':'category'}) lm = sns.lmplot(x='Grade', y='Bumpiness', da...
12,692
Given the following text description, write Python code to implement the functionality described below step by step Description: VSA Syntax and Control Flow This notebook is meant as just a place to express my current thoughts on how to do large-scale VSA development. In particular, I'm interesting in finding a progr...
Python Code: import nengo_spa as spa import nengo model = spa.Network() with model: # configure Nengo to just directly conpute things, rather than trying to implement the # network with neurons model.config[nengo.Ensemble].neuron_type = nengo.Direct() model.config[nengo.Connection].synapse = None ...
12,693
Given the following text description, write Python code to implement the functionality described below step by step Description: Python for Science Python is free, it is open source, and it has a huge community. Python is one of the most popular and loved programming languages in the world! Many blogs come out every y...
Python Code: import numpy # By the way: comments in code cells start with a hash. # here are two arrays, saved as variables x and y: x = numpy.array([1.0, 0.5, 2.5]) y = numpy.array([[ 1.0, 0.5, 2.5], [ 0.5, 1.1, 2.0]]) # The print function works on arrays: print(x) print(y) numpy.shape(y) numpy.shape(x) Explanation: P...
12,694
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: TV Script Generation In this project, you'll generate your own Simpsons TV scripts using RNNs. You'll be using part of the Simpsons dataset of scripts from 27 seasons. The Neural Ne...
Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper data_dir = './data/simpsons/moes_tavern_lines.txt' text = helper.load_data(data_dir) # Ignore notice, since we don't use it for analysing the data text = text[81:] Explanation: TV Script Generation In this project, you'll generate your own Simpsons TV script...
12,695
Given the following text description, write Python code to implement the functionality described below step by step Description: I've been thinking a lot about software achitecure lately. Not just thinking, because I wouldn't come up with these ideas on my own, but consuming a lot about it -- books, talks, slide decks...
Python Code: @app.route('/register', methods=['GET', 'POST']) def register(): form = RegisterUserForm() if form.validate_on_submit(): user = User() form.populate_obj(user) db.session.add(user) db.session.commit() return redirect('homepage') return render_tem...
12,696
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Ocean MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Specify d...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'awi', 'sandbox-1', 'ocean') Explanation: ES-DOC CMIP6 Model Properties - Ocean MIP Era: CMIP6 Institute: AWI Source ID: SANDBOX-1 Topic: Ocean Sub-Topics: Timestepping Framework, Adve...
12,697
Given the following text description, write Python code to implement the functionality described below step by step Description: Statistical Data Modeling Pandas, NumPy and SciPy provide the core functionality for building statistical models of our data. We use models to Step1: Estimation An recurring statistical pro...
Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns sns.set() Explanation: Statistical Data Modeling Pandas, NumPy and SciPy provide the core functionality for building statistical models of our data. We use models to: Concisely describe the compo...
12,698
Given the following text description, write Python code to implement the functionality described below step by step Description: Quick, Draw! GAN code based directly on Grant Beyleveld's, which is derived from Rowel Atienza's under MIT License data provided by Google under Creative Commons Attribution 4.0 license Sele...
Python Code: # import os # os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # # os.environ["CUDA_VISIBLE_DEVICES"] = "" # os.environ["CUDA_VISIBLE_DEVICES"] = "1" Explanation: Quick, Draw! GAN code based directly on Grant Beyleveld's, which is derived from Rowel Atienza's under MIT License data provided by Google under C...
12,699
Given the following text description, write Python code to implement the functionality described below step by step Description: The ipyrad.analysis tool kit Deren Eaton Install software All required software for this walkthrough is available on conda. Step1: Start an ipyparallel cluster In a separate terminal run ...
Python Code: # conda install -c ipyrad ipyrad structure clumpp bpp # conda install -c eaton-lab toytree toyplot # conda install -c bioconda raxml Explanation: The ipyrad.analysis tool kit Deren Eaton Install software All required software for this walkthrough is available on conda. End of explanation # ipcluster sta...