Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Default X points
- MySQL
- SQL
- Else
- line width
- Github
- PANDAS
- Python
- polynomial regression
- iterates
- pie charts
- error
- For loops
- break
- PROJECT
- __init__
- AS
- train/test
- start exercise
- matplotlib
- matplotlib.pyplot
- machine learning
- data distribution
- multiple lines
- Text mining
- self parameter
- continue
- variables
- line color
- Text Analytics
Archives
- Today
- Total
Data Science Explorer
Machine Learning : Polynomial Regression 본문
반응형
- Polynomial Regression
It uses relationship between the variables x and y to find the best way to draw a line through the data points.
import numpy
import matplotlib.pyplot as plt
x = [1,2,3,5,6,7,8,9,10,12,13,14,15,16,18,19,21,22]
y = [100,90,80,60,60,55,60,65,70,70,75,76,78,79,90,99,99,100]
mymodel = numpy.poly1d(numpy.polyfit(x, y, 3))
myline = numpy.linspace(1, 22, 100)
plt.scatter(x, y)
plt.plot(myline, mymodel(myline))
plt.show()
Result
- R-Squared
The r-squared value ranges from 0 to 1, where 0 means no relationship, and 1 means 100% related.
Example
import numpy
from sklearn.metrics import r2_score
x = [1,2,3,5,6,7,8,9,10,12,13,14,15,16,18,19,21,22]
y = [100,90,80,60,60,55,60,65,70,70,75,76,78,79,90,99,99,100]
mymodel = numpy.poly1d(numpy.polyfit(x, y, 3))
print(r2_score(y, mymodel(x)))
- Predict Future Values
Example
import numpy
from sklearn.metrics import r2_score
x = [1,2,3,5,6,7,8,9,10,12,13,14,15,16,18,19,21,22]
y = [100,90,80,60,60,55,60,65,70,70,75,76,78,79,90,99,99,100]
mymodel = numpy.poly1d(numpy.polyfit(x, y, 3))
speed = mymodel(17)
print(speed)
Result
'Machine Learning' 카테고리의 다른 글
Machine Learning: Train/Test (0) | 2023.11.18 |
---|---|
Machine Learning: Linear Regression (0) | 2023.11.15 |
Machine Learning: Percentiles (0) | 2023.11.14 |
Machine Learning : Standard Deviation (0) | 2023.11.13 |
Mean Median Mode (0) | 2023.11.12 |