본문 바로가기

AI(Artificial Intelligence)

[딥러닝] 주짓수 훈련과 복음 활동이 지능적 성장과 심리적 안정에 미치는 영향 분석

728x90
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split #pip install scikit-learn
from sklearn.linear_model import LinearRegression
import tkinter as tk
from tkinter import ttk #pip install ttkthemes

# 데이터 생성 (예시 데이터)
np.random.seed(0)
n_samples = 100

# 주짓수 훈련 시간, 복음 활동 시간, 심리적 안정 및 지능적 성장 점수 생성
jujitsu_hours = np.random.normal(5, 2, n_samples)
gospel_hours = np.random.normal(3, 1, n_samples)
psychological_stability = 50 + jujitsu_hours * 2 + gospel_hours * 3 + np.random.normal(0, 5, n_samples)
cognitive_growth = 40 + jujitsu_hours * 4 + gospel_hours * 2 + np.random.normal(0, 5, n_samples)

# 데이터 나누기
X = np.column_stack((jujitsu_hours, gospel_hours))
y_psychological = psychological_stability
y_cognitive = cognitive_growth

X_train, X_test, y_psychological_train, y_psychological_test = train_test_split(X, y_psychological, test_size=0.2, random_state=0)
_, _, y_cognitive_train, y_cognitive_test = train_test_split(X, y_cognitive, test_size=0.2, random_state=0)

# 모델 학습
model_psychological = LinearRegression().fit(X_train, y_psychological_train)
model_cognitive = LinearRegression().fit(X_train, y_cognitive_train)

# 예측
y_psychological_pred = model_psychological.predict(X_test)
y_cognitive_pred = model_cognitive.predict(X_test)

# 결과 시각화
def plot_results():
    fig, ax = plt.subplots(1, 2, figsize=(12, 5))
   
    # 심리적 안정성 그래프
    ax[0].scatter(y_psychological_test, y_psychological_pred, color='blue', label='Predicted vs Actual')
    ax[0].plot([y_psychological_test.min(), y_psychological_test.max()], [y_psychological_test.min(), y_psychological_test.max()], 'k--', lw=2)
    ax[0].set_xlabel('Actual Psychological Stability')
    ax[0].set_ylabel('Predicted Psychological Stability')
    ax[0].set_title('Psychological Stability')
    ax[0].legend()

    # 지능적 성장 그래프
    ax[1].scatter(y_cognitive_test, y_cognitive_pred, color='green', label='Predicted vs Actual')
    ax[1].plot([y_cognitive_test.min(), y_cognitive_test.max()], [y_cognitive_test.min(), y_cognitive_test.max()], 'k--', lw=2)
    ax[1].set_xlabel('Actual Cognitive Growth')
    ax[1].set_ylabel('Predicted Cognitive Growth')
    ax[1].set_title('Cognitive Growth')
    ax[1].legend()
   
    plt.tight_layout()
    plt.show()


plot_results()

 



728x90