According to the own documentation of scipy
it doesn’t turn very well in Windows
because it has some dependencies that only work in linux
and mac
Alternatively, I recommend using sklearn, she is a very good lib working with Learning machine, and also has good documentation plus several examples.
to install it you can:
pip install -U scikit-learn
or if using anaconda:
conda install scikit-learn
I made an example using the numpy (to work with arrays) and the matplot (to work with graphics)
To install:
pip install numpy
python -m pip install -U pip setuptools
python -m pip install matplotlib
In anaconda usually these libs already come installed.
Below is an example of creating a linear regression with the sklearn
import matplotlib.pyplot as plt
import numpy as np
from sklearn import linear_model
#Logica x = x*10 + acc
#acc = acc + 5
#acc inicia em 0
#dataSet treino
#1 - 10 + 0 = 10
#2 - 20 + 5 = 25
#3 - 30 + 10 = 40
#4 - 40 + 15 = 55
x_train = np.array([ [1], [2], [3], [4] ]);
y_train = np.array([ 10, 25, 40, 55 ]);
#dataSet teste
#5 - 50 + 20 = 70
#6 - 60 + 25 = 85
#7 - 70 + 30 = 100
#8 - 80 + 35 = 115
x_test = np.array([ [5], [6], [7], [8] ])
y_test = np.array([ 70, 85, 100, 115 ])
#cria o modelo e faz o treinamento (fit)
model = linear_model.LinearRegression().fit(x_train, y_train)
#exibe algumas informações
print('Coeficientes: \n', model.coef_)
print("Erro médio quadrado: %.2f" % np.mean((model.predict(x_test) - y_test) ** 2))
print('variância de score: %.2f' % model.score(x_test, y_test))
#monta o plot para exibição do resultado
plt.scatter(x_test, y_test, color='black')
plt.plot(x_test, model.predict(x_test), color='blue', linewidth=3)
plt.xticks(())
plt.yticks(())
plt.show()
This code will generate a graph in this way:
An example of the documentation of the sklearn
with linear regression applied on diabetes tests:
Linear Regression Example
Ever tried to make
pip install scipy
at the prompt?– Woss
So Anderson, quiet? I tried, he does not install, I read on the scipy site and there says that it is not possible to install in windows. I downloaded some whl files and tried to install by Pip and it was not also.
– Matheus
No - scipy is what you have to use - has how to use Windows yes. And if you didn’t, it would be better for you to set up Pyton and Scipy on a virtual machine (or in microsoft’s new scheme of having an Ubuntu hybrid pr inside Windows from the windows app store) than to try to go too far using other tool sets.
– jsbueno