IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

2015-08-01から1ヶ月間の記事一覧

jupyter(iPython notebook)を使ってみる

Anacondaをインストールしたら結果的に入っていた。 (root):test01 foo$ pyenv version anaconda3-2.3.0 (set by /Users/foo/.pyenv/version) (root):test01 foo$ (root):test01 fii$ ipython notebook [I 19:49:42.714 NotebookApp] Using MathJax from CDN…

線形回帰サンプルコーディング

import numpy import pandas import statsmodels.api as sm # データ読み込み df = pandas.read_csv(csvファイル); df['constant'] = 1 col = [独立変数のカラムの配列指定] # 線形回帰分析 X = df[col] y = df[説明変数のカラム名] X = sm.add_constant(X) …

Pythonの配列の計算

numpyを使う。 普通の配列の場合は直接演算はできない。 >>> a = [1,2,3] >>> b = [4,5,6] >>> a -b Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for -: 'list' and 'list' numpyを利用すると計算がで</module></stdin>…

PythonでWebアクセス

requestsというモジュールを使ってgetする。 htmlの取得 >>> import requests >>> requests.get('https://www.example.com').text '\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset="utf-8" />\n <meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n </meta></meta></head></html>

Pythonに入門してみた

Python3系です 型はイラナイらしい >>> x = 'a' >>> x 'a' パラメータにはカッコが必要 >>> x = 'a' >>> x 'a' >>> print x File "<stdin>", line 1 print x ^ SyntaxError: Missing parentheses in call to 'print' >>> print 1+1 File "<stdin>", line 1 print 1+1 ^ Syn</stdin></stdin>…

ggplotインストール

audacityのintoro data scienceを参考にする。それだけだとimportエラーになるので追加でhuslをインストールする。 https://www.udacity.com/wiki/ud359/get-started https://github.com/yhat/ggplot/issues/407 ggplotでの画像の出力はggsaveを使う http://…

ggplotインストールと動作確認

Udacityのintoro data scienceを参考にする。それだけだとimportエラーになるので追加でhuslをインストールする。 https://www.udacity.com/wiki/ud359/get-started https://github.com/yhat/ggplot/issues/407 ggplotでの画像の出力はggsaveを使う http://p…