<?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 Ozan ERTEK on Medium]]></title>
        <description><![CDATA[Stories by Ozan ERTEK on Medium]]></description>
        <link>https://medium.com/@ozan.ertek11?source=rss-cb1c190e725------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zmu6bBKNBykPBcWQ5Gg-3A.jpeg</url>
            <title>Stories by Ozan ERTEK on Medium</title>
            <link>https://medium.com/@ozan.ertek11?source=rss-cb1c190e725------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:26:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ozan.ertek11/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[Topic Modeling of War articles and Other articles -2-]]></title>
            <link>https://medium.com/@ozan.ertek11/topic-modeling-of-war-articles-and-other-articles-2-1ddbc5e17ec0?source=rss-cb1c190e725------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ddbc5e17ec0</guid>
            <category><![CDATA[flask-application]]></category>
            <category><![CDATA[wikipedia]]></category>
            <category><![CDATA[topic-modeling]]></category>
            <category><![CDATA[npl]]></category>
            <category><![CDATA[lda]]></category>
            <dc:creator><![CDATA[Ozan ERTEK]]></dc:creator>
            <pubDate>Sun, 03 Apr 2022 19:40:12 GMT</pubDate>
            <atom:updated>2022-04-03T19:40:12.689Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*KLdnewfIsWNscPu1uVl2Ig.jpeg" /></figure><p>In this project,I have used <strong>Wikipedia API </strong>to get articles from <strong>wikipedia</strong>.The aim for this project is to seperate war articles and other articles between by using <strong>Natural Language Process </strong>and <strong>Latent Dirichlet Allocation.</strong>And creating a flask app for seperating writen text war contain.I will explain all i did,step by step.You can visit project repository(<a href="https://github.com/OzanERTEK/DataScienceProject4">HERE</a>).The methodology of the project is given below.This is part -2</p><p>First PART -1- (<a href="https://medium.com/@ozan.ertek11/topic-modeling-of-war-articles-and-other-articles-1-d09629aa3040">HERE</a>)</p><ul><li>Getting data by using Wikipedia API</li><li>Adding all data to MongoDB</li><li>Connect Python to MongoDB to load dataset</li><li>NPL and Lda Process</li></ul><p>Second PART -2-</p><ul><li>Modeling And Flask App</li></ul><p>In previous part,we scrapped Wikipedia text data by using api and have created cluster from mongoDB to add all our dataset.Now,in this part,we create model for seperating topics between and develop web application.</p><h3>1)Modeling And Flask App</h3><p>At the begining,we use <strong>TF-IDF</strong> Model by using that codes :</p><pre><strong>from</strong> gensim <strong>import</strong> corpora, models<br><br>tfidf <strong>=</strong> models<strong>.</strong>TfidfModel(bow_corpus)<br></pre><p>then,we use <strong>Latent Dirichlet Allocation </strong>method.</p><pre>lda_model <strong>=</strong> gensim<strong>.</strong>models<strong>.</strong>LdaMulticore(bow_corpus, <br>                                       num_topics<strong>=</strong>2, <br>                                       id2word <strong>=</strong> dictionary, <br>                                       passes <strong>=</strong> 2, <br>                                       workers<strong>=</strong>2)</pre><p>This <strong>lda_model </strong>will give us a model which use bow_corpus-dictionary our dataset- and with 2 topics(War Topic or Not ).</p><p>With that codes below,you can see which words contain <strong>topic1</strong> or <strong>topic2</strong></p><pre><strong>for</strong> idx, topic <strong>in</strong> lda_model<strong>.</strong>print_topics():<br>    <br>    print(&quot;Topic: {} \nWords: {}&quot;<strong>.</strong>format(idx, topic ))<br>    print(&quot;\n&quot;)</pre><p>For example : <strong>Topic1</strong> contain ‘elect’ , ‘mathematics’ ,’term’ words</p><p>but <strong>Topic2</strong> contain ‘military’ ,’empire’,’battle’ words</p><pre>Topic: 0 <br>Words: 0.005*&quot;includ&quot; + 0.004*&quot;elect&quot; + 0.004*&quot;mathemat&quot; + 0.004*&quot;state&quot; + 0.004*&quot;term&quot; + 0.003*&quot;physic&quot; + 0.003*&quot;develop&quot; + 0.003*&quot;number&quot; + 0.003*&quot;general&quot; + 0.003*&quot;time&quot;<br><br><br>Topic: 1 <br>Words: 0.008*&quot;world&quot; + 0.008*&quot;state&quot; + 0.007*&quot;forc&quot; + 0.007*&quot;armi&quot; + 0.006*&quot;russian&quot; + 0.005*&quot;militari&quot; + 0.005*&quot;empir&quot; + 0.005*&quot;ottoman&quot; + 0.005*&quot;unit&quot; + 0.005*&quot;battl&quot;</pre><p>and now , we create vectorizer</p><pre>vectorizer <strong>=</strong> TfidfVectorizer(sublinear_tf<strong>=True</strong>, min_df<strong>=</strong>5, max_df<strong>=</strong>0.95)<br><em># fit_transform applies TF-IDF to clean texts - we save the array of vectors in X</em><br>X <strong>=</strong> vectorizer<strong>.</strong>fit_transform(df[&#39;clean_text&#39;])</pre><p>and k-means method :</p><pre>kmeans<strong>=</strong>KMeans(n_clusters<strong>=</strong>2)<strong>.</strong>fit(X)</pre><p>and by the way, you can predict new text data by this code :</p><pre><em>model = pickle.load(open(&#39;kmeans.pkl&#39;,&#39;rb&#39;))</em></pre><pre>model<strong>.</strong>predict(vectorizer<strong>.</strong>transform(new_text))</pre><p>and now,we have to create pickle file for vectorizer and model.We going to use these files in flask app</p><pre><em>import joblib<br>import pickle </em></pre><pre><em>with open(&#39;vectorizer.pkl&#39;, &#39;wb&#39;) as fin:</em><br>    pickle<strong>.</strong>dump(vectorizer, fin)</pre><pre><em>file = open(&quot;kmeans.pkl&quot;,&quot;wb&quot;)</em><br><em>pickle.dump(kmeans,file)</em></pre><p>you can write me on linkedin for flask app project.And you can reach my new BlogSite for reading all these project and for reach me of course.</p><p>— — — — — — — — — — — — — -</p><p>My linkedin(<a href="https://www.linkedin.com/in/ozan-ertek-227360193/"><em>link</em></a><em>)</em></p><p>My BlogSite(<a href="http://ozanertek11.pythonanywhere.com/"><em>link</em></a>)</p><p>— — — — — — — — — —</p><p>Thanks for reading my article.</p><p>Hope to see you again in my next article…</p><p><strong>Ozan ERTEK</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ddbc5e17ec0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Topic Modeling of War articles and Other articles -1-]]></title>
            <link>https://medium.com/@ozan.ertek11/topic-modeling-of-war-articles-and-other-articles-1-d09629aa3040?source=rss-cb1c190e725------2</link>
            <guid isPermaLink="false">https://medium.com/p/d09629aa3040</guid>
            <category><![CDATA[topic-modeling]]></category>
            <category><![CDATA[wikipedia]]></category>
            <category><![CDATA[flask-application]]></category>
            <category><![CDATA[npl]]></category>
            <category><![CDATA[lda]]></category>
            <dc:creator><![CDATA[Ozan ERTEK]]></dc:creator>
            <pubDate>Sun, 03 Apr 2022 14:31:59 GMT</pubDate>
            <atom:updated>2022-04-03T14:35:21.157Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*KLdnewfIsWNscPu1uVl2Ig.jpeg" /></figure><p>In this project,I have used <strong>Wikipedia API </strong>to get articles from <strong>wikipedia</strong>.The aim for this project is to seperate war articles and other articles between by using <strong>Natural Language Process </strong>and <strong>Latent Dirichlet Allocation.</strong>And creating a flask app for seperating writen text war contain.I will explain all i did,step by step.You can visit project repository(<a href="https://github.com/OzanERTEK/DataScienceProject4">HERE</a>).The methodology of the project is given below.</p><p>First PART -1-</p><ul><li>Getting data by using Wikipedia API</li><li>Adding all data to MongoDB</li><li>Connect Python to MongoDB to load dataset</li><li>NPL and Lda Process</li></ul><p>Second PART -2-</p><ul><li>Modeling And Flask App</li></ul><h3>1) Getting Data by using Wikipedia API</h3><p>I used 40 topics(science,math,ukraine-russia war topics etc.) for my project.Each topic i get 500 text dataS and totaly i have got 20000 text datas.</p><p>Firsty,you need to install wikipedia api by code :</p><pre><strong>!</strong>pip install wikipedia</pre><p>then import</p><pre><strong>import</strong> wikipediaapi<br><strong>import</strong> wikipedia<br>import csv</pre><p>choose which language that do you want to get data :</p><pre>wiki_wiki <strong>=</strong> wikipediaapi<strong>.</strong>Wikipedia(&#39;en&#39;)</pre><p>and scrap data by using that codes:</p><p>in this section,<strong>topic_name</strong> is which topic do you want to get data,put the name on it.example; if you want to get data about math : change <strong>topic_name</strong> to mathematics.and keep do this for all topics.</p><pre>topic_name <strong>=</strong>{}<br><strong>for</strong> items <strong>in</strong> wikipedia<strong>.</strong>search(&#39;topic&#39;,results<strong>=</strong>500):<br>    topic[items] <strong>=</strong> wiki_wiki<strong>.</strong>page(items)<strong>.</strong>summary</pre><p>and save the data.</p><pre><strong>with</strong> open(&#39;topic_name.csv&#39;, &#39;w&#39;, newline<strong>=</strong>&#39;&#39;,encoding<strong>=</strong>&quot;UTF-8&quot;) <strong>as</strong> csvfile:<br>    header_key <strong>=</strong> [&#39;Key&#39;, &#39;Text&#39;]<br>    new_val <strong>=</strong> csv<strong>.</strong>DictWriter(csvfile, fieldnames<strong>=</strong>header_key)<br>    new_val<strong>.</strong>writeheader()<br>    <strong>for</strong> new_k <strong>in</strong> topic_name:<br>        new_val<strong>.</strong>writerow({&#39;Key&#39;: new_k, &#39;Text&#39;: topic_name[new_k]})</pre><p>and your text data is ready to use.saved as <strong>topic_name.csv</strong></p><p>after scraped all text datas for this process.We are ready to add all data to MongoDB.</p><h3>2)Adding all data to MongoDB</h3><p>After you scraped text datas.you have <strong>topic_name1.csv,topic_name2.csv</strong> etc.All these csv files,you have to upload MongoDB by using MongoDB Atlas or MongoDB Compass.Atlas and Compass free to use.You can download from <a href="https://www.mongodb.com/">https://www.mongodb.com</a></p><p>And then create cluster and upload all csv files on it.</p><p>Now,You have added all text datas to MongoDB.</p><p>Next Step is to Connect Python to MongoDB to load dataset.</p><h3>3)Connect Python to MongoDB to load dataset</h3><p>In this Step,we load text data that scraped from <strong>wikipedia </strong>in jupyter.</p><p>First you have to import library that we will use</p><pre><strong>import</strong> pandas <strong>as</strong> pd<br><strong>import</strong> re<br><strong>import</strong> numpy <strong>as</strong> np<br><strong>import</strong> string<br><strong>from</strong> sklearn.feature_extraction.text <strong>import</strong> CountVectorizer<br><strong>import</strong> gensim<br><strong>from</strong> gensim.utils <strong>import</strong> simple_preprocess<br><strong>from</strong> gensim.parsing.preprocessing <strong>import</strong> STOPWORDS<br><strong>from</strong> nltk.stem <strong>import</strong> WordNetLemmatizer, SnowballStemmer<br><strong>from</strong> nltk.stem.porter <strong>import</strong> <strong>*</strong><br><strong>import</strong> pymongo<br><strong>import</strong> nltk<br><strong>from</strong> sklearn.feature_extraction.text <strong>import</strong> CountVectorizer<br><strong>from</strong> sklearn.feature_extraction.text <strong>import</strong> TfidfVectorizer</pre><p>if not installed,installed by command:</p><pre><strong>!pip install lib_name</strong></pre><p>and now,we have to connect mongodb cluster from jupyter notebook</p><pre>client <strong>=</strong> pymongo<strong>.</strong>MongoClient(&#39;mongodb+srv://user_name:password@clusterproject4.pjobe.mongodb.net/myFirstDatabase?retryWrites=true&amp;w=majority&#39;)</pre><p><strong>user_name</strong> and <strong>password</strong> are your determined password and name before.</p><pre>print(client<strong>.</strong>list_database_names())</pre><p>with this code,we can see our database_name that created before for wikipedia text datas.</p><p>now,you can select your database as db for reading datas</p><pre>db <strong>=</strong> client<strong>.</strong>wikipedia #my database name is wikipeadia<br>col<strong>=</strong>db[&#39;alldata&#39;] # my dataset name is alldata</pre><pre>#your database name and dataset name may be different.</pre><p>Use these below codes for load all data:</p><pre>all_rec <strong>=</strong> col<strong>.</strong>find()<br>list_cursor <strong>=</strong> list(all_rec)<br>df <strong>=</strong> pd<strong>.</strong>DataFrame(list_cursor)<br>df<strong>.</strong>head()</pre><p>and your dataset is ready to process.</p><h3>4) NPL and Lda Process</h3><p>This is final step.In this section,we clean and make our text data for modeling(process like vectorize,gensim)</p><p>With these codes,you can clean and make ready your text data.(tokenize,stopwords etc.)</p><pre><strong>def</strong> remove_punc(txt):<br>    txt_nopunt <strong>=</strong> &quot;&quot;<strong>.</strong>join([c <strong>for</strong> c <strong>in</strong> txt <strong>if</strong> c <strong>not</strong> <strong>in</strong> string<strong>.</strong>punctuation])<br>    <strong>return</strong> txt_nopunt<br>df[&#39;clean_text&#39;] <strong>=</strong> df[&#39;Text&#39;]<strong>.</strong>apply(<strong>lambda</strong> x :remove_punc(x))</pre><p>— —</p><pre><strong>def</strong> remove_stopwords(txt_tokenized):<br>    txt_clean <strong>=</strong> [word <strong>for</strong> word <strong>in</strong> txt_tokenized <strong>if</strong> word <strong>not</strong> <strong>in</strong> stopwords]<br>    <strong>return</strong> txt_clean<br>df[&#39;txt_no_sw&#39;] <strong>=</strong> df[&#39;clean_text_tokenized&#39;]<strong>.</strong>apply(<strong>lambda</strong> x: remove_stopwords(x))</pre><p>— —</p><pre><strong>def</strong> tokenize(txt):<br>    tokens<strong>=</strong> re<strong>.</strong>split(&#39;\W+&#39;,txt)<br>    <strong>return</strong> tokens<br>df[&#39;clean_text_tokenized&#39;] <strong>=</strong>df[&#39;clean_text&#39;]<strong>.</strong>apply(<strong>lambda</strong> x: tokenize(x<strong>.</strong>lower()))<br></pre><p>Now,your text data<strong> tokenized</strong>(seperate all words as ‘ , ’ ).and <strong>stopword</strong>(clean all adjective(he,she,it) and (is,are,in ,on) like these words cleaned.</p><pre>stopwords <strong>=</strong> nltk<strong>.</strong>corpus<strong>.</strong>stopwords<strong>.</strong>words(&#39;english&#39;)</pre><p>—</p><pre><strong>from</strong> nltk.stem <strong>import</strong> PorterStemmer<br>ps<strong>=</strong> PorterStemmer()<br>stemmer <strong>=</strong> SnowballStemmer(&quot;english&quot;)</pre><p>Stemming</p><pre><strong>def</strong> clean_text(text):<br>    text<strong>=</strong>&quot;&quot;<strong>.</strong>join([c <strong>for</strong> c <strong>in</strong> text <strong>if</strong> c <strong>not</strong> <strong>in</strong> string<strong>.</strong>punctuation])<br>    tokens<strong>=</strong>re<strong>.</strong>split(&#39;\W+&#39;,text)<br>    text <strong>=</strong>[word <strong>for</strong> word <strong>in</strong> tokens <strong>if</strong> word <strong>not</strong> <strong>in</strong> stopwords]<br>    <strong>return</strong> text<br>df[&#39;txt_nostop&#39;] <strong>=</strong> df[&#39;Text&#39;]<strong>.</strong>apply(<strong>lambda</strong> x: clean_text(x<strong>.</strong>lower()))<br><strong>def</strong> stemming(tokenized_text):<br>    text <strong>=</strong> [ps<strong>.</strong>stem(word) <strong>for</strong> word <strong>in</strong> tokenized_text]<br>    <strong>return</strong> text<br>df[&#39;txt_Stemmed&#39;] <strong>=</strong>df[&#39;txt_nostop&#39;]<strong>.</strong>apply(<strong>lambda</strong> x : stemming(x))</pre><p>Lemmatizing</p><pre><strong>def</strong> lemmatize_stemming(text):<br>    <strong>return</strong> stemmer<strong>.</strong>stem(WordNetLemmatizer()<strong>.</strong>lemmatize(text, pos<strong>=</strong>&#39;v&#39;))<br><br><em># Tokenize and lemmatize</em><br><strong>def</strong> preprocess(text):<br>    <br>    result <strong>=</strong> []<br>    <br>    <strong>for</strong> token <strong>in</strong> gensim<strong>.</strong>utils<strong>.</strong>simple_preprocess(text) :<br>        <br>        <strong>if</strong> token <strong>not</strong> <strong>in</strong> gensim<strong>.</strong>parsing<strong>.</strong>preprocessing<strong>.</strong>STOPWORDS <strong>and</strong> len(token) <strong>&gt;</strong> 3:<br>            result<strong>.</strong>append(lemmatize_stemming(token))<br>    <br>    <strong>return</strong> result</pre><p>and with below code,you can add new column that your final clean text data.</p><pre>process_txt <strong>=</strong> df[&#39;Text&#39;]<strong>.</strong>map(preprocess)</pre><p>getting dictionary that you all words in your dataset :</p><pre>dictionary <strong>=</strong> gensim<strong>.</strong>corpora<strong>.</strong>Dictionary(process_txt)<br>dictionary<strong>.</strong>filter_extremes(no_below<strong>=</strong>5, no_above<strong>=</strong>0.7, keep_n<strong>=</strong>100000)<br>bow_corpus <strong>=</strong> [dictionary<strong>.</strong>doc2bow(doc) <strong>for</strong> doc <strong>in</strong> process_txt]</pre><p>Now you have clean text data and dictionary that you all words in your dataset.</p><p>In second part,we talk about modeling for seperating 2 different topics.</p><p>— — — — — — — — — — — — — — — — — — —</p><p>Thanks for reading my article :)</p><p>Hope to see you again in my next article…</p><p><strong>Ozan ERTEK</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d09629aa3040" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prediction of Pokémon’s Rarity and Prediction Flask-App -2-]]></title>
            <link>https://medium.com/i%CC%87stanbuldatascienceacademy/prediction-of-pok%C3%A9mons-rarity-and-prediction-flask-app-2-3c794661ef00?source=rss-cb1c190e725------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c794661ef00</guid>
            <category><![CDATA[pythonanywhere]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pokemon]]></category>
            <dc:creator><![CDATA[Ozan ERTEK]]></dc:creator>
            <pubDate>Fri, 28 Jan 2022 09:54:34 GMT</pubDate>
            <atom:updated>2022-01-28T09:54:34.229Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*i4fFs7dLZUGyIYvg6dEwag.jpeg" /><figcaption><strong>Gotta catch ’em all</strong>. The Pokémon Company.</figcaption></figure><p><strong>Part -2- of Prediction Pokémon’s rarity,</strong>In this project,I have used Pokémon all data from kaggle.The aim for this project is to predict pokémon’s rarity(legendary or common) by using features (for instance; pokémon’s attack,defense,the element that have).And creating a flask app for prediction.I will explain all i did,step by step.You can visit project repository(<a href="https://github.com/OzanERTEK/DataScience_Project3">HERE</a>).The methodology of the project is given below.</p><p>You can access Part -1- link <a href="https://medium.com/@ozan.ertek11/prediction-of-pok%C3%A9mons-rarity-and-prediction-flask-app-1-e4adc143f48b"><em>HERE</em></a></p><p><strong>In This Part</strong></p><ul><li>Create pkl file for our Xgboost model to run with flask app</li><li>We continue from flask app and add pythonanywhere.com</li></ul><ol><li><strong>Create Pkl File</strong></li></ol><p>We will use joblib library for creating pkl file.</p><p>The codes below are our Xgboost model with parameters that found by bayesian optimization</p><pre>xg_reg1 <strong>=</strong> xgb<strong>.</strong>XGBClassifier(learning_rate <strong>=</strong> 0.9193,<br> max_depth<strong>=</strong> 14,<br> n_estimators <strong>=</strong>123,<br> reg_alpha <strong>=</strong>  0.988)</pre><p>And then we have to import joblib,if i dont have install by that code;</p><pre>!pip install joblib </pre><p>import joblib and create pkl file.</p><pre><strong>import</strong> joblib<br>joblib<strong>.</strong>dump(xg_reg1,&quot;model7.pkl&quot;)</pre><pre>file <strong>=</strong> open(&quot;model7.pkl&quot;,&quot;wb&quot;)<br>pickle<strong>.</strong>dump(model7,file)</pre><p>Now we add <strong>prediction</strong> for predict our pokémon.</p><pre>import numpy as np<br>prediction <strong>= </strong>model<strong>.</strong>predict(np<strong>.</strong>array([[type1,type2,hp,attack,defense,sp_attack,sp_defense,speed,total]]))</pre><p><strong>total</strong> is sum of pokémon’s all stats(attack,defense etc.)</p><p>Final part is to add all these codes to <strong>flask</strong> (<a href="https://github.com/OzanERTEK">link for my github</a>)(for flask codes)</p><p>In Flask App ,we have to import numpy and joblib to run our app,the user that access our application(<a href="http://ozanertek11.pythonanywhere.com/">link for my app</a>)give us pokémon’s all stats by using HTML interface.By using that inputs our codes predict our pokémon’s rarity(common or legendary).</p><p><strong>2) Create Account and Adding your APP to Cloud(pythonanywhere.com)</strong></p><p>In this part,we will add our <strong>flask app </strong>to cloud by using pythonanywhere.com</p><p>we have to sign in pythonywhere.com(<a href="http://www.pythonanywhere.com/">HERE</a>).And then we add all our HTML ,CSS,image files and APP codes to cloud.It is DONE!</p><p>Our application in Cloud now. :)</p><p>Thanks for reading my article.</p><p>Hope to see you again in my next article…</p><p><strong>Ozan ERTEK</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c794661ef00" width="1" height="1" alt=""><hr><p><a href="https://medium.com/i%CC%87stanbuldatascienceacademy/prediction-of-pok%C3%A9mons-rarity-and-prediction-flask-app-2-3c794661ef00">Prediction of Pokémon’s Rarity and Prediction Flask-App -2-</a> was originally published in <a href="https://medium.com/i%CC%87stanbuldatascienceacademy">İstanbul Data Science Academy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prediction of Pokémon’s Rarity and Prediction Flask-App -1-]]></title>
            <link>https://medium.com/i%CC%87stanbuldatascienceacademy/prediction-of-pok%C3%A9mons-rarity-and-prediction-flask-app-1-e4adc143f48b?source=rss-cb1c190e725------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4adc143f48b</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[bayesian-optimization]]></category>
            <category><![CDATA[xgboost]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ozan ERTEK]]></dc:creator>
            <pubDate>Mon, 24 Jan 2022 11:01:58 GMT</pubDate>
            <atom:updated>2022-01-24T14:28:19.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*i4fFs7dLZUGyIYvg6dEwag.jpeg" /><figcaption><strong>Gotta catch ’em all. </strong>The Pokémon Company.</figcaption></figure><p>In this project,I have used Pokémon all data from kaggle.The aim for this project is to predict pokémon’s rarity(legendary or common) by using features (for instance; pokémon’s attack,defense,the element that have).And creating a flask app for prediction.I will explain all i did,step by step.You can visit project repository(<a href="https://github.com/OzanERTEK/DataScience_Project3">HERE</a>).The methodology of the project is given below.</p><ul><li>Adding all data to SQL ( This is only for my project,not necessary)(<a href="https://github.com/OzanERTEK/DataScience_Project3/tree/main/Project3">For dataset</a>).</li><li>Defining Data Features</li><li>Identifying Pokémon’s features that have most significant for Machine Learning and Using Hyperparameter Optimization(Bayesian).</li></ul><p>Second Part(-2-)(Link HERE)</p><ul><li>Flask APP</li><li>Adding in the Cloud( pythonanywhere.com)(<a href="http://ozanertek11.pythonanywhere.com/">mylink</a>)</li></ul><p>Let’s Gotta catch them all !</p><h3>1 ) Getting Data</h3><p>I used Pokémon data that have legendary column from kaggle.Includes type of pokémon(type1 ,type2),hp,attack,defense,legendary column in that dataset.(i added in my github repository.)</p><h3>2) Defining Features for ML</h3><p>We have to identify features that have more powerful against to parse target value(0 or 1).Therefore,we have to look pairplot graphs.</p><pre>g <strong>=</strong> sns<strong>.</strong>PairGrid(df, hue<strong>=</strong>&quot;legendary&quot;)<br>g<strong>.</strong>map_diag(sns<strong>.</strong>histplot)<br>g<strong>.</strong>map_offdiag(sns<strong>.</strong>scatterplot)<br>g<strong>.</strong>add_legend()</pre><p>and violinplot for <strong>‘Total’ </strong>feature.</p><pre>sns<strong>.</strong>set(font_scale <strong>=</strong> 2)<br>plt<strong>.</strong>figure(figsize <strong>=</strong> (35,25))<br>sns<strong>.</strong>catplot(x<strong>=</strong>&quot;type1&quot;, y<strong>=</strong>&quot;total&quot;, hue<strong>=</strong>&quot;legendary&quot;,<br>            kind<strong>=</strong>&quot;violin&quot;,height<strong>=</strong>8.27, aspect<strong>=</strong>11.7<strong>/</strong>8.27, split<strong>=True</strong>, data<strong>=</strong>df)<br>plt<strong>.</strong>xticks(rotation<strong>=</strong>45)</pre><p>and in below is most powerful one.(You can see bigger graph)</p><pre>sns<strong>.</strong>set(font_scale <strong>=</strong> 2)<br>plt<strong>.</strong>figure(figsize <strong>=</strong> (15,10))<br>sns<strong>.</strong>histplot(x<strong>=</strong>&#39;total&#39;,hue<strong>=</strong>&#39;legendary&#39;,data<strong>=</strong> df)<br>plt<strong>.</strong>xlabel(&#39;TOTAL&#39;)</pre><p>So,that means we should use<strong> ‘Total’</strong> column for prediction.<strong>’Total’ </strong>columns is sum of pokémon’s all features(for instance, <strong>hp</strong> + <strong>attack</strong> + <strong>defense</strong> …).In the otherhand,that features is important because,we can add to <strong>flask</strong> very simply.So,we use that feature.</p><p>Other important pokémon features are <strong>type1</strong>(pokémon’s primary element),<strong>type2</strong>(pokémon’s secondary element),for example,pikachu is electric pokémon,so pikachu’s <strong>type1</strong> is electric.</p><h3>3)Using best model and Optimising by Bayesian Optimization.</h3><p>We already identified our features in second title.So now,we going to try some powerful classification models.I tried before <strong>LightGBM, XGBoost GaussianNB</strong>.Best option was <strong>XGBoost</strong>.So i will continue with <strong>XGBoost</strong>.</p><pre>cla1_X <strong>=</strong> df<strong>.</strong>drop(columns<strong>=</strong>[&#39;legendary&#39;,&#39;name&#39;,&#39;generation&#39;,&#39;number&#39;])<br>cla_y <strong>=</strong> df[&#39;legendary&#39;]<br>X_train,X_test,y_train,y_test<strong>=</strong>train_test_split(cla1_X,cla_y,test_size<strong>=</strong>0.20,random_state<strong>=</strong>5)</pre><p>and modeling.</p><pre>modelxgb3 <strong>=</strong> XGBClassifier()</pre><p>and then,we have to use <strong>cross-validation</strong> too.</p><pre><strong>from</strong> sklearn.model_selection <strong>import</strong> KFold<br><strong>from</strong> sklearn.model_selection <strong>import</strong> cross_val_score<br>kfold <strong>=</strong> KFold(n_splits<strong>=</strong>10)<br>results <strong>=</strong> cross_val_score(modelxgb3, cla1_X, cla_y, cv<strong>=</strong>kfold)</pre><p>next step; prediction our accuracy,recall and precision scores.that scores high enough (i got before 96 % ).But,we have to give our best shot.We already select good features for prediction.but,bayesian optimization our final best shot.</p><pre><strong>from</strong> bayes_opt <strong>import</strong> BayesianOptimization<br><br><strong>def</strong> xgbc_cv(max_depth,learning_rate,n_estimators,reg_alpha):<br>    <br>    estimator_function <strong>=</strong> xgb<strong>.</strong>XGBClassifier(max_depth<strong>=</strong>int(max_depth),<br>                                           learning_rate<strong>=</strong> learning_rate,<br>                                           n_estimators<strong>=</strong> int(n_estimators),<br>                                           reg_alpha <strong>=</strong> reg_alpha,<br>                                           nthread <strong>=</strong> <strong>-</strong>1,<br>                                          <br>                                           seed <strong>=</strong> seed)<br>    <em># Fit the estimator</em><br>    estimator_function<strong>.</strong>fit(X_train,y_train)<br>    <br><br>    <strong>return</strong> accuracy_score(y_test,estimator_function<strong>.</strong>predict(X_test))<br><br><br><br>gp_params <strong>=</strong> {&quot;alpha&quot;: 1e-10}<br>seed <strong>=</strong> 112<br>hyperparameter_space <strong>=</strong> {<br>    &#39;max_depth&#39;: (1, 150),<br>    &#39;learning_rate&#39;: (0, 1),<br>    &#39;n_estimators&#39; : (20,300),<br>    &#39;reg_alpha&#39;: (0,1)<br>}<br><br>xgbcBO <strong>=</strong> BayesianOptimization(f <strong>=</strong> xgbc_cv, <br>                             pbounds <strong>=</strong>  hyperparameter_space,<br>                             random_state <strong>=</strong> 16,<br>                             verbose <strong>=</strong> 10)<br><br><br>xgbcBO<strong>.</strong>maximize(init_points<strong>=</strong>2,n_iter<strong>=</strong>50,acq<strong>=</strong>&#39;ucb&#39;, kappa<strong>=</strong> 3, <strong>**</strong>gp_params)</pre><p>You can change iteration on this point.This code gives us ‘<strong>max_depth’,’learning rate’,’n estimator’ and ‘reg alpha’</strong> parameters.</p><pre>optimum_parameter<strong>=</strong>xgbcBO<strong>.</strong>max<br>optimum_parameter[&quot;params&quot;]</pre><p>We can get that parameters by using above codes.</p><p>And then we add new Xgboost model by using optimized parameters.</p><pre>xg_reg1 <strong>=</strong> xgb<strong>.</strong>XGBClassifier(learning_rate <strong>=</strong> &#39;your learning rate&#39;,<br> max_depth<strong>=</strong> &#39;your max_depth,<br> n_estimators <strong>=&#39;</strong>your value&#39;,<br> reg_alpha <strong>=</strong>  &#39;your reg_alpha value&#39;)</pre><p>below codes is <strong>confusion matrix</strong>:</p><pre>cm <strong>=</strong> print_confusion_matrix(confusion_matrix(cla_y, xg_reg1<strong>.</strong>predict(cla1_X)), [&#39;Not Legendary&#39;, &#39;Legendary&#39;])</pre><p>Our accuracy is (98.1% now).<strong>Bayesian optimisation</strong> methods increased nearly <strong>+2%,</strong>and<strong> recall score</strong> and <strong>precision score</strong> are 83% -85%.</p><p>Our model is ready for flask app.In second part(-2-) we going to create <strong>pkl file</strong> for <strong>flask</strong> and creating <strong>flask</strong> application.</p><p>Thanks for reading my article :)</p><p>Hope to see you again in my next article…</p><p><strong>Ozan ERTEK</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4adc143f48b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/i%CC%87stanbuldatascienceacademy/prediction-of-pok%C3%A9mons-rarity-and-prediction-flask-app-1-e4adc143f48b">Prediction of Pokémon’s Rarity and Prediction Flask-App -1-</a> was originally published in <a href="https://medium.com/i%CC%87stanbuldatascienceacademy">İstanbul Data Science Academy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prediction Monitor’s Prices Getting Data From Amazon.com]]></title>
            <link>https://medium.com/i%CC%87stanbuldatascienceacademy/prediction-monitors-prices-getting-data-from-amazon-com-227be7f4d16a?source=rss-cb1c190e725------2</link>
            <guid isPermaLink="false">https://medium.com/p/227be7f4d16a</guid>
            <dc:creator><![CDATA[Ozan ERTEK]]></dc:creator>
            <pubDate>Wed, 29 Dec 2021 12:11:54 GMT</pubDate>
            <atom:updated>2021-12-29T13:49:52.602Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kPV9-SCjsxNY9VGBQIRag.png" /><figcaption>Photos by amazon.com and Wallpapersden.com</figcaption></figure><p>In this project, we have used webscraping(beautifulsoup) for getting data.The aim for this project is to predict monitor’s price by using features that ratings of monitor ,specific uses and monitor brands.Pulled that features by beautifulsoup and predicted by linear regression.You can visit project repository <a href="https://github.com/OzanERTEK/DataScience_Project2/tree/main/Project2">HERE</a>.The methodology of the project is given below.</p><ul><li>Webscraping from Amazon.com(filtering minimum price for getting only monitor)</li><li>Defining Features.</li><li>Figuring out what to do with NaN values and monitor brands(adding dummy values.)</li><li>Choosing best Regression Model.</li></ul><p>Each step, i will explain what i did and why.</p><h3>1 ) Webscraping and Defining Features.</h3><p>For first step, we need python libraries such as Numpy,Pandas,BeautifulSoup,requests.</p><p>we can download and install by using following codes in Jupyter :</p><blockquote><em>!pip download pandas</em></blockquote><blockquote><em>!pip install pandas</em></blockquote><p>So,we have all libraries we need now .</p><p>We have to open first page’s url that provide product url’s ( www.amazon.com/…. )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nv6Um8ZA_LPINoNnzbrx5w.png" /></figure><p>And then, we have to get all urls of pages.</p><pre>html <strong>=</strong> getAndParseURL(&#39;https://www.amazon.com.tr/s?k=monitör&amp;i=computers&amp;rh=n%3A12601904031%2Cp_36%3A100000-&amp;__mk_tr_TR=ÅMÅŽÕÑ&amp;qid=1639244193&amp;rnid=13736708031&amp;ref=sr_nr_p_36_4&#39;)<br>page_links <strong>=</strong>[]<br><strong>for</strong> i <strong>in</strong> range(70) :<br>    links <strong>=</strong> str(&#39;https://www.amazon.com.tr/s?k=monitör&amp;i=computers&amp;rh=n%3A12601904031%2Cp_36%3A100000-&amp;page=&#39;) <strong>+</strong> str(i<strong>+</strong>1) <strong>+</strong> str(&#39;&amp;__mk_tr_TR=ÅMÅŽÕÑ&amp;qid=1639244253&amp;rnid=13736708031&amp;ref=sr_pg_&#39;) <strong>+</strong> str(i<strong>+</strong>1)<br>    page_links<strong>.</strong>append(links)<br></pre><p>With these codes,we can pull all page urls(for 70 pages)for finding all product links.</p><p>And then, we want to pull product links in all pages that we want .</p><pre>products_link <strong>=</strong> []<br><strong>for</strong> page <strong>in</strong> new_page_links :<br>    html  <strong>=</strong> getAndParseURL(page)<br>    <br>    <strong>for</strong> b <strong>in</strong> html<strong>.</strong>find_all(&#39;a&#39;,{&#39;class&#39;:&#39;a-link-normal a-text-normal&#39;}):<br>       a<strong>=</strong> str(&quot;https://www.amazon.com.tr&quot;)<strong>+</strong> (b[&#39;href&#39;])<br>       products_link<strong>.</strong>append(a)</pre><p>So,we have got all products link now.Just one step left to get all product features.That step is to find product features’ html location.</p><pre>productlist<strong>=</strong> []<br><strong>for</strong> link <strong>in</strong> products_link:<br>    plink2 <strong>=</strong> getAndParseURL(link)<br>    results <strong>=</strong> plink2<strong>.</strong>find_all(&#39;div&#39;,{&#39;id&#39;:&#39;centerCol&#39;})<br>    <br>    <strong>for</strong> item <strong>in</strong> results :<br>        <strong>try</strong> :  <br>            j <strong>=</strong> item<strong>.</strong>find(&#39;span&#39;,{&#39;class&#39;:&#39;a-offscreen&#39;})<strong>.</strong>text<strong>.</strong>replace(&#39;TL&#39;,&#39;&#39;)<strong>.</strong>replace(&#39;\xa0&#39;,&#39;&#39;)<br>        <strong>except</strong> :<br>            j <strong>=</strong>&#39;&#39;<br>        <strong>try</strong> :  <br>            r <strong>=</strong> item<strong>.</strong>find(&#39;span&#39;,{&#39;id&#39;:&#39;acrCustomerReviewText&#39;})<strong>.</strong>text<br>        <strong>except</strong> :<br>            r <strong>=</strong>&#39;&#39;<br>        <strong>try</strong> :<br>            y <strong>=</strong> item<strong>.</strong>find(&#39;td&#39;,{&#39;class&#39;: &#39;a-span9&#39;})<strong>.</strong>text<br>            <br>        <strong>except</strong> :<br>            y <strong>=</strong> &#39;&#39;<br>        <strong>try</strong> :<br>            h <strong>=</strong> item<strong>.</strong>find(&#39;a&#39;,{&#39;id&#39;:&#39;bylineInfo&#39;})<strong>.</strong>text<br>            <br>        <strong>except</strong> :<br>            h <strong>=</strong> &#39;&#39;<br>        time<strong>.</strong>sleep(5)<br>        product <strong>=</strong> {<br>            &#39;prod_name&#39; : item<strong>.</strong>find(&#39;span&#39;,{&#39;id&#39;:&#39;productTitle&#39;})<strong>.</strong>text,<br>            &#39;prod_comp&#39; : h,<br>            &#39;prod_price&#39; : j ,<br>            &#39;prod_rating&#39; : r ,<br>            &#39;prod_feature&#39;: y,<br>        }<br>        productlist<strong>.</strong>append(product)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XL9B9U40mWQ0F24pOnQYOA.png" /></figure><p>All product features to be found by these codes.And then we add these features to csv.</p><p>By below function,we can create DataFrame.</p><pre><strong>def</strong> output(productlist):<br>    productsdf <strong>=</strong>pd<strong>.</strong>DataFrame(productlist)<br>    productsdf<strong>.</strong>to_csv(&#39;output1.csv&#39;,index <strong>=</strong> <strong>False</strong>)<br>    print(&#39;Saved to CSV&#39;)</pre><p>And then,our dataset is ready to use.After web-scraping process our Dataset looks as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*rgQOegMZ0JZEX_bUETH1gw.png" /></figure><h3>2 ) Figuring out what to do with NaN values and monitor brands(adding dummy values)</h3><p>In our dataset,we have too many NaN values and unique values that has same meaning as (Gaming and Gaming. or Work and Work,Education in same column).We have to find a solution for this situation.That solution is to make unique values in Specific Uses ( Prod_feature column ) such as Gaming,Personal,Education,Work.So that solutions codes like as below</p><pre><strong>for</strong> i <strong>in</strong> range(len(df[&#39;prod_feature&#39;])):<br>    <strong>if</strong> df[&#39;prod_feature&#39;][i] <strong>==</strong> &#39;Video Editing&#39;:<br>        df[&#39;prod_feature&#39;][i] <strong>=</strong> &#39;Video processing&#39;<br>    <strong>elif</strong> df[&#39;prod_feature&#39;][i] <strong>==</strong> &#39;76 Hz, 70 Hz&#39;:<br>        df[&#39;prod_feature&#39;][i] <strong>=</strong> &#39;Gaming&#39;<br>    <strong>elif</strong> df[&#39;prod_feature&#39;][i] <strong>==</strong> &#39;VGA, HDMI&#39;:<br>        df[&#39;prod_feature&#39;][i] <strong>=</strong> &#39;Gaming&#39;<br>    <strong>elif</strong> df[&#39;prod_feature&#39;][i] <strong>==</strong> &#39;24 İnç&#39;:<br>        df[&#39;prod_feature&#39;][i] <strong>=</strong> &#39;Personal&#39;</pre><p>for all unwanted unique values.And second process is to fill NaN values in (product_price and) (product_rating column) .firstly we have to change dtype to float.Because at the beginning all data types were as object.</p><pre>df[&#39;prod_price&#39;] <strong>=</strong> df[&#39;prod_price&#39;]<strong>.</strong>str<strong>.</strong>replace(&#39;,&#39;,&#39;.&#39;)<br>df[&#39;prod_price&#39;] <strong>=</strong> df[&#39;prod_price&#39;]<strong>.</strong>astype(float)<br><em>df[&#39;prod_price&#39;] = df[&#39;prod_price&#39;].replace(&#39;.&#39;,&#39;&#39;)</em></pre><p>and then,we create random values around mean of product price column.Because this process more significant than fill only mean value.(Mean value = 4500).And 112 is prod_rating mean value that we added.</p><pre>random <strong>=</strong> np<strong>.</strong>random<strong>.</strong>randint(3000,6000,size<strong>=</strong>(2000))<br>random <strong>=</strong>pd<strong>.</strong>Series(random) # mean value = 4500</pre><pre>df[&#39;prod_price&#39;] <strong>=</strong> df[&#39;prod_price&#39;]<strong>.</strong>fillna(random)<br>df[&#39;prod_rating&#39;] <strong>=</strong> df[&#39;prod_rating&#39;]<strong>.</strong>fillna(112)</pre><pre>df[&#39;prod_price&#39;] <strong>=</strong> df[&#39;prod_price&#39;]<strong>.</strong>apply(<strong>lambda</strong> x : df[&#39;prod_price&#39;]<strong>.</strong>fillna() <strong>if</strong> x <strong>&gt;</strong> 8000 <strong>else</strong> x)</pre><p>Third process is to design brand column.If we have just one product for that monitor,this brand of monitor must be equal Brand :OTHER.</p><p>For this process, we need two querry such as :</p><pre>query <strong>=</strong> df[&#39;prod_comp&#39;]<strong>.</strong>unique()<br>query2 <strong>=</strong> df[&#39;prod_comp&#39;]<strong>.</strong>value_counts()</pre><pre><strong>for</strong> i <strong>in</strong> range(len(df)):<br>    <strong>for</strong> j <strong>in</strong> range(len(query)):<br>        <strong>if</strong> (df[&#39;prod_comp&#39;][i] <strong>==</strong> query[j]) <strong>&amp;</strong> (query2[j] <strong>&lt;</strong> 3):<br>            df[&#39;prod_comp&#39;][i] <strong>=</strong> &#39;Brand : Other &#39;<br>        <strong>else</strong> : <br>            df[&#39;prod_comp&#39;][i] <strong>=</strong> df[&#39;prod_comp&#39;][i]</pre><p>With this process,we made that if brand has 1 ,2 and 3 product only ,it going to equal Brand : Other.</p><p>So,our dataset is ready for Machine Learning.Now :</p><h3>3) Choosing Best Regression Model</h3><p>Firstly,we have to create dummy variables for all categorical columns by this code as below :</p><pre>df <strong>=</strong> pd<strong>.</strong>get_dummies(df,columns<strong>=</strong>[&#39;prod_comp&#39;])<br>df <strong>=</strong> pd<strong>.</strong>get_dummies(df,columns<strong>=</strong>[&#39;prod_feature&#39;])</pre><p>and now,choosing X and y (independent and dependent variables for Linear Regression Model)</p><pre>X <strong>=</strong> df<strong>.</strong>iloc[:,2:33]<br>y <strong>=</strong> df<strong>.</strong>iloc[:,1]</pre><p>X variables are all categorical columns,y variable is product price only(target)</p><pre>X_train, X_validation, y_train, Y_validation <strong>=</strong> train_test_split(X,y, test_size<strong>=</strong>0.20, random_state<strong>=</strong>5)<br>regressor <strong>=</strong> LinearRegression()<br>regressor<strong>.</strong>fit(X_train, y_train)<br>y_pred<strong>=</strong> regressor<strong>.</strong>predict(X)</pre><pre>X_train, X_test, y_train, y_test <strong>=</strong> train_test_split(X, y, test_size<strong>=</strong>0.2, random_state<strong>=</strong>5)<br><br>regressor <strong>=</strong> LinearRegression()<br>regressor<strong>.</strong>fit(X_train, y_train)<br><br>coeff_df <strong>=</strong> pd<strong>.</strong>DataFrame(regressor<strong>.</strong>coef_, X<strong>.</strong>columns, columns<strong>=</strong>[&#39;Coefficient&#39;])<br>coeff_df<br><br>y_pred <strong>=</strong> regressor<strong>.</strong>predict(X_test)<br>y_pred<br><br>df_pred <strong>=</strong> pd<strong>.</strong>DataFrame({&#39;Actual&#39;: y_test, &#39;Predicted&#39;: y_pred})<br>df_pred<strong>.</strong>head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/142/1*K473AYLTq28UxuJ5pb_Nng.png" /></figure><p>Our model is very bad at this point(for all independent variables)(r²= 0.13).We have to find a more powerful model at next point.So,we would better see on graph.</p><pre>plt<strong>.</strong>figure(figsize <strong>=</strong> (25,15))<br>sns<strong>.</strong>set(font_scale <strong>=</strong> 3)<br>sns<strong>.</strong>regplot(Y_train,predictions)<br>plt<strong>.</strong>xlabel(&#39;Actual_Values&#39;)<br>plt<strong>.</strong>ylabel(&#39;Predicted_Values&#39;)<br>plt<strong>.</strong>title(&#39;Actual_Values vs Predicted_Values&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*vU8qf0g6QgBW2b0LGvtZrw.png" /></figure><p>In this graph ,we can see our features and dataset are not enough (n = 320).Because,spread of values is too high.</p><p>So,we need to select best independent variables that has good correlation.</p><p>Therefore,We should look heatmap of the features</p><pre>df_corr <strong>=</strong> df<strong>.</strong>corr(method <strong>=</strong> &#39;spearman&#39;)<br>df_corr<strong>.</strong>head()</pre><pre>df_brand <strong>=</strong> df_corr<strong>.</strong>iloc[:,0:21]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*tT1QNpiUqDDe6Q-I3-8ZFw.png" /></figure><pre>df_feature <strong>=</strong>df_corr<strong>.</strong>iloc[:,21:31] # i have cut for price and rating </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*A_A4-_26DyozcV21wKO5VA.png" /></figure><p>For Correlation Matrix,we choose as X that have best correlation on price for our regression model.</p><pre>X_new <strong>=</strong> df<strong>.</strong>loc[:,[&#39;prod_comp_Brand: ASUS&#39;,&#39;prod_comp_Brand: Viewsonic&#39;,&#39;prod_feature_Multimedia&#39;,&#39;prod_feature_Gaming&#39;,&#39;prod_feature_Work&#39;]]</pre><pre>y <strong>=</strong> df<strong>.</strong>iloc[:,1]</pre><p>After selecting these features,best model found as OLS .</p><p>r² = 0.45</p><p>F-statistic is significant</p><p>t value for all independent variables is significant (|t|&lt;p for all x)</p><p>By the way,i tried others Linear Methods but not a good solution.All methods that i tried,on my github <a href="https://github.com/OzanERTEK/DataScience_Project2/tree/main/Project2">HERE</a>.Thank you for reading.</p><p>Hope to see you again in my next article…</p><p>Ozan ERTEK</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=227be7f4d16a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/i%CC%87stanbuldatascienceacademy/prediction-monitors-prices-getting-data-from-amazon-com-227be7f4d16a">Prediction Monitor’s Prices Getting Data From Amazon.com</a> was originally published in <a href="https://medium.com/i%CC%87stanbuldatascienceacademy">İstanbul Data Science Academy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>