df = pd.read_csv('/content/drive/MyDrive/sample_data/manhattan.csv') # 맨하탄 입대료
df
df.info()
# rent 타겟 독립변수
df.describe()
# rent 임대료, bedrooms 침실수,bathrooms 화장실수,size_sqft,
# 평수 feet,min_to_subway 지하철과의 거리,floor 층수,building_age_yrs 건축된 연도,
#no_fee 수수료,has_roofdeck 옥상,has_washer_dryer 세탁기 건조기,has_doorman 도어맨,
#has_elevator 엘리베이터,has_dishwasher 식기세척기,has_patio 마당 ,has_gym 체육관,
#헬스장,neighborhood 이웃,borough 자치구
![](https://blog.kakaocdn.net/dn/3Bgcv/btr1CLUY4zz/zy5iUSpBXC38qthXinMyB0/img.png)
![](https://blog.kakaocdn.net/dn/OZzVd/btr1JsAiGdr/0VwZGZt5XEMwovu0b1J5k1/img.png)
임대료 예측
# y = b + a1x1 + a2x2 + a3x3 + ... + anxn
# a1,a2 ... an : 회귀계수
# b 절편 bias
from sklearn.model_selection import train_test_split
y = df[['rent']] # 타겟, 정답
X = df.drop(['rent','rental_id','neighborhood','borough'], axis=1) # rent 삭제
# df.drop(['neighborhood','borough'])
X
![](https://blog.kakaocdn.net/dn/b5ells/btr1pX9Rfgq/hsiK4OjXs1o0i5KTPZ5ZjK/img.png)
학습 데이터 , 테스트 데이터 분리해야 한다
x_train, x_test, y_train, y_test = train_test_split(X,y,train_size=0.8, test_size=0.2)
# 과적합(특정데이터 만을 이한 )을 막기위해서 8 : 2
x_train
y_train
모델 생성
'Colab > 머신러닝' 카테고리의 다른 글
06. K-최근접 이웃 회귀 K-NN Regression (0) | 2023.03.06 |
---|---|
05. 로지스틱 회귀분석 Logistic Regression (0) | 2023.03.03 |
03. 선형회귀(linear regression) (0) | 2023.02.28 |
02. 선형회귀(linear regression) (0) | 2023.02.27 |
01. 기초 이론 (0) | 2023.02.27 |