<filename>regrex1_in_python.py<gh_stars>0
#!/usr/bin/env python
# coding: utf-8

# # importing packages 

# In[22]:


import pandas as pd
import sklearn
import numpy as np
import matplotlib.pyplot as plt
import sys

from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

import argparse
#parser = argparse.ArgumentParser()
#parser.add_argument("file")
#args = parser.parse_args()


# # reading data 

# In[23]:


regrex1 = pd.read_csv(sys.argv[1])
print("loading {}".format(sys.argv[1]))


# In[13]:


regrex1.plot.scatter(x='x',y='y', title='Scatter Plot in Python')
plt.savefig('py_orig.png')
plt.show()


# # making 1D model into 2D, splitting data into test and train 

# In[14]:


data = sklearn.linear_model.LinearRegression()
x = regrex1['x'].values.reshape(-1,1)
y = regrex1['y'].values.reshape(-1,1)
x_train = x
x_test = x
y_train = y
y_test = y


# # training the algorithm 

# In[15]:


regressor = LinearRegression()
regressor.fit(x_train, y_train)
y_pred = regressor.predict(x_test)
LinearRegression()


# # plot linear model with test data 

# In[16]:


plt.scatter(x_test, y_test,  color='gray')
plt.plot(x_test, y_pred, color='red', linewidth=2)
#mpl.plot()
plt.show()


# # plot linear model with original data 

# In[17]:


plt.scatter(regrex1['x'], regrex1['y'], color = 'gray')
plt.plot(x_test, y_pred, color='red', linewidth=2)
plt.savefig('py_Im.png')
plt.show()



# In[ ]:





<filename>regrex1_in_python.py<gh_stars>0
#!/usr/bin/env python
# coding: utf-8

# # importing packages 

# In[22]:


import pandas as pd
import sklearn
import numpy as np
import matplotlib.pyplot as plt
import sys

from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

import argparse
#parser = argparse.ArgumentParser()
#parser.add_argument("file")
#args = parser.parse_args()


# # reading data 

# In[23]:


regrex1 = pd.read_csv(sys.argv[1])
print("loading {}".format(sys.argv[1]))


# In[13]:


regrex1.plot.scatter(x='x',y='y', title='Scatter Plot in Python')
plt.savefig('py_orig.png')
plt.show()


# # making 1D model into 2D, splitting data into test and train 

# In[14]:


data = sklearn.linear_model.LinearRegression()
x = regrex1['x'].values.reshape(-1,1)
y = regrex1['y'].values.reshape(-1,1)
x_train = x
x_test = x
y_train = y
y_test = y


# # training the algorithm 

# In[15]:


regressor = LinearRegression()
regressor.fit(x_train, y_train)
y_pred = regressor.predict(x_test)
LinearRegression()


# # plot linear model with test data 

# In[16]:


plt.scatter(x_test, y_test,  color='gray')
plt.plot(x_test, y_pred, color='red', linewidth=2)
#mpl.plot()
plt.show()


# # plot linear model with original data 

# In[17]:


plt.scatter(regrex1['x'], regrex1['y'], color = 'gray')
plt.plot(x_test, y_pred, color='red', linewidth=2)
plt.savefig('py_Im.png')
plt.show()



# In[ ]:





#!/usr/bin/env python # coding: utf-8 # # importing packages # In[22]: #parser = argparse.ArgumentParser() #parser.add_argument("file") #args = parser.parse_args() # # reading data # In[23]: # In[13]: # # making 1D model into 2D, splitting data into test and train # In[14]: # # training the algorithm # In[15]: # # plot linear model with test data # In[16]: #mpl.plot() # # plot linear model with original data # In[17]: # In[ ]: