# Category Archives: python

## Multivariate Linear Regression by Scikit

Suppose we have training sets for y = 3 + 2 * x1 + x2, run below code to find the coefficient and intercept. import numpy as np from sklearn import datasets, linear_model # z = 3 + 2 * x1 + x2 X = np.array([ [3, 0], [0, 3], [1, 1], [2, 3], [4,… Read More »

## Simple Linear Regression by Scikit

Suppose we have training set for y = 5 + 0.5 * x. Run below code we can find the coefficient(slope) and intercept import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model # y = 5 + 0.5 * x x = [-10.0, -9.5, -9.0, -8.5, -8.0, -7.5, -7.0, -6.5, -6.0, -5.5,… Read More »

## Virtualenv in PyCharm

Run below code, we can check what package we have under current environment. import subprocess p = subprocess.Popen([‘pip’, ‘list’], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() print out In PyCharm -> Project Interpreter -> list box Project Interpreter, here are all the python environments: Under system button, select Create VirtualEnv Now, we have new virtual environment. Let’s… Read More »