Tag Archives: python

How to save sklearn tree plot as file (Vector Graphics)

The Scikit-Learn (sklearn) Python package has a nice function sklearn.tree.plot_tree to plot (decision) trees. The documentation is found here. However, the default plot just by using the command tree.plot_tree(clf) could be low resolution if you try to save it from a … Continue reading

Posted in Uncategorized | Tagged , , | 1 Comment

Calculate Cronbach Alpha using Python

R has the package “psych” which allows one to calculate the Cronbach’s alpha very easily just by one line: psych::alpha(your_data, column_list) For Python, the situation is more tricky since there does not seem to exist any package for calculating Cronbach’s … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Python code for PCA Rotation “varimax” matrix

The R programming language has an excellent package “psych” that Python has no real equivalent of. For example, R can do the following code using the principal() function: principal(r=dat, nfactors=num_pcs, rotate=”varimax”) to return the “rotation matrix” in principal component analysis … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

How to write Bash file to run multiple Python scripts simultaneously

Step 1 is to create a Bash file (using any editor, even Notepad). Sample code: #!/usr/bin/env bash python testing.py & python testingb.py & The above code will run two Python files “testing.py” and “testingb.py” simultaneously. Add more python scripts if … Continue reading

Posted in Uncategorized | Tagged , | 1 Comment

Python Online Courses for Teenagers/Adults

If your child is interested in a Computer Science/Data Science career in the future, do consider learning Python beforehand. Computer Science is getting very popular in Singapore again. To see how popular it is, just check out the latest cut-off … Continue reading

Posted in maths tuition | Tagged , , , , | 1 Comment

import matplotlib on PyCharm: Quick 3 min solution

Students trying to import the package “matplotlib” on PyCharm will soon face the cryptic error message: “Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed … Continue reading

Posted in maths tuition | Tagged | 1 Comment

Python Math Programming

Recently, I am thinking of learning the Python language for Math programming. An advantage for using Python for Math Programming (e.g. testing out some hypothesis about numbers), is that the Python programming language theoretically has no largest integer value that it can … Continue reading

Posted in maths tuition, programming | Tagged , | 2 Comments