1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

バルコニー形状と地域特性による建材販売戦略の実験

Posted at

はじめに
建材の流通店で働いており、業務においてデータ分析が行えると強みになると思い、Aidemyのデータ分析の講座を受講。

目的
都内の築浅物件において、地域別のバルコニー形状の特徴を分析し、特定エリアでよく使用されているバルコニー形状を確認。これを通じて建材(化粧材や手すりなど)の販売促進に役立てる。

データの収集

  • 国土交通省のデータから、都内で住宅着工数が多い上位の区を抽出し、
    不動産情報サイトと照合した後9つのエリアを調査対象とした。
    (※上位10エリアの予定だったが、スケジュールの都合により9エリアとなった。)
  • 不動産情報サイトから新築および築浅物件のバルコニー形状を調査。
  • バルコニーは6種類類し、不明瞭なデータは除外。

分析
Pythonを使用し、ロジスティック回帰分析を実行。バルコニー形状ごとに各エリアでの採用確率を算出。

分析結果と推奨エリア

Accuracy: 0.605

1. Simple Projection
Kamata: 1.007
Ayase: 0.598
Shin-Koiwa: 0.507
2. Inner Balcony
Ichinoe: 0.502
Ogikubo: 0.485
Kamata: -0.100
3. Inset Balcony
Ichinoe: 0.728
Mizue: 0.530
Ayase: 0.336
4. Roof Balcony
Shakujiikoen: 0.915
Ogikubo: 0.632
Oizumigakuen: 0.451
5. Sky Balcony (Rooftop)
Kyodo: 0.784
Kamata: -0.058
Mizue: -0.075
6. Aluminum Balcony
Oizumigakuen: 0.531
Shin-Koiwa: 0.488
Shakujiikoen: 0.326

考察

  • 精度は0.605と高くないが、エリアによる傾向は存在すると考えられる。
  • Innar Balcony、Inset Balconyはその形状の特徴から狭小地で採用されやすい。
    分析結果からも、江戸川区一之江が上位にきており、狭い土地に多くの物件が建っているエリアで採用されやすいことがわかる。
  • Roof Balconyは、物件の2階の一部をバルコニーとして利用するため、広い土地が求められる。
    分析結果からも、石神井公園や荻窪など東京の西側に位置する高級物件にて採用される可能性が高いと予想できる。

今後の課題
物件データ200件程度と少ないため継続したデータ収集が必要となる。
実験的な分析のため、より多角的な分析も必要と考えられる。

所感
データ収集において、調査者にばらつきがあり、Pythonを活用し分析するにしても、データを整える作業が数多く発生した。
データ量が少ないため整理できたが、データクレンジングの重要性も理解し、しっかり扱えるようにする必要があると感じた。

コードサンプル
Google Colaboratory

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import OneHotEncoder
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score


# Google認証
from google.colab import auth
auth.authenticate_user()

import gspread
from google.auth import default
creds, _ = default()

gc = gspread.authorize(creds)

# https://docs.google.com/spreadsheets/d/1lcBUEVq7VJyUzSnTt_zVkrZoiqAwutlOYXdb3ibOreA/edit?usp=sharing

# スプレッドシートの読み込み
spreadsheet_url = 'https://docs.google.com/spreadsheets/d/1lcBUEVq7VJyUzSnTt_zVkrZoiqAwutlOYXdb3ibOreA'
# スプレッドシートIDを取得
spreadsheet_id = '1lcBUEVq7VJyUzSnTt_zVkrZoiqAwutlOYXdb3ibOreA'
worksheet = gc.open_by_key(spreadsheet_id).sheet1

# 全データをDataFrameに読み込む
import pandas as pd
from gspread_dataframe import get_as_dataframe


# データ整理
data['Area'] = data['Area'].replace('Unknown', pd.NA)
data['Shape_Balcony'] = data['Shape_Balcony'].replace('Unknown', pd.NA)
data = data.dropna(subset=['Area', 'Shape_Balcony'])


# Area列をワンホットエンコーディング
encoder = OneHotEncoder()
encoded_features = encoder.fit_transform(data[['Area']]).toarray()
encoded_df = pd.DataFrame(encoded_features, columns=encoder.get_feature_names_out())

# 目的変数をShape_Balcony
y = data['Shape_Balcony']

# 特徴量としてAreaのワンホットエンコーディングされた列を使用
feature_names = [name for name in encoder.get_feature_names_out() if 'Area' in name]
X = encoded_df[feature_names]

# データを訓練用と評価用に分割
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# ロジスティック回帰モデルの作成と訓練
model = LogisticRegression(max_iter=1000)
model.fit(X_train, y_train)

# 予測と評価
y_pred = model.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)

# 精度の出力
print(f'Accuracy: {accuracy:.3f}')

import numpy as np

# モデルの係数を取得し、形状ごとに分析
shape_categories = data['Shape_Balcony'].unique()  #
coefficients = model.coef_
area_features = encoder.get_feature_names_out()

# 各バルコニー形状に対する係数の詳細を表示
for index, shape in enumerate(shape_categories):
    print(f"{shape}")
    shape_coefficients = coefficients[index]  # その形状の係数
    sorted_areas = np.argsort(shape_coefficients)[::-1]  # 係数に基づいて地域をソートし、逆順にする

    # 上位3地域(値が大きい順)
    print("推奨される地域:")
    for i in sorted_areas[:3]:  # 大きい値から3つ取得
        print(f"{area_features[i]}: {shape_coefficients[i]:.3f}")

    print("\n")


1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?