In this week's edition of our open source news roundup, we take a look at Oracle wanting to pass Java EE to an open source foundation, Schiphol airport turns to open source, Colorado investigating open source textbooks, and more.
read more
Data Science, Machine Learning, Natural Language Processing, Text Analysis, Recommendation Engine, R, Python
In this week's edition of our open source news roundup, we take a look at Oracle wanting to pass Java EE to an open source foundation, Schiphol airport turns to open source, Colorado investigating open source textbooks, and more.
>>> import subprocess
>>> process=subprocess.Popen(["powershell","Get-Childitem C:\\Windows\\*.log"],stdout=subprocess.PIPE);
>>> result=process.communicate()[0]
>>> print result
>>> print subprocess.check_output("hostname")
>>> print subprocess.check_output("ping localhost", shell=True)
>>> cmd = 'dir *'
>>> supcmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>>> print supcmd.communicate()[0]
>>> import sys
>>> import subprocess
>>> pid = subprocess.Popen([sys.executable, "calc.py"])
tl;dr; By a slim margin, the fastest way to check a filename matching a list of extensions is filename.endswith(extensions)
This turned out to be premature optimization. The context is that I want to check if a filename matches the file extension in a list of 6.
The list being ['.sym', '.dl_', '.ex_', '.pd_', '.dbg.gz', '.tar.bz2']. Meaning, it should return True for foo.sym or foo.dbg.gz. But it should return False for bar.exe or bar.gz.
I put together a litte benchmark, ran it a bunch of times and looked at the results. Here are the functions I wrote:
def f1(filename):
for each in extensions:
if filename.endswith(each):
return True
return False
def f2(filename):
return filename.endswith(extensions_tuple)
regex = re.compile(r'({})$'.format(
'|'.join(re.escape(x) for x in extensions)
))
def f3(filename):
return bool(regex.findall(filename))
def f4(filename):
return bool(regex.search(filename))
The results are boring. But I guess that's a result too:
FUNCTION MEDIAN MEAN f1 9543 times 0.0110ms 0.0116ms f2 9523 times 0.0031ms 0.0034ms f3 9560 times 0.0041ms 0.0045ms f4 9509 times 0.0041ms 0.0043ms
For a list of ~40,000 realistic filenames (with result True 75% of the time), I ran each function 10 times. So, it means it took on average 0.0116ms to run f1 10 times here on my laptop with Python 3.6.
Upon looking into the data and thinking about this will be used. If I reorder the list of extensions so the most common one is first, second most common second etc. Then the performance improves a bit for f1 but slows down slightly for f3 and f4.
That .endswith(some_tuple) is neat and it's hair-splittingly faster. But really, this turned out to not make a huge difference in the grand scheme of things. On average it takes less than 0.001ms to do one filename match.
market_df = pd.read_csv('../examples/SP500.csv', index_col='DATE', parse_dates=True)
df = market_df.reset_index().rename(columns={'DATE':'ds', 'SP500':'y'})
df['y'] = np.log(df['y'])
#lets take a look at our data quickly
df.set_index('ds').y.plot()
model = Prophet() model.fit(df); future = model.make_future_dataframe(periods=366) forecast = model.predict(future)Prophet has created our model and fit the data. It has also (behind the scenes) created some potential changepoints. We can access these changepoints with
.changepoints. By default, Prophet adds 25 changepoints into the initial 80% of the data-set. The number of changepoints can be set by using the n_changepoints parameter when initializing prophet (e.g., model=Prophet(n_changepoints=30).model.changepoints
figure = model.plot(forecast)
for changepoint in model.changepoints:
plt.axvline(changepoint,ls='--', lw=1)
deltas = model.params['delta'].mean(0)
fig = plt.figure(facecolor='w')
ax = fig.add_subplot(111)
ax.bar(range(len(deltas)), deltas)
ax.grid(True, which='major', c='gray', ls='-', lw=1, alpha=0.2)
ax.set_ylabel('Rate change')
ax.set_xlabel('Potential changepoint')
fig.tight_layout()
m = Prophet(changepoints=['2009-03-09', '2010-07-02', '2011-09-26', '2012-03-20', '2010-04-06']) forecast = m.fit(df).predict(future) m.plot(forecast);We can see that by manually setting our changepoints (and only using a few points), we drastically changed the model compared to the model that prophet built for us using the automatic detection of changepoints. Unless you are very sure about your trend changepoints in the past, its probably good to keep the defaults that prophet provides.
|
Worthy Read
Being uploaded at the time of sending the newsletter.
conference
,
videos
The startup time for the Python interpreter has been discussed by the core developers and others numerous times over the years; optimization efforts are made periodically as well. Startup time can dominate the execution time of command-line programs written in Python, especially if they import a lot of other modules. Python startup time is worse than some other scripting languages and more recent versions of the language are taking more than twice as long to start up when compared to earlier versions (e.g. 3.7 versus 2.7).
core-python
This website contains the full text of the Python Data Science Handbook by Jake VanderPlas; the content is available on GitHub in the form of Jupyter notebooks.
data science
Embed docs directly on your website with a few lines of code.
sponsor
Useful cache helpers in one package.
caching
Regression, Regularization, Residuals and Feature Selection
data science
In the first part of this series we concluded that asyncio is awesome, coroutines are awesome and our code is awesome. But sometimes the outside world is not as awesome and we have to deal with it. Now, for this second part of the series, I’ll run over the options asyncio gives us to handle errors when using these patterns as well as cancelling tasks so as to make our asynchronous systems robust and performant.
asyncio
Companies like Airbnb, Pfizer, and Artsy find great developers. Let us find your next great hire. Get started today.
sponsor
TensorFlow is providing some higher-level constructs itself, and some new ones were introduced in the latest 1.3 version. In this blog, we’ll look at an example using some of these new higher-level constructs, including Estimator, Experiment, and Dataset.
tensorflow
Lane identification system for camera based systems.
machine learning
,
image processing
core-python
We show how to build a very basic, yet not bad, meme retrieval system using pretrained word embeddings.
machine learning
machine learning
,
image processing
This curated list contains python packages for time series analysis.
time series
Jobs
Remote
Projects
setup.py - 1131 Stars, 39 Fork
A Human's Guide to setup.py.
lolviz - 225 Stars, 7 Fork
A simple Python data-structure visualization tool for lists of lists, lists, dictionaries; primarily for use in Jupyter notebooks / presentations.
selenium_extensions - 37 Stars, 2 Fork
Tools that will make writing tests, bots and scrapers using Selenium much easier.
Smoothly-Blend-Image-Patches - 36 Stars, 5 Fork
Make smooth predictions by blending image patches, such as for image segmentation
cloudflare-partner-cli - 12 Stars, 12 Fork
Set CNAME to use Cloudflare using the partner program.
janus - 8 Stars, 0 Fork
A minimalist argument-parsing library for Python.
cbox - 2 Stars, 0 Fork
convert any python function to unix-style command.
|
We often get questions about the difference between PyCharm Community Edition and PyCharm Professional Edition. We receive further questions about the difference between an individual and a commercial subscription for PyCharm Professional Edition. So let’s try to address some of these questions here:
The community edition of PyCharm is Apache 2 licensed: meaning it is free and open source and you can go to GitHub, and look at the source code. You’re free to use it whenever, and wherever you like, including at work. Additionally, you can fork and modify it. See the python subfolder README.md for details about PyCharm rather than IntelliJ IDEA.
Let’s go to the LICENSE.txt in the root of the GitHub repo. JetBrains’ open source projects are generally licensed under the Apache 2.0 License. This means that you can use it anywhere you’d like to, and modify it freely. There are some restrictions, which we’ll look into below.
Yes, you can. You are allowed to use PyCharm Community Edition for commercial use.
Yes, you can. However, you may be interested in learning about our free all product pack licenses for educational usage.
Yes, you can. The Apache 2.0 license doesn’t just permit using this code, but also allows modification. However, before you release YourNamePyCharm, you need to be aware that that the JetBrains and PyCharm trademarks are restricted. So if you do want to fork PyCharm, you will need to take out our branding. Furthermore, in your derived version, you will need to credit us. So you could make ‘YourNameIDE’, with a notice that it’s based on software made by JetBrains.
There are some restrictions that apply when you fork PyCharm. The Apache 2.0 license requires:
We’re not lawyers, so please be aware that this is not legal advice.
The professional edition of PyCharm gives you access to additional features that you don’t get in the community edition:
Many people get confused when we tell them that they are allowed to use a personal license at work. We believe though, that it’s important that developers can use the tools that are right for the job, and therefore we offer low price options to individual developers.
The difference between personal and commercial licenses isn’t about who uses the software; it is about who owns the software.
Individual licenses: yes. Commercial licenses: yes, as long as your user name (login) is the same on all the machines that you’re running it on.
If you’ve had a subscription for at least one year: yes. You have a perpetual fallback license for the version that was released one year before your subscription expired, and all its minor updates. See here for details.
Maybe.
We also offer discounts for startups, recent graduates, and users of commercial competitor products, find out more about discounts on our website.
If you have a specific sales question, contact our sales team to learn more about licenses, prices, discounts, etc. If you have any other question, let us know in the comments below, or reach out to us on Twitter.
"The Compliance Industrial Complex" is a term that evokes dystopian imagery of organizations engaging in elaborate and highly expensive processes to comply with open source license terms. As life often imitates art, many organizations engage in this practice, sadly robbing them of the many benefits of the open source model. This article presents an economically efficient approach to open source software license compliance.
Open source licenses generally impose three requirements on a distributor of code licensed from a third party:
Machine learning is easily one of the biggest buzzwords in tech right now. Over the past three years Google searches for “machine learning” have increased by over 350%. But understanding machine learning can be difficult — you either use pre-built packages that act like ‘black boxes’ where you pass in data and magic comes out the other end, or you have to deal with high level maths and linear algebra.
This tutorial is designed to introduce you to the fundamental concepts of machine learning — you’ll build your very first model from scratch to make predictions, while understanding exactly how your model works.
This tutorial is based on our Dataquest Machine Learning Fundamentals course, which is part of our Data Science Learning Path. The course goes into a lot more detail, and allows you to follow along writing code to learn by doing.
To start though, let’s explore what machine learning actually is.
Machine learning is the practice of building systems, known as models, that can be trained using data to find patterns which can then be used to make predictions on new data.
An important distinction is that a machine learning...