Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
metody_eksploracji_danych [2016/10/17 14:24]
pszwed [Kod Python]
— (current)
Line 1: Line 1:
-====== Metody eksploracji danych ====== 
  
-===== Laboratorium 1 ===== 
- 
- {{:med:med-lab01.pdf|Opis zadań (PDF)}} 
-==== Zbiory danych ==== 
- 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-001.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-002.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-003.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-004.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-005.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-006.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-007.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-008.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-009.arff]] 
-  *[[http://home.agh.edu.pl/~pszwed/med/regression/xy-010.arff]] 
- 
-==== Kod Python ==== 
- 
-Poniżej zamieszczony kod może posłużyć do wizualizacji danych. 
- 
-  - Dane należy wprowadzić, jako tekst ''data='' 
-  - Formułę funkcji regresji w wierszu ''fy=2.3702*fx+6.1973''. Oczywiście ''2.3702'' i ''6.1973'' to parametry wyznaczone podczas regresji 
-  - Kod można uruchomić  
-       * W IDE Spyder 
-       * Uruchamiając lokalnie Jupyter Notebook i wprowadzając kod w przeglądarce 
-       * Online: [[https://try.jupyter.org/]] 
- 
- 
-<code python> 
-%matplotlib notebook 
- 
-import matplotlib.pyplot as plt 
-import numpy as np 
-from scipy import stats 
-from io import StringIO 
- 
-data = """ 
-0.246939,9.011391 
-0.895519,8.950505 
-0.971588,9.671047 
-1.188316,14.735488 
-1.741884,10.265625 
-2.196002,13.501097 
-2.637403,13.887849 
-2.788188,17.180626 
-3.50202,19.321529 
-""" 
-#enter data as a string 
-inp =  StringIO(data) 
-x, y = np.loadtxt(inp, delimiter=',', usecols=(0, 1), unpack=True,skiprows=6) 
- 
-plt.scatter(x,y,s=80, marker='+') 
- 
- 
-#plot function  
-#fx - arguments  
-#fy - values,  
-#ftrue -function used to generate data 
-  
-fx=np.linspace(-10,60,100) 
-fy=2.3702*fx+6.1973  
-ftrue=2.37*fx+7 
-plt.plot(fx,fy,linewidth=2,color='r') 
-plt.plot(fx,ftrue,linewidth=1,linestyle='--',color='g') 
- 
-plt.xlim(-10,60) 
-plt.grid(True) 
-plt.xlabel('X') 
-plt.ylabel('Y') 
- 
-r = stats.pearsonr(x, y)[0]  
-plt.title('Regression $f_{true} = 2.37x+7$ r=' + str(r)) 
- 
-plt.show() 
- 
-</code> 
- 
-=== Spyder === 
- 
-Aby wynik wyświetlił się w osobnym oknie... 
- 
-{{:med:spyder_opcje.png?200|}} 
metody_eksploracji_danych.1476707088.txt.gz · Last modified: 2016/10/17 14:24 by pszwed
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0