<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Comparison of SoP Set and KNN Recommendation Systems*</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Piotr Solarczyk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jakub Stachurski</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Faculty of Applied Mathematics, Silesian University of Technology</institution>
          ,
          <addr-line>Kaszubska 23, 44100 Gliwice</addr-line>
          ,
          <country country="PL">POLAND</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper presents a comparative study between Soft Set and K-Nearest Neighbors (KNN) methods for recommendation systems. We utilize the Netflix dataset to analyze and compare the performance of both methods. The Soft Set approach is highlighted as a potentially more effective method due to its flexibility in handling uncertainties and partial truths, as opposed to the more rigid KNN. The results indicate that the Soft Set method provides more accurate and relevant recommendations, showcasing its potential in improving recommendation systems.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Recommendation Systems</kwd>
        <kwd>Soft Set</kwd>
        <kwd>K-Nearest Neighbors</kwd>
        <kwd>Netflix</kwd>
        <kwd>Data Analysis</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>2. Methodology</title>
      <p>In this section, we detail the methodologies employed in our study: the K-Nearest Neighbors
(KNN) algorithm and the Soft Set method. Both methodologies are implemented to generate
recommendations based on the Netflix dataset, and their performance is compared.</p>
      <sec id="sec-2-1">
        <title>2.1. Data Preprocessing</title>
        <p>The initial step involves loading and preprocessing the Netflix dataset. The dataset contains
information about various titles, including their type, rating, and genres. We start by loading the
dataset and removing rows with missing values to ensure data quality. The relevant features for our
recommendation system, such as title, type, rating, and genres (listed_in), are then extracted
for further analysis.
import pandas as pd
# Load data
d f = pd . r e a d _c s v ( ’ n e t f l i x _ t i t l e s . csv ’ )
# Data c l e a n i n g − remove rows with
d f _c l e a n e d = d f . dropna ( )
m i s s i n g v a l u e s
# E x t r a c t f e a t u r e s n e e d e d f o r r e c o m m e n d a t i o n s
d f _ f e a t u r e s = d f _c l e a n e d [ [ ’ t i t l e ’ , ’ type ’ , ’ r a t i n g ’
, ’ l i s t e d _ i n ’ ] ] . copy ( )</p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. K-Nearest Neighbors (KNN)</title>
        <p>K-Nearest Neighbors (KNN) is a simple yet powerful algorithm used for classification and
regression tasks. In our context, KNN is employed to generate movie recommendations. The
algorithm works by calculating the similarity between the genres of a given movie and those
of other movies in the dataset. The TF-IDF (Term Frequency-Inverse Document Frequency)
vectorizer is used to convert the genres into numerical features, and the cosine similarity metric is
used to find the k-nearest neighbors. The KNN recommendation function is implemented as
follows:
from s k l e a r n . f e a t u r e _ e x t r a c t i o n . t e x t import T f i d f V e c t o r i z e r
from s k l e a r n . n e i g h b o r s import N e a r e s t N e i g h b o r s
# KNN r ecommendation f u n c t i o n
def knn_recommendation ( t i t l e , k = 5 ) :
t f i d f = T f i d f V e c t o r i z e r ( s t o p _ w o r d s = ’ e n g l i s h ’ )
t f i d f _ m a t r i x = t f i d f . f i t _ t r a n s f o r m ( d f _ f e a t u r e s [ ’ l i s t e d _
i n ’</p>
        <p>] )
knn = N e a r e s t N e i g h b o r s ( n _n e i g h b o r s =k + 1 , m e t r i c = ’ c o s i
n e ’ ) knn . f i t ( t f i d f _ m a t r i x )
i d x = d f _ f e a t u r e s [ d f _ f e a t u r e s [ ’ t i t l e ’ ] . s t r . c o n t a i n s ( t
i t l e , c a s e = F a l s e , regex = F a l s e ) ] . index
i f len ( i d x ) == 0 :
print ( f " No t i t l e c o n t a i n i n g ’ { t i t l e } ’ found . " )
return [ ]
i d x = i d x [ 0 ]
d i s t a n c e s , i n d i c e s = knn . k n e i g h b o r s ( t f i d f _ m a t r i x [ i
d x ] , n _n e i g h b o r s =k + 1 )
r e c o m m e n d e d _t i t l e s = d f _ f e a t u r e s . i l o c [ i n d i c e s [ 0 ] ] .</p>
        <p>t i t l e . v a l u e s [ 1 : ]
return r e c o m m e n d e d _t i t l e s
2.3. SoP Set
The Soft Set theory provides a mathematical framework for dealing with uncertainties and
partial truths. Unlike traditional set theory, Soft Set theory allows for the representation of
vague concepts, making it suitable for recommendation systems where user preferences are
often imprecise. The Soft Set recommendation function calculates the similarity between the
genres of the input title and those of other titles in the dataset using the Jaccard similarity
coefficient. This method is more flexible and can handle the partial truths and uncertainties
present in the data. The implementation is as follows:
# S o f t s e t r ecommendation f u n c t i o n
def s o f t _s e t _r e c o m m e n d a t i o n ( t i t l e , t h r e s h o l d = 0 . 6 ) :
input_row = d f _ f e a t u r e s [ d f _ f e a t u r e s [ ’ t i t l e ’ ] . s t r . c o n t a
i n s ( t i t l e , c a s e = F a l s e , regex = F a l s e ) ]
i f input_row . empty :
print ( f " No t i t l e c o n t a i n i n g ’ { t i t l e } ’ found . " )
return [ ]
i n p u t _g e n r e s = s e t ( [ genre . s t r i p ( ) . lower ( ) for genre in
input_row . i l o c [ 0 ] [ ’ l i s t e d _ i n ’ ] . s p l i t ( ’ , ’ ) ] )
g e n r e s _ l i s t = d f _ f e a t u r e s [ ’ l i s t e d _ i n ’ ] . s t r . s p l i t ( ’ , ’ ) .
apply</p>
        <p>( lambda x : s e t ( [ i . s t r i p ( ) . lower ( ) for i in x ] ) )
def c a l c u l a t e _ s i m i l a r i t y ( g e n r e s ) :
return len ( i n p u t _g e n r e s . i n t e r s e c t i o n ( g e n r e s ) ) /</p>
        <p>len ( i n p u t _g e n r e s . union ( g e n r e s ) )
d f _ f e a t u r e s [ ’ s i m i l a r i t y ’ ] = g e n r e s _ l i s t .</p>
        <p>
          apply ( c a l c u l a t e _ s i m i l a r i t y )
recommendations = d f _ f e a t u r e s . s o r t _ v a l u e s ( by= ’ s i m i l a r i t
y ’ , a s c e n d i n g = F a l s e ) . head (
          <xref ref-type="bibr" rid="ref6">6</xref>
          ) . t i t l e . v a l u e s [ 1 : ]
return recommendations
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Experiments</title>
      <p>To evaluate the performance of the KNN and Soft Set methods, we conducted experiments
using the Netflix dataset. We selected the popular TV show "Breaking Bad" as the input title
and generated recommendations using both methods. The accuracy of the recommendations
was then evaluated based on feature similarity, taking into account the type, rating, and genres of
the titles.</p>
      <sec id="sec-3-1">
        <title>3.1. Evaluation of Recommendations</title>
        <p>The accuracy of the recommendations is assessed by calculating the average similarity of the
recommended titles to the input title. The feature similarity is determined by comparing the
type, rating, and genres of the titles. The following functions are used to calculate the feature
similarity and evaluate the accuracy of the recommendations:
# F e a t u r e s i m i l a r i t y c a l c u l a t i o n f u n c t i o n
def f e a t u r e _ s i m i l a r i t y ( t i t l e 1 , t i t l e 2 ) :
f e a t u r e s 1 = d f _ f e a t u r e s [ d f _ f e a t u r e s [ ’ t i t l e ’ ] . s t r . c o n t
a i n s ( t i t l e 1 , c a s e = F a l s e , regex = F a l s e ) ]
f e a t u r e s 2 = d f _ f e a t u r e s [ d f _ f e a t u r e s [ ’ t i t l e ’ ] == t i t l e 2 ]
i f len ( f e a t u r e s 1 ) == 0 or len ( f e a t u r e s 2 ) == 0 :</p>
        <p>return 0
f e a t u r e s 1 = f e a t u r e s 1 . i l o c [
0 ] f e a t u r e s 2 = f e a t u r e s 2 . i l o
c [ 0 ]
s i m i l a r i t y = 0
i f f e a t u r e s 1 [ ’ type ’ ] == f e a t u r e s 2 [ ’ type</p>
        <p>’ ] : s i m i l a r i t y += 1
i f f e a t u r e s 1 [ ’ r a t i n g ’ ] == f e a t u r e s 2 [ ’ r a t i n</p>
        <p>g ’ ] : s i m i l a r i t y += 1
)
g e n r e _ s i m i l a r i t y = len ( g e n r e s 1 . i n t e r s e c t i o n ( g e n r e s 2 ) ) /
len</p>
        <p>( g e n r e s 1 . union ( g e n r e s 2 ) )
s i m i l a r i t y += g e n r e _ s i m i l a r i t y</p>
        <p>return s i m i l a r i t y / 3
# E v a l u a t i o n o f r e commendations a c c u r a c y
def e v a l u a t e _r e c o m m e n d a t i o n s _a c c u r a c y ( i n p u t _ t i t l e
s , r e c o m m e n d e d _t i t l e s ) :
t o t a l _ a c c u r a c y = 0
for i n p u t _ t i t l e in i n p u t _ t i t l e
s : i n p u t _a c c u r a c y = 0
r e c o m m e n d e d _t i t l e s _f o r _ i n p u t = r e c o m m e n d e d _t i t l e
s . g e t ( i n p u t _ t i t l e , [ ] )
i f len ( r e c o m m e n d e d _t i t l e s _f o r _ i n p u t ) &gt; 0 :
for r e c o m m e n d e d _t i t l e in
r e c o m m e n d e d _t i t l e s _f o r _ i n p u t :
i n p u t _a c c u r a c y += f e a t u r e _ s i m i l a r
i t y ( i n p u t _ t i t l e , r e c o m m e n d e d
_t i t l e )
i n p u t _a c c u r a c y / = len ( r e c o m m e n d e d _t i t l e s _f o r _ i n
p u t ) t o t a l _ a c c u r a c y += i n p u t _a c c u r a c y
i f t o t a l _ a c c u r a c y == 0 :</p>
        <p>return 0
t o t a l _ a c c u r a c y / = len ( i n p u t _ t i t l e s )
return t o t a l _ a c c u r a c y ∗ 100</p>
        <p>We generated recommendations for "Breaking Bad" using both KNN and Soft Set methods.
The results were compared to assess the effectiveness of each method in providing relevant
recommendations.</p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. Results</title>
        <p>The results of our experiments indicate that the Soft Set method outperforms the KNN method in
terms of recommendation accuracy. The Soft Set method, with its ability to handle
uncertainties and partial truths, provided recommendations that were more similar to the input title
"Breaking Bad" in terms of type, rating, and genres. The accuracy of the KNN method was
lower, highlighting its limitations in dealing with the imprecise nature of real-world data.</p>
        <p>The accuracy of the recommendations is summarized as follows:</p>
        <p>Recommendations
(KNN)</p>
        <p>Recommendations
(SoP Sets)</p>
        <p>Accuracy
(KNN) (%)</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>In this study, we compared the performance of the K-Nearest Neighbors (KNN) and Soft Set
methods for recommendation systems using the Netflix dataset. The dataset was preprocessed to
remove missing values, and features such as title, type, rating, and genres were extracted for
analysis.</p>
      <p>The KNN method was implemented using the TF-IDF vectorizer to convert genre information into
numerical features, and cosine similarity was used to find the nearest neighbors. The Soft Set
method, on the other hand, calculated the similarity between the genres of the input title and
other titles using the Jaccard similarity coefficient.</p>
      <p>We evaluated the recommendations generated by both methods using the feature similarity
calculation, which took into account the type, rating, and genres of the titles. The accuracy of
the recommendations was measured by comparing the average similarity of the recommended
titles to the input title.</p>
      <p>Our experiments, which focused on the popular TV show "Breaking Bad," demonstrated that
the Soft Set method provided more accurate and relevant recommendations compared to the
KNN method. Specifically, the Soft Set method achieved higher accuracy by effectively handling
the uncertainties and partial truths inherent in user preferences and real-world data.</p>
      <p>The results highlight the potential of the Soft Set method as a superior alternative to KNN
for recommendation systems. The flexibility of Soft Set theory in dealing with imprecise and
incomplete data makes it well-suited for applications where user preferences are not always
clear-cut.</p>
      <p>Future work could explore integrating Soft Set theory with other machine learning techniques to
further enhance the accuracy and effectiveness of recommendation systems. Additionally,
expanding the evaluation to include a larger variety of input titles and diverse datasets could
provide a more comprehensive assessment of the methods’ performance.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Molodtsov</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          (
          <year>1999</year>
          ).
          <article-title>Soft set theory-First results</article-title>
          .
          <source>Computers &amp; Mathematics with Applications</source>
          ,
          <volume>37</volume>
          (
          <issue>4-5</issue>
          ),
          <fpage>19</fpage>
          -
          <lpage>31</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Netflix.</surname>
          </string-name>
          (
          <year>2016</year>
          ).
          <article-title>Netflix Movies and TV Shows Dataset</article-title>
          . Retrieved from https://www.kaggle. com/shivamb/netflix-shows
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Salton</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Buckley</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          (
          <year>1988</year>
          ).
          <article-title>Term-weighting approaches in automatic text retrieval</article-title>
          .
          <source>Information Processing &amp; Management</source>
          ,
          <volume>24</volume>
          (
          <issue>5</issue>
          ),
          <fpage>513</fpage>
          -
          <lpage>523</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Cover</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Hart</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          (
          <year>1967</year>
          ).
          <article-title>Nearest neighbor pattern classification</article-title>
          .
          <source>IEEE Transactions on Information Theory</source>
          ,
          <volume>13</volume>
          (
          <issue>1</issue>
          ),
          <fpage>21</fpage>
          -
          <lpage>27</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Adomavicius</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Tuzhilin</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          (
          <year>2005</year>
          ).
          <article-title>Toward the next generation of recommender systems: A survey of the state-of-the-art and possible extensions</article-title>
          .
          <source>IEEE Transactions on Knowledge and Data Engineering</source>
          ,
          <volume>17</volume>
          (
          <issue>6</issue>
          ),
          <fpage>734</fpage>
          -
          <lpage>749</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Jaccard</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          (
          <year>1901</year>
          ).
          <article-title>Étude comparative de la distribution florale dans une portion des Alpes et du Jura</article-title>
          .
          <source>Bulletin de la Société Vaudoise des Sciences Naturelles</source>
          ,
          <volume>37</volume>
          ,
          <fpage>547</fpage>
          -
          <lpage>579</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Huang</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          (
          <year>2008</year>
          ).
          <article-title>Similarity measures for text document clustering</article-title>
          .
          <source>In Proceedings of the sixth new zealand computer science research student conference (NZCSRSC)</source>
          (pp.
          <fpage>49</fpage>
          -
          <lpage>56</lpage>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <surname>Maji</surname>
            ,
            <given-names>P. K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Biswas</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Roy</surname>
            ,
            <given-names>A. R.</given-names>
          </string-name>
          (
          <year>2002</year>
          ).
          <article-title>An application of soft sets in a decision making problem</article-title>
          .
          <source>Computers &amp; Mathematics with Applications</source>
          ,
          <volume>44</volume>
          (
          <issue>8-9</issue>
          ),
          <fpage>1077</fpage>
          -
          <lpage>1083</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>