PyInv

プログラミングのメモ、海外投資のメモ

Python-Machine Learning

Unsupervised Learning: PCA (主成分分析)の流れ

PCA (Principal Component Analysis) とは Structure 主なParameters 主なAttributes PCA を 1からやってみる Sample Dataの作成 Sample Dataの可視化 PCAの実行 結果の確認 Explained Variance Ratio (寄与率) Cumulative Explained Variance (累積寄与率…

Exploratory Data Analysis - 探索的データ解析

Exploratory Data Analysisとは 実践編 データ準備 データの観察 眺める データの前処理 データの成型 欠損値処理 Box plotで分布の広がりと異常値を観察 基本統計量の確認 組み合わせ散布図 Pair Plot 相関行列のHeat Map その後 特徴量エンジニアリング k-…

第三回:Ensemble Model - Bagging (Bootstrap Aggregating)

Baggingとは Structure 主なParameters Sample Baggingとは Bootstrapping(サンプル集合から復元抽出によりsub-sample setを作成)により作成したsub-sample setそれぞれに対してモデルを作成し、モデルの結果を集約して予測すること。 結果の集約はClassif…

回帰モデルの評価

回帰モデルの評価 平均二乗誤差(MSE: Mean Squared Error ) crross_validateの引数 平均絶対誤差(MAE: Mean Absolute Error) crross_validateの引数 中央値絶対誤差(MedAE: Median Absolute Error) crross_validateの引数 決定係数(R2) crross_valid…

Hot Encoder

Hot Encoderとは Dataの準備 OneHotEncoder Structure 主なParameters Sample get_dummies Structure 主なParameters Sample label_binarize Structure 主なParameters Sample Hot Encoderとは 特徴量(行列X、多分類のときにはyも)をOne Hot Vectorつまり1…

Unsupervised Learning: Clustering (K-means)の流れ

Clustering (K-means)を1からやってみる Sample Dataの作成 Sample Dataの可視化 エルボー法でクラスター数を決める 最適なクラスター数を使った結果の確認 Clustering (K-means)を1からやってみる 流れ 準備:Sample Dataの作成 Sample Dataをグラフ化し…

Decision Treeのvisualisation

Decision Treeを可視化 準備 Visualisation Code 結果 Decision Treeを可視化 Decision Treeは図にして俯瞰すると大変理解しやすくなる。ありふれた(諸先輩方には既知)コードではあるが自分用のメモとして残しておく。 準備 Decision Treeの作り方をおさら…

第二回:Ensemble Model - Gradient Boosted Decistion Trees(GBDT)

概要 引き続いてMachine Learning のEnsemble Model。Gradient Boosted Decision Trees 概要 Gradient-Boosted Decision Trees(GBDT) Pros and Cons Pros Cons Structure 主なParameters Usage Gradient-Boosted Decision Trees(GBDT) 連続したいくつもの…

第一回:Ensemble Model - Random Forestsとはなんぞや

Ensemble Model Random Forests Pros and Cons Structure Parmeters Usage Ensemble Model たくさんのMahcine Learning Model をたばねたもの。ひとつひとつにのOverfittingのような問題があっても、全体としては安定。 サンプルはBootstrapによって集められ…

続Python Machine Laerning Models

モデルの書き忘れ. Logistic Regression Structure Parameters Sample Decision Tree Structure 主なParameters Sample Visualization Feature importance モデルの書き忘れ. Logistic Regression, Decision Tree singapp.hatenablog.com Logistic Regressio…

その他のLinear Classifier - Naive Bayes Classifiers

その他のLinear ClassifierとしてNaive Bayes Classifiersがある Naive Bayes Classifiers Bernoulli Naive Bayes Multinomial Naive Bayes Gaussian Naive Bayes Strucuture Naive Bayes Classifiers 特徴量間で独立となる確率分布を用いて事後確率が最大と…

Modelの選び方 - k分割交差検証(k-fold Cross Validation by Validation Curve)とグリッドサーチ(Grid Search)

どのようにModelを選ぶか Validation Curveを使う Structure 主なParameters Usage Sample Furthermore Grid Search Structure 主なParameters Usage Sample どのようにModelを選ぶか Validation Curveを使って仮定した選んだModelに対して、サンプルのとり…

続続続Modelの評価 - ROC曲線とAUC

予測確率を用いたClassification Modelの評価 Confusion MatrixではPredicted Label (予測ラベル as 0 or 1)を用いてモデルを評価した。しかし、Predict Probability (予測確率)→Predicted Labelへと写すthreshold(閾値)が事前には決められるとは限らない…

続続Modelの評価 - Precision-Recall Curve (RecallとPrecisionの可視化)

RecallとPrecisioinの可視化 前準備としてDecision Function Structure Precision-recall curves Structure RecallとPrecisioinの可視化 前準備としてDecision Function SVC等で推定された境界平面からそのアウトプットへの距離。例えばX_testをインプットし…

続Modelの評価 - Dummy ClassifierとConfusion Matrix

Accuracy以外での評価 Dummy Classifier Usage Confusion Matrix Structure Sample Claffisicatoin Report Structure Sample Accuracy以外での評価 例えばImbalance Data(不均衡データ)の評価はどうあってもAccuracyが高くなるため、他の指標を用いる必要…

Modelの評価 (Accuracy)

Modelの評価値 R値(Score) Usage 評価値の検証用ツール Cross-validation Usage Validation Curve Modelの評価値 R値(Score) 統計の決定係数=(単回帰では)被説明変数の分散をどの程度説明変数の分散でカバーしているか、Accuracy の代表 Usage 各skle…

Python Machine Laerning Models

Machine Learning の基礎 全体の流れ モデルの種類 K-nearest neighbor classifier Ridge Regression Lasso Regression Lasso vs Ridge SVM(RBF) Machine Learning の基礎 Supervised Learning 全体の流れ データを学習用とテスト用に分割する X_train, X_te…