Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sklearn regression

>>> import numpy as np
>>> from sklearn.linear_model import LinearRegression
>>> X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
>>> # y = 1 * x_0 + 2 * x_1 + 3
>>> y = np.dot(X, np.array([1, 2])) + 3
>>> reg = LinearRegression().fit(X, y)
>>> reg.score(X, y)
1.0
>>> reg.coef_
array([1., 2.])
>>> reg.intercept_
3.0...
>>> reg.predict(np.array([[3, 5]]))
array([16.])
Comment

PREVIOUS NEXT
Code Example
Python :: set value through serializer django 
Python :: tkinter responsive gui 
Python :: check file existence python 
Python :: time df.apply() python 
Python :: python if type dict 
Python :: tkinter toplevel 
Python :: python png library 
Python :: dataframe unstack 
Python :: Scrapping tables in an HTML file with BeautifulSoup 
Python :: creating django project 
Python :: django error handling < form 
Python :: anagram python 
Python :: python plot arrays from matrix 
Python :: append to set python 
Python :: ForeignKey on delete django 
Python :: opencv black white image 
Python :: make a label using tkinter in python 
Python :: rename keys in dictionary python 
Python :: reset all weights keras 
Python :: how to create an integer validate python 
Python :: transpose matrix in python without numpy 
Python :: create login system in python 
Python :: installing private python packages from requirements.txt 
Python :: how to host python flask web application 
Python :: A Python Class Constructor 
Python :: basic flask app 
Python :: python how to add to a list 
Python :: cufflink install python jupyter 
Python :: how to print last element in a list python 
Python :: create a date list in postgresql 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =