1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

青チャートで周囲を巻き込んで課題解決したガクチカ【歴史年号因数分解画像認識分類】

Last updated at Posted at 2025-04-14

ガクチカ

学生時代、AIを活用した数学の理解に悩む仲間が多かったことから、自ら「青チャート」を軸にしたPython学習会を企画・主導し、グローバル志向のエンジニアリングリーダーとして、実践的な学びの場を構築しました。

学習会で仲間の声にじっくり耳を傾ける中で、宿題として出される『青チャート』よりも、日本史や世界史といった文系科目に関心を寄せる人が多いことに気付きました。そこで私は、従来の数学学習にとどまらないアプローチとして、**歴史と数学を掛け合わせた“共創型ITカリキュラム”**を自ら構想し、周囲を巻き込みながら実践に移しました。

この取り組みでは、歴史上の重要な年号を因数分解によって構造的に理解する手法と、ニューラルネットワーク(MNIST)による手書き数字認識をPythonで実装する演習を融合。年号を“数字”という切り口で視覚的にとらえながら、「歴史 × 数学 × AI」の相互関係を体験的に学べる教育ソリューションとしてカリキュラムを構築しました。

このソリューションは、数学やAI、プログラミングに不安を抱えていた学生にも親しみやすく、創造性を引き出す設計となっており、最終的には学習意欲の向上と学習コミュニティ全体の活性化につながる成果を上げることができました。

この取り組みを通じて、私はJupyter NotebookやGitHubの活用はもちろん、LLMや生成AIを駆使したプロンプト設計や、Microsoft Officeツールを含む多様な技術手段を組み合わせることで、DX推進を現場に定着させるマネジメント力と、誰とでも信頼関係を築ける柔軟なコミュニケーション能力を養ってきました。

貴社が現場レベルでのデジタル活用に真剣に取り組んでいる姿勢に深く共感しており、私のこれまでの技術支援の知見と巻き込み力を活かすことで、貴社の優れた技術力を組織全体に広げる橋渡し役として貢献できると考えています。

大きな変革の渦中にある今だからこそ、私は“コミュニケーション × テクノロジー”の掛け算で、貴社とともによりよい社会の実現に貢献してまいります。

面接官「取り組み自体は素晴らしいですが、本来の目的と手段が入れ替わっているように感じます。」

To be continued...

面接で提供するPythonコード

# Program Name: year_mnist_ai.py
# Creation Date: 20250414
# Overview: A program to factorize historical years and visualize them with MNIST digits using neural networks
# Usage: To run the program, use the command `python year_mnist_ai.py` in the terminal

# 必要なライブラリをインポート / Import necessary libraries
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.keras.datasets import mnist
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten
from tensorflow.keras.utils import to_categorical

# -----------------------------
# 定数定義 / Define constants
# -----------------------------
year1 = 645  # 大化の改新 / Taika Reform (645 A.D.)
year2 = 476  # 西ローマ帝国滅亡 / Fall of the Western Roman Empire (476 A.D.)
mnist_digit_indices = [int(d) for d in str(year1)]  # 年号の各桁を整数リストに変換 / Convert year into digit list
mnist_epoch = 3  # ニューラルネットワーク学習のエポック数 / Number of training epochs

# -----------------------------
# 素因数分解関数 / Prime factorization
# -----------------------------
def prime_factors(n):
    """
    与えられた整数 n を素因数分解し、1〜9の数ごとの出現回数を記録する
    Perform prime factorization and classify counts of factors in the range 1 to 9
    """
    factors = []  # 素因数のリスト / List of prime factors
    classification = {i: 0 for i in range(1, 10)}  # 1〜9の分類 / Classification dictionary

    i = 2  # 最小の素数から開始 / Start with the smallest prime
    while i * i <= n:
        if n % i == 0:
            factors.append(i)
            if i <= 9:
                classification[i] += 1  # 1〜9に収まる因数をカウント / Count only factors in 1–9
            n //= i
        else:
            i += 1
    if n > 1:
        factors.append(n)
        if n <= 9:
            classification[n] += 1
    return factors, classification

# -----------------------------
# 素因数分類の可視化 / Plot factor classification
# -----------------------------
def plot_factors(year, classification):
    """
    素因数を1〜9の分類で棒グラフに可視化する
    Visualize the frequency of prime factors from 1 to 9 using a bar chart
    """
    keys = list(classification.keys())
    values = list(classification.values())

    plt.figure(figsize=(8, 4))
    plt.bar(keys, values)
    plt.title(f"Prime Factor Classification (1–9) of Year {year}")  # 英語タイトル / Title in English
    plt.xlabel("Digit")  # X軸:因数 / X-axis: factor digit
    plt.ylabel("Count")  # Y軸:出現回数 / Y-axis: count
    plt.xticks(keys)
    plt.tight_layout()
    plt.show()

# -----------------------------
# MNIST画像の表示 / Display MNIST digits
# -----------------------------
def show_mnist_digits(digits):
    """
    指定した数字の手書きMNIST画像を表示する
    Display MNIST digit images corresponding to the digits in the year
    """
    (x_train, y_train), _ = mnist.load_data()  # 学習データのみ使用 / Use training set only

    plt.figure(figsize=(10, 2))
    for i, d in enumerate(digits):
        idx = np.where(y_train == d)[0][0]  # 指定した数字 d の最初の画像を取得 / Get the first image of digit d
        plt.subplot(1, len(digits), i + 1)
        plt.imshow(x_train[idx], cmap="gray")
        plt.title(f"Digit {d}")  # 表示する数字 / Digit label
        plt.axis("off")
    plt.suptitle("MNIST Images of Year Digits")  # サブタイトル / Suptitle
    plt.tight_layout()
    plt.show()

# -----------------------------
# ニューラルネットワークによるMNIST分類 / Train MNIST classifier
# -----------------------------
def train_mnist_classifier():
    """
    簡単な全結合ニューラルネットワークでMNIST手書き数字を分類する
    Train a simple neural network to classify MNIST handwritten digits
    """
    (x_train, y_train), (x_test, y_test) = mnist.load_data()

    # 画像の正規化 / Normalize image data
    x_train, x_test = x_train / 255.0, x_test / 255.0

    # 正解ラベルをone-hot形式に変換 / Convert labels to one-hot vectors
    y_train_cat = to_categorical(y_train, 10)
    y_test_cat = to_categorical(y_test, 10)

    # モデル構築 / Build the model
    model = Sequential([
        Flatten(input_shape=(28, 28)),  # 入力層:28x28画像を1次元に変換 / Flatten image
        Dense(128, activation="relu"), # 中間層:128ユニット / Hidden layer
        Dense(10, activation="softmax")# 出力層:10クラス(数字0〜9)/ Output layer
    ])
    model.compile(optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"])

    # 学習 / Train the model
    model.fit(x_train, y_train_cat, epochs=mnist_epoch, verbose=2)

    # 評価 / Evaluate accuracy
    test_loss, test_acc = model.evaluate(x_test, y_test_cat, verbose=0)
    print(f"Test Accuracy: {test_acc:.4f}")

# -----------------------------
# 実行パート / Run
# -----------------------------
# 各年号の素因数分解を実施 / Perform prime factorization
factors1, class1 = prime_factors(year1)
factors2, class2 = prime_factors(year2)

# 結果表示 / Show result
print(f"{year1} -> Prime Factors: {factors1}")
print(f"Classification (1–9): {class1}")
print(f"{year2} -> Prime Factors: {factors2}")
print(f"Classification (1–9): {class2}")

# 素因数の1〜9分類を可視化 / Visualize prime factor classification
plot_factors(year1, class1)
plot_factors(year2, class2)

# 年号の各桁に対応する手書き数字画像を表示 / Show MNIST images for digits in the year
show_mnist_digits(mnist_digit_indices)

# ニューラルネットで数字分類学習 / Train classifier on MNIST
train_mnist_classifier()


結果

image.png

image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?