Introduction to matplotlib – Part 3

 

After laying the foundation in Introduction to matplotlib and Introduction to matplotlib – Part 2 I want to show you another important chart

Bar Charts

A bar chart is useful to show total values over time e.g. the revenue of a company.

years = (2017, 2018, 2019)
revenue = (5000, 7000, 9000)
plt.bar(years, revenue, width=0.35)
plt.xticks(years)
plt.title("Revenue over years")


Continue reading “Introduction to matplotlib – Part 3”

Linear Regression with sklearn – cheat sheet

# import and instantiate model
from sklearn.linear_model import LinearRegression
model = LinearRegression()

#prepare test data
features_train = df_train.loc[:, 'feature_name']
target_train = df_train.loc[:, 'target_name']

#fit (train) model and print coefficient and intercept
model.fit(features_train , target_train )
print(model.coef_)
print(model.intercept_)

# calculate model quality
from sklearn.metrics import mean_squared_error
from sklearn.metrics import r2_score

target_prediction = model.predict(features_train)
print(mean_squared_error(target_train , target_prediction))
print(r2_score(target_train , target_prediction))

# test predictions
features_test = df_train.loc[:, 'feature_name'] 
target_test = df_train.loc[:, 'target_name']
target_prediction_test = model.predict(features_test) 
print(mean_squared_error(target_test, target_prediction_test )) 
print(r2_score(target_test, target_prediction_test ))

pytest Tutorial – Part 1

At PyConDE Berlin 2019 Florian Bruhin gave a really nice session about testing with pytest, which I try to recap here.

Writing Tests

If You want to work with pytest you can install it via:

pip install pytest

When you know basic python unittest fixtures, good news ahead:

pytest is compatible and will run your old unittest classes as well, but pytest doesn’t need to have a testclass derived from some subclass.

It is sufficient to have a single python file which name starts with test_ containing a function which name also starts with test_ Continue reading “pytest Tutorial – Part 1”

Individual sustainable lifestyle tips

 

It’s tough! Believing in the 1% improvement thing / atomic habits I would start small but consistent. And also believing in the Management 3.0 experimenting culture I would run experiments. Some ideas: Continue reading “Individual sustainable lifestyle tips”

SQL-LIKE and wildcards

Se_en represents a pattern with a wildcard character. The _ means you can substitute any individual character here without breaking the pattern. The names Seven and Se7en both match this pattern.

The percentage sign % is another wildcard character that can be used with LIKE.

15 Steps for successful Bootstrapping – Part 3

In 15 Steps for successful Bootstrapping – Part 1 and 15 Steps for successful Bootstrapping – Part 2 I wrote about bootstrapping. This is the next part of this series.

USP, USP, USP

USP means “unique selling proposition”, which makes it even better than the German word USP. It’s all about “selling”, so selling. That means your unique selling point must also make the customer buy something. Continue reading “15 Steps for successful Bootstrapping – Part 3”

Software Testing Concepts – Part 1

My Tale of Woe

When I graduated from university and had my first job as a software engineer at Harman Becker Automotive Systems GmbH I should do the parental leave cover for a colleague. He showed me his project, gave me some info e.g. contact person and went off to Canada.

Literally on the second day he was away, the phone started to ring. The OEM had a A++ blocker issue found in the software and everything pointed to the component I was now maintaining. Continue reading “Software Testing Concepts – Part 1”

Python Package parameterized

Stackoverflowing around I found this nice package

https://github.com/wolever/parameterized

Parameterized testing in Python sucks.

parameterized fixes that. For everything. Parameterized testing for nose, parameterized testing for py.test, parameterized testing for unittest.

Reading this description I had very high expectations 🙂

so let’s see if the package can hold up to it. Continue reading “Python Package parameterized”