<?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 Felix Hope on Medium]]></title>
        <description><![CDATA[Stories by Felix Hope on Medium]]></description>
        <link>https://medium.com/@felixhope30?source=rss-c92e4542a8ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Felix Hope on Medium</title>
            <link>https://medium.com/@felixhope30?source=rss-c92e4542a8ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:30:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@felixhope30/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[ArgParse as a tool for tracking Machine Learning hyperparameters?]]></title>
            <link>https://medium.datadriveninvestor.com/argparse-as-a-tool-for-tracking-machine-learning-hyperparameters-fe594b9788ef?source=rss-c92e4542a8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe594b9788ef</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[argparse]]></category>
            <category><![CDATA[hyperparameter-tuning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Felix Hope]]></dc:creator>
            <pubDate>Tue, 27 Oct 2020 10:43:22 GMT</pubDate>
            <atom:updated>2020-11-02T16:34:51.099Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uCVjc-xE2uzh2hhtKURh2w.jpeg" /></figure><p>Machine learning hyperparameter is a parameter that is set before the learning process begins. It is used to control the learning process. These parameters are tunable and can directly affect how well a model trains.</p><p>Hyperparameters can be classified as model hyperparameters, that cannot be inferred while <a href="https://en.wikipedia.org/wiki/Model_fitting">fitting the machine to the training set</a> because they refer to the <a href="https://en.wikipedia.org/wiki/Model_selection">model selection</a> task, or algorithm hyperparameters, that in principle have no influence on the performance of the model but affect the speed and quality of the learning process. An example of a model hyperparameter is the topology and size of a neural network.</p><blockquote><strong>What is the importance of hyperparameter tuning? </strong>Hyperparameters are crucial as they control the overall behaviour of a machine learning model. The ultimate goal is to find an optimal combination of hyperparameters that minimizes a predefined loss function to give better results.</blockquote><blockquote>Failure to do so would give sub-optimal results as the model didn’t converge and minimize the loss function effectively.</blockquote><blockquote>It’s like exploring a range of possibilities and trying to locate the best combination that gives you the best results.</blockquote><blockquote>— <a href="https://towardsdatascience.com/why-you-should-do-feature-engineering-first-hyperparameter-tuning-second-as-a-data-scientist-334be5eb276c#:~:text=What%20is%20the%20importance%20of%20hyperparameter%20tuning%3F,function%20to%20give%20better%20results.">Almond Lee</a></blockquote><p>Hilde J.P. Weerts and 2 others from Cornell University submitted a<strong> </strong><a href="https://arxiv.org/abs/2007.07588"><strong>study</strong></a> to determine whether it is important to tune a hyperparameter or whether it can be safely set to a default value. But generally, the reason for tuning a hyperparameter is to reach the somewhat highest performance of a model.</p><p><a href="https://docs.python.org/3/howto/argparse.html#id1">ArgParse</a> is the “recommended command-line parsing module in the Python standard library”. The module makes it easy to write user-friendly command-line interfaces. Sometimes, in machine learning, you would go through multiple experiments just so you can understand budding relationships between scores and hyperparameters and to find ways to obtain the best performing model or algorithm. It makes sense to start new trials from the command line and specify values of parameters in your CLI.</p><p>Below is a simple Python program that shows how you can use argparse.</p><pre><strong>import</strong> argparse<br><br>argparser = argparse.ArgumentParser(description=&#39;Process hyper-parameters&#39;)<br><br>argparser.add_argument(&#39;--tr&#39;,       type=float, default=0.41, help=&#39;training rate&#39;)<br>argparser.add_argument(&#39;--fallout&#39;,  type=float, default=0.01,   help=&#39;fallout mean&#39;)<br>argparser.add_argument(&#39;--data&#39;, type=str,   default=&#39;/this/is/a/test/data/&#39;, help=&#39;data directory for training&#39;)<br><br>args = argparser.parse_args()<br><br><em># then you can access passed values</em><br>print(args.tr)<br>print(args.fallout)<br>print(args.data)</pre><p>Then you can run the code. If you run it without any arguments, defaults will be used to..</p><pre>python main.py</pre><p>Then you should expect the output:</p><pre>0.41<br>0.01<br>/thi/<strong>is</strong>/a/test/data/</pre><p>You can also run the code with arguments. The parameters you specify will be parsed, so that you can use them in your training script:</p><pre>python main.py --tr 0.0213 --fallout 0.5</pre><p>Then you would get the output:</p><pre>0.0213<br>0.5<br>/thi/<strong>is</strong>/a/test/data/</pre><p>Argparse is a good way to track your machine learning hyperparameters but it has some cons. If your project grows rapidly, you’ll find it difficult to maintain CLI parameters. This is because argparse does not save or log parameters passed in the command line and so you would have t save values of parameters yourself. It also requires extra effort to keep track of hyperparameters’ values across long experimentation-based projects.</p><p>With ArgParse, you can easily add new arguments, conveniently begin new trials and also decide on hyperparameters’ values on the go.</p><p>There are also several other ways to track hyperparameters in Machine Learning. And you can also try out others: Click, AttrDict, Hydra, and a few others.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe594b9788ef" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/argparse-as-a-tool-for-tracking-machine-learning-hyperparameters-fe594b9788ef">ArgParse as a tool for tracking Machine Learning hyperparameters?</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Push Notifications(FCM) with Flutter web]]></title>
            <link>https://felixhope30.medium.com/integrating-push-notifications-fcm-with-flutter-web-f9a2e08bbe9c?source=rss-c92e4542a8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9a2e08bbe9c</guid>
            <category><![CDATA[fcm]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[flutter-web]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Felix Hope]]></dc:creator>
            <pubDate>Mon, 26 Oct 2020 19:01:47 GMT</pubDate>
            <atom:updated>2020-11-02T19:28:21.940Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*80fSe55TiestoYr9lJP8lQ.jpeg" /></figure><p>Many applications these days, web, mobile or desktop require notifications. Chances are, 2 of 4 software you’ll build would require some kind of notification system integrated into it. Depending on what your application does, or how it runs, you can decide to use local notifications or push notifications. One way you can achieve push notifications with flutter is through Firebase Cloud Messaging(FCM).</p><p>There’s a flutter package that handles FCM. You can find the package <a href="https://pub.dev/packages/firebase_messaging"><strong>here</strong></a><strong>. </strong>But at the time of writing this article, the package has no support for flutter web. Don’t fret, you can do it yourself. It’s pretty easy.</p><p>To begin, you’ll need a firebase account, and then create a starter project and connect your web application to the firebase project. <a href="https://firebase.flutter.dev/docs/installation/web/"><strong>Here</strong></a><strong> </strong>is a detailed guide on how you can easily connect your flutter web project to firebase.</p><p>After successfully connecting your flutter web project to firebase, open your web/index.html file and locate this code..</p><pre>&lt;script&gt;<br>if (&#39;serviceWorker&#39; in navigator) {<br> window.addEventListener(&#39;load&#39;, function () {<br>  <em>navigator.serviceWorker.register(&#39;flutter_service_worker.js&#39;);<br> </em>});<br>}<br>&lt;/script&gt;</pre><p>Modify the code block like this….</p><pre>&lt;script&gt;<br> if (&#39;serviceWorker&#39; in navigator) {<br>  window.addEventListener(&#39;load&#39;, function () {<br>    navigator.serviceWorker.register(&quot;/firebase-messaging-sw.js&quot;);<br> });<br>}<br>&lt;/script&gt;</pre><p>What we did here was just to register the FCM service worker. We removed the flutter service worker and replaced it with the FCM service worker to avoid errors.</p><blockquote><em>Want to read this story later? Save it in </em><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=blog&amp;utm_campaign=noteworthy&amp;utm_content=eid7"><em>Journal</em></a><em>.</em></blockquote><p>The body tag in your index.html file will now look like this:</p><pre>&lt;body&gt;<br> &lt;script&gt;<br>  if (&#39;serviceWorker&#39; in navigator) {<br>    window.addEventListener(&#39;load&#39;, function () {<br>     navigator.serviceWorker.register(&quot;/firebase-messaging-sw.js&quot;);<br>   });<br>  }<br> &lt;/script&gt;<br>&lt;script src=&quot;https://www.gstatic.com/firebasejs/7.23.0/firebase-app.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;/__/firebase/7.23.0/firebase-analytics.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;script src=&quot;https://www.gstatic.com/firebasejs/7.23.0/firebase-auth.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;script src=&quot;https://www.gstatic.com/firebasejs/7.23.0/firebase-firestore.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;script src=&quot;https://www.gstatic.com/firebasejs/7.23.0/firebase-messaging.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;script&gt;<br> var firebaseConfig = {<br>   apiKey: &quot;API_KEY&quot;,<br>   authDomain: &quot;AUTH_DOMAIN&quot;,<br>   databaseURL: &quot;DATABASE_URL&quot;,<br>   projectId: &quot;PROJECT_ID&quot;, <br>   storageBucket: &quot;STORAGE_BUCKET&quot;, <br>   messagingSenderId: &quot;MESSAGING_SENDER_ID&quot;, <br>   appId: &quot;APP_ID&quot;, <br>   measurementId: &quot;MEASUREMENT_ID&quot;<br>};</pre><pre><em>// Initialize Firebase</em></pre><pre>firebase.initializeApp(firebaseConfig);</pre><pre>firebase.analytics();</pre><pre>&lt;/script&gt;</pre><pre>&lt;script src=&quot;main.dart.js&quot; type=&quot;application/javascript&quot;&gt;&lt;/script&gt;</pre><pre>&lt;/body&gt;</pre><p>Check that your the body tag of your index.html looks like that. Don’t forget to replace the configuration keys with your firebase keys. You can check for the keys in your firebase console under your web project settings. Now Create a new file called firebase-message-sw.js in the web folder where the index.html file is… Now add the following contents</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/117312a2d5ad6ea77f646b84523bab9e/href">https://medium.com/media/117312a2d5ad6ea77f646b84523bab9e/href</a></iframe><p>Now you can create a new dart file anywhere in your project and give it a name you like… I’ll use messaging.dart. Then add the following code..</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2262ac4ff620ee34a07e7820cf89a2e/href">https://medium.com/media/b2262ac4ff620ee34a07e7820cf89a2e/href</a></iframe><p>The Messaging class above handles the intialization, and also requests for permission and get the device token. The token is important if you want to send notifications to a particular user on your application.<br>Don’t forget to add your pair key. You can generate a pair key from your firebase console in your project. Go to your cloud messaging settings, scroll to the bottom and you’ll find the web configuration section where you can generate a pair key for your project.</p><p>From anywhere in your application, you can call the init function, request for permission and get the token…</p><pre><em>final</em> _messaging = Messaging.instance;</pre><pre>Future&lt;void&gt; request() async {</pre><pre>_messaging.requestPermission().then((_) async {<br>  final _token = await _messaging.getToken();</pre><pre>  print(&#39;Token: $_token&#39;);<br>});</pre><pre>}</pre><p>You can call the init function and request for permission like this..</p><pre>_messaging.init().then((value) =&gt; request());</pre><p>Then you can listen for notifications like this..</p><pre>_messaging.stream.listen(<br>(event) {<br>    print(&#39;New Message: ${event}&#39;);<br>  },<br>);</pre><p>You can decide to wire the function call to a button or you can decide to call it in an initState so that it runs immediately the page loads up. Accept the permission request, you’ll see a token printed in your console. Then you can open your firebase console and try sending a test message to the device token.<br>It is important for you to know that the user token changes on new login, so you would need to handle that. One way you can do it is save the user tokens to firestore and then use cloud functions to handle the push notifications. You can check this <a href="https://firebase.flutter.dev/docs/functions/overview/"><strong>cloud functions tutorial</strong> </a>for more on cloud functions.</p><p>Now you can send push notifications to your flutter web app using firebase cloud messaging. Let me know if you have any questions or feedback. And don’t forget to leave that clap.</p><h4>More from Journal</h4><p>There are many Black creators doing incredible work in Tech. This collection of resources shines a light on some of us:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fusejournal.com%2Fapp%2Fembed%2Fjournal%3Aspace%3Aproject%2F5c84f6f0-715c-48b8-9387-9e74f33b7a7b&amp;display_name=Journal&amp;url=https%3A%2F%2Fusejournal.com%2Fapp%2Fspace%2Fjournal%3Aspace%3Aproject%2F5c84f6f0-715c-48b8-9387-9e74f33b7a7b&amp;image=https%3A%2F%2Fimperio.usejournal.com%2Fimage%2Fjournal%3Aspace%3Aproject%2F5c84f6f0-715c-48b8-9387-9e74f33b7a7b%2F1602668529%3Fclient%3Dfacebook&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=usejournal" width="900" height="710" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca84c63a615be91123438987244ec06c/href">https://medium.com/media/ca84c63a615be91123438987244ec06c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9a2e08bbe9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paystack Payment with Flutter]]></title>
            <link>https://felixhope30.medium.com/paystack-payment-with-flutter-e5846d3c5691?source=rss-c92e4542a8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5846d3c5691</guid>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Felix Hope]]></dc:creator>
            <pubDate>Fri, 22 May 2020 09:09:33 GMT</pubDate>
            <atom:updated>2020-10-20T16:49:07.853Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Yhc6jR687S7SsMiVmQVzw.png" /></figure><p>A few days back, I was working on a light weight mobile application with flutter and so I wanted to integrate an online payment gateway. I wanted to integrate paystack and I could not find any article or tutorial that explained the process. So I just read the flutter_paystack package readme, and paystack documentation and after a few hours, I got it working. So i thought to myself, why not write an article about it, so others can just spend a few minutes integrating what took me a few hours. So in this article, I would be talking about how you an integrate paystack in flutter using the flutter_paystack package <br><br>So if you are here, then I’m assuming that you know flutter, that you use flutter and you’ve got it installed on your machine and you know how to start a project. Its always a privilege to upgrade your skillsets through my write-ups. So lets jump in.</p><p>First thing to do will be to create a paystack account and get your publick key and sktest keys.</p><p><a href="https://dashboard.paystack.com/#/signup">https://dashboard.paystack.com/#/signup</a></p><p>First thing you would wanna do is add flutter paystack package to your dependencies and run pub get.</p><p><a href="https://pub.dev/packages/flutter_paystack">flutter_paystack | Flutter Package</a></p><p>Then initialize the plugin preferably in the initState of your widget.</p><pre>import &#39;package:flutter_paystack/flutter_paystack.dart&#39;;<br><br>class _PaymentPageState extends State&lt;PaymentPage&gt; {<br>  var publicKey = &#39;[YOUR_PAYSTACK_PUBLIC_KEY]&#39;;<br><br>  @override<br>  void initState() {<br>    PaystackPlugin.initialize(<br>            publicKey: publicKey);<br>  }<br>}</pre><p>There are two ways of making payment with the plugin.</p><ol><li><strong>Checkout</strong>: This is the easy way; as the plugin handles all the processes involved in making a payment (except transaction initialization and verification which should be done from your backend).</li><li><strong>Charge Card</strong>: This is a longer approach; you handle all callbacks and UI states.</li></ol><p>In this article, I’m only going to talk about the checkout method.</p><h3>🌟 Checkout (Recommended)</h3><p>You initialize a charge object with an amount, email &amp; accessCode or reference. Pass an accessCode only when you have <a href="https://developers.paystack.co/reference#initialize-a-transaction">initialized the transaction</a> from your backend. Otherwise, pass a reference.</p><p>You can create a reference ID, but it has to be different for every transaction</p><pre>String _getReference() {<br>    String platform;<br>    if (Platform.isIOS) {<br>      platform = &#39;iOS&#39;;<br>    } else {<br>      platform = &#39;Android&#39;;<br>    }<br><br>    return &#39;ChargedFrom${platform}_${DateTime.now().millisecondsSinceEpoch}&#39;;<br>  }</pre><p>To initialize the transaction, You can do…</p><pre>import &#39;dart:convert&#39;;                                               import &#39;package:http/http.dart&#39; as http;                                               </pre><pre>Future&lt;String&gt;createAccessCode(skTest, _getReference) async {                        <br> // skTest -&gt; Secret key                        <br> Map&lt;String, String&gt; headers = {                           <br>   &#39;Content-Type&#39;: &#39;application/json&#39;,<br>   &#39;Accept&#39;: &#39;application/json&#39;,<br>   &#39;Authorization&#39;: &#39;Bearer $skTest&#39;};</pre><pre>Map data = {&quot;amount&quot;: 600, &quot;email&quot;: &quot;emailaddress@gmail.com&quot;, &quot;reference&quot;: _getReference};<br>String payload = json.encode(data);                         http.Response response = await http.post(<br>   &#39;https://api.paystack.co/transaction/initialize&#39;,<br>    headers: headers,<br>    body: payload);<br>final Map data = jsonDecode(response.body);<br>String accessCode = data[&#39;data&#39;][&#39;access_code&#39;];<br>return accessCode;</pre><pre> }</pre><p>Please, note that an accessCode is required if the method is CheckoutMethod.bank or CheckoutMethod.selectable.</p><p>It is recommended that when PaystackPlugin.checkout() returns, the payment should be <a href="https://developers.paystack.co/v2.0/reference#verify-transaction">verified</a> on your backend, before you tell the user that the payment was successful. This is because the intialization may be successful but the payment might not be. The response from the verification status could be ‘success’, ‘abandoned’, or ‘failed’.</p><pre>void _verifyOnServer(String reference) async {<br>    <br>   <br>    try {<br>Map&lt;String, String&gt; headers = {                           <br>   &#39;Content-Type&#39;: &#39;application/json&#39;,<br>   &#39;Accept&#39;: &#39;application/json&#39;,<br>   &#39;Authorization&#39;: &#39;Bearer $skTest&#39;};</pre><pre>http.Response response = await http.get(&#39;https://api.paystack.co/transaction/verify/&#39;+reference, headers: headers);<br>     final Map body = json.decode(response.body);<br>      if(body[&#39;data&#39;][&#39;status&#39;] == &#39;success&#39;){<br>       //do something with the response. show success}</pre><pre>      else{//show error prompt}<br>    } catch (e) {<br>      print(e);<br>    }<br>  }</pre><p>PaystackPlugin.checkout() returns the state and details of the payment in an instance of CheckoutResponse .</p><pre>chargeCard() async {<br>  Charge charge = Charge()<br>  ..amount = 10000 <br>  ..reference = _getReference()<br>//..accessCode = _createAcessCode(skTest, _getReference())<br>..email = &#39;customer@email.com&#39;;<br>CheckoutResponse response = await PaystackPlugin.checkout(<br>  context,<br>  method: CheckoutMethod.card,<br>  charge: charge,);<br>if (response.status == true) {<br>   verifyOnServer(response.reference)}<br>else {<br> //show error}}</pre><p>Please note that you can only use the paystack available test cards when you are using your test keys.</p><p><a href="https://developers.paystack.co/docs/test-cards">https://developers.paystack.co/docs/test-cards</a></p><p>If you want to try a real card, then you would have to register and verify your business on paystack so you can get your live keys. And remember, do not commit your keys to github.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5846d3c5691" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>