Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
260 changes: 260 additions & 0 deletions Hideyuki_Komaki/Hideyuki_Komaki.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 課題1"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"
]
}
],
"source": [
"list1= [i for i in range(1, 11)]\n",
"print(list1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 課題2"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[2, 4, 6, 8, 10]\n"
]
}
],
"source": [
"#リスト内包表記を用い,2の剰余が0の数字のみリストに格納する\n",
"list2= [i for i in range(1, 11) if i %2 ==0]\n",
"print(list2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 課題3"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f'}\n"
]
}
],
"source": [
"#リストの作成\n",
"list3= [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"]\n",
"#enumerateを用いて先のリストにインデックスが付いた辞書を作成\n",
"index_list3 = {i:x for i, x in enumerate(list3)}\n",
"print(index_list3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 課題4"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"山田さんは23歳、男性、身長170.3cm、体重60.2kgです。\n",
"高橋さんは30歳、女性、身長165.2cm、体重46.2kgです。\n",
"インクリメント後の高橋さんの年齢は31歳です。\n",
"Humanクラスのインスタンス数は2です。\n"
]
}
],
"source": [
"#Humanクラスの作成\n",
"class Human:\n",
" count = 0 #クラス変数の初期化\n",
" \n",
" #コンストラクタの作成\n",
" def __init__ (self, name , age, sex, height, weight):\n",
" Human.count += 1#クラス変数をカウントアップ\n",
" self.name = name\n",
" self.age = age\n",
" self.sex = sex\n",
" self.height = height\n",
" self.weight = weight\n",
" \n",
" #年齢をインクリメントするメソッドの作成\n",
" def countup_age(self):\n",
" self.age += 1\n",
"\n",
"#Humanクラスのインスタンスを作成\n",
"Yamada = Human(\"山田\", 23, \"男\", \"170.3cm\", \"60.2kg\")\n",
"Takahashi = Human(\"高橋\", 30, \"女\", \"165.2cm\", \"46.2kg\")\n",
"\n",
"print(\"{0}さんは{1}歳、{2}性、身長{3}、体重{4}です。\".format(Yamada.name, Yamada.age, Yamada.sex, Yamada.height, Yamada.weight))\n",
"print(\"{0}さんは{1}歳、{2}性、身長{3}、体重{4}です。\".format(Takahashi.name, Takahashi.age, Takahashi.sex, Takahashi.height, Takahashi.weight))\n",
"\n",
"#年齢をインクリメントするメソッドの呼び出し\n",
"Takahashi.countup_age()\n",
"print(\"インクリメント後の高橋さんの年齢は{}歳です。\".format(Takahashi.age))\n",
"\n",
"#インスtンス数のカウント\n",
"print(\"Humanクラスのインスタンス数は{}です。\".format(Human.count))"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"# 課題 5"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"#必要なモジュールのインポート\n",
"import numpy as np\n",
"#行列の作成\n",
"a = np.arange(16).reshape((4,4))\n",
"b = np.arange(8).reshape((4,2))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 28, 34],\n",
" [ 76, 98],\n",
" [124, 162],\n",
" [172, 226]])"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#行列の積\n",
"a.dot(b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 課題 6"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2.3237900077244502"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#行列の作成\n",
"x = np.array([1, 1, 1, 1, 1])\n",
"y = np.array([1, 0, 1, 0, 1])\n",
"#cosの計算\n",
"x.dot(y)/np.linalg.norm(x)*np.linalg.norm(y)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [py35]",
"language": "python",
"name": "Python [py35]"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
17 changes: 17 additions & 0 deletions Hideyuki_Komaki/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## 名前
小牧秀之

## 大学
慶應義塾大学三年

## 専攻
統計学、マーケティングサイエンス

## 今までの開発経験
・Ruby on Railsを用いたSNSアプリケーション
・Rを用いたデータ分析
・現在irisやboston,titanicのデータセットを用いて、機械学習モデルの実装練習をしております。
・自然言語処理を用いた記事のカテゴリー分類システムの実装に挑戦中です。

## 中期的な目標
・画像認識やログデータの解析の手法を身に着け、それらをマーケティング施策に活かす研究を行いたいと考えております。