Skip to content

Commit

Permalink
Model selection in linear models
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmadrezauf committed Oct 18, 2020
1 parent e5a1390 commit 58694fa
Show file tree
Hide file tree
Showing 59 changed files with 4,393 additions and 0 deletions.
Binary file added week06-19oct2020/.DS_Store
Binary file not shown.
511 changes: 511 additions & 0 deletions week06-19oct2020/Tutorial/Linear-regression-3.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week06-19oct2020/Tutorial/flplinear.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week06-19oct2020/Tutorial/flplinear.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions week06-19oct2020/Tutorial/income-savings.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
YEAR,SAVINGS,INCOME
1974,12298,64968
1975,14196,69233
1976,17320,73824
1977,19995,85267
1978,23601,91507
1979,24213,99632
1980,26881,123067
1981,30896,142181
1982,33787,157291
1983,38091,185749
1984,45453,207491
1985,53389,229527
1986,58036,256413
1987,72264,291585
1988,87166,345011
1989,106092,395239
1990,130010,465097
1991,141089,531515
1992,159682,618587
1993,189933,716964
1994,247462,842261
1995,291002,959733
12 changes: 12 additions & 0 deletions week06-19oct2020/Tutorial/libs/header-attrs-2.3/header-attrs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
// be compatible with the behavior of Pandoc < 2.8).
document.addEventListener('DOMContentLoaded', function(e) {
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
var i, h, a;
for (i = 0; i < hs.length; i++) {
h = hs[i];
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
a = h.attributes;
while (a.length > 0) h.removeAttribute(a[0].name);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
HTMLWidgets.widget({

name: 'highchart',

type: 'output',

initialize: function(el, width, height) {

return {
// TODO: add instance fields as required
};

},

renderValue: function(el, x, instance) {

if(x.debug) {
window.xclone = JSON.parse(JSON.stringify(x));
window.elclone = $(el);
console.log(el);
console.log("hc_opts", x.hc_opts);
console.log("theme", x.theme);
console.log("conf_opts", x.conf_opts);
}

if(x.fonts !== undefined) {

x.fonts = ((typeof(x.fonts) == "string") ? [x.fonts] : x.fonts);

x.fonts.forEach(function(s){
/* http://stackoverflow.com/questions/4724606 */
var urlfont = 'https://fonts.googleapis.com/css?family=' + s;
if (!$("link[href='" + urlfont + "']").length) {
$('<link href="' + urlfont + '" rel="stylesheet" type="text/css">').appendTo("head");
}

});

}

ResetHighchartsOptions();

if(x.theme !== null) {

if(x.debug) console.log("adding THEME");

Highcharts.setOptions(x.theme);

}

if((x.theme && x.theme.chart.divBackgroundImage !== undefined) |
(x.hc_opts.chart && x.hc_opts.chart.divBackgroundImage !== undefined)) {

if(x.debug) console.log("adding BackgroundImage");

var bkgrnd = x.theme.chart.divBackgroundImage || x.hc_opts.chart.divBackgroundImage;

Highcharts.wrap(Highcharts.Chart.prototype, "getContainer", function (proceed) {

proceed.call(this);

$("#" + el.id).css("background-image", "url(" + bkgrnd + ")");
$("#" + el.id).css("-webkit-background-size", "cover");
$("#" + el.id).css("-moz-background-size", "cover");
$("#" + el.id).css("-o-background-size", "cover");
$("#" + el.id).css("background-size", "cover");

});

}

Highcharts.setOptions(x.conf_opts);

if(x.type == "chart") {
if(x.debug) console.log("charting CHART");
$("#" + el.id).highcharts(x.hc_opts);
} else if (x.type == "stock") {
if(x.debug) console.log("charting STOCK");
$("#" + el.id).highcharts('StockChart', x.hc_opts);
} else if (x.type == "map"){
if(x.debug) console.log("charting MAP");

x.hc_opts.series = x.hc_opts.series.map(function(e){
if(e.geojson === true) {
if(x.debug) console.log("geojson\n\t", e.type, "\n\t", typeof(e.series));
e.data = Highcharts.geojson(e.data, e.type);
}
return e;
});

$("#" + el.id).highcharts('Map', x.hc_opts);

if(x.hc_opts.mapNavigation !== undefined && x.hc_opts.mapNavigation.enabled === true){
/* if have navigation option and enabled true: http://stackoverflow.com/questions/7600454 */
$("#" + el.id).bind( 'mousewheel DOMMouseScroll', function ( e ) {
var e0 = e.originalEvent,
delta = e0.wheelDelta || -e0.detail;
this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();

});

}

}

if(x.hc_opts.motion !== undefined) {

$("#" + el.id).css({"position" : "relative" });

if(x.debug) console.log("setting MOTION options");

var pc = $($("#" + el.id).find("#play-controls")[0]);

var ct = x.theme.chart;

if(ct.backgroundColor !== undefined) $(pc.find("#play-pause-button")[0]).css({backgroundColor : x.theme.chart.backgroundColor});
if(ct.style !== undefined) $(pc.find("#play-output")[0]).css(x.theme.chart.style);
if(ct.style !== undefined && ct.style.color !== undefined) $(pc.find("#play-pause-button")[0]).css({color : x.theme.chart.style.color});


}

},

resize: function(el, width, height, instance) {

/* http://stackoverflow.com/questions/18445784/ */
var chart = $("#" +el.id).highcharts();
var w = chart.renderTo.clientWidth;
var h = chart.renderTo.clientHeight;
chart.setSize(w, h);

}

});
48 changes: 48 additions & 0 deletions week06-19oct2020/Tutorial/libs/highcharts-5.0.14/css/motion.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* $("div:has(#play-controls)").css({"position" : "relative"})
div:has(#play-controls) {
position : relative;
}
*/

.loading {
margin-top: 10em;
text-align: center;
color: gray;
}

#play-controls {
position: absolute;
bottom: 0;
text-align: center;
min-width: 310px;
max-width: 800px;
margin: 0 auto;
padding: 5px 0 1em 0;
}

#play-controls * {
display: inline-block;
vertical-align: middle;
}

#play-pause-button {
color: #666666;
width: 30px;
height: 30px;
text-align: center;
font-size: 15px;
cursor: pointer;
border: 1px solid silver;
border-radius: 3px;
background: #f8f8f8;
}

#play-range {
margin: 2.5%;
width: 70%;
}

#play-output {
color: #666666;
font-family: Arial, Helvetica, sans-serif;
}
12 changes: 12 additions & 0 deletions week06-19oct2020/Tutorial/libs/highcharts-5.0.14/custom/reset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var HCDefaults = $.extend(true, {}, Highcharts.getOptions(), {});

function ResetHighchartsOptions() {
// Fortunately, Highcharts returns the reference to defaultOptions itself
// We can manipulate this and delete all the properties
var defaultOptions = Highcharts.getOptions();
for (var prop in defaultOptions) {
if (typeof defaultOptions[prop] !== 'function') delete defaultOptions[prop];
}
// Fall back to the defaults that we captured initially, this resets the theme
Highcharts.setOptions(HCDefaults);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
(function (H) {

// cross http://stackoverflow.com/a/25379352/829971
Highcharts.Renderer.prototype.symbols.cross = function (x, y, radius) {
var r = radius * 0.4,
e = r * 0.8,
a = e / Math.sqrt(2),
p = r / Math.sqrt(2);
return [
'M', x, y + a,
'L', x + p, y + a + p,
x, y + a + (2 * p),
x + a, y + (2 * a) + (2 * p),
x + a + p, y + (2 * a) + p,
x + a + (2 * p), y + (2 * a) + (2 * p),
x + (2 * a) + (2 * p), y + a + (2 * p),
x + (2 * a) + p, y + a + p,
x + (2 * a) + (2 * p), y + a,
x + a + (2 * p), y,
x + a + p, y + p,
x + a, y,
'Z'];
};

// plus http://stackoverflow.com/a/36270224/829971
Highcharts.SVGRenderer.prototype.symbols.plus = function (x, y, w, h) {
return [
'M', x, y + (5 * h) / 8,
'L', x, y + (3 * h) / 8,
'L', x + (3 * w) / 8, y + (3 * h) / 8,
'L', x + (3 * w) / 8, y,
'L', x + (5 * w) / 8, y,
'L', x + (5 * w) / 8, y + (3 * h) / 8,
'L', x + w, y + (3 * h) / 8,
'L', x + w, y + (5 * h) / 8,
'L', x + (5 * w) / 8, y + (5 * h) / 8,
'L', x + (5 * w) / 8, y + h,
'L', x + (3 * w) / 8, y + h,
'L', x + (3 * w) / 8, y + (5 * h) / 8,
'L', x, y + (5 * h) / 8,
'z'
];
};


}(Highcharts));
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Highcharts plugin to handle text symbols */
(function (H) {
function symbolWrap(proceed, symbol, x, y, w, h, options) {
if (symbol.indexOf('text:') === 0) {
var text = unescape(JSON.parse('"\\u' + symbol.split(':')[1] + '"')),
svgElem = this.text(text, x, y)
.attr({
translateY: h,
translateX: -1
})
.css({
fontFamily: 'FontAwesome',
fontSize: h * 2
});

if (svgElem.renderer.isVML) {
svgElem.fillSetter = function (value, key, element) {
element.style.color = H.Color(value).get('rgb');
};
}
return svgElem;
}
return proceed.apply(this, [].slice.call(arguments, 1));
}
H.wrap(H.SVGRenderer.prototype, 'symbol', symbolWrap);
if (H.VMLRenderer) {
H.wrap(H.VMLRenderer.prototype, 'symbol', symbolWrap);
}

// Load the font for SVG files also
/*
H.wrap(H.Chart.prototype, 'getSVG', function (proceed) {
var svg = proceed.call(this);
svg = '<?xml-stylesheet type="text/css" ' +
'href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" ?>' +
svg;
return svg;
});
*/
}(Highcharts));
Loading

0 comments on commit 58694fa

Please sign in to comment.