728x90
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
df = pd.read_csv('training_data.csv')
X = df[['open', 'high', 'low', 'volume']]
y = df['close']
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = RandomForestClassifier()
model.fit(X_train, y_train)
accuracy = model.score(X_test, y_test)
print('Accuracy:', accuracy)
new_data = [[100, 105, 98, 1000]]
prediction = model.predict(new_data)
print('Prediction:', prediction)
'''
This code uses a random forest classifier from the sklearn library to train a model
on a dataset of stock prices. The model is then tested on a separate set of data
and used to make a prediction on a single example.
'''
728x90
'강얼쥐와 함께 즐겁게 읽는 AI' 카테고리의 다른 글
구글 데이터 분석하기 (0) | 2023.02.09 |
---|---|
AI 로 가볍게 주식투자 해보기 (*가벼운 내용입니당~) (0) | 2023.02.07 |
CV2 상에서 포착된 비디오 프레임 안에 있는 HOG 라이브러리를 분석하는 계수에 관하여 (0) | 2023.02.01 |
조던 피터슨이 말한 GPT (0) | 2023.01.20 |
고양이야 선녀야? (feat. tensorflow) (0) | 2022.12.31 |