1594908494

# Neural Network Feature Importance and Feature Effect with Simple Scientific Trick

## Introduction

So you built your neural network, and, based on its holdout and/or out-of-time performance metrics, it’s looking pretty good. Now you need to “sell it” to your business partners, and for that, you need to be able to explain what is happening under the hood. A lot of modelers will skip that part and say “it’s a black box and it’s difficult to really know how the network does it. I can use eli5 and SHAP to get an idea, but it’s hard to explain how it does it.”

While it is true that there is a lot going on in neural networks (hundreds of weights and biases, multiplied by an activation function), it does not mean that we cannot come up with a business explanation of how our network works.

In this article, I am going to show you a simple trick that scientists use all the time to understand and explain the natural world around us, called “Ceteris Paribus”, which translates as “Other things held constant.” It’s the only way we can truly derive causation vs correlation. We will explore how to leverage Ceteris Paribus in Python to understand how our Neural Networks work.

## Building Our Neural Network: The Boston Dataset

I have already published an article on building a neural network for predicting house prices. You can find it here. For the purposes of this article, I am going to pick up right where I left off. The referenced article will provide you with all the details you need as background for the remainder of this story.

## Feature Effect on Predictions: Ceteris Paribus

To truly understand how one feature affects our predictions, we need to hold all input values constant and only vary the feature that we want to study and understand. By measuring the outcome on our prediction, we can draw a clear relationship between input and prediction.

A good analogy for this is studying plant growth. If you want to really know what causes a plant to grow taller, greener, or produce more fruits, you need to isolate each individual growth factor, vary it, then measure the output and compare to the variation in input. This will give you a good idea of how that factor affects the desired outcome.

Now, in our housing example, let’s examine the effect of “# of Bedrooms” against our target outcome, Median Home Value. Based on our correlation matrix and our sns.pairplot, # of bedrooms came out as highly correlated to our outcome, so it would be interesting to see how variations in the # of bedrooms, with everything else held constant (Ceteris Paribus), will affect house prices.

#partial-dependence-plots #feature-importance #feature-effect #machine-learning #neural-networks

1594908494

## Introduction

So you built your neural network, and, based on its holdout and/or out-of-time performance metrics, it’s looking pretty good. Now you need to “sell it” to your business partners, and for that, you need to be able to explain what is happening under the hood. A lot of modelers will skip that part and say “it’s a black box and it’s difficult to really know how the network does it. I can use eli5 and SHAP to get an idea, but it’s hard to explain how it does it.”

While it is true that there is a lot going on in neural networks (hundreds of weights and biases, multiplied by an activation function), it does not mean that we cannot come up with a business explanation of how our network works.

In this article, I am going to show you a simple trick that scientists use all the time to understand and explain the natural world around us, called “Ceteris Paribus”, which translates as “Other things held constant.” It’s the only way we can truly derive causation vs correlation. We will explore how to leverage Ceteris Paribus in Python to understand how our Neural Networks work.

## Building Our Neural Network: The Boston Dataset

I have already published an article on building a neural network for predicting house prices. You can find it here. For the purposes of this article, I am going to pick up right where I left off. The referenced article will provide you with all the details you need as background for the remainder of this story.

## Feature Effect on Predictions: Ceteris Paribus

To truly understand how one feature affects our predictions, we need to hold all input values constant and only vary the feature that we want to study and understand. By measuring the outcome on our prediction, we can draw a clear relationship between input and prediction.

A good analogy for this is studying plant growth. If you want to really know what causes a plant to grow taller, greener, or produce more fruits, you need to isolate each individual growth factor, vary it, then measure the output and compare to the variation in input. This will give you a good idea of how that factor affects the desired outcome.

Now, in our housing example, let’s examine the effect of “# of Bedrooms” against our target outcome, Median Home Value. Based on our correlation matrix and our sns.pairplot, # of bedrooms came out as highly correlated to our outcome, so it would be interesting to see how variations in the # of bedrooms, with everything else held constant (Ceteris Paribus), will affect house prices.

#partial-dependence-plots #feature-importance #feature-effect #machine-learning #neural-networks

1636387040

## Umeng Analytics & Push Flutter Plugins

Umeng Analytics&Push Flutter Plugins（umeng_analytics_push）

• Language: English | 中文简体
• Umeng API: umeng:analytics & umeng:push
• Tip: From v2.1.0 supported Umeng "Compliance Guide" Android IOS, and made appropriate adjustments to facilitate integration.
• Note: The following document description shall prevail, do not refer to the settings in the example

## Usages

### Import

``````dependencies:
umeng_analytics_push: ^x.x.x #The latest version is shown above, plugin1.x supports flutter1.x, plugin2.x supports flutter2.x

# Or import through Git (choose one, Git version may be updated more timely)

dependencies:
umeng_analytics_push:
git:
url: https://github.com/zileyuan/umeng_analytics_push.git
``````

### Android pretreatment settings (with Kotlin example)

#### Create a custom FlutterApplication class as the startup class, if the push function is not needed, uemng_message_secret is set to null or ""

``````package com.demo.umeng.app

import io.flutter.app.FlutterApplication
import io.github.zileyuan.umeng_analytics_push.UmengAnalyticsPushFlutterAndroid

class MyFlutterApplication: FlutterApplication() {
override fun onCreate() {
super.onCreate();
UmengAnalyticsPushFlutterAndroid.androidPreInit(this, "uemng_app_key", "channel", "uemng_message_secret")
}
}
``````

#### Modify MainActivity, add Umeng settings

``````package com.demo.umeng.app

import android.os.Handler
import android.os.Looper
import android.content.Intent
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
import io.github.zileyuan.umeng_analytics_push.UmengAnalyticsPushFlutterAndroid
import io.github.zileyuan.umeng_analytics_push.UmengAnalyticsPushPlugin

class MainActivity: FlutterActivity() {
var handler: Handler = Handler(Looper.myLooper())

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}

override fun onNewIntent(intent: Intent) {
// Actively update and save the intent every time you go back to the front desk, and then you can get the latest intent
setIntent(intent);
super.onNewIntent(intent);
}

override fun onResume() {
super.onResume()
UmengAnalyticsPushFlutterAndroid.androidOnResume(this)
if (getIntent().getExtras() != null) {
var message = getIntent().getExtras().getString("message")
if (message != null && message != "") {
// To start the interface, wait for the engine to load, and send it to the interface with a delay of 5 seconds
handler.postDelayed(object : Runnable {
override fun run() {
UmengAnalyticsPushPlugin.eventSink.success(message)
}
}, 5000)
}
}
}

override fun onPause() {
super.onPause()
UmengAnalyticsPushFlutterAndroid.androidOnPause(this)
}
}
``````

#### Modify the AndroidManifest.xml file

``````<application
android:name="com.demo.umeng.app.MyFlutterApplication">
</application>
``````

#### Add the vendor push channel, see the official documentation for details umeng:push:vendor

Modify MyFlutterApplication

``````package com.demo.umeng.app

import io.flutter.app.FlutterApplication
import io.github.zileyuan.umeng_analytics_push.UmengAnalyticsPushFlutterAndroid

class MyFlutterApplication: FlutterApplication() {
override fun onCreate() {
super.onCreate();
UmengAnalyticsPushFlutterAndroid.androidInit(this, "uemng_app_key", "channel", "uemng_message_secret")
// Register Xiaomi Push (optional)
UmengAnalyticsPushFlutterAndroid.registerXiaomi(this, "xiaomi_app_id", "xiaomi_app_key")
// Register Huawei Push (optional, need add other infomation in AndroidManifest.xml)
UmengAnalyticsPushFlutterAndroid.registerHuawei(this)
// Register Oppo Push (optional)
UmengAnalyticsPushFlutterAndroid.registerOppo(this, "oppo_app_key", "oppo_app_secret")
// Register Vivo Push (optional, need add other infomation in AndroidManifest.xml)
UmengAnalyticsPushFlutterAndroid.registerVivo(this)
// Register Meizu Push (optional)
UmengAnalyticsPushFlutterAndroid.registerMeizu(this, "meizu_app_id", "meizu_app_key")
}
}
``````

Modify the AndroidManifest.xml, fill in the real id or key

``````<application
android:name="com.demo.umeng.app.MyFlutterApplication">
<!-- Vivo push channel start (optional) -->
<meta-data
android:name="com.vivo.push.api_key"
android:value="vivo_api_key" />
<meta-data
android:name="com.vivo.push.app_id"
android:value="vivo_app_id" />
<!-- Vivo push channel end-->

<!-- Huawei push channel start (optional) -->
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="appid=huawei_app_id" />
<!-- Huawei push channel end-->
</application>
``````

Use the following parameters to send, accept offline messages

``````"mipush": true
"mi_activity": "io.github.zileyuan.umeng_analytics_push.OfflineNotifyClickActivity"
``````

If the App needs to use proguard for obfuscated packaging, please add the following obfuscated code

``````-dontwarn com.umeng.**
-dontwarn com.taobao.**
-dontwarn anet.channel.**
-dontwarn anetwork.channel.**
-dontwarn org.android.**
-dontwarn org.apache.thrift.**
-dontwarn com.xiaomi.**
-dontwarn com.huawei.**
-dontwarn com.meizu.**

-keepattributes *Annotation*

-keep class com.taobao.** {*;}
-keep class org.android.** {*;}
-keep class anet.channel.** {*;}
-keep class com.umeng.** {*;}
-keep class com.xiaomi.** {*;}
-keep class com.huawei.** {*;}
-keep class com.meizu.** {*;}
-keep class org.apache.thrift.** {*;}

-keep class com.alibaba.sdk.android.** {*;}
-keep class com.ut.** {*;}
-keep class com.ta.** {*;}

-keep public class **.R\$* {
public static final int *;
}
``````

### IOS pretreatment settings (with Swift example)

#### Modify AppDelegate.swift file

``````import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GeneratedPluginRegistrant.register(with: self)
UmengAnalyticsPushFlutterIos.iosPreInit(launchOptions, appkey:"uemng_app_key", channel:"appstore");
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

// If you need to handle Push clicks, use the following code
@available(iOS 10.0, *)
UmengAnalyticsPushFlutterIos.handleMessagePush(userInfo)
completionHandler()
}
}
``````

``````#import "GeneratedPluginRegistrant.h"
#import <UMCommon/UMCommon.h>
#import <UMCommon/MobClick.h>
#import <UMPush/UMessage.h>
#import <umeng_analytics_push/UmengAnalyticsPushIos.h>
``````

### Use in Flutter

#### Initialize Umeng, call it after agreeing to the "Privacy Policy" according to the "Compliance Guide", two parameter switches, one is log, the other is push

``````import 'package:umeng_analytics_push/umeng_analytics_push.dart';

UmengAnalyticsPush.initUmeng(false, true);
``````

#### Click Push response

``````import 'package:umeng_analytics_push/umeng_analytics_push.dart';
import 'package:umeng_analytics_push/message_model.dart';

print("UmengAnalyticsPush Message ======> \$message");
});
``````

#### Operation Alias

``````import 'package:umeng_analytics_push/umeng_analytics_push.dart';

UmengAnalyticsPush.setAlias('1002', 'jobcode');
UmengAnalyticsPush.deleteAlias('1002', 'jobcode');
``````

#### Operation Tags

``````import 'package:umeng_analytics_push/umeng_analytics_push.dart';

UmengAnalyticsPush.deleteTags('manager');
``````

#### Page buried point operation

``````import 'package:umeng_analytics_push/umeng_analytics_push.dart';

UmengAnalyticsPush.pageStart('memberPage');
UmengAnalyticsPush.pageEnd('memberPage');
``````

#### Custom event

``````import 'package:umeng_analytics_push/umeng_analytics_push.dart';

UmengAnalyticsPush.event('customEvent', '1000');``````

## Use this package as a library

### Depend on it

Run this command:

With Flutter:

`` \$ flutter pub add umeng_analytics_push``

This will add a line like this to your package's pubspec.yaml (and run an implicit `flutter pub get`):

``````dependencies:
umeng_analytics_push: ^2.1.3``````

Alternatively, your editor might support or `flutter pub get`. Check the docs for your editor to learn more.

### Import it

Now in your Dart code, you can use:

``import 'package:umeng_analytics_push/umeng_analytics_push.dart';``

example/lib/main.dart

``````import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
),
),
);
}
} ``````

Author: zileyuan

Source Code: https://github.com/zileyuan/umeng_analytics_push

1619518440

## top 30 Python Tips and Tricks for Beginners

Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.

### 8) Check The Memory Usage Of An Object.

#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners

1623135499

## No Code introduction to Neural Networks

### The simple architecture explained

Neural networks have been around for a long time, being developed in the 1960s as a way to simulate neural activity for the development of artificial intelligence systems. However, since then they have developed into a useful analytical tool often used in replace of, or in conjunction with, standard statistical models such as regression or classification as they can be used to predict or more a specific output. The main difference, and advantage, in this regard is that neural networks make no initial assumptions as to the form of the relationship or distribution that underlies the data, meaning they can be more flexible and capture non-standard and non-linear relationships between input and output variables, making them incredibly valuable in todays data rich environment.

In this sense, their use has took over the past decade or so, with the fall in costs and increase in ability of general computing power, the rise of large datasets allowing these models to be trained, and the development of frameworks such as TensforFlow and Keras that have allowed people with sufficient hardware (in some cases this is no longer even an requirement through cloud computing), the correct data and an understanding of a given coding language to implement them. This article therefore seeks to be provide a no code introduction to their architecture and how they work so that their implementation and benefits can be better understood.

Firstly, the way these models work is that there is an input layer, one or more hidden layers and an output layer, each of which are connected by layers of synaptic weights¹. The input layer (X) is used to take in scaled values of the input, usually within a standardised range of 0–1. The hidden layers (Z) are then used to define the relationship between the input and output using weights and activation functions. The output layer (Y) then transforms the results from the hidden layers into the predicted values, often also scaled to be within 0–1. The synaptic weights (W) connecting these layers are used in model training to determine the weights assigned to each input and prediction in order to get the best model fit. Visually, this is represented as:

#machine-learning #python #neural-networks #tensorflow #neural-network-algorithm #no code introduction to neural networks

1594312560

## Autonomous Driving Network (ADN) On Its Way

Talking about inspiration in the networking industry, nothing more than Autonomous Driving Network (ADN). You may hear about this and wondering what this is about, and does it have anything to do with autonomous driving vehicles? Your guess is right; the ADN concept is derived from or inspired by the rapid development of the autonomous driving car in recent years.

Driverless Car of the Future, the advertisement for “America’s Electric Light and Power Companies,” Saturday Evening Post, the 1950s.

The vision of autonomous driving has been around for more than 70 years. But engineers continuously make attempts to achieve the idea without too much success. The concept stayed as a fiction for a long time. In 2004, the US Defense Advanced Research Projects Administration (DARPA) organized the Grand Challenge for autonomous vehicles for teams to compete for the grand prize of \$1 million. I remembered watching TV and saw those competing vehicles, behaved like driven by drunk man, had a really tough time to drive by itself. I thought that autonomous driving vision would still have a long way to go. To my surprise, the next year, 2005, Stanford University’s vehicles autonomously drove 131 miles in California’s Mojave desert without a scratch and took the \$1 million Grand Challenge prize. How was that possible? Later I learned that the secret ingredient to make this possible was using the latest ML (Machine Learning) enabled AI (Artificial Intelligent ) technology.

Since then, AI technologies advanced rapidly and been implemented in all verticals. Around the 2016 time frame, the concept of Autonomous Driving Network started to emerge by combining AI and network to achieve network operational autonomy. The automation concept is nothing new in the networking industry; network operations are continually being automated here and there. But this time, ADN is beyond automating mundane tasks; it reaches a whole new level. With the help of AI technologies and other critical ingredients advancement like SDN (Software Defined Network), autonomous networking has a great chance from a vision to future reality.

In this article, we will examine some critical components of the ADN, current landscape, and factors that are important for ADN to be a success.

# The Vision

At the current stage, there are different terminologies to describe ADN vision by various organizations.

Even though slightly different terminologies, the industry is moving towards some common terms and consensus called autonomous networks, e.g. TMF, ETSI, ITU-T, GSMA. The core vision includes business and network aspects. The autonomous network delivers the “hyper-loop” from business requirements all the way to network and device layers.

On the network layer, it contains the below critical aspects:

• Intent-Driven: Understand the operator’s business intent and automatically translate it into necessary network operations. The operation can be a one-time operation like disconnect a connection service or continuous operations like maintaining a specified SLA (Service Level Agreement) at the all-time.
• **Self-Discover: **Automatically discover hardware/software changes in the network and populate the changes to the necessary subsystems to maintain always-sync state.
• **Self-Config/Self-Organize: **Whenever network changes happen, automatically configure corresponding hardware/software parameters such that the network is at the pre-defined target states.
• **Self-Monitor: **Constantly monitor networks/services operation states and health conditions automatically.
• Auto-Detect: Detect network faults, abnormalities, and intrusions automatically.
• **Self-Diagnose: **Automatically conduct an inference process to figure out the root causes of issues.
• **Self-Healing: **Automatically take necessary actions to address issues and bring the networks/services back to the desired state.
• **Self-Report: **Automatically communicate with its environment and exchange necessary information.
• Automated common operational scenarios: Automatically perform operations like network planning, customer and service onboarding, network change management.

On top of those, these capabilities need to be across multiple services, multiple domains, and the entire lifecycle(TMF, 2019).

No doubt, this is the most ambitious goal that the networking industry has ever aimed at. It has been described as the “end-state” and“ultimate goal” of networking evolution. This is not just a vision on PPT, the networking industry already on the move toward the goal.

David Wang, Huawei’s Executive Director of the Board and President of Products & Solutions, said in his 2018 Ultra-Broadband Forum(UBBF) keynote speech. (David W. 2018):

“In a fully connected and intelligent era, autonomous driving is becoming a reality. Industries like automotive, aerospace, and manufacturing are modernizing and renewing themselves by introducing autonomous technologies. However, the telecom sector is facing a major structural problem: Networks are growing year by year, but OPEX is growing faster than revenue. What’s more, it takes 100 times more effort for telecom operators to maintain their networks than OTT players. Therefore, it’s imperative that telecom operators build autonomous driving networks.”

Juniper CEO Rami Rahim said in his keynote at the company’s virtual AI event: (CRN, 2020)

“The goal now is a self-driving network. The call to action is to embrace the change. We can all benefit from putting more time into higher-layer activities, like keeping distributors out of the business. The future, I truly believe, is about getting the network out of the way. It is time for the infrastructure to take a back seat to the self-driving network.”

# Is This Vision Achievable?

If you asked me this question 15 years ago, my answer would be “no chance” as I could not imagine an autonomous driving vehicle was possible then. But now, the vision is not far-fetch anymore not only because of ML/AI technology rapid advancement but other key building blocks are made significant progress, just name a few key building blocks:

• software-defined networking (SDN) control
• industry-standard models and open APIs
• Real-time analytics/telemetry
• big data processing
• cross-domain orchestration
• programmable infrastructure
• cloud-native virtualized network functions (VNF)
• DevOps agile development process