<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amanatulamriyah on Medium]]></title>
        <description><![CDATA[Stories by Amanatulamriyah on Medium]]></description>
        <link>https://medium.com/@amanatulamriyah66?source=rss-df2a55506188------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LW1kA1aU2Gg4jQ3r</url>
            <title>Stories by Amanatulamriyah on Medium</title>
            <link>https://medium.com/@amanatulamriyah66?source=rss-df2a55506188------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 03:11:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amanatulamriyah66/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sentiment Analysis — WordCloud]]></title>
            <link>https://medium.com/@amanatulamriyah66/sentiment-analysis-wordcloud-c09787c27803?source=rss-df2a55506188------2</link>
            <guid isPermaLink="false">https://medium.com/p/c09787c27803</guid>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[word-cloud]]></category>
            <dc:creator><![CDATA[Amanatulamriyah]]></dc:creator>
            <pubDate>Mon, 02 Oct 2023 01:55:25 GMT</pubDate>
            <atom:updated>2023-10-02T01:55:25.207Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sentiment Analysis — WordCloud</h3><p>This time I will analyze sentiment using word cloud. Word cloud is a visual representation of word frequency. The more commonly the term appears within the text being analysed, the larger the word appears in the image generated.</p><p>It is a data visualization technique used for representing text data in which the size of each word indicates its frequency or importance. Significant textual data points can be highlighted using a word cloud. Word clouds are widely used for analyzing data from social network websites.</p><p>For generating word cloud in Python, modules needed are — matplotlib, pandas and wordcloud. To install these packages, run the following commands</p><p><strong>Import Lib</strong></p><pre>import pandas as pd<br>import numpy as np<br>import wordcloud<br>!pip install google-play-scraper<br><br>from google_play_scraper import Sort, reviews<br>from google_play_scraper import app<br><br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>plt.style.use(&#39;ggplot&#39;)<br></pre><p><strong>Collecting Data</strong></p><pre>result, continuation_token = reviews(<br>    &#39;com.shopee.id&#39;,<br>    lang=&#39;id&#39;, <br>    country=&#39;id&#39;,<br>    sort=Sort.MOST_RELEVANT, <br>    count=10000, <br>    filter_score_with= None  <br>)<br><br># Dataframe dengan nama <br>dfs = pd.DataFrame(np.array(result),columns=[&#39;review&#39;])<br>dfs = dfs.join(pd.DataFrame(dfs.pop(&#39;review&#39;).tolist()))<br>dfs.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-FTpkYXsvZnDICA1XN9qZw.png" /></figure><p><strong>Analysis Using VADER’s SentimentIntensityAnalyzer</strong></p><pre>from nltk.sentiment import SentimentIntensityAnalyzer<br>from tqdm.notebook import tqdm<br>import nltk<br>nltk.downloader.download(&#39;vader_lexicon&#39;)<br>sia = SentimentIntensityAnalyzer()<br><br># Run the polarity score on the entire dataset<br>res = {}<br>for i, row in tqdm(dfs.iterrows(), total=len(dfs)):<br>    text = row[&#39;content&#39;]<br>    myid = row[&#39;reviewId&#39;]<br>    res[myid] = sia.polarity_scores(text)<br><br>vaders = pd.DataFrame(res).T<br>vaders.reset_index()<br>vaders = vaders.reset_index().rename(columns={&#39;index&#39;: &#39;reviewId&#39;})<br>vaders = vaders.merge(dfs, how=&#39;left&#39;)<br><br>vaders[&#39;sentiment&#39;] = np.where(vaders[&#39;compound&#39;]==0 , &#39;Neutral&#39;,<br>                              np.where(vaders[&#39;compound&#39;]&lt;0 , &#39;Negative&#39;, &#39;Positive&#39;))<br><br>ax = vaders[&#39;sentiment&#39;].value_counts().sort_index() \<br>    .plot(kind=&#39;bar&#39;,<br>          title=&#39;Shopee Review Sentiment&#39;,<br>          figsize=(5, 5))<br>ax.set_xlabel(&#39;Review Sentiment&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*ORvhw3Mhjq9c5rSvYUN15A.png" /></figure><p><strong>Word Cloud</strong></p><pre>vaders[&#39;content&#39;]=vaders[&#39;content&#39;].astype(str)<br>vaders[&#39;content&#39;]=vaders[&#39;content&#39;].str.lower()<br><br>!pip install wordcloud<br><br>import nltk<br>from nltk.corpus import stopwords<br>from nltk.stem import WordNetLemmatizer<br>from wordcloud import WordCloud<br>import re<br>import nltk<br>nltk.download(&#39;stopwords&#39;)<br>nltk.download(&#39;wordnet&#39;)<br>nltk.download(&#39;omw-1.4&#39;)<br><br>#object of WordNetLemmatizer<br>lm = WordNetLemmatizer()<br>def text_transformation(vaders_col):<br>    corpus = []<br>    for item in vaders_col:<br>        new_item = re.sub(&#39;[^a-zA-Z]&#39;,&#39; &#39;,str(item))<br>        new_item = new_item.lower()<br>        new_item = new_item.split()<br>        new_item = [lm.lemmatize(word) for word in new_item if word not in set(stopwords.words(&#39;english&#39;))]<br>        corpus.append(&#39; &#39;.join(str(x) for x in new_item))<br>    return corpus<br>corpus = text_transformation(vaders[&#39;content&#39;])</pre><pre>word_cloud = &quot;&quot;<br>for row in corpus:<br>    for word in row:<br>        word_cloud+=&quot; &quot;.join(word)<br>wordcloud = WordCloud(width = 1000, height = 500,background_color =&#39;white&#39;,min_font_size = 10).generate(word_cloud)<br>plt.imshow(wordcloud)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*ajrgppxuMIFUtFHxcfPxVw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c09787c27803" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RECOMMENDATION SYSTEM Using Cosine Similarity — Movies Dataset]]></title>
            <link>https://medium.com/@amanatulamriyah66/recommendation-system-using-cosine-similarity-movies-dataset-3e8edc799807?source=rss-df2a55506188------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e8edc799807</guid>
            <category><![CDATA[recommender-systems]]></category>
            <category><![CDATA[movie-recommendation]]></category>
            <category><![CDATA[cosine-similarity]]></category>
            <category><![CDATA[recommendation-system]]></category>
            <dc:creator><![CDATA[Amanatulamriyah]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 03:48:09 GMT</pubDate>
            <atom:updated>2023-09-27T03:48:09.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>RECOMMENDATION SYSTEM Using Cosine Similarity — Movies Dataset</h3><p>Recommender systems (RSs) are software tools and techniques that provide suggestions for items that are most likely of interest to a particular user. In this introductory chapter, we briefly discuss basic RS ideas and concepts. Our main goal is to delineate, in a coherent and structured way, the chapters in this handbook. Additionally, we aim to help the reader navigate the rich and detailed content that this handbook offers.</p><p>Movie Recommendation System is a movie recommendation system, also known as a movie recommender system, that uses machine learning (ML) to predict or filter users’ film preferences based on their prior decisions and actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*TOOLlwHyRbuP6sLW_HQ8JA.png" /></figure><p>In this article, I use filtering based on content and collaboration filtering techniques. Filtering based on content is a method of filtering movies in movie recommendation systems that takes advantage of the items’ data (movies). This information, taken from just one user, is quite crucial in this case. This technique uses an ML algorithm to suggest movies that are comparable to the user’s past choices. Therefore, the information about the prior movie choices and likes of just one person generates similarity in content-based filtering. Collaboration filtering is a filtering technique based on the interactions between the relevant person and other users. For the best outcomes, the system contrasts and compares these behaviors. It combines the film choices and usage patterns of several people.</p><p><strong>Following the steps:</strong></p><ol><li><strong>Data Cleaning &amp; Manipulation</strong></li><li><strong>Extracting Features from Text to Using CountVectorizer</strong></li><li><strong>Stemming Words with NLTK</strong></li><li><strong>Finding Similarity using Cosine Similarity</strong></li><li><strong>Output</strong></li><li><strong>Data Cleaning &amp; Manipulation</strong></li></ol><pre>import pandas as pd<br>import numpy as np<br><br>cdf=pd.read_csv(&#39;credits.csv&#39;)<br>mdf=pd.read_csv(&#39;movies.csv&#39;)<br><br>pd.set_option(&#39;display.max_columns&#39;, None)<br>pd.set_option(&#39;display.max_rows&#39;, None)<br><br>cdf.head()<br>mdf.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*RvSBV2VuhZ6zgXaXEw55vA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*bL5qCoLIFuuHD5ORbmYHNA.png" /></figure><pre>mdf=mdf.merge(cdf,on=&#39;title&#39;)<br>mdf=mdf[[&#39;movie_id&#39;,&#39;title&#39;,&#39;overview&#39;,&#39;genres&#39;, &#39;keywords&#39;, &#39;cast&#39;, &#39;crew&#39;]]<br>mdf.isnull().sum()<br>mdf.dropna(inplace=True)<br>mdf.duplicated().sum()</pre><pre>import ast<br>def convert(obj):<br>    L=[]<br>    for i in ast.literal_eval(obj):<br>        L.append(i[&#39;name&#39;])<br>    return L<br><br>mdf[&#39;genres&#39;]=mdf[&#39;genres&#39;].apply(convert)<br>mdf[&#39;keywords&#39;]=mdf[&#39;keywords&#39;].apply(convert)<br>mdf[&#39;cast&#39;]=mdf[&#39;cast&#39;].apply(convert)<br><br>def convert2(obj):<br>    L=[]<br>    counter = 0<br>    for i in ast.literal_eval(obj):<br>        if counter !=3:<br>            L.append(i[&#39;name&#39;])<br>            counter +=1<br>        else:<br>            break<br>        return L<br><br>def fetch_director(obj):<br>    L=[]<br>    for i in ast.literal_eval(obj):<br>        if i[&#39;job&#39;]==&#39;Director&#39;:<br>            L.append(i[&#39;name&#39;])<br>    return L<br><br>mdf[&#39;crew&#39;]=mdf[&#39;crew&#39;].apply(fetch_director)<br>mdf[&#39;overview&#39;]=mdf[&#39;overview&#39;].apply(lambda x : x.split())<br>mdf[&#39;genres&#39;]=mdf[&#39;genres&#39;].apply(lambda x:[i.replace(&quot; &quot;,&quot;&quot;) for i in x])<br>mdf[&#39;keywords&#39;]=mdf[&#39;keywords&#39;].apply(lambda x:[i.replace(&quot; &quot;,&quot;&quot;) for i in x])<br>mdf[&#39;crew&#39;]=mdf[&#39;crew&#39;].apply(lambda x:[i.replace(&quot; &quot;,&quot;&quot;) for i in x])<br><br>mdf[&#39;cast&#39;]=mdf[&#39;cast&#39;].apply(lambda x:[i.replace(&quot; &quot;,&quot;&quot;) for i in x])<br>mdf[&#39;tags&#39;]=mdf[&#39;overview&#39;]+mdf[&#39;genres&#39;]+mdf[&#39;keywords&#39;]+mdf[&#39;cast&#39;]+mdf[&#39;crew&#39;]<br>new_df=mdf[[&#39;movie_id&#39;,&#39;title&#39;,&#39;tags&#39;]]<br><br>new_df[&#39;tags&#39;]=new_df[&#39;tags&#39;].apply(lambda x:&#39; &#39;.join(x))<br>new_df[&#39;tags&#39;]=new_df[&#39;tags&#39;].apply(lambda X:X.lower())<br>new_df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*4qQLon4pwa6Zg_otH0TYXg.png" /></figure><p><strong>2. Extracting Features from Text to Using CountVectorizer</strong></p><pre>from sklearn.feature_extraction.text import CountVectorizer<br>cv=CountVectorizer(max_features=5000, stop_words=&#39;english&#39;)<br>vectors=cv.fit_transform(new_df[&#39;tags&#39;]).toarray()<br>vectors</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*fU2KcD2kDZ1ZtXEnUq9I4g.png" /></figure><p><strong>3. Stemming Words with NLTK</strong></p><pre>import nltk<br>from nltk.stem.porter import PorterStemmer<br>ps=PorterStemmer()<br>def stem(text):<br>    y=[]<br>    for i in text.split():<br>        y.append(ps.stem(i))<br>    return &quot; &quot;.join(y)<br>new_df[&#39;tags&#39;]=new_df[&#39;tags&#39;].apply(stem)<br>new_df[&#39;tags&#39;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*LW_6XDHRqG4L4Gc2_bdonw.png" /></figure><p><strong>4. Finding Similarity using Cosine Similarity</strong></p><pre>from sklearn.metrics.pairwise import cosine_similarity<br>similarity=cosine_similarity(vectors)<br><br>def recommend(movie):<br>    movie_index=new_df[new_df[&#39;title&#39;]==movie].index[0]<br>    distances=similarity[movie_index]<br>    movies_list=sorted(list(enumerate(distances)), reverse=True, key=lambda x:x[1])[1:6]<br>    <br>    for i in movies_list:<br>        print(new_df.iloc[i[0]].title)<br></pre><p><strong>5. Output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*_BzClLPGz786hDfATsfU9A.png" /></figure><p>credits:</p><ol><li>Ricci, Francesco; Rokach, Lior; Shapira, Bracha (2022). <a href="https://link.springer.com/chapter/10.1007/978-1-0716-2197-4_1">“Recommender Systems: Techniques, Applications, and Challenges”</a>. In Ricci, Francesco; Rokach, Lior; Shapira, Bracha (eds.). <em>Recommender Systems Handbook</em> (3 ed.). New York:</li><li>Mayank Banoula</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e8edc799807" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SEGMENTATION — Getting Started with RFM Analysis]]></title>
            <link>https://medium.com/@amanatulamriyah66/segmentation-getting-started-with-rfm-analysis-1010d99cea5c?source=rss-df2a55506188------2</link>
            <guid isPermaLink="false">https://medium.com/p/1010d99cea5c</guid>
            <category><![CDATA[rfm-analysis]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[marketing-analysis]]></category>
            <category><![CDATA[segmentation]]></category>
            <dc:creator><![CDATA[Amanatulamriyah]]></dc:creator>
            <pubDate>Sat, 23 Sep 2023 11:14:46 GMT</pubDate>
            <atom:updated>2023-09-23T11:14:46.628Z</atom:updated>
            <content:encoded><![CDATA[<h3>SEGMENTATION — Getting Started with RFM Analysis</h3><p>Customer Segmentation is dividing up our customers into different buckets or segments based on customer behaviors or other criteria.</p><p>RFM Analysis can be used for segmentation analysis to dive deeper into the data and gain better insights into the customers, subscribers, or users. RFM stands for Recency, Frequency, and Monetary.</p><p>RFM analysis is also a marketing technique that is used to quantitatively rank and group customers based on the recency, frequency, and monetary total of their recent transactions to identify the best customers and perform targeted marketing campaigns.</p><p>These RFM metrics are important indicators of a customer’s behavior because frequency and monetary value affect a customer’s lifetime value, and recency affects retention, a measure of engagement.</p><p>RFM analysis ranks each customer on the following factors:</p><ul><li><strong>Recency: </strong>How recent was the customer’s last purchase? Customers who recently made a purchase will still have the product on their minds and are more likely to purchase or use the product again. Businesses often measure recency in days. But, depending on the product, they may measure it in years, weeks, or even hours.</li><li><strong>Frequency:</strong> How often did this customer purchase in a given period? Customers who purchase once are often more likely to purchase again. Additionally, first-time customers may be good targets for follow-up advertising to convert them into more frequent customers.</li><li><strong>Monetary:</strong> How much money did the customer spend in a given period? Customers who spend a lot of money are more likely to spend money in the future and have a high value to a business.</li></ul><p>The given dataset is provided by an e-commerce platform containing customer transaction data including customer ID, purchase date, transaction amount, product information, ID command and location. The platform aims to leverage RFM (recency, frequency, monetary value) analysis to segment customers and optimize customer engagement strategies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*0po7FGT46hNEtHDtwbAxew.png" /></figure><p>The following are the steps I took to carry out RFM analysis on the data:</p><ol><li><strong>Import Library &amp; Data</strong></li><li><strong>Recency Analysis</strong></li><li><strong>Frequency Analysis</strong></li><li><strong>Monetary Analysis</strong></li><li><strong>RFM calculation</strong></li></ol><p><strong>Import Library &amp; Data</strong></p><pre>import pandas as pd<br>import numpy as np<br>import datetime as dt<br><br>import warnings<br>warnings.filterwarnings(&quot;ignore&quot;)</pre><pre>df=pd.read_csv(&#39;rfm_data.csv&#39;)<br>df.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*U9SXdtO9hj2dTrInkvjJfQ.png" /></figure><pre>df[&#39;PurchaseDate&#39;]=pd.DatetimeIndex(df[&#39;PurchaseDate&#39;]).date</pre><pre>df[&#39;CustomerID&#39;]=df[&#39;CustomerID&#39;].astype(str)<br>df[&#39;OrderID&#39;]=df[&#39;OrderID&#39;].astype(str)</pre><p><strong>Recency Analysis</strong></p><p>Grouping customers by the last date they purchased</p><pre>recency_df = df.groupby([&#39;CustomerID&#39;],as_index=False)[&#39;PurchaseDate&#39;].max()<br>recency_df.columns = [&#39;CustomerID&#39;,&#39;LastPurchaseDate&#39;]<br>recency_df.head()</pre><pre>import datetime as dt<br>now = dt.date(2023,9,1)<br>recency_df[&#39;Recency&#39;] = recency_df.LastPurchaseDate.apply(lambda x : (now - x).days<br>recency_df.drop(columns=[&#39;LastPurchaseDate&#39;],inplace=True)</pre><p><strong>Frequency Analysis</strong></p><pre>frequency_df = df.copy()<br>frequency_df.drop_duplicates(subset=[&#39;CustomerID&#39;,&#39;OrderID&#39;], keep=&quot;first&quot;, inplace=True) <br>frequency_df = frequency_df.groupby(&#39;CustomerID&#39;,as_index=False)[&#39;OrderID&#39;].count()<br>frequency_df.columns = [&#39;CustomerID&#39;,&#39;Frequency&#39;]<br>frequency_df.head()</pre><p><strong>Monetary Analysis</strong></p><pre>df[&#39;Total_cost&#39;] = df[&#39;TransactionAmount&#39;]<br>monetary_df=df.groupby(&#39;CustomerID&#39;,as_index=False)[&#39;Total_cost&#39;].sum()<br>monetary_df.columns = [&#39;CustomerID&#39;,&#39;Monetary&#39;]</pre><p><strong>RFM calculation</strong></p><p>Combine all together all dataframe in so we have recency, frequency and monetary values together. Also combine first recency and frequency.</p><pre>rf = recency_df.merge(frequency_df,left_on=&#39;CustomerID&#39;,right_on=&#39;CustomerID&#39;)<br>#combibe rf frame with monetary values..<br>rfm = rf.merge(monetary_df,left_on=&#39;CustomerID&#39;,right_on=&#39;CustomerID&#39;)</pre><pre># Arguments (x = value, p = recency, monetary_value, frequency, d = quartiles dict)<br><br>#lower the recency, good for store..<br>def RScore(x,p,d):<br>    if x &lt;= d[p][0.25]:<br>        return 1<br>    elif x &lt;= d[p][0.50]:<br>        return 2<br>    elif x &lt;= d[p][0.75]: <br>        return 3<br>    else:<br>        return 4<br>    <br>    <br># Arguments (x = value, p = recency, monetary_value, frequency, k = quartiles dict)<br><br>#higher value of frequency and monetary lead to a good consumer. here higher value = 1 in reverse way.<br><br>def FMScore(x,p,d):<br>    if x &lt;= d[p][0.25]:<br>        return 4<br>    elif x &lt;= d[p][0.50]:<br>        return 3<br>    elif x &lt;= d[p][0.75]: <br>        return 2<br>    else:<br>        return 1<br>        return 1</pre><pre>rfm=rfm[[&#39;Recency&#39;,&#39;Frequency&#39;,&#39;Monetary&#39;]]<br>rfm.quantile(q=[0.25,0.5,0.75])<br>new_rfm = rf.merge(monetary_df,left_on=&#39;CustomerID&#39;,right_on=&#39;CustomerID&#39;)<br>new_rfm[&#39;CustomerType&#39;]=np.where((new_rfm[&#39;Recency&#39;]&lt;=97) &amp; (new_rfm[&#39;Frequency&#39;]&gt;1)&amp;(new_rfm[&#39;Monetary&#39;]&gt;=782.695),&#39;Loyalist&#39;,<br>                                 np.where((new_rfm[&#39;Recency&#39;]&lt;=97)&amp;(new_rfm[&#39;Frequency&#39;]==1),&#39;New Comer&#39;,<br>                                          np.where((new_rfm[&#39;Recency&#39;]&gt;=127)&amp;(new_rfm[&#39;Frequency&#39;]==1),&#39;Lost&#39;,<br>                                                    np.where((new_rfm[&#39;Recency&#39;]&gt;=127)&amp;(new_rfm[&#39;Frequency&#39;]&gt;1)&amp;(new_rfm[&#39;Monetary&#39;]&gt;=782.695),&#39;Need Attention&#39;,<br>                                                             np.where((new_rfm[&#39;Recency&#39;]&lt;127)&amp;(new_rfm[&#39;Frequency&#39;]&gt;1)&amp;(new_rfm[&#39;Monetary&#39;]&lt;782.695),&#39;Promising&#39;,<br>                                                              &#39;Hibernating&#39;)))))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*OuZyYAhsDvTMxJSS6JjHXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*16xN_ptrh47gI_lfMbm9QQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*NJ5xXG22-l-Y8ZmJlSImFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*L7aiQn9hePNZlsyXuyX5HA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHfDPVR6iZjmgUKNAZUP6Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1010d99cea5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scraping and Sentiment Analysis on Shopee Indonesia Data in Python Using VADER Technique& ROBERTA…]]></title>
            <link>https://medium.com/@amanatulamriyah66/scraping-and-sentiment-analysis-on-shopee-indonesia-data-in-python-using-vader-technique-roberta-1ba199e27d89?source=rss-df2a55506188------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ba199e27d89</guid>
            <category><![CDATA[scraping-with-python]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[shopee]]></category>
            <dc:creator><![CDATA[Amanatulamriyah]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 12:12:09 GMT</pubDate>
            <atom:updated>2023-10-15T09:47:53.713Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scraping and Sentiment Analysis on Shopee Indonesia Data in Python Using VADER Technique&amp; ROBERTA Pre-trained Model</h3><p>Sentiment analysis is the process of using text analysis to obtain various data sources from the internet and various social media platforms. The objective is to obtain opinions from users on the platform. Sentiment analysis is also the process of analyzing digital text to determine if the emotional tone of the message is positive, negative, or neutral.</p><p>The following are the results of my learning about sentiment analysis using the VADER technique ROBERTA pre-trained model by scrapping the data first.</p><ol><li><strong><em>Collecting Data &amp; EDA (Exploratory Data Analysis)</em></strong></li><li><strong><em>VADER Sentiment Scoring</em></strong></li><li><strong><em>ROBERTA Pre-trained Model</em></strong></li><li><strong><em>Compare &amp; Combine</em></strong></li></ol><h3>1. Collecting Data &amp; EDA (Exploratory Data Analysis)</h3><p>Scraping shopee data</p><pre>!pip install google-play-scraper<br><br>from google_play_scraper import Sort, reviews<br>from google_play_scraper import app<br>import pandas as pd<br>import numpy as np<br><br>result, continuation_token = reviews(<br>    &#39;com.shopee.id&#39;,<br>    lang=&#39;id&#39;, <br>    country=&#39;id&#39;,<br>    sort=Sort.MOST_RELEVANT, <br>    count=10000, <br>    filter_score_with= None  <br>)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j82W-V0zwIniRFn8X8AAEw.png" /></figure><p>Then quick EDA</p><pre>import matplotlib.pyplot as plt<br>import seaborn as sns<br>plt.style.use(&#39;ggplot&#39;)<br><br>ax = dfs[&#39;score&#39;].value_counts().sort_index() \<br>    .plot(kind=&#39;bar&#39;,<br>          title=&#39;Count of Reviews by Stars&#39;,<br>          figsize=(10, 5))<br>ax.set_xlabel(&#39;Review Stars&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*-XwWn7Qs6yKA1izK1pfZpQ.png" /></figure><h3>2. <strong><em>VADER Sentiment Scoring</em></strong></h3><p>We will use NLTK’s SentimentIntensityAnalyzer to get the neg/neu/pos scores of the text.</p><p>This uses a “bag of words” approach:</p><ol><li>Stop words are removed</li><li>each word is scored and combined to a total score.</li></ol><pre>from nltk.sentiment import SentimentIntensityAnalyzer<br>from tqdm.notebook import tqdm<br>import nltk<br>nltk.downloader.download(&#39;vader_lexico&#39;)<br>sia = SentimentIntensityAnalyzer()</pre><pre># Run the polarity score on the entire dataset<br>res = {}<br>for i, row in tqdm(dfs.iterrows(), total=len(dfs)):<br>    text = row[&#39;content&#39;]<br>    myid = row[&#39;reviewId&#39;]<br>    res[myid] = sia.polarity_scores(text)</pre><pre>vaders = pd.DataFrame(res).T<br>vaders = vaders.reset_index().rename(columns={&#39;index&#39;: &#39;reviewId&#39;})<br>vaders = vaders.merge(dfs, how=&#39;left&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cVKSqi0q6XmvHd5JdCBPVA.png" /></figure><pre>def sentiment_group(sen):<br>    if sen == 0:<br>        return &#39;Neutral&#39;<br>    elif sen &lt;0:<br>        return &#39;Negative&#39;<br>    else:<br>        return &#39;Positive&#39;<br><br>vaders[&#39;sentiment_category&#39;] = vaders[&#39;compound&#39;].apply(sentiment_group)<br>vaders.groupby(&#39;sentiment_category&#39;)[&#39;userName&#39;].nunique().plot.bar(title=&#39;Sentiment Distribution&#39;,figsize=(5,5), color=[&#39;pink&#39;])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*s1biWzlOzjjZego6ZTrBZQ.png" /></figure><p>Now we have sentiment score and metadata. Plot VADER results are attached below</p><pre>ax = sns.barplot(data=vaders, x=&#39;score&#39;, y=&#39;compound&#39;)<br>ax.set_title(&#39;Compund Score by Shopee Star Review&#39;)<br>plt.show()<br><br>fig, axs = plt.subplots(1, 3, figsize=(12, 3))<br>sns.barplot(data=vaders, x=&#39;score&#39;, y=&#39;pos&#39;, ax=axs[0])<br>sns.barplot(data=vaders, x=&#39;score&#39;, y=&#39;neu&#39;, ax=axs[1])<br>sns.barplot(data=vaders, x=&#39;score&#39;, y=&#39;neg&#39;, ax=axs[2])<br>axs[0].set_title(&#39;Positive&#39;)<br>axs[1].set_title(&#39;Neutral&#39;)<br>axs[2].set_title(&#39;Negative&#39;)<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*RNbcIaqbGkNGkx2rp13bcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftAOE4apPPzn71iHOB59tw.png" /></figure><h3>3. ROBERTA Pre-trained Model</h3><pre>from transformers import AutoTokenizer<br>from transformers import AutoModelForSequenceClassification<br>from scipy.special import softmax<br><br>MODEL = f&quot;cardiffnlp/twitter-roberta-base-sentiment&quot;<br>tokenizer = AutoTokenizer.from_pretrained(MODEL)<br>model = AutoModelForSequenceClassification.from_pretrained(MODEL)</pre><pre>def polarity_scores_roberta(example):<br>    encoded_text = tokenizer(example, return_tensors=&#39;pt&#39;)<br>    output = model(**encoded_text)<br>    scores = output[0][0].detach().numpy()<br>    scores = softmax(scores)<br>    scores_dict = {<br>        &#39;roberta_neg&#39; : scores[0],<br>        &#39;roberta_neu&#39; : scores[1],<br>        &#39;roberta_pos&#39; : scores[2]<br>    }<br>    return scores_dict</pre><pre>res = {}<br>for i, row in tqdm(dfs.iterrows(), total=len(dfs)):<br>    try:<br>        text = row[&#39;content&#39;]<br>        myid = row[&#39;reviewId&#39;]<br>        vader_result = sia.polarity_scores(text)<br>        vader_result_rename = {}<br>        for key, value in vader_result.items():<br>            vader_result_rename[f&quot;vader_{key}&quot;] = value<br>        roberta_result = polarity_scores_roberta(text)<br>        both = {**vader_result_rename, **roberta_result}<br>        res[myid] = both<br>    except RuntimeError:<br>        print(f&#39;Broke for id {myid}&#39;)</pre><h3>4. Compare &amp; Combine</h3><pre>results_dfs = pd.DataFrame(res).T<br>results_dfs = results_dfs.reset_index().rename(columns={&#39;index&#39;: &#39;reviewId&#39;})<br>results_dfs = results_dfs.merge(dfs, how=&#39;left&#39;)<br><br>## Compare Scores between models<br><br>results_dfs.columns<br><br>sns.pairplot(data=results_dfs,<br>             vars=[&#39;vader_neg&#39;, &#39;vader_neu&#39;, &#39;vader_pos&#39;,<br>                  &#39;roberta_neg&#39;, &#39;roberta_neu&#39;, &#39;roberta_pos&#39;],<br>            hue=&#39;score&#39;,<br>            palette=&#39;tab10&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DkQqYdkeoQ9BUlMIHA1hLg.png" /></figure><p>Credits: Rob Mulla</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ba199e27d89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PENGUJIAN HIPOTESIS]]></title>
            <link>https://medium.com/@amanatulamriyah66/pengujian-hipotesis-419a96a857b5?source=rss-df2a55506188------2</link>
            <guid isPermaLink="false">https://medium.com/p/419a96a857b5</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[two-way-test]]></category>
            <category><![CDATA[one-way-test]]></category>
            <category><![CDATA[null-hipotesis]]></category>
            <category><![CDATA[hipotesis]]></category>
            <dc:creator><![CDATA[Amanatulamriyah]]></dc:creator>
            <pubDate>Sun, 12 Jun 2022 14:00:18 GMT</pubDate>
            <atom:updated>2022-06-12T14:00:18.160Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hipotesis statistik</strong></p><p>Secara definisi, hipotesis statistik merupakan pernyataan atau dugaan mengenai satu atau lebih populasi. Benar atau salahnya suatu hipotesis tidak akan pernah diketahui dengan pasti kecuali jika kita memeriksa seluruh populasi. Dalam kebanyakan situasi tentu hal tersebut tidak mungkin dilakukan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*91OYOsQCQcC_tNQMCwSn4w.jpeg" /><figcaption><a href="https://pin.it/3XImZjl">https://pin.it/3XImZjl</a></figcaption></figure><p>Oleh karena itu kita bisa mengambil suatu contoh acak dari populasi tersebut dan menggunakan informasi yang dimiliki contoh itu untuk memutuskan apakah hipotesis tersebut kemungkinan benar atau salah. <em>Penolakan hipotesis dilakukan ketika adanya bukti dari contoh yang tidak konsisten dengan hipotesis yang dinyatakan.</em> Lalu untuk penerimaan hipotesis dilakukan ketika adanya bukti yang mendukung hipotesis. Dalam statistika, bahwa penerimaan suatu hipotesis statistik merupakan akibat tidak cukupnya bukti untuk menolaknya dan tidak berimplikasi bahwa hipotesis itu pasti benar.</p><blockquote>Hipotesis yang dirumuskan dengan harapan akan ditolak biasa disebut dengan hipotesis nol.</blockquote><p>Saat ini, istilah tersebut telah digunakan pada sembarang hipotesis yang ingin diuji dan dilambangkan dengan <em>H0.</em></p><blockquote>Penolakan <em>H0</em> mengakibatkan penerimaan suatu hipotesis alternatif yang dilambangkan dengan <em>H1.</em></blockquote><p>Hipotesis nol mengenai suatu parameter populasi, harus diucapkan sedemikian rupa sehingga menyatakan dengan pasti nilai bagi parameter itu, sedangkan hipotesis alternatifnya membolehkan beberapa kemungkinan nilainya.</p><p>Prosedur pengambilan keputusan yang diuraikan di atas dapat membawa pada dua jenis kesimpulan yang salah. Kesalahan/galat jenis I merupakan penolakan hipotesis nol yang benar. Sementara penerimaan hipotesis nol yang salah merupakan kesalahan / galat jenis II. Peluang melakukan galat I disebut taraf nyata pada uji tersebut dan dilambangkan dengan σ.</p><p>Ada beberapa sifat penting pada topik ini yakni:</p><p>a. Galat jenis I dan galat jenis II saling berhubungan. Menurunnya peluang yang satu akan menaikkan peluang yang lain.</p><p>b. Ukuran wilayah kritik yang berarti juga peluang melakukan galat jenis I selalu dapat diperkecil dengan mengubah nilai kritiknya.</p><p>c. Peningkatan ukuran contoh <em>n</em> akan memperkecil α (Peluang galat jenis I) dan β (Peluang galat jenis II) secara Bersama-sama.</p><p>d. Bila hipotesis nolnya salah, nilai β akan sangat besar bila nilai parameternya dekat dengan nilai yag dihipotesiskan. Semakin besar jarak antara nilai yang sesungguhnya dengan nilai yang dihipotesiskan maka semakin kecil nilai β.</p><p><strong>Pengujian Hipotesis statistik</strong></p><p>Suatu uji hipotesis statistik yang alternatifnya bersifat satu arah seperti:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/154/1*IUJvLVQl-K0e5qLMdL7HJw.png" /></figure><p>Atau mungkin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/132/1*1925IPGgCQxAPQLHL8iyBw.png" /></figure><p>Wilayah kritik bagi hipotesis alternatif</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/67/1*roPvx1tVTBvI-tFz5yfH0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/68/1*lQZDBtRVp8nhJyB3q6PrzA.png" /></figure><p>terletak seluruhnya di ekor kanan sebaran tersebut sedangkan wilayah kritik bagi hipotesis alternatif</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/68/1*lQZDBtRVp8nhJyB3q6PrzA.png" /></figure><p>terletak seluruhnya di ekor kiri. Dalam pengertian ini, tanda ke taksamaan menunjuk ke arah wilayah kritiknya.</p><p>Sementara uji hipotesis statistik yang alternatifnya bersifat dua arah seperti berikut:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/127/1*-TF_3hznahV2Vq-t6xMQmA.png" /></figure><p>Disebut uji dua arah karena wilayah kritiknya dipisah menjadi dua bagian yang ditempatkan di masing-masing ekor sebaran statistik ujinya. Hipotesis alternatif</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/66/1*LI25e31nRsc_2SFNIAEq7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/1*wLpQkN6QyTbToALwxHPUhw.png" /></figure><p>menyatakan bahwa</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/1*wLpQkN6QyTbToALwxHPUhw.png" /></figure><p>atau</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/1*YrGXEtVwmkFItq_Zw6lnEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*PGs3T3C8FVqAk_NtVqop5g.png" /><figcaption>Ilustrasi wilayah kritik uji satu arah &amp; uji dua arah</figcaption></figure><p>Langkah-langkah pengujian hipotesis mengenai parameter populasi θ lawan suatu hipotesis alternatifnya dapat diringkas sebagai berikut:</p><p>i. Nyatakan hipotesis nol nya <em>H0 </em>bahwa</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/69/1*KP8LCJt14IzZhw2j_TyUBg.png" /></figure><p>ii. Pilih hipotesis alternatif <em>H1</em> yang sesuai diantara</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/229/1*lmu5raf8gQ10pOPvgmFYxQ.png" /></figure><p>iii. Tentukan taraf nyatanya α</p><p>iv. Pilih statistik uji yang sesuai dan kemudian tentukan wilayah kritiknya</p><p>v. Hitung nilai statistik uji berdasarkan data contohnya</p><p>vi. Keputusan:</p><p>Tolak <em>H0 </em>bila nilai statistik uji tersebut jatuh dalam wilayah kritiknya sedangkan bila nilai itu jatuh di luar wilayah kritiknya maka terima <em>H0.</em></p><p><em>Source : Walpole, Ronald E (1995). Introduction to Statistics 3rd Edition.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=419a96a857b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parameter & Statistik]]></title>
            <link>https://medium.com/@amanatulamriyah66/parameter-statistik-debd5a6eb425?source=rss-df2a55506188------2</link>
            <guid isPermaLink="false">https://medium.com/p/debd5a6eb425</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[statistik]]></category>
            <category><![CDATA[parameter]]></category>
            <category><![CDATA[basic-statistics]]></category>
            <dc:creator><![CDATA[Amanatulamriyah]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 01:37:30 GMT</pubDate>
            <atom:updated>2022-06-09T23:44:19.328Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Parameter merupakan sembarang nilai yang menjelaskan ciri populasi. Parameter juga bisa dikatakan sebagai suatu konstanta yang menjelaskan populasi.</blockquote><p>Sementara populasi sendiri dapat diartikan sebagai keseluruhan pengamatan yang menjadi perhatian kita — Banyaknya pengamatan atau anggota dari populasi disebut ukuran populasi. Biasanya parameter dilambangkan dengan huruf Yunani.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*g601HeUZ-KuVE766VUQDmQ.png" /><figcaption>Source : <a href="https://www.pinterest.com/pin/532339618451344023/">https://www.pinterest.com/pin/532339618451344023/</a></figcaption></figure><p><em>Contoh 1</em></p><p><em>Berikut merupakan himpunan data kesalahan ketik pada setiap halaman yang dilakukan oleh seorang sekretaris Ketika mengetik sebuah dokumen setebal 10 halaman : 1 0 1 2 3 1 1 4 0 dan 2.</em></p><p>Pertama-tama, mari kita asumsikan data tersebut berurutan untuk setiap halamannya. Dari persoalan tersebut dapat kita katakan bahwa banyak kesalahan terbesar adalah 4 pada halaman 8. Lalu bisa dinyatakan juga bahwa nilai tengah 10 bilangan tersebut adalah 1,5. Bilangan 4 dan 1,5 merupakan deskripsi bagi populasi atau kita menyebut nilai-nilai demikian itu sebagai parameter populasi.</p><p>Dimisalkan jika contoh 10 halaman naskah tersebut pada contoh 1 merupakan bagian dari naskah jauh lebih tebal. Jelaslah bahwa sekarang populasinya tersusun dari data yang jauh lebih besar dan kita hanya memiliki informasi Sebagian yang diberikan oleh contoh. Dengan demikian 4 dan 1,5 menjadi ukuran deskripsi contoh dan tidak lagi menjadi parameter populasi. Suatu nilai yang demikian biasa disebut statistik. Dengan kalimat lain,</p><blockquote>statistik merupakan sembarang nilai yang menjelaskan ciri suatu contoh.</blockquote><p><em>Source : Walpole, Ronald E (1995). Introduction to Statistics 3rd Edition.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=debd5a6eb425" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistika Deskriptif dan Statistika Inferensia]]></title>
            <link>https://medium.com/@amanatulamriyah66/statistika-deskriptif-dan-statistika-inferensia-62870461a235?source=rss-df2a55506188------2</link>
            <guid isPermaLink="false">https://medium.com/p/62870461a235</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[statistika-inferensia]]></category>
            <category><![CDATA[statistical-modeling]]></category>
            <category><![CDATA[statistika-deskriptif]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Amanatulamriyah]]></dc:creator>
            <pubDate>Wed, 08 Jun 2022 14:01:05 GMT</pubDate>
            <atom:updated>2022-06-09T23:38:21.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*aIWW4nNsaYb0WXH0tnf-Xg.png" /><figcaption>source: <a href="https://www.instagram.com/p/CcsjXN3t0Qt/">https://www.instagram.com/p/CcsjXN3t0Qt/</a></figcaption></figure><p>Dalam mempelajari statistika, pada dasarnya kita berkepentingan untuk menyajikan dan menafsirkan kejadian yang bersifat peluang yang terjadi dalam suatu penyelidikan terencana ataupun penelitian ilmiah. Bisa dikatakan bahwa biasanya statistikawan bekerja dengan data numerik yang berupa hasil cacahan ataupun hasil pengukuran atau mungkin dengan data kategorik yang diklasifikasikan menurut kriteria tertentu. Kita juga bisa menyebutkan setiap informasi yang tercatat, apakah itu numerik atau kategorik sebagai pengamatan.</p><p>Metode statistik adalah prosedur-prosedur yang digunakan dalam pengumpulan, penyajian, analisis, dan penafsiran data. Metode-metode tersebut dapat dikelompokan menjadi 2 kelompok besar, yaitu statistika deskriptif dan statistika inferensia.</p><blockquote>Statistika deskriptif merupakan metode-metode yang berkaitan dengan pengumpulan dan penyajian suatu himpunan data sehingga memberikan informasi yang berguna.</blockquote><p>Statistika deskriptif memberikan informasi hanya mengenai data yang dimiliki dan sama sekali tidak menarik inferensia atau kesimpulan apapun tentang himpunan data induknya yang lebih besar. Penyusunan tabel, diagram, grafik, dan lainnya termasuk dalam kategori statistika deskriptif.</p><blockquote>Sementara statistika inferensia adalah mencakup semua metode yang berhubungan dengan analisis sebagian data untuk kemudian sampai pada peramalan atau penarikan kesimpulan mengenai keseluruhan himpunan data induknya.</blockquote><p>Generalisasi yang berhubungan dengan inferensia statistik selalu mempunyai sifat takpasti. Oleh karena kita mendasarkan pada informasi parsial yang diperoleh dari sebagian data. Untuk memperhitungkan ketidakpastian ini pengetahuan terkait teori peluang mutlak diperlukan.</p><p><em>Source : Walpole, Ronald E (1995). Introduction to Statistics 3rd Edition.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62870461a235" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>