Sort by

recency

|

208 Discussions

|

  • + 0 comments
    Currently, I am at a beginner level, so if you notice any mistakes, please let me know.
    
    
    import numpy as np
    import pandas as pd
    from sklearn.linear_model import LinearRegression
    
    
    def read_input_data():
        x_train,y_train = [],[]
        with open('trainingdata.txt','r') as file:
            data = [list(map(float, line.strip().split(','))) for line in file]
        data = np.array(data)
        # Identify minimum charge time for full charge
        full_charge= 8.0
        filtered_data = data[data[:,1]!=full_charge]
        x_train = filtered_data[:, 0].reshape(-1, 1)  # Charging time
        y_train=filtered_data[:, 1]  # Battery life
    
        return x_train,y_train
    
    def prediction_model(x,y):
        lr_model = LinearRegression()
        lr_model.fit(x,y)
        return lr_model
    
    def prediction(model,t):
        return model.predict(np.array([[t]]))[0]
        
    if __name__ == '__main__':
        x_train,y_train = read_input_data()
        lrr_model = prediction_model(x_train,y_train)
        timeCharged = float(input().strip())
        if timeCharged>4:
            result = 8.00
        else:
            result = prediction(lrr_model,timeCharged)
        print(round(result,2))
    
  • + 0 comments

    Simple C++ Solution: All Test Case pass int main() { double time; cin >> time; if (time >= 4) cout<<"8.00"; else cout<< time*2;
    return 0; }

  • + 0 comments

    very easy 8 if timeCharged > 4 else timeCharged*2

  • + 1 comment

    Polynomial Regression wasn't really needed..

    If you copy the data provided and plot it -- the solution is pretty clear.

    `

    !/bin/python3

    import math import os import random import re import sys from sklearn.linear_model import LinearRegression

    if name == 'main': timeCharged = float(input().strip()) battery, duration = [], [] with open('trainingdata.txt', 'r') as inf: for line in inf.readlines(): x, y = line.replace('\n', '').split(',') battery.append(float(x)) duration.append(float(y))

    lr = LinearRegression()
    # Split the data
    X, Y = [], []
    for x, y in zip(battery, duration):
        if x < 4.0:
            X.append([x])
            Y.append(y)
    
    lr.fit(X, Y)
    
    # predict
    print(lr.predict([[timeCharged]])[0] if timeCharged < 4 else 8.0)```
    
  • + 0 comments

    Hey everyone! I’ve been diving into BGMI on my laptop, but I’m finding battery life to be a challenge during those intense gaming sessions. I’m curious: what strategies do you use to keep your battery running longer while playing? Any tips or experiences to share?