Skip to content

Instantly share code, notes, and snippets.

View fufufukakaka's full-sized avatar
:shipit:

Yusuke Fukasawa fufufukakaka

:shipit:
View GitHub Profile
@fufufukakaka
fufufukakaka / custom_full_sort_scores.py
Created February 20, 2022 13:09
RecBole full_sort_scores のカスタム版(for sequential model)
import numpy as np
import torch
from recbole.data.interaction import Interaction
@torch.no_grad()
def full_sort_scores(uid_series, model, test_data, device=None):
"""Calculate the scores of all items for each user in uid_series.
Note:
import Select from 'react-select'
import { List } from 'react-virtualized'
import React, { useState, Component } from 'react'
import { filter } from 'lodash/fp'
const MenuList = props => {
const rows = props.children
const rowRenderer = ({ key, index, isScrolling, isVisible, style }) => (
<div key={key} style={style}>
{rows[index]}
def fast_access_sparse_matrix(idx, row, sparse_matrix):
# index
start, stop = sparse_matrix.indptr[idx], sparse_matrix.indptr[idx+1]
index_data = sparse_matrix.data[start:stop]
index_rows = sparse_matrix.indices[start:stop]
# row
## find row index
if row in index_rows:
row_index = np.where(index_rows==row)[0][0]
extract_elements = index_data[row_index]
import math
def precision_and_recall(ranked_list, ground_list):
hits = 0
for i in range(len(ranked_list)):
id = ranked_list[i]
if id in ground_list:
hits += 1
pre = hits / (1.0 * len(ranked_list))
rec = hits / (1.0 * len(ground_list))
return pre, rec
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fufufukakaka
fufufukakaka / pokemontest.Rmd
Created May 13, 2017 09:43
Lab-on article "Transition from Excel to R" Appendix
---
title: "pokemontest"
output: html_document
---
## 列数
```{r}
#データの読み込み
df<-read.csv('../dataset/pokemon.csv',encoding = 'utf-8',sep='\t')
#列数の取得