• Skip to main content
  • Skip to primary sidebar

学習記録

プログラミング

sparse matrixで0以外の値の位置を表示

2018年2月27日 by 河副 太智 Leave a Comment

Netflixのユーザーの視聴データがあったとして、
どの映画を見たのかを表すデータを使うと映画タイトルの
全てが表示され、凄まじい量になる。

基本的にNetflixユーザーは全部の映画を見るわけではないので
当然データセットは0だらけになる

sparse matrixではデータセットが0以外のものの
arrayの位置を返す

1
2
3
4
5
6
7
8
9
10
11
12
13
# Load libraries
import numpy as np
from scipy import sparse
 
# Create a matrix
matrix = np.array([[0, 0],
                   [0, 1],
                   [3, 0]])
 
# Create compressed sparse row (CSR) matrix
matrix_sparse = sparse.csr_matrix(matrix)
 
print(matrix_sparse)

結果

1
2
(1, 1)    1
(2, 0)    3

 

Filed Under: Numpy, scipy

かけ算九九

2018年2月16日 by 河副 太智 Leave a Comment

forの練習

1
2
3
4
5
6
7
8
9
10
11
import sys  
import math
 
arr = np.empty((0,), int)    
for i in range(1, 10):
    print(" \n")
    for j in range(1,10):
        if int(math.log10(i*j) + 1) == 1:
            print("", i*j ,end=" ")
        else:
            print(i*j, end=" ")

 

Filed Under: 作成実績

複数言語のチートシート

2018年2月13日 by 河副 太智 Leave a Comment

複数言語のチートシート

Filed Under: python3

Python3チートシート

2018年2月13日 by 河副 太智 Leave a Comment

Python3チートシート

その他チートシート多数

Filed Under: python3, チートシート

numpyチートシート

2018年2月13日 by 河副 太智 Leave a Comment

numpyチートシート

Filed Under: Numpy, チートシート

forにforを入れる練習 かけ算9×9

2018年2月13日 by 河副 太智 Leave a Comment

1
2
3
4
5
6
7
8
9
10
11
import sys  
import math
 
arr = np.empty((0,), int)    
for i in range(1, 10):
    print(" \n")
    for j in range(1,10):
        if int(math.log10(i*j) + 1) == 1:
            print("", i*j ,end=" ")
        else:
            print(i*j, end=" ")

 

Filed Under: 作成実績

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 12
  • Page 13
  • Page 14
  • Page 15
  • Page 16
  • Interim pages omitted …
  • Page 55
  • Go to Next Page »

Primary Sidebar

カテゴリー

  • AWS
  • Bootstrap
  • Dash
  • Django
  • flask
  • GIT(sourcetree)
  • Plotly/Dash
  • VPS
  • その他tool
  • ブログ
  • プログラミング
    • Bokeh
    • css
    • HoloViews
    • Jupyter
    • Numpy
    • Pandas
    • PosgreSQL
    • Python 基本
    • python3
      • webアプリ
    • python3解説
    • scikit-learn
    • scipy
    • vps
    • Wordpress
    • グラフ
    • コマンド
    • スクレイピング
    • チートシート
    • データクレンジング
    • ブロックチェーン
    • 作成実績
    • 時系列分析
    • 機械学習
      • 分析手法
      • 教師有り
    • 異常値検知
    • 自然言語処理
  • 一太郎
  • 数学
    • sympy
      • 対数関数(log)
      • 累乗根(n乗根)
    • 暗号学

Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in