<commit_before>import sys
from pylab import show, plot, figure, subplot, mean, genfromtxt, corrcoef, legend
from scipy import stats
from scipy.optimize import curve_fit

x = genfromtxt(fname=sys.argv[1], skip_header = 1, usecols = 0 )
xi = x

for col in xrange(1,7):
	figure(1)
	subplot(2,3,col )
	y =  genfromtxt(fname=sys.argv[1], skip_header = 1, usecols = col )
	yi = y	
	   

	#slope calculated for b = 0 in y = ax + b
	a = mean(xi*yi)/mean(xi**2)


	corrr = corrcoef(yi, a*xi) 
	#print 'corrr ', corrr[1][0]
	print 'slope '+str(col), a
	
	print corrcoef(yi, a*xi)[1][0] 
	#def func(xi, a):
	#	return a*xi

	#popt, pcov = curve_fit(func, xi, yi)	

	#print 'popt', popt
	#print 'pcov', pcov 

	line = a*xi

	plot(xi,line,'r-',xi,yi,'o', label = a)
	legend()
	#legend(['m ', 'r**2 '],[a, corrr])

show()
<commit_msg>landscape.io: Import only necessary and ident correctly in stations/cal_zero_forced.py (issue #11).<commit_after>import sys
from pylab import show, plot, figure, subplot, mean, genfromtxt, corrcoef, legend

x = genfromtxt(fname=sys.argv[1], skip_header = 1, usecols = 0 )
xi = x

for col in xrange(1,7):
	figure(1)
	subplot(2,3,col )
	y =  genfromtxt(fname=sys.argv[1], skip_header = 1, usecols = col )
	yi = y
	#slope calculated for b = 0 in y = ax + b
	a = mean(xi*yi)/mean(xi**2)
	corrr = corrcoef(yi, a*xi) 
	#print 'corrr ', corrr[1][0]
	print 'slope '+str(col), a
	print corrcoef(yi, a*xi)[1][0] 
	#def func(xi, a):
	#	return a*xi
	#popt, pcov = curve_fit(func, xi, yi)	
	#print 'popt', popt
	#print 'pcov', pcov 
	line = a*xi
	plot(xi,line,'r-',xi,yi,'o', label = a)
	legend()
	#legend(['m ', 'r**2 '],[a, corrr])
show()
{'fraction_non_alphanumeric': 0.17800729040097205, 'fraction_numerical': 0.02187120291616039, 'mean_word_length': 4.228571428571429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '122512', 'n_tokens_mistral': 769, 'n_tokens_neox': 727, 'n_words': 190}