Skip to content

Instantly share code, notes, and snippets.

💭
Active!

Vivek Maskara maskaravivek

💭
Active!
Block or report user

Report or block maskaravivek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View variance_percentage.m
figure();
pareto(EXPLAINED);
title('Percentage of Variance Explained');
saveas(gcf,strcat(feature_plots, strcat('Plot_','Percentage of Variance Explained')), 'jpeg');
View pca_variance_distribution.m
figure();
pareto(LATENT);
title('Variance Distribution')
saveas(gcf,strcat(feature_plots, strcat('Plot_','Variance Distribution')), 'jpeg');
View pca_scatter_plot.m
scatter3(SCORE(:,1),SCORE(:,2),SCORE(:,3))
saveas(gcf,strcat(feature_plots, strcat('Scatter_Plot_Top_3_Features')), 'jpeg');
hold off;
View plot_features.m
plotpca={'f1','f2','f3','f4','f5'};
for p=1:5
figure('Name',plotpca{p},'NumberTitle','off');
score_length = size(SCORE, 1);
tx_vect= SCORE(1:score_length, p);
scatter(1:score_length,tx_vect,'r')
xlabel('Timestamp in order')
ylabel("Feature Values("+ plotpca{p}+")")
saveas(gcf,strcat(feature_plots, strcat('Plot_',plotpca{p})), 'jpeg');
View plot_eigen_vectors_pca.m
figure('Name','EigenVectors','NumberTitle','off');
bar(COEFF);
saveas(gcf, 'EigenVectors', 'jpeg');
View pca.m
featureMatrix = normalize(featureMatrix); % Normalize the feature matrix
% No of dimensions to keep
numberOfDimensions = 5;
[COEFF, SCORE, LATENT, TSQUARED, EXPLAINED] = pca(featureMatrix); % Perform PCA analysis
reducedDimension = COEFF(:,1:numberOfDimensions);
reducedFeatureMatrix = featureMatrix * reducedDimension;
View k-means.m
K = 6;
color = lines(K);
[idx, C, SSE] = kmeans(X, K, 'Distance', 'sqEuclidean', 'Replicates', 10);
totalSSE = sum(SSE);
fprintf('SSE using K-means is %d \n', totalSSE);
figure
gscatter(X(:,1),X(:,2),idx,color(1:K,:))
hold on
View db_scan.m
epsilon = 2.08;
minpts = 2;
labels = dbscan(X, epsilon, minpts);
gscatter(X(:,1),X(:,2),labels);
title('epsilon = '+ string(epsilon) +' and minpts = ' + string(minpts))
grid
View day_of_the_week.java
public String dayOfTheWeek(int day, int month, int year) {
String[] days = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int k = day;
int m = month < 3 ? month + 10 : month - 2;
int d = month < 3 ? (year % 100) - 1 : (year % 100);
int c = year / 100;
double f = k + Math.floor((13.0 * m - 1.0) / 5.0) + d + Math.floor(d / 4.0) + Math.floor(c / 4.0) - 2.0 * c;
int rem = (int) f % 7;
if (rem < 0) {
rem = 7 + rem;
View single_led.py
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
print "LED on"
GPIO.output(17,GPIO.HIGH)
time.sleep(10)
print "LED off"
You can’t perform that action at this time.