Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

recall at k calculate python

def precision(actual, predicted, k):
    act_set = set(actual)
    pred_set = set(predicted[:k])
    result = len(act_set & pred_set) / float(k)
    return result

def recall(actual, predicted, k):
    act_set = set(actual)
    pred_set = set(predicted[:k])
    result = len(act_set & pred_set) / float(len(act_set))
    return result
Comment

PREVIOUS NEXT
Code Example
Python :: Python NumPy asfarray Function Example Tuple to float type array 
Python :: python subtract between list 
Python :: python immutable dataclass 
Python :: convert all columns to float pandas 
Python :: python sh command 
Python :: set pop in python 
Python :: how to check python version in script 
Python :: how to print tables using python 
Python :: how to split strings in python 
Python :: how to create a function in python 
Python :: 12 month movinf average in python for dataframe 
Python :: async asyncio input 
Python :: pandas create dataframe from multiple dictionaries 
Python :: python re.findall() 
Python :: how to save python-pptx 
Python :: arma-garch model python 
Python :: how to display items on a list on new lines python 
Python :: difference between 2 dataframes 
Python :: Common Python String Methods 
Python :: python set workspace dir 
Python :: python re split 
Python :: Function in python with input method 
Python :: pandas fill missing index values 
Python :: stemmer nltk 
Python :: SciPy Spatial Data 
Python :: python strftime cheat sheet 
Python :: flask add_url_rule 
Python :: maximum recursion depth exceeded while calling a Python object 
Python :: parse invoice python 
Python :: python how to make boxplots with jitter 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =