ipython

WARNING: IPython History requires SQLite, your history will not be saved

六眼飞鱼酱① 提交于 2020-06-24 03:49:09
问题 Hi I'm using Ubuntu release 12.10 (quantal) 32-bit with Linux Kernel 3.5.0-21-generic. I'm trying to get IPython's History to work. I've set it up using pythonbrew and a virtual environment. In there I use pip to install IPython. Currently, when I start up IPython in a terminal I get: WARNING: IPython History requires SQLite, your history will not be saved Python 2.7.3 (default, Nov 8 2012, 18:25:10) Type "copyright", "credits" or "license" for more information. IPython 0.13.1 -- An enhanced

ipython autoreload kills state

泪湿孤枕 提交于 2020-06-17 13:20:27
问题 As recommended in (Reloading submodules in IPython) I added %load_ext autoreload %autoreload 2 to my notebook and now, indeed, the modules are automatically reloaded. Alas, I have try: # https://docs.python.org/library/importlib.html rala_all # reload will not reset rala_all except NameError: rala_all = {} in my module. It did work before using importlib, but, with autoreload I see rala_all being reset (to an empty dictionary) every time the module is reloaded. Is there a way to avoid this? I

Running Tkinter with interactive ipython notebook

时间秒杀一切 提交于 2020-06-17 10:46:01
问题 I want to create an interactive python coding game, where users can enter commands into a jupyter notebook and see the result on a GUI in real time. This seems to work fine in the regular python interactive shell. The way I get this to run is the following: I make a file, lets call it example.py with the following code: import tkinter as tk def create_canvas(): root = tk.Tk() root.resizable(False, False) root.title("Karel") frame = tk.Frame(root) frame.pack() canvas = tk.Canvas(frame, bg=

Running Tkinter with interactive ipython notebook

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-17 10:45:12
问题 I want to create an interactive python coding game, where users can enter commands into a jupyter notebook and see the result on a GUI in real time. This seems to work fine in the regular python interactive shell. The way I get this to run is the following: I make a file, lets call it example.py with the following code: import tkinter as tk def create_canvas(): root = tk.Tk() root.resizable(False, False) root.title("Karel") frame = tk.Frame(root) frame.pack() canvas = tk.Canvas(frame, bg=

ROC curve for binary classification in python

半城伤御伤魂 提交于 2020-06-10 04:23:07
问题 I am tying to plot an ROC curve for Binary classification using RandomForestClassifier I have two numpy arrays one contains predicted values and one contains true values as follows: In [84]: test Out[84]: array([0, 1, 0, ..., 0, 1, 0]) In [85]: pred Out[85]: array([0, 1, 0, ..., 1, 0, 0]) How do I port ROC curve and obtain AUC (Area Under Curve) for this binary classification result in ipython? 回答1: You need probabilities to create ROC curve. In [84]: test Out[84]: array([0, 1, 0, ..., 0, 1,

Format output of code cell with Markdown

泪湿孤枕 提交于 2020-06-10 02:15:40
问题 Output of Python code cell seems to be not processed by Markdown. For example in Python code cell there could be something like that: print "**bold**" And the output is: **bold** instead of bold . Is there a way to make it really bold? 回答1: To get markdown formatted output, you can use the Markdown object of the display machinery. A print-like function could thus look like from IPython.display import Markdown, display def printmd(string): display(Markdown(string)) printmd('**bold**') 来源:

iPyWidget with date slider?

别来无恙 提交于 2020-06-09 17:53:10
问题 I am wondering if there's an easy way to build an iPyWidget with a datetime slider. Right now it is easy to slide over integer or floating point ranges (e.g. numbers 1-10, decimals 0.01, 0.02, ...). I imagine you could convert dates to floats or integers, build some sort of slider using these, and then convert back to dates for the display labels on the slider. However, this seems clunky. Does anyone have a smoother solution? 回答1: I had the same issue recently. I had to write my own class to

-n and -r arguments to IPython's %timeit magic

久未见 提交于 2020-06-09 17:02:20
问题 I would like to time a code block using the timeit magic command in a Jupyter notebook. According to the documentation, timeit takes several arguments. Two in particular control number of loops and number of repetitions. What isn't clear to me is the distinction between these two arguments. For example import numpy N = 1000000 v = numpy.arange(N) %timeit -n 10 -r 500 pass; w = v + v will run 10 loops and 500 repetitions. My question is, Can this be interpreted as the following? (with obvious

trying to add an input layer to CNN model in keras

删除回忆录丶 提交于 2020-06-01 07:41:27
问题 I tried to add input to a parallel path cnn, to make a residual architecture, but I am getting dimension mismatch. from keras import layers, Model input_shape = (128,128,3) # Change this accordingly my_input = layers.Input(shape=input_shape) # one input def parallel_layers(my_input, parallel_id=1): x = layers.SeparableConv2D(32, (9, 9), activation='relu', name='conv_1_'+str(parallel_id))(my_input) x = layers.MaxPooling2D(2, 2)(x) x = layers.SeparableConv2D(64, (9, 9), activation='relu', name=

How to reset iPython/Jupyter profile after upgrade to 'factory' defaults?

*爱你&永不变心* 提交于 2020-05-29 06:05:21
问题 Returning to using iPython Notebooks after a year, [I installed my distro's version of Jupyter and now] Jupyter launches without menu bar. I'm guessing some of my old settings are carrying over. I'm guessing the fastest way to fix this is to .bak the old profile and create a new default. First, initialized a Jupyter profile from instructions on how-to setup multiple Jupyter profiles: $ jupyter notebook --generate-config Then, [after further investigation] I created a new iPython profile, $